Home > . > prt_ui_prepare_datamod.m

prt_ui_prepare_datamod

PURPOSE ^

PRT_UI_KERNEL_MODALITY M-file for prt_ui_kernel_modality.fig

SYNOPSIS ^

function varargout = prt_ui_prepare_datamod(varargin)

DESCRIPTION ^

 PRT_UI_KERNEL_MODALITY M-file for prt_ui_kernel_modality.fig
 
 PRT_UI_KERNEL_MODALITY, by itself, creates a new PRT_UI_KERNEL_MODALITY 
 or raises the existing singleton*.

 H = PRT_UI_KERNEL_MODALITY returns the handle to a new 
 PRT_UI_KERNEL_MODALITY or the handle to the existing singleton*.

 PRT_UI_KERNEL_MODALITY('CALLBACK',hObject,eventData,handles,...) calls 
 the local function named CALLBACK in PRT_UI_KERNEL_MODALITY.M with the 
 given input arguments.

 PRT_UI_KERNEL_MODALITY('Property','Value',...) creates a new 
 PRT_UI_KERNEL_MODALITY or raises the existing singleton*.  Starting from 
 the left, property value pairs are applied to the GUI before 
 prt_ui_kernel_modality_OpeningFcn gets called.  An unrecognized property 
 name or invalid value makes property application stop.  All inputs are 
 passed to prt_ui_kernel_modality_OpeningFcn via varargin.

 *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt_ui_prepare_datamod(varargin)
