0001 function varargout = prt_ui_prepare_datamod(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 gui_Singleton = 1;
0037 gui_State = struct('gui_Name', mfilename, ...
0038 'gui_Singleton', gui_Singleton, ...
0039 'gui_OpeningFcn', @prt_ui_prepare_datamod_OpeningFcn, ...
0040 'gui_OutputFcn', @prt_ui_prepare_datamod_OutputFcn, ...
0041 'gui_LayoutFcn', [] , ...
0042 'gui_Callback', []);
0043 if nargin && ischar(varargin{1})
0044 gui_State.gui_Callback = str2func(varargin{1});
0045 end
0046
0047 if nargout
0048 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0049 else
0050 gui_mainfcn(gui_State, varargin{:});
0051 end
0052
0053
0054
0055
0056 function prt_ui_prepare_datamod_OpeningFcn(hObject, eventdata, handles, varargin)
0057
0058
0059
0060
0061
0062
0063
0064 set(handles.figure1,'Name','PRoNTo :: Specify modality to include')
0065
0066 S0= spm('WinSize','0',1);
0067 if ispc
0068 PF='MS Sans Serif';
0069 else
0070 PF= spm_platform('fonts');
0071 PF=PF.helvetica;
0072 end
0073 tmp = [S0(3)/1280 (S0(4))/800];
0074 ratio=min(tmp)*[1 1 1 1];
0075 FS = 1 + 0.85*(min(ratio)-1);
0076 x=get(handles.figure1,'Position');
0077 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0078 'DefaultUicontrolFontSize',FS*12,...
0079 'DefaultTextFontName',PF,...
0080 'DefaultAxesFontName',PF,...
0081 'DefaultUicontrolFontName',PF)
0082 set(handles.figure1,'Position',ratio.*x)
0083 set(handles.figure1,'Resize','on')
0084
0085
0086 color=prt_get_defaults('color');
0087 set(handles.figure1,'Color',color.bg1)
0088 aa=get(handles.figure1,'children');
0089 for i=1:length(aa)
0090 if strcmpi(get(aa(i),'type'),'uipanel')
0091 set(aa(i),'BackgroundColor',color.bg2)
0092 bb=get(aa(i),'children');
0093 if ~isempty(bb)
0094 for j=1:length(bb)
0095 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0096 'radiobutton','checkbox'})))
0097 set(bb(j),'BackgroundColor',color.bg2)
0098 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0099 set(bb(j),'BackgroundColor',color.fr)
0100 end
0101 set(bb(j),'FontUnits','pixel')
0102 xf=get(bb(j),'FontSize');
0103 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0104 'FontUnits','normalized','Units','normalized')
0105 end
0106 end
0107 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0108 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0109 'radiobutton','checkbox'})))
0110 set(aa(i),'BackgroundColor',color.bg1)
0111 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0112 set(aa(i),'BackgroundColor',color.fr)
0113 end
0114 end
0115 set(aa(i),'FontUnits','pixel')
0116 xf=get(aa(i),'FontSize');
0117 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0118 'Units','normalized')
0119 end
0120
0121
0122
0123 set(handles.par_name,'Visible','off')
0124 set(handles.par_value,'Visible','off')
0125 set(handles.pop_det,'String',{'No', ...
0126 'Polynomial','Discrete Cosine Transform'})
0127 set(handles.pop_det,'Value',1)
0128 set(handles.pop_norm,'String',{'No scaling', ...
0129 'Specify from .mat'});
0130 set(handles.pop_norm,'Value',1)
0131 set(handles.froi, 'Value',0)
0132 set(handles.froi,'Enable','on')
0133 set(handles.edit_atlas,'Visible','on')
0134 set(handles.br_atlas,'Visible','on')
0135 set(handles.edit_atlas,'Enable','off')
0136 set(handles.br_atlas,'Enable','off')
0137 if ~isempty(varargin{1}) && strcmpi(varargin{1},'UserData')
0138 handles.PRT=varargin{2}{1};
0139 handles.nmtc=varargin{2}{2};
0140 else
0141 beep
0142 disp('Select a PRT.mat first')
0143 return
0144 end
0145 mod_n={handles.PRT.masks(:).mod_name};
0146 set(handles.pop_mod,'String',mod_n)
0147 set(handles.pop_mod,'Value',1)
0148
0149 if length(mod_n)==1 && (isempty(handles.PRT.group(1).subject(1).modality(1).design) ...
0150 || ~isstruct(handles.PRT.group(1).subject(1).modality(1).design))
0151 set(handles.pop_cond,'String',{'All scans'})
0152 else
0153 set(handles.pop_cond,'String',{'All scans','All conditions'})
0154 end
0155 set(handles.pop_cond,'Value',1)
0156 handles.mod=struct('mod_name',[],'mode',[],'mask',[],'detrend',[], ...
0157 'param_dt',[],'normalise',[],'matnorm',[]);
0158 handles.mod.mod_name=mod_n(1);
0159 handles.mod.mode='all_scans';
0160 handles.mod.detrend=0;
0161 handles.mod.normalise=0;
0162 handles.mod.mask=[];
0163 handles.mod.multroi=0;
0164 handles.mod.atlasroi=[];
0165
0166
0167 guidata(hObject, handles);
0168
0169
0170 uiwait(handles.figure1);
0171
0172
0173
0174 function varargout = prt_ui_prepare_datamod_OutputFcn(hObject, eventdata, handles)
0175
0176
0177
0178
0179
0180
0181 if ~isempty(handles)
0182 varargout{1} = handles.output;
0183
0184 delete(handles.figure1);
0185 end
0186
0187
0188
0189
0190 function edit_mask_Callback(hObject, eventdata, handles)
0191
0192
0193
0194
0195
0196
0197 handles.mod.mask=get(handles.edit_mask,'String');
0198
0199 guidata(hObject, handles);
0200
0201
0202 function edit_mask_CreateFcn(hObject, eventdata, handles)
0203
0204
0205
0206
0207
0208
0209 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0210 set(hObject,'BackgroundColor','white');
0211 end
0212
0213
0214
0215 function br_mask_Callback(hObject, eventdata, handles)
0216
0217
0218
0219 handles.mod.mask=spm_select(1,'image','Select mask for the considered modality');
0220 set(handles.edit_mask,'String',handles.mod.mask);
0221
0222 guidata(hObject, handles);
0223
0224
0225 function pop_cond_Callback(hObject, eventdata, handles)
0226
0227
0228
0229
0230
0231
0232 val=get(handles.pop_cond,'Value');
0233 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0234
0235 if val==0
0236 set(handles.pop_cond,'Value',1)
0237 end
0238 val=get(handles.pop_cond,'Value');
0239 if val==1
0240 handles.mod.mode='all_scans';
0241 else
0242 handles.mod.mode='all_cond';
0243 end
0244
0245 guidata(hObject, handles);
0246
0247
0248 function pop_cond_CreateFcn(hObject, eventdata, handles)
0249
0250
0251
0252
0253
0254
0255 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0256 set(hObject,'BackgroundColor','white');
0257 end
0258
0259
0260
0261 function pop_det_Callback(hObject, eventdata, handles)
0262
0263
0264
0265
0266
0267
0268 val=get(handles.pop_det,'Value');
0269 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0270
0271 if val==0
0272 set(handles.pop_det,'Value',1)
0273 end
0274 val=get(handles.pop_det,'Value')-1;
0275 handles.mod.detrend=val;
0276 if val==0
0277 set(handles.par_name,'Visible','off')
0278 set(handles.par_value,'Visible','off')
0279 handles.mod.param_dt=[];
0280 elseif val==1
0281 set(handles.par_name,'Visible','on')
0282 set(handles.par_value,'Visible','on')
0283 set(handles.par_name,'String','Order')
0284 set(handles.par_value,'String','1')
0285 handles.mod.param_dt=1;
0286 elseif val==2
0287 set(handles.par_name,'Visible','on')
0288 set(handles.par_value,'Visible','on')
0289 set(handles.par_name,'String','Highpass filter cutoff (s)')
0290 set(handles.par_value,'String','128')
0291 handles.mod.param_dt=128;
0292 end
0293
0294 guidata(hObject, handles);
0295
0296
0297
0298 function pop_det_CreateFcn(hObject, eventdata, handles)
0299
0300
0301
0302
0303
0304
0305 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0306 set(hObject,'BackgroundColor','white');
0307 end
0308
0309
0310
0311 function pop_mod_Callback(hObject, eventdata, handles)
0312
0313
0314
0315
0316
0317
0318 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0319 list=get(handles.pop_mod,'String');
0320
0321 if length(list)==1
0322 set(handles.pop_mod,'Value',1)
0323 end
0324 val=get(handles.pop_mod,'Value');
0325 if val==0
0326 set(handles.pop_mod,'Value',1)
0327 end
0328 val=get(handles.pop_mod,'Value');
0329 handles.mod.mod_name=list(val);
0330
0331
0332 im=find(strcmpi(list(val),{handles.PRT.group(1).subject(1).modality(:).mod_name}));
0333 if isempty(handles.PRT.group(1).subject(1).modality(1).design) ...
0334 || ~isstruct(handles.PRT.group(1).subject(1).modality(im).design)
0335 set(handles.pop_cond,'String',{'All scans'})
0336 else
0337 set(handles.pop_cond,'String',{'All scans','All conditions'})
0338 end
0339 set(handles.pop_cond,'Value',1)
0340
0341
0342 guidata(hObject, handles);
0343
0344
0345 function pop_mod_CreateFcn(hObject, eventdata, handles)
0346
0347
0348
0349
0350
0351
0352 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0353 set(hObject,'BackgroundColor','white');
0354 end
0355
0356
0357
0358 function par_value_Callback(hObject, eventdata, handles)
0359
0360
0361
0362
0363
0364
0365
0366 temp=get(handles.par_value,'Value');
0367 handles.mod.param_dt=temp;
0368
0369 guidata(hObject, handles);
0370
0371
0372 function par_value_CreateFcn(hObject, eventdata, handles)
0373
0374
0375
0376
0377
0378
0379 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0380 set(hObject,'BackgroundColor','white');
0381 end
0382
0383
0384
0385 function pop_norm_Callback(hObject, eventdata, handles)
0386
0387
0388
0389
0390
0391
0392 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0393 val=get(handles.pop_norm,'Value');
0394 if val==0
0395 set(handles.pop_norm,'Value',1)
0396 end
0397 val=get(handles.pop_norm,'Value')-1;
0398 handles.mod.normalise=val;
0399 if val==0
0400 handles.mod.matnorm=[];
0401 elseif val==1
0402 handles.mod.matnorm=spm_select(1,'mat','Select .mat file containing scaling');
0403 handles.mod.normalise=2;
0404 end
0405
0406 guidata(hObject, handles);
0407
0408
0409 function pop_norm_CreateFcn(hObject, eventdata, handles)
0410
0411
0412
0413
0414
0415
0416 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0417 set(hObject,'BackgroundColor','white');
0418 end
0419
0420
0421
0422
0423 function froi_Callback(hObject, eventdata, handles)
0424
0425
0426
0427
0428
0429 handles.mod.multroi=get(handles.froi,'Value');
0430 if handles.mod.multroi
0431 set(handles.edit_atlas,'Enable','on')
0432 set(handles.br_atlas,'Enable','on')
0433 else
0434 set(handles.edit_atlas,'Enable','off')
0435 set(handles.br_atlas,'Enable','off')
0436 end
0437
0438 guidata(hObject, handles);
0439
0440 function edit_atlas_Callback(hObject, eventdata, handles)
0441
0442
0443
0444
0445
0446
0447 handles.mod.atlasroi=get(handles.edit_atlas,'String');
0448
0449 guidata(hObject, handles);
0450
0451
0452 function edit_atlas_CreateFcn(hObject, eventdata, handles)
0453
0454
0455
0456
0457
0458
0459 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0460 set(hObject,'BackgroundColor','white');
0461 end
0462
0463
0464
0465 function br_atlas_Callback(hObject, eventdata, handles)
0466
0467
0468
0469 handles.mod.atlasroi=spm_select(1,'image','Select atlas to build one kernel per region');
0470 set(handles.edit_atlas,'String',handles.mod.atlasroi);
0471
0472 guidata(hObject, handles);
0473
0474
0475 function okbutt_Callback(hObject, eventdata, handles)
0476
0477
0478
0479
0480 if handles.mod.multroi ==1 && isempty(handles.mod.atlasroi)
0481 beep
0482 disp('One kernel per region selected but no atlas provided')
0483 disp('Please provide atlas')
0484 return
0485 end
0486
0487 handles.output=handles.mod;
0488
0489 guidata(hObject, handles);
0490
0491 uiresume(handles.figure1)