0001 function varargout = prt_ui_prepare_data(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 gui_Singleton = 1;
0035 gui_State = struct('gui_Name', mfilename, ...
0036 'gui_Singleton', gui_Singleton, ...
0037 'gui_OpeningFcn', @prt_ui_prepare_data_OpeningFcn, ...
0038 'gui_OutputFcn', @prt_ui_prepare_data_OutputFcn, ...
0039 'gui_LayoutFcn', [] , ...
0040 'gui_Callback', []);
0041 if nargin && ischar(varargin{1})
0042 gui_State.gui_Callback = str2func(varargin{1});
0043 end
0044
0045 if nargout
0046 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0047 else
0048 gui_mainfcn(gui_State, varargin{:});
0049 end
0050
0051
0052
0053
0054 function prt_ui_prepare_data_OpeningFcn(hObject, eventdata, handles, varargin)
0055
0056
0057
0058
0059
0060
0061
0062 handles.output = hObject;
0063
0064 Tag='FSwin';
0065 F = findall(allchild(0),'Flat','Tag',Tag);
0066 if length(F) > 1
0067
0068 close(F(2:end))
0069 F = F(1);
0070 uistack(F,'top')
0071 elseif length(F)==1
0072 uistack(F,'top')
0073 else
0074 set(handles.figure1,'Tag',Tag)
0075
0076 set(handles.figure1,'Name','PRoNTo :: Prepare feature set')
0077
0078 S0= spm('WinSize','0',1);
0079 if ispc
0080 PF='MS Sans Serif';
0081 else
0082 PF= spm_platform('fonts');
0083 PF=PF.helvetica;
0084 end
0085 tmp = [S0(3)/1280 (S0(4))/800];
0086 ratio=min(tmp)*[1 1 1 1];
0087 FS = 1 + 0.85*(min(ratio)-1);
0088 x=get(handles.figure1,'Position');
0089 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0090 'DefaultUicontrolFontSize',FS*12,...
0091 'DefaultTextFontName',PF,...
0092 'DefaultAxesFontName',PF,...
0093 'DefaultUicontrolFontName',PF)
0094 set(handles.figure1,'Position',ratio.*x)
0095 set(handles.figure1,'Resize','on')
0096
0097
0098 color=prt_get_defaults('color');
0099 set(handles.figure1,'Color',color.bg1)
0100 handles.color=color;
0101 aa=get(handles.figure1,'children');
0102 for i=1:length(aa)
0103 if strcmpi(get(aa(i),'type'),'uipanel')
0104 set(aa(i),'BackgroundColor',color.bg2)
0105 bb=get(aa(i),'children');
0106 if ~isempty(bb)
0107 for j=1:length(bb)
0108 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0109 'radiobutton','checkbox'})))
0110 set(bb(j),'BackgroundColor',color.bg2)
0111 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0112 set(bb(j),'BackgroundColor',color.fr)
0113 end
0114 set(bb(j),'FontUnits','pixel')
0115 xf=get(bb(j),'FontSize');
0116 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0117 'FontUnits','normalized','Units','normalized')
0118 end
0119 end
0120 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0121 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0122 'radiobutton','checkbox'})))
0123 set(aa(i),'BackgroundColor',color.bg1)
0124 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0125 set(aa(i),'BackgroundColor',color.fr)
0126 end
0127 end
0128 set(aa(i),'FontUnits','pixel')
0129 xf=get(aa(i),'FontSize');
0130 if ispc
0131 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0132 'FontUnits','normalized','Units','normalized')
0133 else
0134 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0135 'Units','normalized')
0136 end
0137 end
0138
0139
0140 set(handles.sel_mod,'Enable','off')
0141 handles.kname=[];
0142 end
0143
0144 guidata(hObject, handles);
0145
0146
0147
0148
0149
0150
0151 function varargout = prt_ui_prepare_data_OutputFcn(hObject, eventdata, handles)
0152
0153
0154
0155
0156
0157
0158 varargout{1} = handles.output;
0159
0160
0161
0162 function edit_prt_Callback(hObject, eventdata, handles)
0163
0164
0165
0166
0167
0168
0169 fname=get(handles.edit_prt,'String');
0170 if exist('PRT','var')
0171 clear PRT
0172 end
0173 try
0174 load(fname)
0175 handles.dat=PRT;
0176 catch
0177 beep
0178 disp('Could not load file')
0179 return
0180 end
0181
0182 n_mod=length(PRT.group(1).subject(1).modality);
0183 handles.modnames={PRT.masks(:).mod_name};
0184 if n_mod==1
0185 try
0186 handles.mod=prt_ui_prepare_datamod('UserData',{PRT,1});
0187 set(handles.num_mod,'Value',1)
0188 set(handles.num_mod,'String',1)
0189 set(handles.sel_mod,'String',{PRT.masks(1).mod_name})
0190 catch
0191 set(handles.edit_prt,'String','');
0192 return
0193 end
0194 set(handles.edit_kname,'ForegroundColor',handles.color.high)
0195 else
0196 set(handles.text8,'ForegroundColor',handles.color.high)
0197 end
0198 handles.fname=fname;
0199
0200 guidata(hObject, handles);
0201
0202
0203 function edit_prt_CreateFcn(hObject, eventdata, handles)
0204
0205
0206
0207
0208
0209
0210 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0211 set(hObject,'BackgroundColor','white');
0212 end
0213
0214
0215
0216 function br_prt_Callback(hObject, eventdata, handles)
0217
0218
0219
0220 fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0221 if exist('PRT','var')
0222 clear PRT
0223 end
0224 try
0225 load(fname)
0226 handles.dat=PRT;
0227 set(handles.edit_prt,'String',fname);
0228 catch
0229 beep
0230 disp('Could not load file')
0231 return
0232 end
0233
0234 n_mod=length(PRT.group(1).subject(1).modality);
0235 handles.modnames={PRT.masks(:).mod_name};
0236 if n_mod==1
0237 try
0238 handles.mod=prt_ui_prepare_datamod('UserData',{PRT,1});
0239 set(handles.num_mod,'Value',1)
0240 set(handles.num_mod,'String',1)
0241 set(handles.sel_mod,'String',{PRT.masks(1).mod_name})
0242 catch
0243 set(handles.edit_prt,'String','');
0244 return
0245 end
0246 set(handles.edit_kname,'ForegroundColor',handles.color.high)
0247 else
0248 set(handles.text8,'ForegroundColor',handles.color.high)
0249 end
0250 handles.fname=fname;
0251
0252 guidata(hObject, handles);
0253
0254
0255 function edit_kname_Callback(hObject, eventdata, handles)
0256
0257
0258
0259
0260
0261
0262 handles.kname=deblank(get(handles.edit_kname,'String'));
0263 if ~prt_checkAlphaNumUnder(handles.kname)
0264 beep
0265 disp('Kernel name should be entered in alphanumeric format only')
0266 disp('Please correct')
0267 set(handles.edit_kname,'ForegroundColor',[1,0,0])
0268 return
0269 else
0270 set(handles.edit_kname,'ForegroundColor',[0 0 0])
0271 end
0272
0273 guidata(hObject, handles);
0274
0275
0276
0277 function edit_kname_CreateFcn(hObject, eventdata, handles)
0278
0279
0280
0281
0282
0283
0284 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0285 set(hObject,'BackgroundColor','white');
0286 end
0287
0288
0289 function num_mod_Callback(hObject, eventdata, handles)
0290
0291
0292
0293
0294
0295
0296 val=str2double(get(handles.num_mod,'String'));
0297 set(handles.text8,'ForegroundColor',handles.color.high)
0298 n_mod=length(handles.modnames);
0299
0300 list=[];
0301
0302 for i=1:n_mod
0303 handles.mod(i)=struct('mod_name',[],'mode',[],'mask',[],'detrend',[], ...
0304 'param_dt',[],'normalise',[],'matnorm',[]);
0305 end
0306
0307 for i=1:val
0308 try
0309 tmp=prt_ui_prepare_datamod('UserData',{handles.dat,i});
0310 catch
0311 return
0312 end
0313 list=[list,tmp.mod_name];
0314 set(handles.sel_mod,'String',list)
0315 ind=find(strcmpi(handles.modnames,tmp.mod_name));
0316 handles.mod(ind)=tmp;
0317 end
0318
0319 guidata(hObject, handles);
0320
0321
0322
0323 function num_mod_CreateFcn(hObject, eventdata, handles)
0324
0325
0326
0327
0328
0329
0330 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0331 set(hObject,'BackgroundColor','white');
0332 end
0333
0334
0335 function sel_mod_Callback(hObject, eventdata, handles)
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345 function sel_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 buildbutt_Callback(hObject, eventdata, handles)
0359
0360
0361
0362
0363 input=struct('fname',[],'kname',[],'mod',[]);
0364 input.fname=handles.fname;
0365 if isempty(handles.kname)
0366 beep
0367 disp('Enter a name for the feature set to be saved')
0368 set(handles.edit_kname,'ForegroundColor',handles.color.high)
0369 return
0370 end
0371 input.fs_name=handles.kname;
0372 if ~isfield(handles,'mod') || isempty(handles.mod)
0373 beep
0374 disp('No modality was selected to build the dataset!')
0375 disp('Please, enter a number of modalities to use')
0376 set(handles.text8,'ForegroundColor',handles.color.high)
0377 return
0378 end
0379 input.mod=handles.mod;
0380 load(input.fname);
0381 prt_fs(PRT,input);
0382 delete(handles.figure1)