I would like to have a script that takes a list of all my mri files in my project, e.g.:
fs_root/subect01/mri/T1.mgz…
fs_root/subect02/mri/T1.mgz…
I would like the scirpt to automatically open each one for fiducial placement, e.g. when I click save fiducials for one subject the next subjects pops up.
Then, I would like to import all the freesurfer directories/surfs/create head models for those subjects using the fiducials I specified with a script, so I can go do some other task while it imports every subject.
Then, I would like to specify each fif for each subject (like I did with the mris) and have the mri/meg registration refinement happen automatically without any guis requiring my input. Based on my current test subject, 30 or so subjects should take a full day to run one at a time. (Although, if I have code for each of these steps I can run each in parallel.)
If all goes well, I only need to interact with the gui for 30subjectsx3minutes per fiducials placement, and then everything else is imported with scripts (perhaps over night).
I have a working in house MEG stream at my lab, so I can only spare a few hours (of my time) to test this out on our data. I image other MEG labs not using bst will have similar priorities, so this kind of thing could be very helpful for converting users.
It might be faster for you to import manually all the subjects anatomy folders, and then run a script to import and process the recordings.
Alternatively, you can add a file “fiducials.m” directly in the subject’s FreeSurfer folder (next to the “surf” and “mri” folders…). This file defines the 6 fiducial point in Matlab syntax, in millimeters, MRI coordinates (like in the first line of coordinates in the MRI Viewer):
NAS = [x y z];
RPA = [x y z];
LPA = [x y z];
AC = [x y z];
PC = [x y z];
IH = [x y z];
If this file is present in the folder, the MRI Viewer would not show when importing the anatomy. But this require that you import the MRI of one subject, write the fiducials.m file, save, move to the next subject.
Then the main script would be more complicated to write. I’m not sure that would save a lot of time in the end. You just have to wait for 2min after setting the points of each subject before moving to the next one.
For help with generating the script that imports and process the FIF files, you can read the following tutorial, that shows how to reproduce with a script the analysis performed in the 3 tutorials “Processing continuous file”: http://neuroimage.usc.edu/brainstorm/Tutorials/TutRawScript
With such a script, you can only process one FIF file at a time. You need to generate the script and edit it: replace the FIF full file names with a variable that you set at the beginning of the script, and add a big for loop around all the processes.
The script generator will be improved in the future to support the processing of multiple continuous files, but probably not within the next few weeks.
If it can be of any help, I used the following script to pop up the fiducials (.nii):
pause on
name_nii = dir(fullfile(bst_db_dir,protocol_name,‘anat’,subject_name,’*nii.mat’));
name_nii = name_nii.name;
view_mri(fullfile(bst_db_dir,protocol_name,‘anat’,subject_name,name_nii), ‘EditMri’)
disp(‘Please press a key after the fiducials have been set in order to continue the treatment’)
pause
disp(’…’)
disp(‘Processing in progress’)
By looping over name_nii, and if the data are already loaded, it should work fine