CbuImaging/DanStructural - Meg Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Flind the wroneg tetters tin eaech wrord

location: CbuImaging / DanStructural


==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)

<tt>mksubjdirs <participant></tt>

This will create the necessary directory structure for freesurfer including the bem directory.

<tt>unpacksdcmdir -src <source> -targ <target> -scanonly unpack1.log</tt>

This will create the unpack.log file, which can be used to unpack the file.

<tt>emacs unpack1.log &</tt>

<tt>mri_convert <source/(file1 listed in unpack1.log)> 003.mgh</tt>

<tt>mri_convert <source/(file2 listed in unpack1.log)> 004.mgh</tt> ... continue for however many scans you have.

(nmr-dev-env)

<tt>grad_unwarp -i 003.mgh -unwarp avanto -o 003_unwarped.mgh</tt>

<tt>grad_unwarp -i 004.mgh -unwarp avanto -o 004_unwarped.mgh</tt> ... 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)

<tt>mri_convert 003_unwarped.mgh 003.mgz</tt>

<tt>mri_convert 004_unwarped.mgh 004.mgz</tt> ... 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.'''

<tt>recon-all -s <participant> -autorecon1

Stop to check for problems with autorecon1.

=====Talairach=====

<tt>tkregister2 --mgz --s <participant> --fstal</tt>

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=====

<tt>tkmedit <participant> brainmask.mgz -aux T1.mgz</tt>

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%).'''

<tt>tkmedit <participant> brainmask.mgz -aux T1.mgz</tt>

If there are no problems or if you only made edits to the skull stripping, continue.

====autorecon2====

<tt>recon-all -subjid <participant> -autorecon2</tt>

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=====

<tt>tkmedit <participant> brainmask.mgz lh.white -aux T1.mgz -aux-surface rh.white</tt>

For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/ControlPoints intensity normalization].

If control points were added: 

<tt>recon-all -subjid <participant> -autorecon2-cp -autorecon3</tt>

Then, you must stop and check all the surfaces (as you did after autorecon2) and make any appropriate edits.

=====White Matter Edits=====

<tt>tkmedit <participant> brainmask.mgz lh.white -aux wm.mgz -aux-surface rh.white</tt>

For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/WhiteMatterEdits White Matter Edits].

<tt>recon-all -subjid <participant> -autorecon2-wm -autorecon3</tt>

Then, you must stop and check all the surfaces (as you did after autorecon2) and make any appropriate edits.

=====Pial Edits=====

<tt>tkmedit <participant> brainmask.mgz lh.white -aux-surface rh.white</tt>

For more information see [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/PialEdits Pial Edits].

<tt>recon-all -subjid <participant> -autorecon2-pial -autorecon3</tt>

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====
<tt>recon-all -subjid <participant> -autorecon3</tt>

===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.

<tt>tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz</tt>

If they are not properly lined up,

(nmr-dev-env)

<tt>tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader</tt>

Align the two images together perfectly.

<tt>mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat</tt>

<tt>[[dans_bem2.csh]]</tt>

<tt>tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl</tt>

The bright surfaces are the surfaces from <tt>mri_make_bem_surfaces</tt> and the dark ones are from <tt>mne_watershed_bem</tt>.  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.

<tt>cd $SUBJECTS_DIR/$SUBJECT/bem/</tt>

For all of the <tt>mri_make_bem_surfaces</tt> surfaces that you will use run the following command:

<tt>mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

For all of the <tt>mne_watershed_bem</tt> surfaces that you will use run the following command:

<tt>cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/<participant>_<that surface>_surface $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

<tt>mne_setup_forward_model --surf --ico 4</tt>

====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.

<tt>tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz</tt>

If they are not properly lined up,

(nmr-dev-env)

<tt>tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader</tt>

Align the two images together perfectly.

<tt>mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat</tt>

[[dans_bem2.csh]]

<tt>tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl</tt>

The bright surfaces are the surfaces from <tt>mri_make_bem_surfaces</tt> and the dark ones are from <tt>mne_watershed_bem</tt>.  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.

<tt>cd $SUBJECTS_DIR/$SUBJECT/bem/</tt>

For all of the <tt>mri_make_bem_surfaces</tt> surfaces that you will use run the following command:

<tt>mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

For all of the <tt>mne_watershed_bem</tt> surfaces that you will use run the following command:

<tt>cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/<participant>_<that surface>_surface $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

<tt>mne_setup_forward_model --surf --ico 4</tt>

====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.

<tt>tkmedit -f $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz -aux $SUBJECTS_DIR/$SUBJECT/mri/flash/flash5_reg.mgz</tt>

If they are not properly lined up,

(nmr-dev-env)

<tt>tkregister2 --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --regheader</tt>

Align the two images together perfectly.

<tt>mri_vol2vol --mov $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps/flash5_reg.mgz --targ $SUBJECTS_DIR/$SUBJECT/mri/orig/rawavg.mgz --reg register.dat</tt>

[[dans_bem2.csh]]

<tt>tkmedit $SUBJECT T1.mgz -tcl $SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT\_bem.tcl</tt>

The bright surfaces are the surfaces from <tt>mri_make_bem_surfaces</tt> and the dark ones are from <tt>mne_watershed_bem</tt>.  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.

<tt>cd $SUBJECTS_DIR/$SUBJECT/bem/</tt>

For all of the <tt>mri_make_bem_surfaces</tt> surfaces that you will use run the following command:

<tt>mne_convert_surface --tri $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.tri --swap --surfout $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

For all of the <tt>mne_watershed_bem</tt> surfaces that you will use run the following command:

<tt>cp $SUBJECTS_DIR/$SUBJECT/bem/watershed/<participant>_<that surface>_surface $SUBJECTS_DIR/$SUBJECT/bem/<that surface>.surf</tt>

<tt>mne_setup_forward_model --surf --ico 4</tt>