-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsave_nifti.m
33 lines (29 loc) · 1006 Bytes
/
save_nifti.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [nifti_out] = save_nifti(nii, image_path, type)
%*****************************************************************
% SAVE NIFTI function
%
% Simple function to save nii/nii.gz files automatically
% - parameter type controls if the image has to be saved compressed or uncrompressed.
% - type = 'C' --> compressed
% - type = 'U' --> uncompressed
%
% This library makes use of the wonderful toolbox provided by Jimmy Shen.
% https://www.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image
%
%
% ****************************************************************
% images are compressed by default
switch nargin
case 2
type = 'c';
otherwise
type = type;
end
if strcmp(type,'c')
save_compressed_nii(nii, image_path);
elseif strcmp(type,'u')
save_untouch_nii(nii, [image_path,'.nii']);
else
error('NIFTI TOOLS: the option you are specifiying is not found or available. :(');
end
end