bids-matlab-tools icon indicating copy to clipboard operation
bids-matlab-tools copied to clipboard

Export with sessions as string

Open arnodelorme opened this issue 3 years ago • 7 comments

Cheng shared some files (file-cheng on my computer)

However, there is no script, and the files actually have numerical sessions (in the file name itself). Also, when creating a study with these files, the files do not have sessions or subjects defined.

Cheng, please share a script that takes these files as input to recreate the problem.

arnodelorme avatar May 25 '22 03:05 arnodelorme

I simply used the bids plugin in eeglab to export bids format. I did some scripts to identify the files from the file name etc: The bids-eeglab plugin will then automatically identify the information. The GUI from eeglab will identify the run/session/group correctly when create a study, however, it creates errors when exporting them to bids format.

Modified script below

for iEEG = 1:length(ALLEEG)
    EEG = ALLEEG(iEEG);
    EEG.subject = extractBefore(EEG.setname,'_'); % find out the subject ID
    EEG.session = str2num(char(extractBetween(EEG.setname,'ses-','_')));
    EEG.condition = char(extractBetween(EEG.setname,'task-','_'));
    EEG.run = str2num(char(extractAfter(EEG.setname,'run-')));
    EEG.task = EEG.condition;
    ALLEEG(iEEG).task = '';
    ALLEEG(iEEG) = EEG;
end

arnodelorme avatar May 25 '22 06:05 arnodelorme

Fixed in 20f89e7

arnodelorme avatar May 25 '22 07:05 arnodelorme

Hi Arnaud,

I have tried to export the EEG data using the branch pernet_x from eeglab but it still did not work. I got an error message as below: image Best regards, Cheng

ChengtengIp avatar May 31 '22 12:05 ChengtengIp

The same error message appears again even when I deleted that subject.

ChengtengIp avatar May 31 '22 13:05 ChengtengIp

I have merged the pernet_x branch to the master branch now.

  1. Use the modified script above
  2. Import all the datasets in EEGLAB
  3. Export to BIDS

Works for me.

arnodelorme avatar May 31 '22 17:05 arnodelorme

@CPernet can help. He knows how to do that.

arnodelorme avatar May 31 '22 17:05 arnodelorme

@ChengtengIp put a few of those subjects in a folder on our server and let see what is failing or not then I can update the function as needed and PR it

CPernet avatar Jun 02 '22 12:06 CPernet