Imaging Data Formats

From BrainImagingCenter
Jump to: navigation, search

Imaging Data Formats

Data collected from the scanner are in PAR/REC format and converted to SPM/ANALYZE using the DBIC's par_convert utility. Other supported formats include NIfTI and AFNI (BRIK+HEAD).

In addition to conversion from PAR/REC to ANALYZE, NIfTI & AFNI it is also possible to use command line tools to convert between formats.

  • To convert between 3D analyze and NIfTI formats (note: you must run from the shell, not MATLAB):
$ fslchfiletype NIFTI output input
$ fslchfiletype ANALYZE output input
  • To create a gzipped nifti file from a 3D analyze image, simply use:
$ fslchfiletype NIFTI_GZ output input
  • To convert a series of 3D images (e.g. bold1_0001.img ... bold1_000n.img) to a single 4D NIfTI file:
$ fslmerge -t bold1 bold1*.img
  • To convert a 4D NIfTI file to a series of 3D images:
$ fslsplit bold1 bold1_ -t
  • Notes on using 4D fMRI volumes with SPM5/8.

John Ashbuner provides notes on using 4d volumes with SPM5/8.

PAR/REC to NIFTI conversion issues

Converting data to NIFTI format from Philip PAR/REC, or directly from the Philips console using the tools provided by the recent upgrade, can lead to origin problems associated with improper transformations from scanner "world" space to image "voxel" space. From what we understand, scanner space on the Philips machine has an origin defined by the magnetic isocenter of the B0 field and, if the head coil was properly laser marked, this will correspond to the physical center of the head coil. Thus, the origin in world/scanner space is generally the center of the head coil, while the origin of image/voxel space is the center of the of the slice acquistion box. (someone correct this if I'm mistaken).

Unlike spm analyse format, the NIFTI header stores a transformation matrix to move between voxel and world space. Unfortunately, this transformation varies depending on the NIFTI conversion tool used. This becomes especially problematic as most neuroimaging applications use the origin as a starting point for realignment and normalization to standard space. In SPM this seems to be done by simply aligning the native space data to the standard space template based on the origin, which should be near the center of the brain for both volumes. SPM can tolerate a certain amount of shift in the origin from the center of the brain, but anything beyond this will result in poor realignment and a complete failure to normalize the images.

The easy way out is to simply remove these transformations, forcing SPM to work in voxel space (one way is to convert to analyze and use fslchfiletype and fslmerge to convert to NIFTI). However, preserving the transformation to scanner space has the advantage of making multimodal registration more efficient (as images within a session should all be in the same position relative to scanner world space, even if their acquisition details change as we go from EPI to DTI to MRI).

Below are the results comparing different NIFTI conversion methods along with where SPM8 and FSL place the origin and finally comparing this placement to what the origin actually was prior to acquisition (using the power of SCREENSHOT).

  • Scanner origin prior to slice placement. I believe the numbers in parentheses refer to the center of the image/head coil, indicating that the head coil was not perfectly centered with respect to the scanner isocenter.
This images shows where the scanner origin was prior to slice placement, I believe the numbers in parenthesis refer to center of the image.
  • Placement of slices for this run.
This images shows slice placement.

Conversion methods: Caveat: I haven't found a way to figure out what exactly is the true scanner origin in voxel space, which means we have to eyeball the origins spat out by SPM and FSL and compare them to the screenshot of where the console said it was. If anyone has a better trick, by all means, fix this! Also, FSL starts counting slices at 0, in general FSL and SPM agree on the origin but FSL displays them in radiological convention (spm8 is neurological).

1.Scanner exported NIFTI:

  • Origin: 40.3, 44.2, 7.5(SPM8) 39,43,6(FSL)
  • Voxels reported as: 3X3X3.5

2.Scanner exported NIFTI-FSL:

  • Origin: 40.3, 38.4, 20.5(SPM8) 39,37,19(FSL)
  • Voxels reported as: -3X3X3.5
  • Both SPM8 and FSL get the origin way off with the NIFTI_FSL format, placing it too high in the z-plane.

4. dcm2nii:

  • Origin: 39.8,36.8,7.45(SPM8) or 38,35,6(FSL).
  • Voxels reported as: -3X3X3.5
  • Voxels reported as: -3X3X3.48

5. r2agui:

  • Origin: 39.8,36.8,7.5 (SPM8) or 38,35,6 (FSL)
  • r2agui is very similar to dcm2nii, but not identical. Comparing the full transformation matrix win the qform field of the nifti header shows some differences.
  • Voxels reported as: -3X3X3.48

4. par_convert:

  • The current version of par_convert converts PAR/REC to the older spm_analyze format and then uses fsl tools to convert this NIFTI, making changes to the header (Setting qform to 1). No other transformation is added to the header and in theory this should be the same as having no transformation at all, however the matrix specified in the qform field of the NFITI header is interpreted as indicating that the scanner origin is at 80,1,1 (SPM8) or 79,0,0 (FSL) (i.e. absolute bottom slice, way outside the brain). In SPM this causes poor realignment and failure of normalization.

5. Manual conversion from analyze to nifti:

  • In SPM8 the lack of qform setting put the origin at center of the volume (i.e. 40.5 40.5 17.0)
  • In FSL this lack of transformation sets the origin to 79,0,0!
  • Voxels reported as: 3X3X3.5

Which is best? So far it looks like the closest match is the scanner exported NIFTI (see below). Unfortunately that means there's no good solution for converting previously acquired data that are no longer on the console. dcm2nii and r2agui are close but the way they scale intensities is wildly different than our previously acquired data and could cause problems if directly comparing to previous results. Zeroing the qform field by converting to analyze then back to nifti without modifying the header works great with SPM but not so good for FSL.

Origin of scanner nifti export.

Further issues:

  • scanner exported NIFTI_FSL gets the origin wrong on anatomical data. Both SPM and FSL place the origin outside the brain. Regular scanner exported NIFTI anatomicals are fine.
  • dcm2nii and r2agui both change the scaling of the image intensities while par_convert and the scanner NIFTI exports are similar to our previously acquired analyze data.