Skip to content

QC and fix MRIs converted from other formats

Alexandra Talpalaru edited this page Sep 23, 2017 · 1 revision

Convert MRIs from other formats

There are 4 common medical image file formats: Analyze, Neuroimaging Informatics Technology Initiative (Nifti), Digital Imaging and Communication in Medicine (Dicom), Medical Image NetCDF (MINC). Medical image processing may start with some form of image conversion from Dicom to a format compatible with available pipelines. For bpipe, CIVET, or MAGeT brain, it is necessary that the files are in MINC format.

Additional information on file formats can be found here: Larobina, Michele, and Loredana Murino. “Medical Image File Formats.” Journal of Digital Imaging 27.2 (2014): 200–206. PMC. Web. 28 Feb. 2017.

Converting from different data types to MINC: http://www.bic.mni.mcgill.ca/ServicesSoftware/ConvertingOtherFileTypesToMINC

Dicom [.dcm] -> MINC: dcm2mnc

dcm2mnc [options] -usecoordinates <dicomdirectoryname> <output>

Analyze [.img, .hdr]-> MINC: ana2mnc

ana2mnc [options] <filename>.img <output>.mnc

Nifti [.nii, or separate image and header file]-> MINC: nii2mnc

nii2mnc [options] <filename>.nii <output>.mnc

All of the options for the commands are listed in the help files. To view the help files use the -help command.

ana2mnc -help

World coordinate systems for the different file formats:

Analyze: +x Left, +y Anterior, +z Superior (LAS)

MINC: +x Right, +y Anterior, +z Superior (RAS)

Nifti: RAS or LAS

In the case of RAS coordinate system:

Positive x: increases from left to right, positive y: increases from posterior to anterior, positive z: increases from inferior to superior.

Dicom file format is the most complete, containing information about the pixels, orientation, procedure and the patient. Nifti files storage is not standardised and can be stored either in the RAS or LAS coordinate system. Nifti header files may contain transformation matrices, qform and sform, that can be used to bring the data coordinates into real world coordinates, but sometimes this information is missing, or dependent on the software used in the conversion. Analyze file format does not store enough information to establish the image orientation.

For more information about Nifti orientation see: https://nifti.nimh.nih.gov/nifti-1/documentation/faq#Q14

Check the output of every conversion

Useful atlases to compare conversion against are located in the following folder:

/opt/quarantine/resources/

Symmetric atlas:

/opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c.mnc

Asymmetric atlas:

/opt/quarantine/resources/mni_icbm152_nlin_asym_09c_minc2/mni_icbm152_t1_tal_nlin_asym_09c.mnc

To view the atlases use the MINC visualisation tools. The Display and Register commands are the most useful for this application. To view a single MRI use the Display command. To view two MRIs side by side as well as a superposition of the two use the Register command.

Load the appropriate modules

module load minc-toolkit minc-toolkit-extras

The Display command is used as follows:

Display minc_volume.mnc

The Register command is used as follows:

register minc_volume1.mnc minc_volume2.mnc

More information can be found at: http://www.bic.mni.mcgill.ca/ServicesSoftwareVisualization/HomePage

Below is an example of how to use the Display command to view one of the atlases and the register command to register two atlases together.

module load minc-toolkit minc-toolkit-extras

Display /opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c.mnc

register /opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c.mnc /opt/quarantine/resources/mni_icbm152_nlin_asym_09c_minc2/mni_icbm152_t1_tal_nlin_asym_09c.mnc

The output should look as follows:

Fig. 1 Fig. 1

If you are checking multiple images against the atlas, it might be useful to set the atlas location as a variable.

export var_name=location/of/atlas/atlas.mnc

For example:

export MNIMODEL=/opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c.mnc

Then you can use the Register command with this variable.

register myfile.mnc $MNIMODEL

Things that can go wrong

Following image file conversion, the orientation of the volume may not be identical to the atlas image. In this case the processing pipelines will not function properly. Below are two example images of instances where the converted image does not match the atlas.

Fig. 2 shows an instance where the axial, sagittal, and coronal orientations match but need to be rotated.

Fig. 2

volflip

Fig. 3 shows an instance where the axial, sagittal, coronal orientations do not match.

Fig. 3

volmash

Before attempting to fix any image, contact the provider and inquire if you can get the original, dicom format, MRIs. If the original files are not available, information about which converter was used to transform the images to Nifti or ANALYZE would be useful in determining the orientation. If none of this information is available from the provider, continue to possible fixes.

Possible fixes

Two commands can be used to rotate the MR volumes: volflip, volmash. For a full explanation, as well as a list of options, see the help files. Volflip can be used if the order of the orientations is correct but some of the slice orientation need to be rotated, as is seen in Fig. 2. Volmash is useful when the orientations are not in the proper order, as exemplified in Fig. 3.

The following will make the axial orientation of Fig. 2 match the atlas.

volflip -y input.mnc output.mnc

Fig. 4

Fig. 4

The following will swap the orientations of Fig.3 such that they match the atlas.

volmash -swap xz input.mnc temp1.mnc

volmash -swap xy temp1.mnc output.mnc

Fig. 5

Fig. 5

The general rules for volmash are:

volmash -swap xy -OR- volmash -swap yx : swap bottom two orientations

volmash -swap xz -OR- volmash -swap zx : swap top two orientations

volmash -swap yz -OR- volmash -swap zy : swap top and bottom orientations

Check against atlas

Edited images can be checked against the atlas using the Register command. To perform a thorough comparison, and ensure that all of the changes are correct, register your MRI to MNI space before comparing it to the atlas. This can be done using the bestlinreg command.

The form of the command is:

bestlinreg_g -nmi -lsq12 -target_mask $MNI_MASK source.mnc $MNIMODEL transform.xfm [optional transformed source.mnc]

The MNI mask is located here in the following folder:

/opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c_mask.mnc

And can be set as a variable using the following command:

export MNI_MASK=/opt/quarantine/resources/mni_icbm152_nlin_sym_09c_minc2/mni_icbm152_t1_tal_nlin_sym_09c_mask.mnc

The following command will register the image in Fig. 5 to MNI space:

bestlinreg_g -nmi -lsq12 -target_mask $MNI_MASK input.mnc $MNIMODEL output_reg.xfm output_reg.mnc

It should now be easier to make comparisons to the atlas.

register output_reg.mnc $MNIMODEL

Fig. 6

Fig. 6

Check for brain asymmetry

One way to ensure that the orientation is correct is to check for brain asymmetries. In particular, look at the frontal and occipital regions of the brain. In a correctly oriented image, the anterior part of the right hemisphere should protrude across the mid-line. In the posterior part of the brain the left hemisphere should protrude past the mid-line. The right frontal hemisphere is wider than the left and the left occipital hemisphere is wider than the right.

Fig. 7

Fig. 7

Additional information on Petalia and Yakovlevian torque can be found here: Toga, Arthur W., and Paul M. Thompson. "Mapping brain asymmetry." Nature Reviews Neuroscience 4, no. 1 (2003): 37-48.

When comparing against the atlas, first make sure that the locations are synced. This can be done by toggling the "Not Synced" button in the Register window to show "Synced". Then scroll through the slices and check for brain asymmetries. An example is shown in Fig. 8.

Fig. 8

Fig. 8

Clone this wiki locally