-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiCLSM.m
270 lines (200 loc) · 7.32 KB
/
iCLSM.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
function varargout = iCLSM(varargin)
%iCLSM
% Requirements:
% Before using iCLSM, SPM should be installed previously.
% Refer to SPM website
% http://www.fil.ion.ucl.ac.uk/spm/
global CLSM;
warning('off','all');
if nargin == 0 % LAUNCH GUI
exepath=which('iCLSM');
[p,f,e]=fileparts(exepath);
CLSM.iCLSMpath = p;
addpath(genpath(p));
spm_dir = which('spm');
if isempty(spm_dir),
errordlg('SPM path should be added before executing this program.');
return;
end
CLSM.spmVer = spm('ver');
license=fullfile(p,'license.txt');
if exist(license,'file')==0, fprintf('No license file...\n'); return; end;
% Generate a structure of handles to pass to callbacks, and store it.
fig = openfig(mfilename,'new');
handles = guihandles(fig);
guidata(fig, handles);
set(fig, 'Name','Expanding your insight with iCLSM');
iCLSM_defaults;
iCLSM_init(handles);
CLSM.handle=fig;
CLSM.figure.handles=handles;
fprintf('--------------------------------------------------\n');
fprintf(' Welcome to iCLSM\n');
fprintf(' Copyright (c) 2018 Sunghyon Kyeong \n');
fprintf('--------------------------------------------------\n');
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
if (nargout)
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
else
feval(varargin{:}); % FEVAL switchyard
end
catch
disp(lasterr);
end
end
%**************************************************************************
% INITIALIZE
%**************************************************************************
function iCLSM_init(handles)
global CLSM
nHM = CLSM.prep.nHM;
fprintf('Number of head motions: %d \n',nHM);
set(handles.edit_prep_BW, 'String', sprintf('[%.3f, %.3f]',CLSM.prep.BW));
set(handles.edit_prep_dummy, 'String', num2str(CLSM.prep.dummyoff));
set(handles.edit_prefix, 'String', CLSM.prep.prefix);
%**************************************************************************
% Methods for loading lesion data
%**************************************************************************
function select_lesionpath_Callback(hObject, eventdata, handles)
global CLSM
LESIONpath = uigetdir(pwd,'Select Lesion Project Path');
set(handles.LESIONpath,'String',LESIONpath);
CLSM.LESIONpath = LESIONpath;
CLSM.anal.OUTpath = fullfile(CLSM.LESIONpath,'Results');
mkdir(CLSM.anal.OUTpath);
fn_lesionList = fullfile(CLSM.LESIONpath,CLSM.fn_lesionlist);
if ~exist(fn_lesionList,'file')
errordlg(sprintf('cannot find %s',CLSM.fn_lesionlist));
return;
end
lesionList = readtable(fn_lesionList);
CLSM.lesionList = lesionList.subjname;
fprintf('Number of lesions = %3d\n',length(CLSM.lesionList));
CLSM.group = lesionList.group;
fprintf('Number of groups = %3d\n',length(unique(CLSM.group)));
function LESIONpath_Callback(hObject, eventdata, handles)
global CLSM
CLSM.LESIONpath = get(hObject,'String');
CLSM.anal.OUTpath = fullfile(CLSM.LESIONpath,'Results');
mkdir(CLSM.anal.OUTpath);
fn_lesionList = fullfile(CLSM.LESIONpath,CLSM.fn_lesionlist);
if ~exist(fn_lesionList,'file')
errordlg(sprintf('cannot find %s',CLSM.fn_lesionlist));
return;
end
lesionList = readtable(fn_lesionList);
CLSM.lesionList = lesionList.subjname;
fprintf('Number of lesions = %3d\n',length(CLSM.lesionList));
CLSM.group = lesionList.group;
fprintf('Number of groups = %3d\n',length(unique(CLSM.group)));
%**************************************************************************
% Methods for loading normal database
%**************************************************************************
function select_fmripath_Callback(hObject, eventdata, handles)
global CLSM
fMRIpath = uigetdir(pwd,'Select fMRI DATA path');
set(handles.fMRIpath,'String',fMRIpath);
CLSM.fMRIpath = fMRIpath;
% Load normal subject list
fn_normalList = fullfile(CLSM.fMRIpath,CLSM.fn_normallist);
if ~exist(fn_normalList,'file')
errordlg(sprintf('cannot find %s',CLSM.fn_normallist));
return;
end
normalList = readtable(fn_normalList);
CLSM.normalList = normalList.subjname;
fprintf('Number of normal subjects = %3d\n',length(CLSM.normalList));
function fMRIpath_Callback(hObject, eventdata, handles)
global CLSM
fMRIpath = get(hObject,'String');
CLSM.fMRIpath = fMRIpath;
% Load normal subject list
fn_normalList = fullfile(CLSM.fMRIpath,CLSM.fn_normallist);
if ~exist(fn_normalList,'file')
errordlg(sprintf('cannot find %s',CLSM.fn_normallist));
return;
end
normalList = readtable(fn_normalList);
CLSM.normalList = normalList.subjname;
fprintf('Number of normal subjects = %3d\n',length(CLSM.normalList));
%**************************************************************************
% Temporal Preprocessing
%**************************************************************************
function edit_prefix_Callback(hObject, eventdata, handles)
global CLSM
CLSM.prep.prefix = get(hObject,'String');
function edit_prep_BW_Callback(hObject, eventdata, handles)
global CLSM
BW = get(hObject,'String');
fprintf(' Bandpass filter: %s Hz\n', BW);
CLSM.prep.BW = eval(BW);
function edit_prep_dummy_Callback(hObject, eventdata, handles)
global CLSM
dummyoff = get(hObject,'String');
CLSM.prep.dummyoff = eval(dummyoff);
function edit_prep_TR_Callback(hObject, eventdata, handles)
global CLSM
TR = get(hObject,'String');
CLSM.prep.TR = eval(TR);
function edit_fmripath_Callback(hObject, eventdata, handles)
global CLSM
fmripath = get(hObject,'String');
CLSM.prep.fmridir = fmripath;
function edit_lesiondir_Callback(hObject, eventdata, handles)
global CLSM
lesiondir = get(hObject,'String');
CLSM.anal.lesiondir = lesiondir;
function checkbox_scrubbing_Callback(hObject, eventdata, handles)
global CLSM
CLSM.anal.doScrubbing = get(hObject,'Value');
function edit_FDthr_Callback(hObject, eventdata, handles)
global CLSM
CLSM.anal.FDthr = str2double(get(hObject,'String'));
%**************************************************************************
% Functional connectivity analysis
%**************************************************************************
function run_analysis_Callback(hObject, eventdata, handles)
global CLSM
if strcmpi(CLSM.anal.mode,'Preprocess'),
if check_iCLSM_params(0)==1,
run_preprocess;
end
elseif strcmpi(CLSM.anal.mode,'CLSM'),
if check_iCLSM_params(1)==1,
run_clsm;
end
elseif strcmpi(CLSM.anal.mode,'Stat (Individual)'),
if check_iCLSM_params(1)==1,
run_stat_individual;
end
elseif strcmpi(CLSM.anal.mode,'Stat (Group)'),
if check_iCLSM_params(1)==1,
%run_stat_group;
run_lesion_network_mapping;
end
elseif strcmpi(CLSM.anal.mode,'Lesion Overlapping'),
if check_iCLSM_params(1)==1,
run_lesion_overlapping;
end
else
errordlg('Specify parameters correctly!!','Error Dialog');
return
end
% --- Executes on selection change in popupmenu_analmode.
function popupmenu_analmode_Callback(hObject, eventdata, handles)
global CLSM
button_state = get(hObject,'Value');
if button_state == 1,
analmode = 'Preprocess';
elseif button_state == 2,
analmode = 'CLSM';
elseif button_state == 3,
analmode = 'Stat (Individual)';
elseif button_state == 4,
analmode = 'Stat (Group)';
elseif button_state == 5,
analmode = 'Lesion Overlapping';
end
CLSM.anal.mode = analmode;
fprintf('analysis mode: %s \n',analmode);