-
Notifications
You must be signed in to change notification settings - Fork 0
/
pps.m
executable file
·83 lines (58 loc) · 2.74 KB
/
pps.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
function [ ] = pps(path)
%Runs the pre-processing procedure, that is imports the dicoms and
%preprocesses them. The path can either be the subject
%directory(preprocessing only) or the transfer folder(import and
%preprocessing).
DS = filesep();
%% Extract path information
exPath = regexpi(path,'(?<workingDir>.*)(?<mode>subjects|transfer|measurements)(?<subDir>.*)', 'names');
workingDir = exPath.workingDir;
mode = exPath.mode;
inputDir = strcat(workingDir,mode);
% determine nesting level of the subpath by adding the non-empty parts of the path
subDir = exPath.subDir;
subDirLevel = sum(not(cellfun(@isempty, regexp(subDir, DS, 'split'))));
if (strcmp(mode, 'measurements'))
%% Preprocessing only
if subDirLevel == 0
% Preprocessing for the whole measurements directory
ppProcessAllMeasurements(workingDir);
elseif subDirLevel == 1
% Preprocessing for a single measurement date
ppProcessMeasurementsAtDate(workingDir, path);
elseif subDirLevel == 2
% Preprocessing for a single subject
ppProcessMeasurementsSubject(workingDir, path);
elseif subDirLevel == 3
% Preprocessing for a single scan
ppProcessMeasurementsScan(workingDir, path);
else
throw(MException('PPS:invalidPath','Source path in the subjects directory can point to either the subjects dir itself, a single subject''s dir, a measurement''s dir or the dir of a single scan. Single DICOMs/Niftis cannot be processed individually!'));
end
elseif (strcmp(mode,'subjects'))
%% Preprocessing only
if subDirLevel == 0
% Preprocessing for the whole subjects dir
ppProcessAllScans(workingDir);
elseif subDirLevel == 1
% Preprocessing for a single subject
ppProcessSubject(workingDir, path);
elseif subDirLevel == 2
% Preprocessing for a single measurement
ppProcessMeasurement(workingDir, path);
elseif subDirLevel == 3
% Preprocessing for a single scan
ppProcessScan(workingDir, path);
else
throw(MException('PPS:invalidPath','Source path in the subjects directory can point to either the subjects dir itself, a single subject''s dir, a measurement''s dir or the dir of a single scan. Single DICOMs/Niftis cannot be processed individually!'));
end
return
elseif (strfind(mode,'transfer'))
%% Transfer files and preprocess
%% rsl: strfind instead strcmp to allow for variations of transfer
%% folder name
ppTransferFiles(workingDir, path);
else
throw(MException('PPS:invalidPath','Source Directory must either be a subfolder of the "subject", "measurement" or "transfer" folder!'));
end
end