Home > . > prt_ui_prepare_data.m

prt_ui_prepare_data

PURPOSE ^

PRT_UI_KERNEL MATLAB code for prt_ui_kernel.fig

SYNOPSIS ^

function varargout = prt_ui_prepare_data(varargin)

DESCRIPTION ^

 PRT_UI_KERNEL MATLAB code for prt_ui_kernel.fig
 
 PRT_UI_KERNEL, by itself, creates a new PRT_UI_KERNEL or raises the 
 existing singleton*.

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

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

 PRT_UI_KERNEL('Property','Value',...) creates a new PRT_UI_KERNEL or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_ui_kernel_OpeningFcn gets called.
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_ui_kernel_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_data(varargin)
0002 % PRT_UI_KERNEL MATLAB code for prt_ui_kernel.fig
0003 %
0004 % PRT_UI_KERNEL, by itself, creates a new PRT_UI_KERNEL or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_KERNEL returns the handle to a new PRT_UI_KERNEL or the handle
0008 % to the existing singleton*.
0009 %
0010 % PRT_UI_KERNEL('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_KERNEL.M with the given input arguments.
0012 %
0013 % PRT_UI_KERNEL('Property','Value',...) creates a new PRT_UI_KERNEL or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_ui_kernel_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_ui_kernel_OpeningFcn via varargin.
0018 %
0019 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0020 %  instance to run (singleton)".
0021 %
0022 % See also: GUIDE, GUIDATA, GUIHANDLES
0023 %__________________________________________________________________________
0024 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0025 
0026 % Written by J. Schrouff
0027 % $Id: prt_ui_prepare_data.m 527 2012-05-16 12:59:08Z schrouff $
0028 
0029 % Edit the above text to modify the response to help prt_ui_kernel
0030 
0031 % Last Modified by GUIDE v2.5 28-Sep-2011 17:30:50
0032 
0033 % Begin initialization code - DO NOT EDIT
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 % End initialization code - DO NOT EDIT
0051 
0052 
0053 % --- Executes just before prt_ui_kernel is made visible.
0054 function prt_ui_prepare_data_OpeningFcn(hObject, eventdata, handles, varargin)
0055 % This function has no output args, see OutputFcn.
0056 % hObject    handle to figure
0057 % eventdata  reserved - to be defined in a future version of MATLAB
0058 % handles    structure with handles and user data (see GUIDATA)
0059 % varargin   command line arguments to prt_ui_kernel (see VARARGIN)
0060 
0061 % Choose default command line output for prt_ui_kernel
0062 handles.output = hObject;
0063 %if window already exists, just put it as the current figure
0064 Tag='FSwin';
0065 F = findall(allchild(0),'Flat','Tag',Tag);
0066 if length(F) > 1
0067     % Multiple Graphics windows - close all but most recent
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 %set size of the window, taking screen resolution and platform into account
0078 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0079 if ispc
0080     PF='MS Sans Serif';
0081 else
0082     PF= spm_platform('fonts');     %-Font names (for this platform)
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);  %factor to scale the fonts
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 % Choose the color of the different backgrounds and figure parameters
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 % Update handles structure
0144 guidata(hObject, handles);
0145 
0146 % UIWAIT makes prt_ui_kernel wait for user response (see UIRESUME)
0147 % uiwait(handles.figure1);
0148 
0149 
0150 % --- Outputs from this function are returned to the command line.
0151 function varargout = prt_ui_prepare_data_OutputFcn(hObject, eventdata, handles) 
0152 % varargout  cell array for returning output args (see VARARGOUT);
0153 % hObject    handle to figure
0154 % eventdata  reserved - to be defined in a future version of MATLAB
0155 % handles    structure with handles and user data (see GUIDATA)
0156 
0157 % Get default command line output from handles structure
0158 varargout{1} = handles.output;
0159 
0160 
0161 
0162 function edit_prt_Callback(hObject, eventdata, handles)
0163 % hObject    handle to edit_prt (see GCBO)
0164 % eventdata  reserved - to be defined in a future version of MATLAB
0165 % handles    structure with handles and user data (see GUIDATA)
0166 
0167 % Hints: get(hObject,'String') returns contents of edit_prt as text
0168 %        str2double(get(hObject,'String')) returns contents of edit_prt as a double
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 %if only one modality, than fill some fields automatically
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 % Update handles structure
0200 guidata(hObject, handles);
0201 
0202 % --- Executes during object creation, after setting all properties.
0203 function edit_prt_CreateFcn(hObject, eventdata, handles)
0204 % hObject    handle to edit_prt (see GCBO)
0205 % eventdata  reserved - to be defined in a future version of MATLAB
0206 % handles    empty - handles not created until after all CreateFcns called
0207 
0208 % Hint: edit controls usually have a white background on Windows.
0209 %       See ISPC and COMPUTER.
0210 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0211     set(hObject,'BackgroundColor','white');
0212 end
0213 
0214 
0215 % --- Executes on button press in br_prt.
0216 function br_prt_Callback(hObject, eventdata, handles)
0217 % hObject    handle to br_prt (see GCBO)
0218 % eventdata  reserved - to be defined in a future version of MATLAB
0219 % handles    structure with handles and user data (see GUIDATA)
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 %if only one modality, than fill some fields automatically
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 % Update handles structure
0252 guidata(hObject, handles);
0253 
0254 
0255 function edit_kname_Callback(hObject, eventdata, handles)
0256 % hObject    handle to edit_kname (see GCBO)
0257 % eventdata  reserved - to be defined in a future version of MATLAB
0258 % handles    structure with handles and user data (see GUIDATA)
0259 
0260 % Hints: get(hObject,'String') returns contents of edit_kname as text
0261 %        str2double(get(hObject,'String')) returns contents of edit_kname as a double
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 % Update handles structure
0273 guidata(hObject, handles);
0274 
0275 
0276 % --- Executes during object creation, after setting all properties.
0277 function edit_kname_CreateFcn(hObject, eventdata, handles)
0278 % hObject    handle to edit_kname (see GCBO)
0279 % eventdata  reserved - to be defined in a future version of MATLAB
0280 % handles    empty - handles not created until after all CreateFcns called
0281 
0282 % Hint: edit controls usually have a white background on Windows.
0283 %       See ISPC and COMPUTER.
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 % hObject    handle to num_mod (see GCBO)
0291 % eventdata  reserved - to be defined in a future version of MATLAB
0292 % handles    structure with handles and user data (see GUIDATA)
0293 
0294 % Hints: get(hObject,'String') returns contents of num_mod as text
0295 %        str2double(get(hObject,'String')) returns contents of num_mod as a double
0296 val=str2double(get(handles.num_mod,'String'));
0297 set(handles.text8,'ForegroundColor',handles.color.high)
0298 n_mod=length(handles.modnames);
0299 %handles.mod=struct();
0300 list=[];
0301 %initialize for all modalities
0302 for i=1:n_mod
0303     handles.mod(i)=struct('mod_name',[],'mode',[],'mask',[],'detrend',[], ...
0304         'param_dt',[],'normalise',[],'matnorm',[]);
0305 end
0306 %get information for the selected modalities
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 % Update handles structure
0319 guidata(hObject, handles);
0320 
0321 
0322 % --- Executes during object creation, after setting all properties.
0323 function num_mod_CreateFcn(hObject, eventdata, handles)
0324 % hObject    handle to num_mod (see GCBO)
0325 % eventdata  reserved - to be defined in a future version of MATLAB
0326 % handles    empty - handles not created until after all CreateFcns called
0327 
0328 % Hint: edit controls usually have a white background on Windows.
0329 %       See ISPC and COMPUTER.
0330 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0331     set(hObject,'BackgroundColor','white');
0332 end
0333 
0334 % --- Executes on selection change in sel_mod.
0335 function sel_mod_Callback(hObject, eventdata, handles)
0336 % hObject    handle to sel_mod (see GCBO)
0337 % eventdata  reserved - to be defined in a future version of MATLAB
0338 % handles    structure with handles and user data (see GUIDATA)
0339 
0340 % Hints: contents = get(hObject,'String') returns sel_mod contents as cell array
0341 %        contents{get(hObject,'Value')} returns selected item from sel_mod
0342 
0343 
0344 % --- Executes during object creation, after setting all properties.
0345 function sel_mod_CreateFcn(hObject, eventdata, handles)
0346 % hObject    handle to sel_mod (see GCBO)
0347 % eventdata  reserved - to be defined in a future version of MATLAB
0348 % handles    empty - handles not created until after all CreateFcns called
0349 
0350 % Hint: listbox controls usually have a white background on Windows.
0351 %       See ISPC and COMPUTER.
0352 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0353     set(hObject,'BackgroundColor','white');
0354 end
0355 
0356 
0357 % --- Executes on button press in buildbutt.
0358 function buildbutt_Callback(hObject, eventdata, handles)
0359 % hObject    handle to buildbutt (see GCBO)
0360 % eventdata  reserved - to be defined in a future version of MATLAB
0361 % handles    structure with handles and user data (see GUIDATA)
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)

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005