-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpm_mvfiles.m
115 lines (103 loc) · 3.08 KB
/
pm_mvfiles.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
root_pth ='D:\thk';
addpath('D:\thk\thk_codes')
data = pm0_COF_data(fullfile(root_pth));
for ii = 1:size(data,2)
fprintf(1,' Subject %i\n',ii)
if exist(fullfile(data(ii).dir,'MRI','nii2','Results')) ==7
cd(fullfile(data(ii).dir,'MRI','nii2','Results'))
mkdir('hMRI')
Files = dir('c*.nii');
for ifile = 1:size(Files,1)
fprintf(1,' file %i\n',ifile)
copyfile(Files(ifile).name,fullfile('hMRI',Files(ifile).name))
end
end
end
% ---------------------------
sub = ls('E*')
for isub = 4:size(sub,1)
cd(sub(isub,:));
mkdir MRI;
mkdir PET;
mkdir z_old;
Nii = ls('ni*');
movefile(Nii,'MRI');
Vfiles = ls('*.v');
for ifile = 1:size(Vfiles,1);
movefile(Vfiles(ifile,:),'PET');
end
Type = {'*.nii' '*.mat' '*.ps' '*.txt'};
for itype = 1:size(Type,2);
eval(['Cof = ls(''' Type{itype} ''')']);
for ifile = 1:size(Cof,1);
movefile(Cof(ifile,:),'z_old');
end
end
cd('..')
end
% changer un champ dans data
root_pth ='D:\thk';
for ii = 1:size(data,2)
Ind = regexp(data(ii).dir,'\');
Sname = data(ii).dir(Ind(end)+1:end)
data(ii).dir = fullfile(root_pth,Sname)
end
root_pth ='D:\thk';
addpath('D:\thk\thk_codes')
data = pm0_COF_data(fullfile(root_pth));
for ii = 1:size(data,2)
Ind = regexp(data(ii).dir,'\');
Sname = data(ii).dir(Ind(end)+1:end)
data(ii).dir = fullfile(root_pth,Sname)
end
% Recursively checking a field in directories
root_pth ='D:\thk';
addpath('D:\thk\thk_codes')
data = pm0_COF_data(fullfile(root_pth));
for ii = 1:size(data,2)
Ind = regexp(data(ii).dir,'\');
Sname = data(ii).dir(Ind(end)+1:end);
REs = exist(fullfile(root_pth,Sname,'MRI','nii2')); %,'Results'));
if REs == 7
fprintf(1,'%s %i\n',Sname,REs)
movefile(fullfile(root_pth,Sname,'MRI','nii2'),fullfile(root_pth,Sname,'MRI','nii3'))
end
end
%------------------------------------------
% moving Exxx to COFxxx
data = COF_data(pwd);
Dirs = ls('E*');
for isub = 1:size(data,2)
for idir = 1:size(Dirs,1)
if strcmp(data(isub).thkid,Dirs(idir,:))==1
fprintf(1,'rename %s in %s \n',data(isub).thkid,data(isub).id)
movefile(data(isub).thkid,data(isub).id)
end
end
end
%------------------------------------------
% Delete dynamic directories
global data;
root_pth ='D:/thk';
data = pm0_COF_data(root_pth);
for isub = 1:size(data,2)
cd(fullfile(data(isub).dir,'PET'));
if exist('Dynamic')==7
rmdir('Dynamic','s')
end
delete('*.nii')
fprintf(1,'Sub %i %s\n',isub, data(isub).dir)
end
%------------------------------------------
% Delete old MR directories
global data;
root_pth ='D:\thk';
data = pm0_COF_data([ root_pth ]);
for isub = 1:size(data,2)
fprintf(1,'subject %i %s \n',isub, data(isub).id)
cd(fullfile(data(isub).dir,'MRI'));
if exist('nii') == 7
fprintf(1,'nii in %s removed\n', data(isub).dir)
rmdir('nii','s')
end
end