help > RE: MATLAB and MRIcron flipped images
Sep 12, 2018  12:09 PM | Chris Rorden
RE: MATLAB and MRIcron flipped images
MRIcron is able to use the spatial rotation transform to re-orient images for consistent display. Use the Help/Preferences to decide if you want to view the raw data (rows, columns and slices as saved on disk, regardless of spatial orientation), rotated to nearest orthogonal, or resliced. 

If you want consistent spatial display in Matlab you will need to take the spatial transforms (S/Q Forms) into account. 

My personal favorite solution is Xiangrui Li's nii_viewer and nii_tool. This includes simple functions for reorienting data
  nii_viewer('nifti.nii')

Other solutions include

Matlab 2018: (see hdr.Transform.T)
hdr = niftiinfo('nifti.nii');
img = niftiread('nifti.nii');

SPM: (see hdr.mat)
hdr = spm_vol('nifti.nii');
img = spm_read_vols(hdr);

Jimmy Shen's Matlab tools.

Be aware that the NIfTI S-Form is indexed from zero (since the first element in a C array is v[0]), whereas the transforms shown by some of the tools above adjust this to be indexed from one (singe the first element in a Matlab array is v[1]). You need to keep this in mind when determining coordinates and saving NIfTI files.

Threaded View

TitleAuthorDate
sjack Sep 11, 2018
RE: MATLAB and MRIcron flipped images
Chris Rorden Sep 12, 2018