Differences between revisions 1 and 11 (spanning 10 versions)
Revision 1 as of 2017-10-03 16:13:24
Size: 6014
Comment:
Revision 11 as of 2017-10-04 08:29:34
Size: 8945
Comment:
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:
mri_label2label - converts a label in one subject's space to a label in another subject's space using either Talairach space or spherical space as an intermediate registration space mri_vol2vol - Resamples a volume into another field-of-view using varous types of matrices (!FreeSurfer, FSL, SPM, and MNI).
Line 17: Line 17:
mri_label2label [<options>] --srcsubject srcsubject --srclabel srclabelfile --trgsubject trgsubject --trglabel trglabelfile --regmethod registrationmethod <<BR>>
mri_label2label [<options>] --srcsubject srcsubject --srclabel srclabelfile --trgsubject trgsubject --trglabel trglabelfile --regmethod surface --hemi hemisphere
mri_vol2vol
Line 22: Line 21:
|| --srcsubject srcsubject || source subject ||
|| --srclabel srclabelfile || input label file ||
|| --trgsubject trgsubject || target subject ||
|| --trglabel trglabel || output label file] ||
|| --regmethod registrationmethod || Legal values: surface, volume ||
|| --mov movvol || input (or output template with --inv) ||
|| --o outvol || output volume ||
Line 29: Line 25:
|| --hemi hemisphere || (lh or rh) || required with --regmethod surface||
|| --srchemi hemisphere || (lh or rh) (with surface) ||
|| --trghemi hemisphere || (lh or rh) (with surface) ||
|| --srcicoorder n || when srcsubject=ico ||
|| --trgicoorder n || when trgsubject=ico||
|| --trgsurf || get xyz from this surface (white) ||
|| --surfreg srfregfile || surface registration (sphere.reg)] ||
|| --srcsurfreg srcsurfregfile || source surface registration (sphere.reg) ||
|| --trgsurfreg trgsurfregfile || target surface registration (sphere.reg) ||
|| --srcmask surfvalfile ||
|| --srcmasksign sign || Legal values: <abs>, pos, neg ||
|| --srcmaskframe frameno || 0-based frame number. Default = 0. ||
|| --projabs dist || project dist mm along surf normal ||
|| --projfrac frac || project frac of thickness along surf normal ||
|| --sd subjectsdir || Default=SUBJECTS_DIR ||
|| --nohash || don not use hash table when regmethod is surface ||
|| --norevmap || do not use reverse mapping regmethod is surface ||

