forked from Chaogan-Yan/REST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_ReadNiiNum.m
executable file
·30 lines (24 loc) · 1 KB
/
rest_ReadNiiNum.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
function N=rest_ReadNiiNum(PI)
%function N=rest_ReadNiiNum(PI)
%Get the number of volume in the *.nii file.
%Input:
% PI: *.nii file name;
%Output:
% N: the number of volume;
%___________________________________________________________________________
% By DONG Zhang-Ye 110817.
% State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University, China, 100875
% Last revised by YAN Chao-Gan, 111111. Add the support for .nii.gz files.
addpath(fullfile(rest_misc('WhereIsREST'), 'rest_spm5_files'));
if strcmpi(PI(end-6:end), '.nii.gz') %YAN Chao-Gan, 111111. Uncompress data for .nii.gz file.
gunzip(PI);
IsNeedDeleteUncompressedVersioin = 1;
PI = PI(1:end-3);
end
V = rest_spm_vol(PI);
N=length(V);
if exist('IsNeedDeleteUncompressedVersioin','var') && IsNeedDeleteUncompressedVersioin == 1
delete(PI); %YAN Chao-Gan, 111111. Delete the uncompressed version after reading for .nii.gz file.
end
rmpath(fullfile(rest_misc('WhereIsREST'), 'rest_spm5_files'));