Differences between revisions 1 and 9 (spanning 8 versions)
Revision 1 as of 2026-02-09 12:30:12
Size: 13149
Editor: LiamrSennott
Comment:
Revision 9 as of 2026-02-10 17:24:04
Size: 6115
Editor: YujingHuang
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
mri_convert mri_warp_convert
Line 7: Line 7:
mri_convert is a general purpose utility for converting between different file formats. The file type can be specified in two ways. First, mri_convert will try to figure it out on its own from the format of the file name (eg, files that end in .img are assumed to be in spm analyze format). Second, the user can explicity set the type of file using --in_type and/or --out_type.

Legal values for --in_tye (-it) and --out_type (-ot) are listed under optional flagged arguments.

A note on specifying orientation:

Do not use this to try to change the orientation for FSL. This is only to be used when the orientation information in the input file is *wrong*. If it is correct, this will make it wrong! If you are having problems with fslview displaying your data, consult the FSL website for methods to reorient.

Ideally, the orientation information is derived from a DICOM file so that you have some confidence that it is correct. It is generally pretty easyto determine which direction Anterior/Posterior or Inferior/Superior are. Left/Right is very difficult. However, if you have some way of knowing which direction is which, you can use these options to incorporate this information into the header of the output format. For analyze files, it will be stored in the output.mat file. For NIFTI, it is stored as the qform matrix. For bshort/bfloat, it is stored in the .bhdr file. For mgh/mgz it is internal.
First of all, determining and setting the orientation is hard. Don't fool yourself into thinking otherwise. Second, don't think you are going to learn all you need to know from this documentation. Finally, you risk incorporating a left-right flip in your data if you do it incorrectly. OK, there are two ways to specify this information on the command-line.
(1) explicitly specify the direction cosines with -iid, -ijd, -ikd. If you don't know what a direction cosine is, don't use this method.
(2) specify an orientation string with --in_orientation ostring and --out_orientation ostring
Supply the orientation information in the form of an orientation string (ostring). The ostring is three letters that roughly describe how the volume is oriented. This is usually described by the direction cosine information as originally derived from the dicom but might not be available in all data sets. You'll have to determine the correct ostring for your data. The first character of ostring determines the direction of increasing column. The second character of ostring determines the direction of increasing row. The third character of ostring determines the direction of increasing slice. Eg, if the volume is axial starting inferior and going superior the slice is oriented such that nose is pointing up and the right side of the subject is on the left side of the image, then this would correspond to LPS, ie, as the column increases, you move to the patients left; as the row increases, you move posteriorly, and as the slice increases, you move superiorly. Valid letters are L, R, P, A, I, and S. There are 48 valid combinations (eg, RAS LPI, SRI). Some invalid ones are DPS (D is not a valid letter), RRS (can't specify R twice), RAP (A and P refer to the same axis). Invalid combinations are detected immediately, an error printed, and the program exits. Case-insensitive. Note: you can use tkregister2 to help determine the correct orientation string.
Converts non-linear deformation warp fields between different file formats. Some formats may require you to pass an image if the geometry information is missing from the transform file.
Line 22: Line 10:
mri_convert [options] <in volume> <out volume> mri_warp_convert <input-type> <output-type> [options]
Line 25: Line 13:
== Positional Arguments ==
|| involume || Input volume ||
|| outvolume || Output volume ||
== Required Flagged Arguments ==
=== Exactly one input is required ===
||'''Flag''' ||'''Description''' ||
||--inm3z <in.m3z> ||input Freesurfer 3D morph in M3Z format ||
||--inmgzwarp <inwarp.mgz> ||input Freesurfer 3D morph in mgz format ||
||--infsl <in.nii.gz> ||input FSL warp (recommend to use with --insrcgeom) ||
||--inspm <y_rinput.nii> ||input SPM warp (use with --insrcgeom). Use --inwarpformat <> to specify the data format, which is either abs-ras (default) or abs-crs. ||
||--inlps, --initk <in.nii.gz> ||input LPS-to-LPS displacement field (e.g. ITK, ANTs) ||
||--inras <in.nii.gz> ||input RAS-to-RAS displacement field (e.g. NiftyReg) ||
||--invox <in.mgz> ||input displacement field in source-voxel space ||
Line 29: Line 24:
== Required Flagged Arguments ==
None

