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 if ispc
0118 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0119 'FontUnits','normalized','Units','normalized')
0120 else
0121 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0122 'Units','normalized')
0123 end
0124 end
0125
0126
0127
0128 set(handles.par_name,'Visible','off')
0129 set(handles.par_value,'Visible','off')
0130 set(handles.pop_det,'String',{'No', ...
0131 'Polynomial','Discrete Cosine Transform'})
0132 set(handles.pop_det,'Value',1)
0133 set(handles.pop_norm,'String',{'No scaling', ...
0134 'Specify from .mat'});
0135 set(handles.pop_norm,'Value',1)
0136 if ~isempty(varargin{1}) && strcmpi(varargin{1},'UserData')
0137 handles.PRT=varargin{2}{1};
0138 else
0139 beep
0140 disp('Select a PRT.mat first')
0141 return
0142 end
0143 mod_n={handles.PRT.masks(:).mod_name};
0144 set(handles.pop_mod,'String',mod_n)
0145 set(handles.pop_mod,'Value',1)
0146
0147 if length(mod_n)==1 && (isempty(handles.PRT.group(1).subject(1).modality(1).design) ...
0148 || ~isstruct(handles.PRT.group(1).subject(1).modality(1).design))
0149 set(handles.pop_cond,'String',{'All scans'})
0150 else
0151 set(handles.pop_cond,'String',{'All scans','All conditions'})
0152 end
0153 set(handles.pop_cond,'Value',1)
0154 handles.mod=struct('mod_name',[],'mode',[],'mask',[],'detrend',[], ...
0155 'param_dt',[],'normalise',[],'matnorm',[]);
0156 handles.mod.mod_name=mod_n(1);
0157 handles.mod.mode='all_scans';
0158 handles.mod.detrend=0;
0159 handles.mod.normalise=0;
0160 handles.mod.mask=[];
0161
0162
0163 guidata(hObject, handles);
0164
0165
0166 uiwait(handles.figure1);
0167
0168
0169
0170 function varargout = prt_ui_prepare_datamod_OutputFcn(hObject, eventdata, handles)
0171
0172
0173
0174
0175
0176
0177 if ~isempty(handles)
0178 varargout{1} = handles.output;
0179
0180 delete(handles.figure1);
0181 end
0182
0183
0184
0185
0186 function edit_mask_Callback(hObject, eventdata, handles)
0187
0188
0189
0190
0191
0192
0193 handles.mod.mask=get(handles.edit_mask,'String');
0194
0195 guidata(hObject, handles);
0196
0197
0198 function edit_mask_CreateFcn(hObject, eventdata, handles)
0199
0200
0201
0202
0203
0204
0205 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0206 set(hObject,'BackgroundColor','white');
0207 end
0208
0209
0210
0211 function br_mask_Callback(hObject, eventdata, handles)
0212
0213
0214
0215 handles.mod.mask=spm_select(1,'image','Select mask for the selected modality');
0216 set(handles.edit_mask,'String',handles.mod.mask);
0217
0218 guidata(hObject, handles);
0219
0220
0221 function pop_cond_Callback(hObject, eventdata, handles)
0222
0223
0224
0225
0226
0227
0228 val=get(handles.pop_cond,'Value');
0229 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0230
0231 if val==0
0232 set(handles.pop_cond,'Value',1)
0233 end
0234 val=get(handles.pop_cond,'Value');
0235 if val==1
0236 handles.mod.mode='all_scans';
0237 else
0238 handles.mod.mode='all_cond';
0239 end
0240
0241 guidata(hObject, handles);
0242
0243
0244 function pop_cond_CreateFcn(hObject, eventdata, handles)
0245
0246
0247
0248
0249
0250
0251 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0252 set(hObject,'BackgroundColor','white');
0253 end
0254
0255
0256
0257 function pop_det_Callback(hObject, eventdata, handles)
0258
0259
0260
0261
0262
0263
0264 val=get(handles.pop_det,'Value');
0265 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0266
0267 if val==0
0268 set(handles.pop_det,'Value',1)
0269 end
0270 val=get(handles.pop_det,'Value')-1;
0271 handles.mod.detrend=val;
0272 if val==0
0273 set(handles.par_name,'Visible','off')
0274 set(handles.par_value,'Visible','off')
0275 handles.mod.param_dt=[];
0276 elseif val==1
0277 set(handles.par_name,'Visible','on')
0278 set(handles.par_value,'Visible','on')
0279 set(handles.par_name,'String','Order')
0280 set(handles.par_value,'String','1')
0281 handles.mod.param_dt=1;
0282 elseif val==2
0283 set(handles.par_name,'Visible','on')
0284 set(handles.par_value,'Visible','on')
0285 set(handles.par_name,'String','Cutoff of highpass filter (s)')
0286 set(handles.par_value,'String','128')
0287 handles.mod.param_dt=1/128;
0288 end
0289
0290 guidata(hObject, handles);
0291
0292
0293
0294 function pop_det_CreateFcn(hObject, eventdata, handles)
0295
0296
0297
0298
0299
0300
0301 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0302 set(hObject,'BackgroundColor','white');
0303 end
0304
0305
0306
0307 function pop_mod_Callback(hObject, eventdata, handles)
0308
0309
0310
0311
0312
0313
0314 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0315 list=get(handles.pop_mod,'String');
0316
0317 if length(list)==1
0318 set(handles.pop_mod,'Value',1)
0319 end
0320 val=get(handles.pop_mod,'Value');
0321 if val==0
0322 set(handles.pop_mod,'Value',1)
0323 end
0324 val=get(handles.pop_mod,'Value');
0325 handles.mod.mod_name=list(val);
0326
0327
0328 im=find(strcmpi(list(val),{handles.PRT.group(1).subject(1).modality(:).mod_name}));
0329 if isempty(handles.PRT.group(1).subject(1).modality(1).design) ...
0330 || ~isstruct(handles.PRT.group(1).subject(1).modality(im).design)
0331 set(handles.pop_cond,'String',{'All scans'})
0332 else
0333 set(handles.pop_cond,'String',{'All scans','All conditions'})
0334 end
0335 set(handles.pop_cond,'Value',1)
0336
0337
0338 guidata(hObject, handles);
0339
0340
0341 function pop_mod_CreateFcn(hObject, eventdata, handles)
0342
0343
0344
0345
0346
0347
0348 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0349 set(hObject,'BackgroundColor','white');
0350 end
0351
0352
0353
0354 function par_value_Callback(hObject, eventdata, handles)
0355
0356
0357
0358
0359
0360
0361
0362 handles.mod.param_dt=get(handles.paramd,'Value');
0363
0364 guidata(hObject, handles);
0365
0366
0367 function par_value_CreateFcn(hObject, eventdata, handles)
0368
0369
0370
0371
0372
0373
0374 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0375 set(hObject,'BackgroundColor','white');
0376 end
0377
0378
0379
0380 function pop_norm_Callback(hObject, eventdata, handles)
0381
0382
0383
0384
0385
0386
0387 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0388 val=get(handles.pop_norm,'Value');
0389 if val==0
0390 set(handles.pop_norm,'Value',1)
0391 end
0392 val=get(handles.pop_norm,'Value')-1;
0393 handles.mod.normalise=val;
0394 if val==0
0395 handles.mod.matnorm=[];
0396 elseif val==1
0397 handles.mod.matnorm=spm_select(1,'mat','Select .mat file containing scaling');
0398 handles.mod.normalise=2;
0399 end
0400
0401 guidata(hObject, handles);
0402
0403
0404 function pop_norm_CreateFcn(hObject, eventdata, handles)
0405
0406
0407
0408
0409
0410
0411 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0412 set(hObject,'BackgroundColor','white');
0413 end
0414
0415
0416
0417 function okbutt_Callback(hObject, eventdata, handles)
0418
0419
0420
0421
0422 handles.output=handles.mod;
0423
0424 guidata(hObject, handles);
0425
0426 uiresume(handles.figure1)