= Outputs =
||??||??||
|| --targ targvol || output template (or input with --inv) ||
|| --disp dispvol || displacement volume ||
|| --reg register.dat || tkRAS-to-tkRAS matrix (tkregister2 format) ||
|| --lta register.lta || Linear Transform Array (usually only 1 transform) ||
|| --fsl register.fsl || fslRAS-to-fslRAS matrix (FSL format) ||
|| --xfm register.xfm || ScannerRAS-to-ScannerRAS matrix (MNI format) ||
|| --regheader || ScannerRAS-to-ScannerRAS matrix = identity ||
|| --mni152reg || target MNI152 space (need FSL installed) ||
|| --s subject || set matrix = identity and use subject for any templates ||
|| --inv || sample from targ to mov ||
|| --tal || map to a sub FOV of MNI305 (with --reg only) ||
|| --talres resolution || set voxel size 1mm or 2mm (def is 1) ||
|| --talxfm xfmfile || default is talairach.xfm (looks in mri/transforms) ||
|| --m3z morph || non-linear morph encoded in the m3z format ||
|| --noDefM3zPath || flag indicating that the code should not be looking for the non-linear m3z morph in the default location (subj/mri/transforms), but should use the morph name as is ||
|| --inv-morph || compute and use the inverse of the m3z morph ||
|| --fstarg <vol> || optionally use vol from subject in --reg as target. default is orig.mgz ||
|| --crop scale || crop and change voxel size ||
|| --slice-crop sS eE || crop output slices to be within sS and eE ||
|| --slice-reverse || reverse order of slices, update vox2ras ||
|| --slice-bias alpha || apply half-cosine bias field ||
|| --trilin || trilinear interpolation (default)||
|| --nearest || nearest neighbor interpolation ||
|| --cubic || cubic B-Spline interpolation ||
|| --interp interptype || interpolation cubic, trilin, nearest (default is trilin) ||
|| --mul mulval || multiply output by mulval ||
|| --precision precisionid || output precision (default is float) ||
|| --keep-precision || set output precision to that of input ||
|| --kernel || save the trilinear interpolation kernel instead ||
|| --no-resample || do not resample, just change vox2ras matrix||
|| --rot Ax Ay Az || rotation angles (deg) to apply to reg matrix||
|| --trans Tx Ty Tz || translation (mm) to apply to reg matrix ||
|| --shear Sxy Sxz Syz || xz is in-plane ||
|| --reg-final regfinal.dat || final reg after rot and trans (but not inv) ||
|| --synth || replace input with white Gaussian noise ||
|| --seed seed || seed for synth (default is to set from time of day) ||
|| --save-reg || write out output volume registration matrix ||
Line 52: Line 66:
Converts a label in one subject's space to a label in another subject's space using either talairach or spherical as an intermediate registration space. If a source mask is used, then the input label must have been created from a surface (ie, the vertex numbers are valid). The format can be anything supported by mri_convert or curv or paint. Vertices in the source label that do not meet threshold in the mask will be removed from the label. See Example 2. Resamples a volume into another field-of-view using various types of matrices (!FreeSurfer, FSL, SPM, and MNI). This is meant to be used in conjunction with tkregister2.
Line 54: Line 69:
  1. A label can be converted to/from talairach space by specifying the target/source subject as 'talairach'.
  1. A label can be converted to/from the icosahedron by specifying the target/source subject as 'ico'. When the source or target subject is specified as 'ico', then the order of the icosahedron must be specified with --srcicoorder/--trgicoorder.
  1. When the surface registration method is used, the xyz coordinates in the target label file are derived from the xyz coordinates from the target subject's white surface. This can be changed using the --trgsurf option.
  1. When the volume registration method is used, the xyz coordinates in the target label file are computed as xyzTrg = inv(Ttrg)*Tsrc*xyzSrc where Tsrc is the talairach transform in srcsubject/mri/transforms/talairach.xfm, and where Ttrg is the talairach transform in trgsubject/mri/transforms/talairach.xfm.
  1. The registration surfaces are rescaled to a radius of 100 (including the ico)
  1. Projections along the surface normal can be either negative or positive, but can only be used with surface registration method.
The data file format can be specified implicitly (through the path name) or explicitly. All formats accepted by mri_convert can be used.
Line 63: Line 73:
If you have a label from subject fred called broca-fred.label defined on fred's left hemispherical surface and you want to convert it to sally's surface, then

 mri_label2label --srclabel broca-fred.label --srcsubject fred --trglabel broca-sally.label --trgsubject sally --regmethod surface --hemi lh

This will map from fred to sally using sphere.reg. The registration surface can be changed with --surfreg.