=== Exactly one output is required ===
||'''Flag''' ||'''Description''' ||
||--outm3z <out.m3z> ||output Freesurfer 3D morph in M3Z format ||
||--outmgzwarp <outwarp.mgz> ||output Freesurfer 3D morph in mgz format ||
||--outfsl <out.nii.gz> ||output warp in FSL format ||
||--outlps, --outitk <out.nii.gz> ||output LPS-to-LPS displacement field (e.g. ITK, ANTs) ||
||--outras <out.nii.gz> ||output RAS-to-RAS displacement field (e.g. NiftyReg) ||
||--outvox <out.mgz> ||output displacement field in source-voxel space ||
Line 33: Line 36:
|| Flag || Description||
||-ro or --read_only || ||
||-nw or --no_write || ||
||-ii or --in_info || ||
||-oi or --out_info || ||
||-is or --in_stats || Print statistics on input volume ||
||-os or --out_stats || Print statistics on output volume ||
||-im or --in_matrix || ||
||-om or --out_matrix || ||
||-upsample N <size> || Reduce voxel size by a factor of N in all dimensions ||
||-iis or --in_i_size <size> || ||
||-ijs or --in_j_size <size> || ||
||-ikd or --in_k_size <size> || ||
||--in_orientation orientation-string || see SPECIFYING THE ORIENTATION ||
||-ic or --in_center <R coordinate> <A coordinate> <S coordinate> || ||
||-dic or --delta_in_center <dR coordinate> <dA coordinate> <dS coordinate> || ||
||--sphinx || Change orientation info to sphinx ||
||-oni or -oic or --out_i_count <count> || ||
||-onj or -ojc or --out_j_count <count> || ||
||-onk or -okc or --out_k_count <count> || ||
||-oid or --out_i_direction <R direction> <A direction> <S direction> || ||
||-ojd or --out_j_direction <R direction> <A direction> <S direction> || ||
||-okd or --out_k_direction <R direction> <A direction> <S direction> || ||
||--out_orientation orientation-string || See SETTING ORIENTATION ||
||-oc or --out_center <R direction> <A direction> <S direction> || ||
||-odt or --out_data_type <uchar|short|int|float> || ||
||--bfile-little-endian || Write out bshort/bfloat files in little endian ||
||--in_stats_table || Input data is a stats table as produced by asegstats2table or aparcstats2table ||
||--out_stats_table || Output data is a stats table (use --like to pass template table for measure, columns, and rows heads) ||
||-rt or --resample_type <interpolate|weighted|nearest|cubic> || Default is interpolate ||
||-nth || Specify frame number ||
||--no_scale flag <-ns> || 1 means don't rescale values for COR ||
||-nc or --nochange || Don't change type of input to that of template ||
||-tr TR || TR in msec ||
||-te TE || TE in msec ||
||-TI TI || TI in msec (note uppercase flag)||
||-flip_angle flip angle || Angle in radians ||
||--autoalign mtxfile || Text file with autoalign matrix ||
||-oval val || ||
||--outside_val val || Set the values outside of the image that may rotate in if a transform is applied to val ||
||'''Flag''' ||'''Description''' ||
||-g, --insrcgeom <geom.mgz> ||specify volume geometry of the input to the warp space, i.e., srcgeom shares an RAS space with the warp volume. Usually this is identical to the geom of the warp volume itself (if the warp input is in a format that has such info). This also allows the input to the warp to have a different geometry than the warp itself, though this is probably better handled with -lta1. ||
||-d, --downsample ||downsample output M3Z to spacing of 2. ||
||-lta2 LTA (or -lta2-inv) ||create composite morph for warping a source image -> LTA1 -> GCAM -> LTA2 -> atlas/destination image ||
||--inwarpformat <format> ||specify warp data format: abs-crs, disp-crs, abs-ras, or disp-ras (default is abs-crs). This option only works with '--inspm <>'. ||
||--outwarpformat <format> ||specify warp data format: abs-crs, disp-crs, abs-ras, or disp-ras (default is abs-crs) ||
||--vg-thresh <vgthresh> ||specify threshold for testing diffs in volume geom ||
Line 74: Line 44:
== Applying Transforms Flagged Arguments ==
||--apply_transform xfmfile (-T or -at) || Apply transform given by xfm or m3z files. The volume can be resampled into another space by supplying a transform using the -apply_transform flag. This reads the transform file and applies the transform (when --apply_inverse_transform is used, the transform is inverted an then applied). An example of a transform file is talairach.xfm as found in subjectid/mri/transforms. To convert a subject's orig volume to talairach space, execute the following lines: cd subjectid/mri , mkdir talairach, mri_convert orig.mgz --apply_transform transforms/talairach.xfm -oc 0 0 0 orig.talairach.mgz. This properly accounts for the case where the input volume does not have it's coordinate center at 0. To evaluate the result, run: tkmedit -f $SUBJECTS_DIR/talairach/mri/orig.mgz -aux orig.talairach.mgz . The main and aux volumes should overlap very closely. If they do not, use tkregister2 to fix it. ||
||--apply_inverse_transform xfmfile (-ait) || Apply inverse transform given by xfm or m3z files. ||
||--devolvexfm subjectid || ||
||--like name || Output is embedded in a volume like name, or in stats-table like name (measure, columns, rows) ||
||--crop <x> <y> <z> || Crop to 256 around center (x,y,z) ||
||--cropsize <dx> <dy> <dz> || Crop to size <dx, dy, dz> ||
||--cutends ncut || Remove ncut slices from the ends ||
||--slice-crop s_start s_end || Keep slices s_start to s_end ||
||--slice-reverse || Reverse order of slices, update vox2ras ||
||--nslices-override nslices || Use this number of slices when converting DICOM mosaics ||
||--slice-bias alpha || Apply half-cosine bias field ||
||--fwhm fwhm || Smooth input volume by fwhm mm ||
Line 88: Line 45:
== Specifying the Input and Output File Types ==
Legal values for --in_type (-it) and --out_type (-ot) are:
|| cor || MGH-NMR COR format (deprecated) ||
|| mgh || MGH-NMR format ||
|| mgz || MGH-NMR gzipped (compressed) mgh format ||
|| minc || MNI's Medical Imaging NetCDF format (output may not work) ||
|| analyze || 3D analyze (same as spm ) ||
|| analyze4d || 4D analyze ||
|| spm || SPM Analyze format (same as analyze and analyze3d) ||
|| ge || GE Genesis format (input only) ||
|| gelx || GE LX (input only) ||
|| lx || Same as gelx ||
|| ximg || GE XIMG variant (input only) ||
|| siemens || Siemens IMA (input only) ||
|| dicom || Generic DICOM format (input only) ||
|| siemens_dicom || Siemens DICOM format (input only) ||
|| afni || AFNI format ||
|| brik || Same as afni ||
|| bshort || MGH-NMR bshort format ||
|| bfloat || MGH-NMR bfloat format ||
|| sdt || Varian ||
|| outline || MGH-NMR outline format ||
|| otl || Same as outline ||
|| gdf || GDF volume (requires image stem for output; use -gis) ||
|| nifti1 || NIfTI-1 volume (separate image and header files) ||
|| nii || NIfTI-1 volume (single file). If the input/output has extension .nii.gz, then compressed is used. ||
= Examples =
== Example 1 ==
Convert FSL warp to M3Z (FreeSurfer):
Line 115: Line 49:
== Converting to SPM-Analyze Format ==
Converting to SPM-Analyze format can be done in two ways, depending upon whether a single frame or multiple frames are desired. For a single frame, simply specify the output file name with a .img extension, and mri_convert will save the first frame into the file. For multiple frames, specify the base as the output file name and add --out_type spm. This will save each frame as baseXXX.img where XXX is the three-digit, zero-padded frame number. Frame numbers being at one. By default, the width of the zero padding is 3. This can be controlled with --in_nspmzeropad N where N is the new width.
||--ascii || Save output as ascii. This will be a data file with a single column of data. The fastest dimension will be col, then row, then slice, then frame ||
||--ascii+crsf || Same as --ascii but includes col, row, slice, and frame ||
||-r or --reorder olddim1 olddim2 olddim3 || ||
||-r4 or --reorder4 olddim1 olddim2 olddim3 olddim4 || Reorder axes such that olddim1 is the new column dimensions, olddim2 is the new row dimension, olddim3 is the new slice, and olddim4 is the new frame dimension. Example: 2 1 3 will swap row and colms. If using -r4, the output geometry will likely be wrong. It is best to re-run mri_convert and specify a correctly orientated volume through the --in_like option ||
||--invert_contrast threshold || All voxels in volume greater than threshold are replaced with 255-value. Only makes sense for 8 bit images. Only operates on first frame. ||
||-i or --input_volume || ||
||-o or --output_volume || ||
||-c or --conform || Conform to 1mm voxel size in coronal slice direction with 256^3 or more. ||
||-cm or --conform_min || Conform to the src min direction size ||
||-cs or --conform_size size_in_mm || conform to the size given in mm ||
||-po or --parse_only || ||
||-is or --in_stats || ||
||-os or --out_stats || ||
||-ro or --read_only || ||
||-nw or --no_write || ||
||-sn or --subject_name || ||
||-rl or --reslice_like || ||
||-tt or --template_type <type> || ||
||--split || Split output frames into separate output files. Example: mri_convert a.nii b.nii --split will create b0000.nii b0001.nii b0002.nii ... ||
||--erode-seg Nerodes || Erode segmentation boundaries Nerode times (based on 6 nearest neighbors) ||
||--dil-seg Ndilations || Dilate segmentation boundaries Ndilate times (based on 6 nearest neighbors) to fill seg=0 voxels ||
||--dil-seg-mask mask || Dilate segmentation boundaries to fill mask ||
||-f or --frame frameno [...] || Keep only 0-based frame number(s) ||
||--mid-frame || Keep only the middle frame ||
||--nskip n || Skip the first n frames ||
||--ndrop n || Drop the last n frames ||
||--fsubsample start delta end || Frame subsampling (end = -1 for end) ||
||--sc or --scale factor || Input intensity scale factor ||
||-osc or --out-scale factor || Output intensity scale factor ||
||-il or --in_like || ||
||-roi || ||
||-fp or --fill_parcellation || ||
||-sp or --smooth_parcellation || ||
||-zo or --zero_outlines || ||
||-cf or --color_file || ||
||-nt or --no_translate || ||
||--status || Status file for DICOM conversion ||
||--sdcmlist || List of DICOM files for conversion ||
||-ti or --template_info || Dump info about template ||
||-gis <gdf image file stem> || ||
||-cg or --crop_gdf || Apply GDF cropping ||
||-zgez or --zero_ge_z_offset || Set c_s=0 (appropriate for dicom files from GE machines with isocenter scanning) ||
||--sphinx || Reorient to sphinx the position. This function is applicable when the input geometry information is correct but the subject was in the scanner in the 'sphinx' position (ie AP in line with the bore) instead of head-first-supine (HFS). This is often the case with monkeys. Note that the assumption is that the geometry information in the input file is otherwise accurate. ||
{{{
mri_warp_convert --infsl fsl.nii.gz --outm3z out.m3z --insrcgeom src.nii.gz
}}}
== Example 2 ==
Convert ITK warp (e.g. ANTs) to M3Z (FreeSurfer):
Line 161: Line 55:
= Outputs =
|| outvolume || Output volume ||
{{{
mri_warp_convert --initk itk.nii.gz --outm3z out.m3z --insrcgeom src.nii.gz
}}}
== Example 3 ==
Convert ANTS antsRegistrationSyN.sh or antsRegistrationSyNQuick.shboutput to M3Z (FreeSurfer):
Line 164: Line 61:
= Additional Information =
https://surfer.nmr.mgh.harvard.edu/pub/docs/html/mri_convert.help.xml.html
{{{
antsRegistrationSyNQuick.sh -d 3 -m mov.mgz -f targ.mgz -o reg.
}}}
{{{
ConvertTransformFile 3 ants.reg0GenericAffine.mat ants.reg0GenericAffine.txt --hm --ras
}}}
{{{
lta_convert --src mov.mgz --trg targ.mgz --inniftyreg ants.reg0GenericAffine.txt --outlta ants.reg0GenericAffine.lta
}}}
{{{
mri_warp_convert --lta1-inv ants.reg0GenericAffine.lta --initk ants.reg1Warp.nii.gz --outm3z out.m3z --insrcgeom targ.mgz
}}}
Note that the insrcgeom is the target, not the mov; this is needed to work with --lta1-inv.

