forked from netstim/leaddbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ea_checkctmrpresent.m
79 lines (69 loc) · 2.82 KB
/
ea_checkctmrpresent.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
function modality=ea_checkctmrpresent(varargin)
if ischar(varargin{1})
uipatdir{1}=varargin{1};
else % call from lead directly:
handles=varargin{1};
uipatdir=getappdata(handles.leadfigure,'uipatdir');
end
if length(uipatdir) > 1 % to enable CT registration setting by default when multiple patients chose
modality = [0; 1];
status = 'Multiple patients are chosen, CT/MR modality will be automatically detected.';
else
% check for MR-files
[~,patientname]=fileparts(uipatdir{1});
prefs=ea_prefs(patientname);
modality=zeros(2,1);
% check for unnormalized images first:
% CT
if exist([uipatdir{1},filesep,prefs.rawctnii_unnormalized],'file')
status = 'Raw CT file found. Please coregister CT to preoperative MR first.';
modality(2)=1;
end
if exist([uipatdir{1},filesep,prefs.ctnii_coregistered],'file')
status = 'Coregistered CT file found. Set Normalization option.';
modality(2)=1;
end
% MR
if exist([uipatdir{1},filesep,prefs.tranii_unnormalized],'file')
status = 'Unnormalized MR-volumes found. Set Normalization option.';
modality(1)=1;
end
% MR & CT
if exist([uipatdir{1},filesep,prefs.tranii_unnormalized],'file') && exist([uipatdir{1},filesep,prefs.rawctnii_unnormalized],'file')
status = 'Unnormalized MR-volumes and raw CT volume found. Set Normalization option or Coregister CT.';
modality(1:2)=1;
end
if exist([uipatdir{1},filesep,prefs.tranii_unnormalized],'file') && exist([uipatdir{1},filesep,prefs.ctnii_coregistered],'file')
status = 'Unnormalized MR-volumes and coregistered CT file found. Set Normalization option.';
modality(1:2)=1;
end
% Now check for normalized images:
if exist([uipatdir{1},filesep,prefs.ctnii],'file')
try
load([uipatdir{1},filesep,'ea_normmethod_applied.mat'])
nmused=eval([norm_method_applied{1},'(''check'')']);
status = ['CT-volumes have been normalized with: ',nmused];
catch
status = 'Normalized CT-volumes found.';
end
modality(2)=1;
end
if exist([uipatdir{1},filesep,prefs.tranii],'file')
try
load([uipatdir{1},filesep,'ea_normmethod_applied.mat'])
nmused=eval([norm_method_applied{1},'(''check'')']);
status = ['MR-volumes have been normalized with: ',nmused];
catch
status = 'Normalized MR-volumes found.';
end
modality(1)=1;
end
if exist([uipatdir{1},filesep,prefs.tranii],'file') && exist([uipatdir{1},filesep,prefs.ctnii],'file')
status = 'Normalized MR- and CT-volumes found.';
modality(1:2)=1;
end
end
try % not available when calling from group
set(handles.statusone,'String',status);
set(handles.statusone,'TooltipString',status);
end