Creating the environment
The processing steps are required for MNE, but they are actually performed in Freesurfer. The main purpose is to reconstruct the cortical surface from MRI images, which will later be used for source space creation in MNE. Before starting the Freesurfer analysis, you have to set some "environment variables", so that the following processing scripts know where to look for programs and data.
setenv SUBJECTS_DIR </myMRIdirectory/>
in your Linux command window.
Freesurfer will create a number of files in several subdirectories for each subject. You can automatically create the subdirecties for each subject:
This will create the directory /myMRIdirectory/mysubjectname/, as well as several subdirectories. Check whether it worked, then forget about it for the time being. This is a good time to remind you that you will have to link each MRI data set with one MEG data set - you may therefore want to choose the names for your MRI subject directories wisely. If you link an MRI data set to the wrong MEG data set - well, you know what that means.
Convert your structural MRI image using
mri_convert </mridata/cbu/*/*/onedcmfile.dcm> </myMRIdirectory/mysubjectname/mri/orig/001.mgz>
You should specify one *.dcm-file for an MPRAGE MRI, which is usually located in a directory of the form
For example, choose the first or last dcm-file in the corresponding directory, the program will do the rest. The output directory .../mri/orig was created previously (remember, you've checked whether it worked...).
The next three steps are the ones that do the important stuff. You can run them one after the other and hope for the best. But it is recommended to check the result of each step, and rerun the analysis if necessary. There's more information on the FreeSurfer pages.
recon-all -subjid <mysubjectname> -autorecon1
Check the result of autorecon1.
recon-all -subjid <mysubjectname> -autorecon2
Check the result of autorecon2.
When you are happy so far, you can run the final step:
recon-all -subjid <mysubjectname> -autorecon3
You can combine steps, e.g.
recon-all -subjid <mysubjectname> -autorecon2 -autorecon3
For example, you may want to run autorecon1 first, check whether the MRI is ok (and coregistration and skull-stripping worked), and then run autorecon2 and 3 together (which may take up to a day). Then carefully check the surfaces - if that's good, all's good.
If you are an optimist, you can run
recon-all -subjid <mysubjectname> -all