== Example 4 ==
Convert M3Z (FreeSurfer) to ITK warp (e.g. ANTs):

{{{
mri_warp_convert --inm3z in.m3z --outitk out.nii.gz
}}}
== Example 5 ==
Convert M3Z (FreeSurfer) to mgz warp (FreeSurfer) in absolute CRS:

{{{
mri_warp_convert --inm3z in.m3z --outmgzwarp outwarp.mgz --outwarpformat abs-crs
}}}
= Notes on Freesurfer 3D Morph MGZ Format =
The Freesurfer 3D morph MGZ files follow Freesurfer MGZ format with intent MGZ_INTENT_WARPMAP and specific TAG attributes.
=== TAG Attributes ===
||'''TAG''' ||'''Comment''' ||
||TAG_GCAMORPH_GEOM ||gcamorph image (source) geom gcamorph atlas (target) geom ||
||TAG_GCAMORPH_GEOM_PLUSSHEAR ||gcamorph image (source) geom with shears gcamorph atlas (target) geom with shears ||
||TAG_GCAMORPH_META || 1. WARPFIELD_DTFMT_ABS_CRS, WARPFIELD_DTFMT_DISP_CRS, WARPFIELD_DTFMT_ABS_RAS, or WARPFIELD_DTFMT_DISP_RAS 2. spacing (int) 3. exp_k (double) ||
||TAG_GCAMORPH_LABELS || gcamorph label data ||
||TAG_GCAMORPH_AFFINE || gcamorph m_affine matrix ||

