-
Notifications
You must be signed in to change notification settings - Fork 7
/
magia_clean_files.m
70 lines (58 loc) · 1.71 KB
/
magia_clean_files.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
function magia_clean_files(subject)
data_path = getenv('DATA_DIR');
D = sprintf('%s/%s',data_path,subject);
if(exist(D,'dir'))
fprintf('Deleting files (%s)...',subject);
% Remove bad directories
dir_names = {'MRI' 'masks' 'results'};
for i = 1:length(dir_names)
d = sprintf('%s/%s',D,dir_names{i});
if(exist(d,'dir'))
rmdir(d,'s');
end
end
% Remove PET files
pet_dir = sprintf('%s/PET',D);
if(exist(pet_dir,'dir'))
good_dirs = {
sprintf('%s/dcm',pet_dir);
sprintf('%s/ecat',pet_dir);
sprintf('%s/nii',pet_dir);
};
f = setdiff(get_filenames(pet_dir,''),good_dirs);
cellfun(@delete,f);
fprintf(' Done.\n');
else
warning('Could not find PET files for %s.\n',subject);
end
plasma_dir = sprintf('%s/plasma',D);
if(exist(plasma_dir,'dir'))
f = get_filenames(plasma_dir,'*.png');
if(~isempty(f))
delete(f{1});
end
end
% Delete the QC file
qc_file = sprintf('%s/qc_%s.ps',D,subject);
if(exist(qc_file,'file'))
delete(qc_file);
end
% Delete the modeling options file
mo_file = sprintf('%s/modeling_options_%s.txt',D,subject);
if(exist(mo_file,'file'))
delete(mo_file);
end
% Delete the githash file
gh_file = sprintf('%s/githash_%s.txt',D,subject);
if(exist(gh_file,'file'))
delete(gh_file);
end
% Delete the specs file
specs_file = sprintf('%s/specs_%s.txt',D,subject);
if(exist(specs_file,'file'))
delete(specs_file);
end
else
error('Could not find the subject directory for %s.',subject);
end
end