0002 % PRT_UI_KERNEL_MODALITY M-file for prt_ui_kernel_modality.fig
0003 %
0004 % PRT_UI_KERNEL_MODALITY, by itself, creates a new PRT_UI_KERNEL_MODALITY
0005 % or raises the existing singleton*.
0006 %
0007 % H = PRT_UI_KERNEL_MODALITY returns the handle to a new
0008 % PRT_UI_KERNEL_MODALITY or the handle to the existing singleton*.
0009 %
0010 % PRT_UI_KERNEL_MODALITY('CALLBACK',hObject,eventData,handles,...) calls
0011 % the local function named CALLBACK in PRT_UI_KERNEL_MODALITY.M with the
0012 % given input arguments.
0013 %
0014 % PRT_UI_KERNEL_MODALITY('Property','Value',...) creates a new
0015 % PRT_UI_KERNEL_MODALITY or raises the existing singleton*.  Starting from
0016 % the left, property value pairs are applied to the GUI before
0017 % prt_ui_kernel_modality_OpeningFcn gets called.  An unrecognized property
0018 % name or invalid value makes property application stop.  All inputs are
0019 % passed to prt_ui_kernel_modality_OpeningFcn via varargin.
0020 %
0021 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0022 %  instance to run (singleton)".
0023 %
0024 % See also: GUIDE, GUIDATA, GUIHANDLES
0025 %__________________________________________________________________________
0026 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0027 
0028 % Written by J. Schrouff
0029 % $Id: prt_ui_prepare_datamod.m 523 2012-05-09 11:43:36Z jrichiar $
0030 
0031 % Edit the above text to modify the response to help prt_ui_kernel_modality
0032 
0033 % Last Modified by GUIDE v2.5 30-Sep-2011 15:37:09
0034 
0035 % Begin initialization code - DO NOT EDIT
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 % End initialization code - DO NOT EDIT
0053 
0054 
0055 % --- Executes just before prt_ui_kernel_modality is made visible.
0056 function prt_ui_prepare_datamod_OpeningFcn(hObject, eventdata, handles, varargin)
0057 % This function has no output args, see OutputFcn.
0058 % hObject    handle to figure
0059 % eventdata  reserved - to be defined in a future version of MATLAB
0060 % handles    structure with handles and user data (see GUIDATA)
0061 % varargin   command line arguments to prt_ui_kernel_modality (see
0062 % VARARGIN)
0063     
0064 set(handles.figure1,'Name','PRoNTo :: Specify modality to include')
0065 %set size of the window, taking screen resolution and platform into account
0066 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0067 if ispc
0068     PF='MS Sans Serif';
0069 else
0070     PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
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 % Choose the color of the different backgrounds and figure parameters
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 %GUI specific initialization
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 % if only one modality and no design, suppress the "all conditions" option
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 % Update handles structure
0163 guidata(hObject, handles);
0164 
0165 % UIWAIT makes prt_ui_kernel_modality wait for user response (see UIRESUME)
0166 uiwait(handles.figure1);
0167 
0168 
0169 % --- Outputs from this function are returned to the command line.
0170 function varargout = prt_ui_prepare_datamod_OutputFcn(hObject, eventdata, handles) 
0171 % varargout  cell array for returning output args (see VARARGOUT);
0172 % hObject    handle to figure
0173 % eventdata  reserved - to be defined in a future version of MATLAB
0174 % handles    structure with handles and user data (see GUIDATA)
0175 
0176 % Get default command line output from handles structure
0177 if ~isempty(handles)
0178     varargout{1} = handles.output;
0179     % The figure can be deleted now
0180     delete(handles.figure1);
0181 end
0182 
0183 
0184 
0185 
0186 function edit_mask_Callback(hObject, eventdata, handles)
0187 % hObject    handle to edit_mask (see GCBO)
0188 % eventdata  reserved - to be defined in a future version of MATLAB
0189 % handles    structure with handles and user data (see GUIDATA)
0190 
0191 % Hints: get(hObject,'String') returns contents of edit_mask as text
0192 %        str2double(get(hObject,'String')) returns contents of edit_mask as a double
0193 handles.mod.mask=get(handles.edit_mask,'String');
0194 % Update handles structure
0195 guidata(hObject, handles);
0196 
0197 % --- Executes during object creation, after setting all properties.
0198 function edit_mask_CreateFcn(hObject, eventdata, handles)
0199 % hObject    handle to edit_mask (see GCBO)
0200 % eventdata  reserved - to be defined in a future version of MATLAB
0201 % handles    empty - handles not created until after all CreateFcns called
0202 
0203 % Hint: edit controls usually have a white background on Windows.
0204 %       See ISPC and COMPUTER.
0205 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0206     set(hObject,'BackgroundColor','white');
0207 end
0208 
0209 
0210 % --- Executes on button press in br_mask.
0211 function br_mask_Callback(hObject, eventdata, handles)
0212 % hObject    handle to br_mask (see GCBO)
0213 % eventdata  reserved - to be defined in a future version of MATLAB
0214 % handles    structure with handles and user data (see GUIDATA)
0215 handles.mod.mask=spm_select(1,'image','Select mask for the selected modality');
0216 set(handles.edit_mask,'String',handles.mod.mask);
0217 % Update handles structure
0218 guidata(hObject, handles);
0219 
0220 % --- Executes on selection change in pop_cond.
0221 function pop_cond_Callback(hObject, eventdata, handles)
0222 % hObject    handle to pop_cond (see GCBO)
0223 % eventdata  reserved - to be defined in a future version of MATLAB
0224 % handles    structure with handles and user data (see GUIDATA)
0225 
0226 % Hints: contents = get(hObject,'String') returns pop_cond contents as cell array
0227 %        contents{get(hObject,'Value')} returns selected item from pop_cond
0228 val=get(handles.pop_cond,'Value');
0229 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0230 %handle particular bug with matlab(7.10.0499) and mac (OSX 10.6.4)
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 % Update handles structure
0241 guidata(hObject, handles);
0242 
0243 % --- Executes during object creation, after setting all properties.
0244 function pop_cond_CreateFcn(hObject, eventdata, handles)
0245 % hObject    handle to pop_cond (see GCBO)
0246 % eventdata  reserved - to be defined in a future version of MATLAB
0247 % handles    empty - handles not created until after all CreateFcns called
0248 
0249 % Hint: popupmenu controls usually have a white background on Windows.
0250 %       See ISPC and COMPUTER.
0251 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0252     set(hObject,'BackgroundColor','white');
0253 end
0254 
0255 
0256 % --- Executes on selection change in pop_det.
0257 function pop_det_Callback(hObject, eventdata, handles)
0258 % hObject    handle to pop_det (see GCBO)
0259 % eventdata  reserved - to be defined in a future version of MATLAB
0260 % handles    structure with handles and user data (see GUIDATA)
0261 
0262 % Hints: contents = get(hObject,'String') returns pop_det contents as cell array
0263 %        contents{get(hObject,'Value')} returns selected item from pop_det
0264 val=get(handles.pop_det,'Value');
0265 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0266 %handle particular bug with matlab(7.10.0499) and mac (OSX 10.6.4)
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 % No detrend
0273     set(handles.par_name,'Visible','off')
0274     set(handles.par_value,'Visible','off')
0275     handles.mod.param_dt=[];
0276 elseif val==1 % Polynomial detrend
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 % Discrete Cosine Transform
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 % Update handles structure
0290 guidata(hObject, handles);
0291 
0292 
0293 % --- Executes during object creation, after setting all properties.
0294 function pop_det_CreateFcn(hObject, eventdata, handles)
0295 % hObject    handle to pop_det (see GCBO)
0296 % eventdata  reserved - to be defined in a future version of MATLAB
0297 % handles    empty - handles not created until after all CreateFcns called
0298 
0299 % Hint: popupmenu controls usually have a white background on Windows.
0300 %       See ISPC and COMPUTER.
0301 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0302     set(hObject,'BackgroundColor','white');
0303 end
0304 
0305 
0306 % --- Executes on selection change in pop_mod.
0307 function pop_mod_Callback(hObject, eventdata, handles)
0308 % hObject    handle to pop_mod (see GCBO)
0309 % eventdata  reserved - to be defined in a future version of MATLAB
0310 % handles    structure with handles and user data (see GUIDATA)
0311 
0312 % Hints: contents = get(hObject,'String') returns pop_mod contents as cell array
0313 %        contents{get(hObject,'Value')} returns selected item from pop_mod
0314 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0315 list=get(handles.pop_mod,'String');
0316 %handle particular bug with matlab(7.10.0499) and mac (OSX 10.6.4)
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 % if only one modality and no design, suppress the "all conditions" option
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 % Update handles structure
0338 guidata(hObject, handles);
0339 
0340 % --- Executes during object creation, after setting all properties.
0341 function pop_mod_CreateFcn(hObject, eventdata, handles)
0342 % hObject    handle to pop_mod (see GCBO)
0343 % eventdata  reserved - to be defined in a future version of MATLAB
0344 % handles    empty - handles not created until after all CreateFcns called
0345 
0346 % Hint: popupmenu controls usually have a white background on Windows.
0347 %       See ISPC and COMPUTER.
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 % hObject    handle to par_value (see GCBO)
0356 % eventdata  reserved - to be defined in a future version of MATLAB
0357 % handles    structure with handles and user data (see GUIDATA)
0358 
0359 % Hints: get(hObject,'String') returns contents of par_value as text
0360 %        str2double(get(hObject,'String')) returns contents of par_value as
0361 %        a double
0362 handles.mod.param_dt=get(handles.paramd,'Value');
0363 % Update handles structure
0364 guidata(hObject, handles);
0365 
0366 % --- Executes during object creation, after setting all properties.
0367 function par_value_CreateFcn(hObject, eventdata, handles)
0368 % hObject    handle to par_value (see GCBO)
0369 % eventdata  reserved - to be defined in a future version of MATLAB
0370 % handles    empty - handles not created until after all CreateFcns called
0371 
0372 % Hint: edit controls usually have a white background on Windows.
0373 %       See ISPC and COMPUTER.
0374 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0375     set(hObject,'BackgroundColor','white');
0376 end
0377 
0378 
0379 % --- Executes on selection change in pop_norm.
0380 function pop_norm_Callback(hObject, eventdata, handles)
0381 % hObject    handle to pop_norm (see GCBO)
0382 % eventdata  reserved - to be defined in a future version of MATLAB
0383 % handles    structure with handles and user data (see GUIDATA)
0384 
0385 % Hints: contents = get(hObject,'String') returns pop_norm contents as cell array
0386 %        contents{get(hObject,'Value')} returns selected item from pop_norm
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 % Update handles structure
0401 guidata(hObject, handles);
0402 
0403 % --- Executes during object creation, after setting all properties.
0404 function pop_norm_CreateFcn(hObject, eventdata, handles)
0405 % hObject    handle to pop_norm (see GCBO)
0406 % eventdata  reserved - to be defined in a future version of MATLAB
0407 % handles    empty - handles not created until after all CreateFcns called
0408 
0409 % Hint: popupmenu controls usually have a white background on Windows.
0410 %       See ISPC and COMPUTER.
0411 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0412     set(hObject,'BackgroundColor','white');
0413 end
0414 
0415 
0416 % --- Executes on button press in okbutt.
0417 function okbutt_Callback(hObject, eventdata, handles)
0418 % hObject    handle to okbutt (see GCBO)
0419 % eventdata  reserved - to be defined in a future version of MATLAB
0420 % handles    structure with handles and user data (see GUIDATA)
0421     
0422 handles.output=handles.mod;
0423 % Update handles structure
0424 guidata(hObject, handles);
0425 
0426 uiresume(handles.figure1)

Generated on Sun 20-May-2012 13:24:48 by m2html © 2005