=== Data Array ===
The data array (width x height x depth x nframes) is indexed by atlas CRS:
 * frame 0 - image voxel ABS coordinate C, voxel DISP coordinate C, image RAS ABS coordinate X, or RAS DISP coordinate X
 * frame 1 - image voxel ABS coordinate R, voxel DISP coordinate R, image RAS ABS coordinate Y, or RAS DISP coordinate Y
 * frame 2 - image voxel ABS coordinate S, voxel DISP coordinate S, image RAS ABS coordinate Z, or RAS DISP coordinate Z

=== Data Formats ===
||WARPFIELD_DTFMT_ABS_CRS || CRS coordinates in image space ||
||WARPFIELD_DTFMT_DISP_CRS || displacement CRS, delta = image_CRS - atlas_CRS ||
||WARPFIELD_DTFMT_ABS_RAS || RAS coordinates in image space ||
||WARPFIELD_DTFMT_DISP_RAS || displacement RAS, delta = image_RAS - atlas_RAS ||

=== MGZ to Nifti Conversion ===
The Freesurfer 3D morph MGZ files (MGZ_INTENT_WARPMAP) can be converted to Nifti with intent code NIFTI_INTENT_DISPVECT.

NIFTI_INTENT_DISPVECT has shape [5, c, r, s, 1, 3], and the displacement field vector is in RAS space. Freesurfer reads the 5th dimensions as extra frames in MRI struct.
Line 168: Line 115:
[[mris_convert]] [[lta_convert]] (convert between different linear transform formats)

