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$
0028 
0029 % Edit the above text to modify the response to help prt_ui_kernel
0030 
0031 % Last Modified by GUIDE v2.5 23-Jul-2013 12:53:10
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     set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0131         'Units','normalized')
0132 end
0133 
0134 
0135 set(handles.sel_mod,'Enable','on')
0136 set(handles.multkernflag,'Enable','off')
0137 set(handles.multkernflag,'Value',0)
0138 handles.kname=[];
0139 handles.flag_mm = 0;
0140 end
0141 % Update handles structure
0142 guidata(hObject, handles);
0143 
0144 % UIWAIT makes prt_ui_kernel wait for user response (see UIRESUME)
0145 % uiwait(handles.figure1);
0146 
0147 
0148 % --- Outputs from this function are returned to the command line.
0149 function varargout = prt_ui_prepare_data_OutputFcn(hObject, eventdata, handles) 
0150 % varargout  cell array for returning output args (see VARARGOUT);
0151 % hObject    handle to figure
0152 % eventdata  reserved - to be defined in a future version of MATLAB
0153 % handles    structure with handles and user data (see GUIDATA)
0154 
0155 % Get default command line output from handles structure
0156 varargout{1} = handles.output;
0157 
0158 
0159 
0160 function edit_prt_Callback(hObject, eventdata, handles)
0161 % hObject    handle to edit_prt (see GCBO)
0162 % eventdata  reserved - to be defined in a future version of MATLAB
0163 % handles    structure with handles and user data (see GUIDATA)
0164 
0165 % Hints: get(hObject,'String') returns contents of edit_prt as text
0166 %        str2double(get(hObject,'String')) returns contents of edit_prt as a double
0167 fname=get(handles.edit_prt,'String');
0168 if exist('PRT','var')
0169     clear PRT
0170 end
0171 try
0172     load(fname)
0173     handles.dat=PRT;
0174 catch
0175     beep
0176     disp('Could not load file')
0177     return
0178 end
0179 %if only one modality, than fill some fields automatically
0180 n_mod=length(PRT.group(1).subject(1).modality);
0181 handles.modnames={PRT.masks(:).mod_name};
0182 if n_mod==1
0183     try
0184         handles.mod=prt_ui_prepare_datamod('UserData',{PRT,1});
0185         set(handles.num_mod,'Value',1)
0186         set(handles.num_mod,'String',1)
0187         set(handles.sel_mod,'String',{PRT.masks(1).mod_name})
0188     catch
0189         set(handles.edit_prt,'String','');
0190         return
0191     end
0192     set(handles.edit_kname,'ForegroundColor',handles.color.high)
0193 else
0194     set(handles.text8,'ForegroundColor',handles.color.high)
0195 end
0196 handles.fname=fname;
0197 % Update handles structure
0198 guidata(hObject, handles);
0199 
0200 % --- Executes during object creation, after setting all properties.
0201 function edit_prt_CreateFcn(hObject, eventdata, handles)
0202 % hObject    handle to edit_prt (see GCBO)
0203 % eventdata  reserved - to be defined in a future version of MATLAB
0204 % handles    empty - handles not created until after all CreateFcns called
0205 
0206 % Hint: edit controls usually have a white background on Windows.
0207 %       See ISPC and COMPUTER.
0208 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0209     set(hObject,'BackgroundColor','white');
0210 end
0211 
0212 
0213 % --- Executes on button press in br_prt.
0214 function br_prt_Callback(hObject, eventdata, handles)
0215 % hObject    handle to br_prt (see GCBO)
0216 % eventdata  reserved - to be defined in a future version of MATLAB
0217 % handles    structure with handles and user data (see GUIDATA)
0218 fname=spm_select(1,'.mat','Select PRT.mat',[],pwd,'PRT.mat');
0219 if exist('PRT','var')
0220     clear PRT
0221 end
0222 try
0223     load(fname)
0224     handles.dat=PRT;
0225     set(handles.edit_prt,'String',fname);
0226 catch
0227     beep
0228     disp('Could not load file')
0229     return
0230 end
0231 %if only one modality, than fill some fields automatically
0232 n_mod=length(PRT.group(1).subject(1).modality);
0233 handles.modnames={PRT.masks(:).mod_name};
0234 if n_mod==1
0235     try
0236         handles.mod=prt_ui_prepare_datamod('UserData',{PRT,1});
0237         set(handles.num_mod,'Value',1)
0238         set(handles.num_mod,'String',1)
0239         set(handles.sel_mod,'String',{PRT.masks(1).mod_name})
0240     catch
0241         set(handles.edit_prt,'String','');
0242         return
0243     end
0244     set(handles.edit_kname,'ForegroundColor',handles.color.high)
0245 else
0246     set(handles.text8,'ForegroundColor',handles.color.high)
0247 end
0248 handles.fname=fname;
0249 % Update handles structure
0250 guidata(hObject, handles);
0251 
0252 
0253 function edit_kname_Callback(hObject, eventdata, handles)
0254 % hObject    handle to edit_kname (see GCBO)
0255 % eventdata  reserved - to be defined in a future version of MATLAB
0256 % handles    structure with handles and user data (see GUIDATA)
0257 
0258 % Hints: get(hObject,'String') returns contents of edit_kname as text
0259 %        str2double(get(hObject,'String')) returns contents of edit_kname as a double
0260 handles.kname=deblank(get(handles.edit_kname,'String'));
0261 if ~prt_checkAlphaNumUnder(handles.kname)
0262     beep
0263     disp('Kernel name should be entered in alphanumeric format only')
0264     disp('Please correct')
0265     set(handles.edit_kname,'ForegroundColor',[1,0,0])
0266     return
0267 else
0268     set(handles.edit_kname,'ForegroundColor',[0 0 0])
0269 end
0270 % Update handles structure
0271 guidata(hObject, handles);
0272 
0273 
0274 % --- Executes during object creation, after setting all properties.
0275 function edit_kname_CreateFcn(hObject, eventdata, handles)
0276 % hObject    handle to edit_kname (see GCBO)
0277 % eventdata  reserved - to be defined in a future version of MATLAB
0278 % handles    empty - handles not created until after all CreateFcns called
0279 
0280 % Hint: edit controls usually have a white background on Windows.
0281 %       See ISPC and COMPUTER.
0282 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0283     set(hObject,'BackgroundColor','white');
0284 end
0285 
0286 
0287 function num_mod_Callback(hObject, eventdata, handles)
0288 % hObject    handle to num_mod (see GCBO)
0289 % eventdata  reserved - to be defined in a future version of MATLAB
0290 % handles    structure with handles and user data (see GUIDATA)
0291 
0292 % Hints: get(hObject,'String') returns contents of num_mod as text
0293 %        str2double(get(hObject,'String')) returns contents of num_mod as a double
0294 val=str2double(get(handles.num_mod,'String'));
0295 set(handles.text8,'ForegroundColor',handles.color.high)
0296 n_mod=length(handles.modnames);
0297 if n_mod>1 && val>1
0298     set(handles.multkernflag,'Enable','on')
0299 end
0300 %handles.mod=struct();
0301 list=[];
0302 %initialize for all modalities
0303 for i=1:n_mod
0304     handles.mod(i)=struct('mod_name',[],'mode',[],'mask',[],'detrend',[], ...
0305         'param_dt',[],'normalise',[],'matnorm',[],'multroi',[],'atlasroi',[]);
0306 end
0307 %get information for the selected modalities
0308 for i=1:val
0309     try
0310         tmp=prt_ui_prepare_datamod('UserData',{handles.dat,val});
0311     catch
0312         error('prt_ui_prepare_data:NoModSpecified','No modality was specified')
0313     end
0314     if isempty(tmp)
0315         error('prt_ui_prepare_data:EmptyModality','No modality was specified')
0316     end
0317     list=[list,tmp.mod_name];
0318     set(handles.sel_mod,'String',list)
0319     ind=find(strcmpi(handles.modnames,tmp.mod_name));
0320     handles.mod(ind)=tmp;
0321 end
0322 set(handles.text8,'ForegroundColor',handles.color.black)
0323 % Update handles structure
0324 guidata(hObject, handles);
0325 
0326 
0327 % --- Executes during object creation, after setting all properties.
0328 function num_mod_CreateFcn(hObject, eventdata, handles)
0329 % hObject    handle to num_mod (see GCBO)
0330 % eventdata  reserved - to be defined in a future version of MATLAB
0331 % handles    empty - handles not created until after all CreateFcns called
0332 
0333 % Hint: edit controls usually have a white background on Windows.
0334 %       See ISPC and COMPUTER.
0335 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0336     set(hObject,'BackgroundColor','white');
0337 end
0338 
0339 % --- Executes on selection change in sel_mod.
0340 function sel_mod_Callback(hObject, eventdata, handles)
0341 % hObject    handle to sel_mod (see GCBO)
0342 % eventdata  reserved - to be defined in a future version of MATLAB
0343 % handles    structure with handles and user data (see GUIDATA)
0344 
0345 % Hints: contents = get(hObject,'String') returns sel_mod contents as cell array
0346 %        contents{get(hObject,'Value')} returns selected item from sel_mod
0347 
0348 
0349 % --- Executes during object creation, after setting all properties.
0350 function sel_mod_CreateFcn(hObject, eventdata, handles)
0351 % hObject    handle to sel_mod (see GCBO)
0352 % eventdata  reserved - to be defined in a future version of MATLAB
0353 % handles    empty - handles not created until after all CreateFcns called
0354 
0355 % Hint: listbox controls usually have a white background on Windows.
0356 %       See ISPC and COMPUTER.
0357 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0358     set(hObject,'BackgroundColor','white');
0359 end
0360 
0361 
0362 % --- Executes on button press in multkernflag.
0363 function multkernflag_Callback(hObject, eventdata, handles)
0364 % hObject    handle to multkernflag (see GCBO)
0365 % eventdata  reserved - to be defined in a future version of MATLAB
0366 % handles    structure with handles and user data (see GUIDATA)
0367 
0368 % Hint: get(hObject,'Value') returns toggle state of multkernflag
0369 v=get(handles.multkernflag,'Value');
0370 handles.flag_mm=v;
0371 % Update handles structure
0372 guidata(hObject, handles);
0373 
0374 % --- Executes on button press in buildbutt.
0375 function buildbutt_Callback(hObject, eventdata, handles)
0376 % hObject    handle to buildbutt (see GCBO)
0377 % eventdata  reserved - to be defined in a future version of MATLAB
0378 % handles    structure with handles and user data (see GUIDATA)
0379 
0380 input=struct('fname',[],'kname',[],'mod',[],'flag_mm',[]);
0381 input.fname=handles.fname;
0382 input.flag_mm = handles.flag_mm;
0383 if isempty(handles.kname)
0384     beep
0385     disp('Enter a name for the feature set to be saved')
0386     set(handles.edit_kname,'ForegroundColor',handles.color.high)
0387     return
0388 end
0389 input.fs_name=handles.kname;
0390 if ~isfield(handles,'mod') || isempty(handles.mod)
0391     beep
0392     disp('No modality was selected to build the dataset!')
0393     disp('Please, enter a number of modalities to use')
0394     set(handles.text8,'ForegroundColor',handles.color.high)
0395     return
0396 end
0397 input.mod=handles.mod;
0398 load(input.fname);
0399 prt_fs(PRT,input);
0400 delete(handles.figure1)

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005