Export to file: script +add subject number

Hi François,

You can see the organization of my protocol here:

Capture d’écran 2022-11-02 à 13.01.00

For the Avg, the name of the participant (e.g., AF01) is not specified. When I do an « export to file » (exporting in SPM format), the name of the file is the following: « F_CtF_average_220701_1415_interpbad » (example of the first avg.

Is there a way to have the name of the participant in the exported file ? I assume we can do it probably with a script but I don’t know where I can find the script for exporting the file in the SPM format. I usually export scripts from the pipeline editor but I don’t find the function export to file in the pipeline editor.

Additionally, when I do « export to file » for multiple selected files, I get the .mat of all the files but the . dat of the first file only. Is that normal? Can I get the .dat for each subject and each condition as well?

Thank you for your help,

Adeline

When you export a single file from the interface, you can always set the file name, you can add the subject name manually.

If you want to use a script instead, see the header of function export_data.m. For example:

export_data(DataFile, [], '/path/to/subjectname_F_CtF_average_220701_1415_interpbad.mat', 'SPM-DAT');

For help with getting started with Brainstorm scripting (you need to be familiar with Matlab programming):
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

Additionally, when I do « export to file » for multiple selected files, I get the .mat of all the files but the . dat of the first file only. Is that normal?

This was a bug. Only the first file was saved in SPM format, the rest was copied in Brainstorm format.
I fixed it here: Bugfix: Keep file format when exporting multiple data files · brainstorm-tools/brainstorm3@b50b906 · GitHub
Update Brainstorm to get this fix.

Hi François,

Thank you very much for your reply. Indeed, I wanted to use a script as I have 2 conditions to export for one hundred participants but as the files are in different folders (one for each subject), I am not sure I will be able to write a script (I am quite new to writing script); I will try.

Ok for the bug (I have this problem with SPM when I update brainstorm so I will see study your second answer in my second post before).