[[mri_concatenate_lta]] (concatenate or invert LTA transforms)

[[mri_concatenate_gcam]] (concatenate or invert warp fields)

[[mri_convert]] -at or -ait (apply transforms to an image)
Line 172: Line 125:

= Author/s =
DougGreve, BruceFischl

Index

Name

mri_warp_convert

Description

Converts non-linear deformation warp fields between different file formats. Some formats may require you to pass an image if the geometry information is missing from the transform file.

Synopsis

mri_warp_convert <input-type> <output-type> [options]

Arguments

Required Flagged Arguments

Exactly one input is required

Flag

Description

--inm3z <in.m3z>

input Freesurfer 3D morph in M3Z format

--inmgzwarp <inwarp.mgz>

input Freesurfer 3D morph in mgz format

--infsl <in.nii.gz>

input FSL warp (recommend to use with --insrcgeom)

--inspm <y_rinput.nii>

input SPM warp (use with --insrcgeom). Use --inwarpformat <> to specify the data format, which is either abs-ras (default) or abs-crs.

--inlps, --initk <in.nii.gz>

input LPS-to-LPS displacement field (e.g. ITK, ANTs)

--inras <in.nii.gz>

input RAS-to-RAS displacement field (e.g. NiftyReg)

--invox <in.mgz>

