I wish to convert data from fieldtrip to eeglab using fieldtrip2eeglab function. My Data.trial is a cell array, and apply the follwing code, it gives me an error on line 17, "not enough arguments". Can anyone please help, to figure me out the error?

endfunction [EEG] = fieldtrip2eeglab(data)
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
e
load chanlocs.mat
EEG.chanlocs = chanlocs;
%EEG.chanlocs = [];
for i=1:size(data.trial,2)
EEG.data(:,:,i) = single(data.trial{i}); % error here at line 17
end
EEG.setname = data.cfg.dataset;
EEG.filename = '';
EEG.filepath = '';
EEG.subject = '';
EEG.group = '';
EEG.condition = '';
EEG.session = [];
EEG.comments = 'preprocessed with fieldtrip';
EEG.nbchan = size(data.trial{1},1);
EEG.trials = size(data.trial,2);
EEG.pnts = size(data.trial{1},2);
EEG.srate = data.fsample;
EEG.xmin = data.time{1}(1);
EEG.xmax = data.time{1}(end);
EEG.times = data.time{1};
EEG.ref = []; %'common';
EEG.event = [];
EEG.epoch = [];
EEG.icawinv = [];
EEG.icasphere = [];
EEG.icaweights = [];
EEG.icaact = [];
EEG.saved = 'no';
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG);
eeglab redraw
pop_eegplot( EEG, 1, 1, 1);
%%%%%%%%%%%%%%%% error msg %%%%%%%%%%%%%%%%%%%%%%%%%
eglab: options file is C:\Users\Differentielle 222\eeg_options.m
EEGLAB: adding "Biosig" to the path; subfolders (if any) might be missing from the path
EEGLAB: adding "bva-io" v1.5.13 (see >> help eegplugin_bva_io)
EEGLAB: adding "dipfit" v2.3 (see >> help eegplugin_dipfit)
EEGLAB: adding "firfilt" v1.6.2 (see >> help eegplugin_firfilt)
Error using fieldtrip2eeglab (line 17)
Not enough input arguments.

7 Comments

Please format the code in your question with the {}Code button.
Is this the original source of the code you are using? Did you edit the code to change the dataf into data? How did you call this function? Did you supply the data variable in the format this function expects?
I format the code now. Yes this is the original code I'm using. I changed dataf to data(struct with 7 fields; hdr,label,time.trial,fsample,sampleinfo,cfg). And I called this function after pre.processing the raw EEG data and seperating the interesting trials (data.trial = 34*1 cell with 34 trials). Not sure, if they are correct formats of variables to be supplied!!!
Please post a copy of the complete error message. I cannot see which one is the "line 17".
With 'complete error message' we mean all the red text, which almost always includes the entire stack of function calls, which gives a lot of information, including what code is on line 17. The text I'm assuming you added to your question was already in your title.
Hi Rik, I've now pasted the exact error. What I find out that data.trial is a cell array and assigning cell array to EEG.data is not possible. Use of cell2mat, double also did not work here. Any suggestions?
If you attach the .mat file we might be able to help you.
Hi RIk, I have attached three matlab files. cued.m extract the EEG signal between 'S100' to 'S102' (S100 and S102 are the triggers supplied onset of stimuli to the time when participant started typing the answer). i am interested in the signal between these triggers. 1prepro_trudy.m preprocess the data and concatenate the trials. fieldtrip2eeglab is where I wish to convert the data format from fieldtrip to EEGLAB.

Sign in to comment.

Answers (0)

Categories

Asked:

on 24 Jun 2018

Edited:

on 27 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!