Error in sort function when grouping events
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there,
I've got a piece of code, which I'm using to select and sort (average) some electroencephalography events. Here is my code:
fname=dir('*_TF_cue_pru_rej_conditions_TF.mat'); % select all participant files
fname={fname.name};
% do a grand average of the data for each condition, per person
for k=1:length(fname),
load(fname{k})
cfg.trials =L1_NS_data_rej; %Language 1 non-switch events
G_L1_NS{k}=ft_redefinetrial(cfg,data_TF);
cfg.trials =L1_S_data_rej; %Language 1 switch events
G_L1_S{k}=ft_redefinetrial(cfg,data_TF);
cfg.trials =L2_NS_data_rej; %Language 2 non-switch events
G_L2_NS{k}=ft_redefinetrial(cfg,data_TF);
cfg.trials =L2_S_data_rej; %Language 2 switch events
G_L2_S{k}=ft_redefinetrial(cfg,data_TF);
end
The events are 4 types and are already grouped into 4 different substructures of my data file (as commented above). My data file countains the whole data (data_TF) and 4 other structures named L1_NS_data_rej, L1_S_data_rej, L2_NS_data_rej and L2_S_data_rej. However, when I try running it, I get the following error in the sort function:
Error using sort
Check for missing argument or incorrect argument data type in call to function 'sort'.
Error in ft_selectdata>getselection_rpt (line 1179)
rptindx = unique(sort(rptindx));
Error in ft_selectdata (line 291)
[selrpt{i}, dum, rptdim{i}, selrpttap{i}] = getselection_rpt(cfg, varargin{i}, dimord{j});
Error in ft_redefinetrial (line 129)
data = ft_selectdata(tmpcfg, data);
It used to work perfectly on the same datafiles I'm attempting to use it now. I've checked my data files and they're not empty, all the events are there and named appropriately, etc. I'm attaching a link to two of my files, so that one could run the code: https://we.tl/t-pjfMr2hwSf MatLab version: MATLAB Version: 9.9.0.1570001 (R2020b) Update 4 (Windows 10). Fieldtrip versions: fieldtrip-lite-20210310 and fieldtrip-lite-20210411. Could you please help me resolve where the problem might be? Thank you!
4 commentaires
dpb
le 9 Juin 2021
Only the top level code; there's no code that has any reference to sort there; what are we to try to do?
And, attach the data as .mat file here as well; nobody is going to an external site.
If you expect somebody to try to actually debug what is going on, need a sample case that can run in its entirety without having to make it themselves by bits and pieces scattered all around.
Réponses (2)
Jan
le 9 Juin 2021
Use the debugger:
dbstop if error
Afterwards start your code again. When Matlab stops at the error, what is the contents of rptindx?
0 commentaires
Voir également
Catégories
En savoir plus sur Variables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!