input displacement field in source-voxel space

Exactly one output is required

Flag

Description

--outm3z <out.m3z>

output Freesurfer 3D morph in M3Z format

--outmgzwarp <outwarp.mgz>

output Freesurfer 3D morph in mgz format

--outfsl <out.nii.gz>

output warp in FSL format

--outlps, --outitk <out.nii.gz>

output LPS-to-LPS displacement field (e.g. ITK, ANTs)

--outras <out.nii.gz>

output RAS-to-RAS displacement field (e.g. NiftyReg)

--outvox <out.mgz>

output displacement field in source-voxel space

Optional Flagged Arguments

Flag

Description

-g, --insrcgeom <geom.mgz>

specify volume geometry of the input to the warp space, i.e., srcgeom shares an RAS space with the warp volume. Usually this is identical to the geom of the warp volume itself (if the warp input is in a format that has such info). This also allows the input to the warp to have a different geometry than the warp itself, though this is probably better handled with -lta1.

-d, --downsample

downsample output M3Z to spacing of 2.

-lta2 LTA (or -lta2-inv)

create composite morph for warping a source image -> LTA1 -> GCAM -> LTA2 -> atlas/destination image

--inwarpformat <format>

specify warp data format: abs-crs, disp-crs, abs-ras, or disp-ras (default is abs-crs). This option only works with '--inspm <>'.

--outwarpformat <format>

specify warp data format: abs-crs, disp-crs, abs-ras, or disp-ras (default is abs-crs)

--vg-thresh <vgthresh>

specify threshold for testing diffs in volume geom

Examples

Example 1

Convert FSL warp to M3Z (FreeSurfer):

mri_warp_convert --infsl fsl.nii.gz --outm3z out.m3z --insrcgeom src.nii.gz

Example 2

Convert ITK warp (e.g. ANTs) to M3Z (FreeSurfer):

mri_warp_convert --initk itk.nii.gz --outm3z out.m3z --insrcgeom src.nii.gz