If a functional volume is f.bhdr (or f.nii.gz, or f.mgh, etc), and the
subject is bert, and the registration file is register.dat, then
running the following command should show that they are in
registration:
{{{
tkregister2 --reg register.dat --mov f.nii.gz
}}}
If they are not, then fix it because nothing below is going to work. You can also check the registration with:
{{{
tkmedit bert orig.mgz -overlay f.nii.gz -overlay-reg register.dat
}}}
The register.dat will look something like this:
{{{
bert
3.125
5.000
0.150000
1.000000e+00 0.000000e+00 0.000000e+00 -2.252487e+00
0.000000e+00 -8.902127e-01 4.555448e-01 2.342102e+00
0.000000e+00 4.555449e-01 8.902128e-01 -2.159538e-01
0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00
round
}}}
'''A.''' To resample the functional into anatomical space:
{{{
mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o f-in-anat.mgh
}}}
f-in-anat.mgh will have the same size and geometry as bert/mri/orig.mgz. You can test the result in two ways:

 * This will show the low-res functional alighned with its resampled self:
{{{
tkregister2 --reg register.dat --mov f.nii.gz --targ f-in-anat.mgh
}}}
 * This will show the resampled functional aligned with the anatomical:
{{{
tkregister2 --mov f-in-anat.mgh --targ $SUBJECTS_DIR/bert/mri/orig.mgz \
     --regheader --reg /tmp/reg
}}}
'''B.''' To resample the anatomical into the functional space. This is basically the same command line as 1.A, but --inv has been included and the name of the output is changed.
{{{
mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o anat-in-func.mgh --inv
}}}
anat-in-func.mgh will be the same size and geometry as f.nii.gz. You can test the result in two ways:

 * This will show the low-res anat aligned with its hires self:
{{{
tkregister2 --reg register.dat --mov anat-in-func.mgh
}}}
 * This will show the resampled anat aligned with the functional:
{{{
tkregister2 --mov anat-in-func.mgh --targ f.nii.gz --regheader --reg /tmp/reg
}}}
'''C.''' Map functional to anatomical without resampling. Rather, change the vox2ras (sform/qform) matrix. This is the same cmd line as 1.A, but --no-resample as been added.
{{{
mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o f.new.vox2ras.nii.gz --no-resample
}}}
f.new.vox2ras.nii.gz will have the same dimension and voxel size as f.nii.gz, but its vox2ras (sform/qform) matrix will have changed. You can check the registration in two ways:

 * The registration is created implicitly from the vox2ras matrix (that is what --regheader does). There's no need to specify and input registration
{{{
tkregister2 --mov f.new.vox2ras.nii.gz --s bert --regheader --reg /tmp/reg
}}}
 * Display the functional as an overlay in tkmedit (no registration needed).
{{{
tkmedit bert orig.mgz -overlay f.new.vox2ras.nii.gz
}}}
'''D.''' Map a binary mask in functional space to anatomical space. This is basically the same cmd line as 1.A, but --interp nearest has been added so that it does not try to interpolate the mask (ie, it will still be binary after resampling):
{{{
mri_vol2vol --reg register.dat --mov mask.nii.gz --fstarg --o mask-in-anat.mgh --interp nearest
}}}
Line 71: Line 144:
Same as Example 1 but with a mask

 mri_label2label --srclabel broca-fred.label --srcsubject fred --trglabel broca-sally.label --trgsubject sally --regmethod surface --hemi lh --srcmask fred-omnibus-sig 2 bfloat

This will load the bfloat data from fred-omnibus-sig and create a mask by thresholding the first frame absolute values at 2. To change it to only the positive values of the 3rd frame, add --srcmasksign pos --srcmaskframe 2
'''A.''' Map functional to talairach (MNI305) space with 2mm isotropic resolution. This is very similar to 1.A with the addition of --tal and --talres 2.
{{{
mri_vol2vol --mov f.nii.gz --reg register.dat --o f-in-tal.2mm.mgh --tal --talres 2
}}}
f-in-tal.2mm.mgh will be 2mm isotropic with the same geometry as $FREESURFER_HOME/average/mni305.cor.subfov2.mgz. This command will
also create f-in-tal.2mm.mgh.reg, which will register the volume with any average MNI305 !FreeSurfer subject (fsaverage is used by default). The resampling can be checked with:

 * This will show the functional with the fsaverage anatomical:
{{{
tkregister2 --mov f-in-tal.2mm.mgh --reg f-in-tal.2mm.mgh.reg
}}}
'''B.''' Map functional to talairach (MNI305) space with 1mm isotropic resolution. Same as 2.A but use --talres 1.
{{{
mri_vol2vol --mov f.nii.gz --reg register.dat --o f-in-tal.1mm.mgh --tal --talres 1
}}}
f-in-tal.1mm.mgh will take up 8 times as much space as f-in-tal.2mm.mgh
Line 79: Line 162:
You could also do the same mapping using talairach space as an intermediate:

    mri_label2label --srclabel broca-fred.label --srcsubject fred --trglabel broca-sally.label --trgsubject sally --regmethod volume

Note that no hemisphere is specified with --regmethod volume.

== Example 4 ==
You have a label in the volume and you want to find the closest surface vertices:

   mri_label2label --srclabel your.volume.label --s subject --trglabel lh.your.volume.on-pial.label --hemi lh --paint 30 pial --trgsurf pial

This keeps the label on a single subject (but could also map to another subject). The label is mapped to vertices on the pial surface that are within 30mm of the label point. The xyz of the output label takes the coordinates of the pial surface (--trgsurf pial).

Apply an MNI transform to data by resampling the anatomical orig.mgz into talairach space using bert/mri/transforms/talairach.xfm:

First, check that the talairach.xfm is correct (this is basically the samething as 'tkregister2 --s bert --fstal' in Example 2):

{{{
cd bert/mri
tkregister2 --targ orig.mgz \
     --mov $FREESURFER_HOME/average/mni305.cor.mgz \
     --xfm transforms/talairach.xfm --reg /tmp/reg
}}}

