-
Notifications
You must be signed in to change notification settings - Fork 2
0A. FreeSurfer reconstruction
Here describes the procedure to reconstruct FreeSurfer brain models using T1-weighted MRI data (MPRAGE sequence)
Make sure that you have access to FreeSurfer software. SUBJECTS_DIR
environment variable must be set.
$ setenv SUBJECTS_DIR /space_lin2/fhlin/eegmri_wm/subjects
FreeSurfer has a convention to put files in different subfolders, whjich will be created automatically. But the first sub-folder must be created manually. Here is my routine to reconstruct the brain for subject s004
:
$ cd $SUBJECTS_DIR
$ mkdir s004; cd s004; mkdir mri; cd mri; mkdir orig; cd orig; mkdir dicom; cd dicom;
$ ln -s /space_lin2/kwoudsma/eegfmri_wm/s004/T1/* .
Basically, MPRAGE dicom files at /space_lin2/kwoudsma/eegfmri_wm/s004/T1/ were linked to $SUBJECTS_DIR/mri/orig/dicom.
A quick file listing gives:
...
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0154.2023.02.24.17.53.54.227018.233313898.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0155.2023.02.24.17.53.54.227018.233313916.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0156.2023.02.24.17.53.54.227018.233313934.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0157.2023.02.24.17.53.54.227018.233313952.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0158.2023.02.24.17.53.54.227018.233313970.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0159.2023.02.24.17.53.54.227018.233313988.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0160.2023.02.24.17.53.54.227018.233314006.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0161.2023.02.24.17.53.54.227018.233314024.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0162.2023.02.24.17.53.54.227018.233314042.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0163.2023.02.24.17.53.54.227018.233314060.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0164.2023.02.24.17.53.54.227018.233314078.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0165.2023.02.24.17.53.54.227018.233314096.IMA
EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0166.2023.02.24.17.53.54.227018.233314114.IMA
...
We learned that these are for run number 37.
Then, we "unpack" (convert) the dicom data into the FreeSurfer format. A unpack.rule file is created at $SUBJECTS_DIR/s004/mri/orig/unpack
folder. The editor vi is used to create this file.
$ cd $SUBJECTS_DIR/s004/mri/orig/
$ mkdir unpack; cd unpack
$ vi unpack.rule
The content of unpack.rule file, in this case, is:
$ cat unpack.rule
37 3danat COR blah
This means that run 37 will be unpacked to 3danat
folder in the COR
format. The folder will be created during the unpacking process.
Once the unpack.rule is made, you can start unpacking.
$ cd $SUBJECTS_DIR/s004/mri/orig/unpack
$ unpacksdcmdir -src ../dicom -targ . -cfg ./unpack.rule
If no error occurs, it will show the following.
...
Done scanning Wed Jul 5 15:37:53 EDT 2023
------------------------------------------
37 t1_mprage_sag_p2iso1.0 ok 256 256 176 1 EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0001.2023.02.24.17.53.54.227018.233311136.IMA
unpacking config ------------------
{37 3danat COR blah}
-----------------------------------
---------------------------------------------------------
Run 37 -----------------------------------------
Wed Jul 5 15:37:53 EDT 2023
37 3danat COR blah
mri_convert ../dicom/EEGFMRI_WM_S004.MR.RESEARCH_FHLIN.0037.0001.2023.02.24.17.53.54.227018.233311136.IMA ./3danat/037 --sdcmlist ./3danat/037/flf -ot cor --nspmzeropad 3 --in_type siemens_dicom
StartTime: Wed Jul 5 15:37:41 EDT 2023
EndTime: Wed Jul 5 15:38:11 EDT 2023
unpacksdcmdir Done
Before running the FreeSurfer reconstruction, we need to convert again the COR files into MGZ format.
$ cd $SUBJECTS_DIR/s004/mri/orig
$ mri_convert unpack/3danat/037/COR-.info ./001.mgz
COR files in the folder $SUBJECTS_DIR/s004/mri/orig/unpack/3danat/037 are converted to
001.mgz` at $SUBJECTS_DIR/s004/mri/orig
Finally, recon-all
is all you need.
$ cd $SUBJECTS_DIR/s004
$ recon-all -subjid s004 -all
It will take about 10 hours to complete the whole processing.