Example 3

Convert ANTS antsRegistrationSyN.sh or antsRegistrationSyNQuick.shboutput to M3Z (FreeSurfer):

antsRegistrationSyNQuick.sh -d 3 -m mov.mgz -f targ.mgz -o reg.

ConvertTransformFile 3 ants.reg0GenericAffine.mat ants.reg0GenericAffine.txt --hm --ras

lta_convert --src mov.mgz --trg targ.mgz --inniftyreg ants.reg0GenericAffine.txt --outlta ants.reg0GenericAffine.lta

mri_warp_convert --lta1-inv ants.reg0GenericAffine.lta --initk ants.reg1Warp.nii.gz --outm3z out.m3z --insrcgeom targ.mgz

Note that the insrcgeom is the target, not the mov; this is needed to work with --lta1-inv.

Example 4

Convert M3Z (FreeSurfer) to ITK warp (e.g. ANTs):

mri_warp_convert --inm3z in.m3z --outitk out.nii.gz

Example 5

Convert M3Z (FreeSurfer) to mgz warp (FreeSurfer) in absolute CRS:

mri_warp_convert --inm3z in.m3z --outmgzwarp outwarp.mgz --outwarpformat abs-crs

Notes on Freesurfer 3D Morph MGZ Format

The Freesurfer 3D morph MGZ files follow Freesurfer MGZ format with intent MGZ_INTENT_WARPMAP and specific TAG attributes.

TAG Attributes

TAG

Comment

TAG_GCAMORPH_GEOM

gcamorph image (source) geom gcamorph atlas (target) geom

TAG_GCAMORPH_GEOM_PLUSSHEAR

gcamorph image (source) geom with shears gcamorph atlas (target) geom with shears

TAG_GCAMORPH_META

1. WARPFIELD_DTFMT_ABS_CRS, WARPFIELD_DTFMT_DISP_CRS, WARPFIELD_DTFMT_ABS_RAS, or WARPFIELD_DTFMT_DISP_RAS 2. spacing (int) 3. exp_k (double)

TAG_GCAMORPH_LABELS

gcamorph label data

TAG_GCAMORPH_AFFINE

gcamorph m_affine matrix

Data Array

The data array (width x height x depth x nframes) is indexed by atlas CRS:

  • frame 0 - image voxel ABS coordinate C, voxel DISP coordinate C, image RAS ABS coordinate X, or RAS DISP coordinate X
  • frame 1 - image voxel ABS coordinate R, voxel DISP coordinate R, image RAS ABS coordinate Y, or RAS DISP coordinate Y
  • frame 2 - image voxel ABS coordinate S, voxel DISP coordinate S, image RAS ABS coordinate Z, or RAS DISP coordinate Z

Data Formats

WARPFIELD_DTFMT_ABS_CRS

CRS coordinates in image space

WARPFIELD_DTFMT_DISP_CRS

displacement CRS, delta = image_CRS - atlas_CRS

WARPFIELD_DTFMT_ABS_RAS

RAS coordinates in image space

WARPFIELD_DTFMT_DISP_RAS

displacement RAS, delta = image_RAS - atlas_RAS

MGZ to Nifti Conversion

The Freesurfer 3D morph MGZ files (MGZ_INTENT_WARPMAP) can be converted to Nifti with intent code NIFTI_INTENT_DISPVECT.

NIFTI_INTENT_DISPVECT has shape [5, c, r, s, 1, 3], and the displacement field vector is in RAS space. Freesurfer reads the 5th dimensions as extra frames in MRI struct.

See Also

lta_convert (convert between different linear transform formats)

mri_concatenate_lta (concatenate or invert LTA transforms)

mri_concatenate_gcam (concatenate or invert warp fields)

mri_convert -at or -ait (apply transforms to an image)

Reporting Bugs

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

mri_warp_convert (last edited 2026-02-10 18:09:31 by YujingHuang)