support for reading TIFF images
Rudimentary support has now been added to import TIFF images, whether as a series of individual slices, or as a single multi-page TIFF. RGB images will appear as 4D images with 3 volumes, one for each of the red, green & blue channels. Multi-page TIFFs will be loaded with each page assumed to correspond to a different slice.
To be able to use this fully relies on MRtrix3’s existing numbered image support to load a set of image slices or volumes. It will also most likely require further adjustments to various parameters, notably the voxel size, the orientation of the data, and the ordering of the axes.
Examples
To convert a set of single-slice RGB TIFFs as-is:
$ mrconvert tiff/images-[].tif out.nii
This will result in a 5D image, since each TIFF image is concatenated along the last dimension. In other words, the image will look something like this (assuming there were 64 TIFF images):
$ mrinfo out.nii
************************************************
Image: "b0.nii"
************************************************
Dimensions: 96 x 96 x 1 x 3 x 64
To deal with this, you can use the -axes
option to permute the data:
$ mrconvert tiff/images-[].tif out.nii -axes 0,1,4,3
giving the expected result:
$ mrinfo out.nii
************************************************
Image: "b0.nii"
************************************************
Dimensions: 96 x 96 x 64 x 3
You can also use the -vox
option to set the correct voxel dimensions, and if needed changes the order of the axes to rotate the data as required.
Loading a multi-page tiff is simpler since each page in the file is assumed to correspond to a different slice. Again, an RGB image will be imported as a 4D image. If required, a set of multi-page TIFF images can be imported as a single dataset using MRtrix3’s numbered file support.
In due course, we hope to add support for TIFF export (the issue is already listed on GitHub)