Now resample:
{{{
mri_vol2vol --mov orig.mgz \
     --targ $FREESURFER_HOME/average/mni305.cor.mgz \
     --xfm transforms/talairach.xfm \
     --o orig-in-mni305.mgz
}}}

Now test the resampling:
{{{
tkregister2 --mov orig-in-mni305.mgz \
    --targ $FREESURFER_HOME/average/mni305.cor.mgz \
    --reg /tmp/reg --regheader
}}}
Line 94: Line 190:
When using volume registration method, you cannot specify the SUBJECTS_DIR on the command-line. sinc interpolation is broken except for maybe COR to COR.
Line 97: Line 193:
[[label_area]], [[mri_mergelabels]] [[mri_convert]] [[tkregister2]]
Line 111: Line 207:
BruceFischl

Index

Name

mri_vol2vol - Resamples a volume into another field-of-view using varous types of matrices (FreeSurfer, FSL, SPM, and MNI).

Synopsis

mri_vol2vol

Arguments

Required Flagged Arguments

--mov movvol

input (or output template with --inv)

--o outvol

output volume

Optional Flagged Arguments

--targ targvol

output template (or input with --inv)

--disp dispvol

displacement volume

--reg register.dat

tkRAS-to-tkRAS matrix (tkregister2 format)

--lta register.lta

Linear Transform Array (usually only 1 transform)

--fsl register.fsl

fslRAS-to-fslRAS matrix (FSL format)

--xfm register.xfm

ScannerRAS-to-ScannerRAS matrix (MNI format)

--regheader

ScannerRAS-to-ScannerRAS matrix = identity

--mni152reg

target MNI152 space (need FSL installed)

--s subject

set matrix = identity and use subject for any templates

--inv

sample from targ to mov

--tal

map to a sub FOV of MNI305 (with --reg only)

--talres resolution

set voxel size 1mm or 2mm (def is 1)

--talxfm xfmfile

default is talairach.xfm (looks in mri/transforms)

--m3z morph

non-linear morph encoded in the m3z format

--noDefM3zPath

flag indicating that the code should not be looking for the non-linear m3z morph in the default location (subj/mri/transforms), but should use the morph name as is

--inv-morph

compute and use the inverse of the m3z morph

--fstarg <vol>

optionally use vol from subject in --reg as target. default is orig.mgz

--crop scale

crop and change voxel size

--slice-crop sS eE

crop output slices to be within sS and eE

--slice-reverse

reverse order of slices, update vox2ras

--slice-bias alpha

apply half-cosine bias field

--trilin

trilinear interpolation (default)

--nearest

nearest neighbor interpolation

--cubic

cubic B-Spline interpolation

--interp interptype

interpolation cubic, trilin, nearest (default is trilin)

--mul mulval

multiply output by mulval

--precision precisionid

output precision (default is float)

--keep-precision

set output precision to that of input

--kernel

save the trilinear interpolation kernel instead

--no-resample

do not resample, just change vox2ras matrix

--rot Ax Ay Az

rotation angles (deg) to apply to reg matrix

--trans Tx Ty Tz

translation (mm) to apply to reg matrix

--shear Sxy Sxz Syz

xz is in-plane

--reg-final regfinal.dat

final reg after rot and trans (but not inv)

--synth

replace input with white Gaussian noise

--seed seed

seed for synth (default is to set from time of day)

--save-reg

write out output volume registration matrix

Description

General

Resamples a volume into another field-of-view using various types of matrices (FreeSurfer, FSL, SPM, and MNI). This is meant to be used in conjunction with tkregister2.

Notes

The data file format can be specified implicitly (through the path name) or explicitly. All formats accepted by mri_convert can be used.

Examples

Example 1

If a functional volume is f.bhdr (or f.nii.gz, or f.mgh, etc), and the subject is bert, and the registration file is register.dat, then running the following command should show that they are in registration:

tkregister2 --reg register.dat --mov f.nii.gz

If they are not, then fix it because nothing below is going to work. You can also check the registration with:

tkmedit bert orig.mgz  -overlay f.nii.gz -overlay-reg register.dat

The register.dat will look something like this:

bert
3.125
5.000
0.150000
1.000000e+00 0.000000e+00 0.000000e+00 -2.252487e+00
0.000000e+00 -8.902127e-01 4.555448e-01 2.342102e+00
0.000000e+00 4.555449e-01 8.902128e-01 -2.159538e-01
0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00
round

A. To resample the functional into anatomical space:

mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o f-in-anat.mgh

