-
Notifications
You must be signed in to change notification settings - Fork 1
/
FG_voxbo_moveRawDICOM_to_root_matlab.m
97 lines (84 loc) · 3.96 KB
/
FG_voxbo_moveRawDICOM_to_root_matlab.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
function FG_voxbo_moveRawDICOM_to_root_matlab
clc
hi = questdlg('Please backup your original DICOM images before you continue to use this function!','Please backup your data first...','Continue','Cancel','Cancel');
if strcmpi(hi,'Cancel')
fprintf('\n----Quit to backup data first...............................\n')
return
end
%%
h=questdlg('**. It is going to move all raw DICOM-images to the root folder of each subject, are you sure to continue?','Move files....','Yes','Skip','Skip') ;
%%%%%%%% obsolete
% switch h
% case 'Yes'
%
% anyreturn=FG_modules_selection('Select the root folder containing all the subject folders','Please select all subjects...','','^','r','g');
% if anyreturn, return;end
%
% for i=1:size(groups,1)
% % [all_files,all_cell_files]=FG_list_all_files(deblank(groups(i,:)),'**','*');
% tem=dir(fullfile(root_dir,deblank(groups(i,:))));
% for k=3:size(tem,1)
% if tem(k).isdir==1
% try
% movefile(fullfile(root_dir,deblank(groups(i,:)),tem(k).name,'*'),fullfile(root_dir,deblank(groups(i,:))))
% catch me
% me.message
% continue
% end
% end
% end
%
% try
% delete(fullfile(root_dir,deblank(groups(i,:)),'DICOMDIR'))
% catch me
% me.message
% end
%
% tem=dir(fullfile(root_dir,deblank(groups(i,:))));
% for k=3:size(tem,1)
% if tem(k).isdir==1
% try
% FG_DelDir(fullfile(root_dir,deblank(groups(i,:)),deblank(tem(k).name)))
% catch me
% me.message
% continue
% end
% end
% end
% end
%
% fprintf('-------Files-moving is done............\n\n')
%
% case 'Skip'
% fprintf('------Skip the moving files..............\n\n')
% end
switch h
case 'Yes'
fprintf('\n----Running...............................\n')
anyreturn=FG_modules_selection('Select the root folder containing all the subject folders','Please select all subjects...','','^','r','g');
if anyreturn, return;end
for i=1:size(groups,1)
% [all_files,all_cell_files]=FG_list_all_files(deblank(groups(i,:)),'**','*');
all_folders=FG_genpath(fullfile(root_dir,deblank(groups(i,:))));
for k=size(all_folders,1):-1:2
try
movefile(fullfile(deblank(all_folders(k,:)),'*.*'),deblank(all_folders(1,:)))
catch me
me.message
continue
end
end
all_folders=FG_genpath(fullfile(root_dir,deblank(groups(i,:)))); % regenerate all subfolders
for k=size(all_folders,1):-1:2
try
FG_DelDir(deblank(all_folders(k,:)))
catch me
me.message
continue
end
end
end
fprintf('-------Files-moving is done............\n\n')
case 'Skip'
fprintf('------Skip the moving files..............\n\n')
end