This is an extension to Tools for NIfTI and ANALYZE image and contains additional utilities that I found useful when dealing with NIFTIs in MATLAB.
Utilities in this package allow for data processing to occur WRT storage orientation while also taking data scaling into account, saving NIFTIs after they have been modified/processed in the same orientation, getting the volume in "voxel RAS" orientation which is useful for plotting results without resampling or reslicing the data, and more...
There's more info and a tutorial here for working with NIFTI files in MATLAB with this library.
- (optional - only if you want to use radiological storage orientation check) Install FSL
- Download repo:
git clone https://github.com/justinblaber/nifti_utils.git
- In MATLAB:
You can try out some of the utilties like so:
% Load volume test_vol = nifti_utils.load_untouch_nii_vol_scaled('test.nii.gz','double'); % Get "voxel RAS" transform xform_RAS = nifti_utils.get_voxel_RAS_xform('test.nii.gz'); % Apply transform to volume test_vol_RAS = nifti_utils.vol_apply_xform(test_vol,xform_RAS); % View the 4D volume slice-wise nifti_utils.vol_viewer_4D(test_vol_RAS);
The viewer should look something like: