-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppVerifyScan.m
executable file
·92 lines (63 loc) · 3.14 KB
/
ppVerifyScan.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function [ ] = ppVerifyScan( workingDir, scanDir )
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
DS = filesep();
dicomDir = strcat(scanDir, 'dicom', DS);
niftiDir = strcat(scanDir, 'nifti', DS);
nifti4dPath = strcat(niftiDir, 'vols.nii');
archiveName = 'dicom.tar.gz';
archivePath = strcat(dicomDir, archiveName);
[paradigm, paradigmPath] = ppFindParadigm(workingDir, scanDir);
[PPmode,dicomVolumes,tarSize] = ppReadParadigm(paradigmPath, paradigm);
%% Check if 4D-nifti exists
if ( exist(nifti4dPath, 'file') == 0 )
throw(MException('PPS:VerificationError','4d-nifti missing: "%s".', nifti4dPath));
end
%-----------------------------------------------------------------------------------------------------------
%% Check if 4D-nifti is valid
% Get number of DICOMs
[nDicoms, unused] = ppGetFilesUsingPattern(dicomDir, '\.ima$');
% Determine the number of volumes in the 4D-nifti
nVolumes = ppGetVolumeCountNifti4d(nifti4dPath);
if (nVolumes < dicomVolumes )
throw(MException('PPS:VerificationError','4d-nifti contains too few volumes: "%s".', nifti4dPath));
end
%-----------------------------------------------------------------------------------------------------------
%% Check DICOM archive exists
if ( exist(archivePath, 'file') == 0 )
throw(MException('PPS:VerificationError','DICOM-archive missing: "%s".', archivePath));
end
%-----------------------------------------------------------------------------------------------------------
%% Check if DICOM archive is valid
% Get number of files in the archive
%rsl deactivated feature
% nFiles = ppGetTarFileCount(archivePath);
%
% % Compare the number of files in the archive with those in the DICOM folder
% if ( nFiles < nDicoms )
% throw(MException('PPS:VerificationError','DICOM-archive contains too few DICOMs: "%s".', archivePath));
% end
%-----------------------------------------------------------------------------------------------------------
%% Check if statistical derivates exist
meanPath = strcat(niftiDir, 'mean.nii');
stdPath = strcat(niftiDir, 'std.nii');
snrPath = strcat(niftiDir, 'snr.nii');
if ( exist(meanPath, 'file') == 0 )
throw(MException('PPS:VerificationError','Mean volume is missing: "%s".', meanPath));
end
if ( exist(stdPath, 'file') == 0 )
throw(MException('PPS:VerificationError','Standard deviation volume is missing: "%s".', stdPath));
end
if ( exist(snrPath, 'file') == 0 )
throw(MException('PPS:VerificationError','Signal-to-noise volume is missing: "%s".', snrPath));
end
%-----------------------------------------------------------------------------------------------------------
%% Check if the data fulfills the requirements of the paradigm
ppCheckParadigmDicom(dicomDir,dicomVolumes,tarSize);
%-----------------------------------------------------------------------------------------------------------
%% Check if all requirements to run the preprocessing job were fulfilled
if ( PPmode(1:1) ~= '-' )
ppCheckParadigmNifti(workingDir, niftiDir, PPmode, 1);
end
%-----------------------------------------------------------------------------------------------------------
end