forked from rordenlab/spmScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnii_nii2voi.m
executable file
·27 lines (25 loc) · 915 Bytes
/
nii_nii2voi.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
function nii_nii2voi (V);
% Converts a NIfTI image to a MRIcron VOI file.
% A VOI file is a GZipped NIfTI image with the extension '.VOI'
% MRIcron uses VOI files for binary volumes of interest (e.g. lesion maps)
% Currently, only works for .nii images, not .hdr/.img images
% Example
% nii_nii2voi('C:\irate\chrisr.nii');
if nargin <1 %no files
V = spm_select(inf,'image','Select images to delete');
end;
for i=1:size(V,1)
ref = deblank(V(i,:));
[pth,nam,ext] = spm_fileparts(ref);
if (exist(ref) ~= 2)
fprintf('nii_nii2voi warning unable to find file %s.\n',ref);
return;
end;
upext = upper(ext);
if (strcmp(upext,'.IMG') || strcmp(upext,'.HDR'))
fprintf('nii_nii2voi warning: currently only supports .nii files, not .hdr/.img pairs');
return;
end;
gzip(ref);
movefile(fullfile(pth,[nam ext '.gz']), fullfile(pth,[nam '.voi']));
end; %for each file