-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathChiDist.m
More file actions
75 lines (61 loc) · 2.41 KB
/
Copy pathChiDist.m
File metadata and controls
75 lines (61 loc) · 2.41 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
classdef ChiDist < handle
properties
% volume properties
type
matrix
image_res
volume
sus
end
methods
function obj = ChiDist( matrix, image_res, sus, type )
% Method chi_dist (constructor)
obj.matrix = matrix ;
obj.image_res = image_res ;
obj.sus = sus ;
if nargin < 2
obj.type = 'generic' ;
else
obj.type = type ;
end
end
function vol = save(obj, fileName, saveFormat)
% Get magnitude data
% fileName: String. Prefix of filename (without extension)
% saveFormat: 'nifti' (default) or 'mat'
vol = obj.volume;
if ~exist('saveFormat', 'var')
warning('No save format given - saving to NIfTI')
saveFormat = 'nifti';
end
if strcmp(fileName(end-3:end), '.nii')
if ~strcmp(saveFormat, 'nifti')
warning('File extension and saveFormat do not match - saving to NIfTI format')
saveFormat = 'nifti';
end
fileName = fileName(1:end-4);
elseif strcmp(fileName(end-3:end), '.mat')
if ~strcmp(saveFormat, 'mat')
warning('File extension and saveFormat do not match - saving to MAT format')
saveFormat = 'mat';
end
fileName = fileName(1:end-4);
end
switch saveFormat
case 'nifti'
if strcmp(obj.type,'Zubal')
nii_vol = make_nii(vol);
else
nii_vol = make_nii(imrotate(fliplr(vol), -90));
% set image resolution in nifti header
nii_vol.hdr.dime.pixdim(2) = obj.image_res(1);
nii_vol.hdr.dime.pixdim(3) = obj.image_res(2);
nii_vol.hdr.dime.pixdim(4) = obj.image_res(3);
end
save_nii(nii_vol, [fileName '.nii']);
case 'mat'
save([fileName '.mat'], 'vol')
end
end
end
end