-
Notifications
You must be signed in to change notification settings - Fork 10
/
brant_check_tps.m
29 lines (26 loc) · 1.1 KB
/
brant_check_tps.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
function num_niis = brant_check_tps(is4d_ind, process_str, nifti_list, working_dir)
% check and output time points
% works only for unzipped files!
if (is4d_ind == 1)
num_niis = cellfun(@brant_get_nii_frame, nifti_list);
if numel(unique(num_niis)) ~= 1
print_diff_vols_msg(working_dir, process_str, num_niis, nifti_list);
end
else
num_niis = cellfun(@numel, nifti_list);
if (numel(unique(num_niis)) ~= 1)
print_diff_vols_msg(working_dir, process_str, num_niis, nifti_list);
end
end
function print_diff_vols_msg(working_dir, process_str, num_niis, data_files)
arrayfun(@(x, y) fprintf('Timepoint:%d\t%s\n', x, y{1}), num_niis, data_files);
try
time_now = ceil(clock);
log_fn = fullfile(working_dir, ['brant_', process_str, '_diff_tps', sprintf('_%d', time_now), '.txt']);
warning('The numbers of volume/subject are different! Please visit %s!', log_fn);
fid = fopen(log_fn, 'rw');
arrayfun(@(x, y) fprintf(fid, 'Timepoint:%d\t%s\n', x, y{1}), num_niis, data_files);
fclose(fid);
catch
warning('The numbers of volume/subject are different! Please chcek');
end