f-in-anat.mgh will have the same size and geometry as bert/mri/orig.mgz. You can test the result in two ways:

  • This will show the low-res functional alighned with its resampled self:

tkregister2 --reg register.dat --mov f.nii.gz --targ f-in-anat.mgh
  • This will show the resampled functional aligned with the anatomical:

tkregister2 --mov f-in-anat.mgh --targ $SUBJECTS_DIR/bert/mri/orig.mgz \
     --regheader --reg /tmp/reg

B. To resample the anatomical into the functional space. This is basically the same command line as 1.A, but --inv has been included and the name of the output is changed.

mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o anat-in-func.mgh --inv

anat-in-func.mgh will be the same size and geometry as f.nii.gz. You can test the result in two ways:

  • This will show the low-res anat aligned with its hires self:

tkregister2 --reg register.dat --mov anat-in-func.mgh
  • This will show the resampled anat aligned with the functional:

tkregister2 --mov anat-in-func.mgh --targ f.nii.gz --regheader --reg /tmp/reg

C. Map functional to anatomical without resampling. Rather, change the vox2ras (sform/qform) matrix. This is the same cmd line as 1.A, but --no-resample as been added.

mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o f.new.vox2ras.nii.gz --no-resample

f.new.vox2ras.nii.gz will have the same dimension and voxel size as f.nii.gz, but its vox2ras (sform/qform) matrix will have changed. You can check the registration in two ways:

  • The registration is created implicitly from the vox2ras matrix (that is what --regheader does). There's no need to specify and input registration

tkregister2 --mov f.new.vox2ras.nii.gz --s bert --regheader --reg /tmp/reg
  • Display the functional as an overlay in tkmedit (no registration needed).

tkmedit bert orig.mgz -overlay f.new.vox2ras.nii.gz

D. Map a binary mask in functional space to anatomical space. This is basically the same cmd line as 1.A, but --interp nearest has been added so that it does not try to interpolate the mask (ie, it will still be binary after resampling):

mri_vol2vol --reg register.dat --mov mask.nii.gz --fstarg --o mask-in-anat.mgh --interp nearest

Example 2

A. Map functional to talairach (MNI305) space with 2mm isotropic resolution. This is very similar to 1.A with the addition of --tal and --talres 2.

mri_vol2vol --mov f.nii.gz --reg register.dat --o f-in-tal.2mm.mgh --tal --talres 2

f-in-tal.2mm.mgh will be 2mm isotropic with the same geometry as $FREESURFER_HOME/average/mni305.cor.subfov2.mgz. This command will also create f-in-tal.2mm.mgh.reg, which will register the volume with any average MNI305 FreeSurfer subject (fsaverage is used by default). The resampling can be checked with:

  • This will show the functional with the fsaverage anatomical:

tkregister2 --mov f-in-tal.2mm.mgh --reg f-in-tal.2mm.mgh.reg

B. Map functional to talairach (MNI305) space with 1mm isotropic resolution. Same as 2.A but use --talres 1.

mri_vol2vol --mov f.nii.gz --reg register.dat --o f-in-tal.1mm.mgh --tal --talres 1

f-in-tal.1mm.mgh will take up 8 times as much space as f-in-tal.2mm.mgh

Example 3

Apply an MNI transform to data by resampling the anatomical orig.mgz into talairach space using bert/mri/transforms/talairach.xfm:

First, check that the talairach.xfm is correct (this is basically the samething as 'tkregister2 --s bert --fstal' in Example 2):

cd bert/mri
tkregister2 --targ orig.mgz \
     --mov $FREESURFER_HOME/average/mni305.cor.mgz \
     --xfm transforms/talairach.xfm --reg /tmp/reg

Now resample:

mri_vol2vol --mov orig.mgz \
     --targ $FREESURFER_HOME/average/mni305.cor.mgz \
     --xfm transforms/talairach.xfm  \
     --o orig-in-mni305.mgz

Now test the resampling:

tkregister2 --mov orig-in-mni305.mgz \
    --targ $FREESURFER_HOME/average/mni305.cor.mgz \
    --reg /tmp/reg --regheader

Bugs

sinc interpolation is broken except for maybe COR to COR.

See Also

mri_convert tkregister2

Links

FreeSurfer, FsFast

Methods Description

References

Reporting Bugs

Report bugs to <analysis-bugs@nmr.mgh.harvard.edu>

Author/s

mri_vol2vol (last edited 2017-10-04 08:29:34 by MorganFogarty)