Differences between revisions 7 and 12 (spanning 5 versions)
Revision 7 as of 2010-03-15 11:44:03
Size: 1346
Comment: added some more explanation and mri dir as location to cd into
Revision 12 as of 2013-12-02 17:17:05
Size: 3250
Editor: MartinReuter
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Question: I have successfully run a subject's data through FreeSurfer. FreeSurfer creates volumes in 1mm^3, 256^3 space, but I want the FreeSurfer results in the space of my original anatomical. How do I do this?
== Regular Stream ==
For the longitudinal stream, scroll down.

Question: I have successfully run a subject's data through FreeSurfer. FreeSurfer creates volumes in 1mm^3^, 256^3^ space, but I want the FreeSurfer results in the space of my original anatomical. How do I do this?
Line 11: Line 15:
mri_vol2vol --mov brain.mgz --targ rawavg.mgz --regheader --o brain-in-rawavg.mgz mri_vol2vol --mov brain.mgz --targ rawavg.mgz --regheader --o brain-in-rawavg.mgz --no-save-reg
Line 20: Line 24:
mri_label2vol --seg aseg.mgz --regheader rawavg.mgz --o aseg-in-rawavg.mgz --temp aseg.mgz mri_label2vol --seg aseg.mgz --temp rawavg.mgz --o aseg-in-rawavg.mgz --regheader aseg.mgz
Line 27: Line 31:

You can also map a surface into the native anatomical space

First, create a registration matrix between the conformed space
(orig.mgz) and the native anatomical (rawavg.mgz)
{{{
tkregister2 --mov rawavg.mgz --targ orig.mgz --reg register.native.dat --noedit --regheader
}}}

Next, map the surface to the native space:

{{{
mri_surf2surf --sval-xyz pial --reg register.native.dat rawavg.mgz --tval lh.pial.native --tval-xyz --hemi lh --s subjectname
}}}

The output will be stored in $SUBJECTS_DIR/subjectname/surf/lh.pial.native

To verify that this worked, run
{{{
freeview -v rawavg.mgz -f lh.pial.native
}}}

== Longitudinal Stream ==

In the longitudinal stream, the base (subject-template) and the longitudinal runs have their data all in the same space. With the following commands you can map the results from long to the native space.

Image (best to use cubic interpolation):
{{{
cd $SUBJECTS_DIR/<tpid>.long.<baseid>/mri
mri_convert -ait transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            -rl $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz \
            -rt cubic brain.mgz brain-in-rawavg.mgz
}}}

Segmentation (needs nearest-neighbor method):
{{{
cd $SUBJECTS_DIR/<tpid>.long.<baseid>/mri
mri_convert -ait transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            -rl $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz \
            -rt nearest aseg.mgz aseg-in-rawavg.mgz
}}}

To map surfaces:
{{{
cd $SUBJECTS_DIR/<tpid>.long.<baseid>/surf
lta_convert --inlta ../mri/transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            --outreg register.native.dat --src $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz
mri_surf2surf --sval-xyz pial --reg register.native.dat ../../$tp/mri/rawavg.mgz \
              --tval lh.pial.native --tval-xyz --hemi lh --s ${tp}.long.${base}
}}}

How to Convert from FreeSurfer Space Back to Native Anatomical Space

Regular Stream

For the longitudinal stream, scroll down.

Question: I have successfully run a subject's data through FreeSurfer. FreeSurfer creates volumes in 1mm3, 2563 space, but I want the FreeSurfer results in the space of my original anatomical. How do I do this?

The exact command you use depends on what you want to convert, an image (like brain.mgz) or a segmentation (like aseg.mgz).

For an image:

cd $SUBJECTS_DIR/<subjid>/mri
mri_vol2vol --mov brain.mgz --targ rawavg.mgz --regheader --o brain-in-rawavg.mgz --no-save-reg

"rawavg.mgz" is a file created by FreeSurfer and is in the native space of your anatomical so we use that volume as a target space. The output is brain-in-rawavg.mgz and will be in the native space of the anatomical. Substitute brain.mgz with whatever other images you want in native space.

For a segmentation (aseg.mgz, aparc+aseg.mgz, wmparc.mgz, etc):

cd $SUBJECTS_DIR/<subjid>/mri
mri_label2vol --seg aseg.mgz --temp rawavg.mgz --o aseg-in-rawavg.mgz --regheader aseg.mgz

If you ran both of the commands above, tkmedit should show the aseg (in native space) overlaid properly on the brain (in native space) all matching up well with the rawavg.mgz (your native space target).

tkmedit -f brain-in-rawavg.mgz -aux rawavg.mgz -seg aseg-in-rawavg.mgz 

You can also map a surface into the native anatomical space

First, create a registration matrix between the conformed space (orig.mgz) and the native anatomical (rawavg.mgz)

tkregister2 --mov rawavg.mgz --targ orig.mgz --reg register.native.dat --noedit --regheader

Next, map the surface to the native space:

mri_surf2surf --sval-xyz pial --reg register.native.dat rawavg.mgz --tval lh.pial.native --tval-xyz --hemi lh --s subjectname

The output will be stored in $SUBJECTS_DIR/subjectname/surf/lh.pial.native

To verify that this worked, run

freeview -v rawavg.mgz -f lh.pial.native

Longitudinal Stream

In the longitudinal stream, the base (subject-template) and the longitudinal runs have their data all in the same space. With the following commands you can map the results from long to the native space.

Image (best to use cubic interpolation):

cd $SUBJECTS_DIR/<tpid>.long.<baseid>/mri
mri_convert -ait transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            -rl $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz \
            -rt cubic brain.mgz brain-in-rawavg.mgz

Segmentation (needs nearest-neighbor method):

cd $SUBJECTS_DIR/<tpid>.long.<baseid>/mri
mri_convert -ait transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            -rl $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz \
            -rt nearest aseg.mgz aseg-in-rawavg.mgz

To map surfaces:

cd $SUBJECTS_DIR/<tpid>.long.<baseid>/surf
lta_convert --inlta ../mri/transforms/<tpid>_to_<tpid>.long.<baseid>.lta \
            --outreg register.native.dat --src $SUBJCECTS_DIR/<tpid>/mri/rawavg.mgz
mri_surf2surf --sval-xyz pial --reg register.native.dat ../../$tp/mri/rawavg.mgz \
              --tval lh.pial.native --tval-xyz --hemi lh --s ${tp}.long.${base}

FsAnat-to-NativeAnat (last edited 2019-04-16 15:40:48 by 172)