{{{#!media
==Basic Ideas==
The structural analysis is both its own separate analysis set and the basis for all of your fMRI and MEG/EEG analysis. It is the basis for your fMRI analysis, because this is one of the techniques used to define ROIs, and even if you define your ROIs via a functional measure you will likely need to describe the ROIs in a structural way. The surfaces you create with Freesurfer are used in your MEG/EEG analysis. There accuracy will greatly influence your MEG/EEG analysis.
Prove it!
The first and obvious point is that for both fMRI and MEG/EEG, if our reconstruction is off what we call X could be Y. This can affect the outcome greatly if for example part of the temporal lobe is called frontal lobe. Because Freesurfer is fairly robust the likelihood of this happening is low; however, it does happen. Because we typically use the so called "loose constraint" on our MEG/EEG forward and inverse solutions, any distortions in the geometric shape will greatly influence the results we get. It is critical to perform these calculations accurately
==Do it!==
===MRI Surface Reconstruction Workflow===
(nmr-std-env)
mksubjdirs
This will create the necessary directory structure for freesurfer including the bem directory.
unpacksdcmdir -src
This will create the unpack.log file, which can be used to unpack the file.
emacs unpack1.log &mri_convert mri_convert ... continue for however many scans you have.
(nmr-dev-env)
grad_unwarp -i 003.mgh -unwarp avanto -o 003_unwarped.mghgrad_unwarp -i 004.mgh -unwarp avanto -o 004_unwarped.mgh ... continue for however many scans you have.
These steps unwarp the gradient non-linearity. It needs to be performed in the dev environment, because this will provide you the path to the table with the spherical harmonics for our magnets (Bays 2, 3 (not with the AC88 insert), 4, and 5 (also, not with the AC88 insert)). For further information see the links above.
(nmr-std-env)
mri_convert 003_unwarped.mgh 003.mgzmri_convert 004_unwarped.mgh 004.mgz ... continue for however many scans you have.
====autorecon1====
'''Note! I (Daniel Wakeman) have run into very few problems with autorecon1. There have been a few cases where the Talairach has gone bad and crashed autorecon1 (always check this, if autorecon1 crashes). Because of the extremely high quality of our sequences, I have not needed to do any skull stripping editing.'''
recon-all -s -autorecon1
Stop to check for problems with autorecon1.
=====Talairach=====
tkregister2 --mgz --s --fstal
For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/Talairach Talairach].
'''Note! Unfortunately, the freesurfer wiki assumes that you have run all of recon-all for this part of the tutorial. Since this will not be the case for this data, you need to understand what they are doing. Be sure you can fix the bad Talairach without the orig surface. I always check the Talairach after autorecon1, because autorecon2 takes so long ~24hrs. But please check Claus' note.'''
'''Note (Claus): Due to a reasonable amount of computational resources and the good quality of the scans, the easiest way to start with the whole recon-all script and start it again after the point, where edits were made. However, to understand what each step does, everybody should have performed at least once the recon-all script step by step as described here. Fixing a bad talairach will be necessary in approximately 50% of Martinos-Data.'''
If you make edits here, you must start again from [[#autorecon1|autorecon1]].
=====Skull Stripping=====
tkmedit brainmask.mgz -aux T1.mgz
For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/SkullStripFix Skull Stripping]
'''Note! Unfortunately, the freesurfer wiki assumes that you have run all of recon-all for this part of the tutorial. Since this will not be the case for this data, you need to understand what they are doing. Be sure you can fix the skull stripping without the surfaces.'''
'''Note (Claus): To my experience, fixing a bad skull stripping is not very frequent in Martinos-Data (ca. 5%).'''
tkmedit brainmask.mgz -aux T1.mgz
If there are no problems or if you only made edits to the skull stripping, continue.
====autorecon2====
recon-all -subjid -autorecon2
Stop to check surfaces and make appropriate edits
'''Note! I (Daniel Wakeman) have yet to have a brain that did not require any edits after autorecon2. Because of the extremely high quality of our sequences, I have not needed to do any intensity normalization. I have needed to do White Matter edits on about 25% of the brains, which I have edited. I have needed pial edits on 100% of the brains I have edited.'''
=====Intensity Normalization=====
tkmedit brainmask.mgz lh.white -aux T1.mgz -aux-surface rh.white
For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/ControlPoints intensity normalization].
If control points were added:
recon-all -subjid -autorecon2-cp -autorecon3
Then, you must stop and check all the surfaces (as you did after autorecon2) and make any appropriate edits.
=====White Matter Edits=====
tkmedit brainmask.mgz lh.white -aux wm.mgz -aux-surface rh.white
For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/WhiteMatterEdits White Matter Edits].
recon-all -subjid -autorecon2-wm -autorecon3
Then, you must stop and check all the surfaces (as you did after autorecon2) and make any appropriate edits.
=====Pial Edits=====
tkmedit brainmask.mgz lh.white -aux-surface rh.white
For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/PialEdits Pial Edits].
recon-all -subjid -autorecon2-pial -autorecon3
Then, you must stop and check all the surfaces (as you did after [[#autorecon2|autorecon2]]) and make any appropriate edits.
'''Note (Claus): Pial edits almost always involve tentorial / dural tissue. So be especially aware of the anterior sections of coronal slices between the temporal and frontal lobe'''
'''Note! I added autorecon3 as part of the step after these edits, because as you become skilled with edits you will only need to do edits once after autorecon2, so incorporating autorecon3 after it is completed makes sense. If you include autorecon3, skip running autorecon3 in the next section.'''
====autorecon3====
recon-all -subjid -autorecon3
===BEM Reconstruction Workflow===
All of these assume that you have already set up the environment variables for the SUBJECT and SUBJECTS_DIR. They also assume that autorecon1 has successfully completed and all edits on autorecon1 have been completed. All of these commands can be run from the SUBJECTS_DIR directory.
====Multiecho Flash 5 & 30====
Edit [[dans_bem.csh]] to properly change the source of the multiecho flashes for your participant.
[[dans_bem.csh]]
Now, you need to check the final registration of the flash5 to the rawavg.mgz. They should be perfectly lined up.
tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz
If they are not properly lined up,
(nmr-dev-env)
tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader
Align the two images together perfectly.
mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat[[dans_bem2.csh]]tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl
The bright surfaces are the surfaces from mri_make_bem_surfaces and the dark ones are from mne_watershed_bem. Analyze each of the surfaces to determine, which surface best represents each of the three surfaces inner skull (red), outer skull (green), outer skin (blue). Typically, mri_make bem_surfaces makes better inner and outer skull surfaces and mne_watershed_bem makes a better outer skin surface.
cd $SUBJECTS_DIR/$SUBJECT/bem/
For all of the mri_make_bem_surfaces surfaces that you will use run the following command:
mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/.surf
For all of the mne_watershed_bem surfaces that you will use run the following command:
cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/__surface $SUBJECTS_DIR/$SUBJECT/bem/.surfmne_setup_forward_model --surf --ico 4
====Multiecho Flash 5 (with computed average)====
Edit [[flash_5waverage.csh]] to properly change the source of the multiecho flash average for your participant.
[[flash_5waverage.csh]]
Now, you need to check the final registration of the flash5 to the rawavg.mgz. They should be perfectly lined up.
tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz
If they are not properly lined up,
(nmr-dev-env)
tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader
Align the two images together perfectly.
mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat
[[dans_bem2.csh]]
tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl
The bright surfaces are the surfaces from mri_make_bem_surfaces and the dark ones are from mne_watershed_bem. Analyze each of the surfaces to determine, which surface best represents each of the three surfaces inner skull (red), outer skull (green), outer skin (blue). Typically, mri_make bem_surfaces makes better inner and outer skull surfaces and mne_watershed_bem makes a better outer skin surface.
cd $SUBJECTS_DIR/$SUBJECT/bem/
For all of the mri_make_bem_surfaces surfaces that you will use run the following command:
mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/.surf
For all of the mne_watershed_bem surfaces that you will use run the following command:
cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/__surface $SUBJECTS_DIR/$SUBJECT/bem/.surfmne_setup_forward_model --surf --ico 4
====Multiecho Flash 5 Only====
Edit [[flash_5only.csh]] to properly change the source of the multiecho flash for your participant.
[[flash_5only.csh]]
Now, you need to check the final registration of the flash5 to the rawavg.mgz. They should be perfectly lined up.
tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz
If they are not properly lined up,
(nmr-dev-env)
tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader
Align the two images together perfectly.
mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat
[[dans_bem2.csh]]
tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl
The bright surfaces are the surfaces from mri_make_bem_surfaces and the dark ones are from mne_watershed_bem. Analyze each of the surfaces to determine, which surface best represents each of the three surfaces inner skull (red), outer skull (green), outer skin (blue). Typically, mri_make bem_surfaces makes better inner and outer skull surfaces and mne_watershed_bem makes a better outer skin surface.
cd $SUBJECTS_DIR/$SUBJECT/bem/
For all of the mri_make_bem_surfaces surfaces that you will use run the following command:
mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/.surf
For all of the mne_watershed_bem surfaces that you will use run the following command:
cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/__surface $SUBJECTS_DIR/$SUBJECT/bem/.surfmne_setup_forward_model --surf --ico 4
}}}