Home > . > prt_ui_results.m

prt_ui_results

PURPOSE ^

PRT_UI_RESULTS MATLAB code for prt_ui_results.fig

SYNOPSIS ^

function varargout = prt_ui_results(varargin)

DESCRIPTION ^

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

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

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

 PRT_UI_RESULTS('Property','Value',...) creates a new PRT_UI_RESULTS or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_ui_results_OpeningFcn gets called.
 An unrecognized property name or invalid value makes property application
 stop.  All inputs are passed to prt_ui_results_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_results(varargin)
0002 % PRT_UI_RESULTS MATLAB code for prt_ui_results.fig
0003 %
0004 % PRT_UI_RESULTS, by itself, creates a new PRT_UI_RESULTS or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_UI_RESULTS returns the handle to a new PRT_UI_RESULTS or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_UI_RESULTS('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_UI_RESULTS.M with the given input arguments.
0012 %
0013 % PRT_UI_RESULTS('Property','Value',...) creates a new PRT_UI_RESULTS or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_ui_results_OpeningFcn gets called.
0016 % An unrecognized property name or invalid value makes property application
0017 % stop.  All inputs are passed to prt_ui_results_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 M. J. Rosa
0027 % $Id: prt_ui_results.m 542 2012-05-20 10:48:51Z cphillip $
0028 
0029 % Edit the above text to modify the response to help prt_ui_results
0030 
0031 % Last Modified by GUIDE v2.5 08-Apr-2012 10:35:42
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_results_OpeningFcn, ...
0038                    'gui_OutputFcn',  @prt_ui_results_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_results is made visible.
0054 function prt_ui_results_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_results (see VARARGIN)
0060 
0061 %if window already exists, just put it as the current figure
0062 Tag='Results';
0063 F = findall(allchild(0),'Flat','Tag',Tag);
0064 if length(F) > 1
0065     % Multiple Graphics windows - close all but most recent
0066     close(F(2:end))
0067     F = F(1);
0068     uistack(F,'top')
0069 elseif length(F)==1
0070     uistack(F,'top')
0071 else
0072     set(handles.figure1,'Tag',Tag)
0073 set(handles.figure1,'Name','PRoNTo :: Results')
0074 %set size of the window, taking screen resolution and platform into account
0075 %--------------------------------------------------------------------------
0076 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0077 if ispc
0078     PF='MS Sans Serif';
0079 else
0080     PF= spm_platform('fonts');     %-Font names (for this platform)
0081     PF=PF.helvetica;
0082 end
0083 tmp  = [S0(3)/1280 (S0(4))/800];
0084 ratio=min(tmp)*[1 1 1 1];
0085 FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0086 x=get(handles.figure1,'Position');
0087 set(handles.figure1,'Position',ratio.*x)
0088 set(handles.figure1,'Resize','on')
0089 
0090 
0091 color=prt_get_defaults('color');
0092 set(handles.figure1,'Color',color.bg1)
0093 aa=get(handles.figure1,'children');
0094 for i=1:length(aa)
0095     if strcmpi(get(aa(i),'type'),'uipanel')
0096         set(aa(i),'BackgroundColor',color.bg2)
0097         bb=get(aa(i),'children');
0098         if ~isempty(bb)
0099             for j=1:length(bb)
0100                 if strcmpi(get(bb(j),'type'),'uipanel')
0101                     cc=get(bb(j),'children');
0102                     set(bb(j),'BackgroundColor',color.bg2)
0103                     for k=1:length(cc)
0104                         if strcmpi(get(cc(k),'type'),'uipanel')
0105                             dd=get(cc(k),'children');
0106                             set(cc(k),'BackgroundColor',color.bg2)
0107                             for l=1:length(dd)
0108                                 if strcmpi(get(dd(l),'type'),'uicontrol')
0109                                     if ~isempty(find(strcmpi(get(dd(l),'Style'),{'text',...
0110                                         'radiobutton','checkbox'}))) 
0111                                         set(dd(l),'BackgroundColor',color.bg2)
0112                                     elseif ~isempty(find(strcmpi(get(dd(l),'Style'),'pushbutton'))) 
0113                                         set(dd(l),'BackgroundColor',color.fr)
0114                                     end
0115                                 end
0116                                 set(dd(l),'FontUnits','pixel')
0117                                 xf=get(dd(l),'FontSize');                                
0118                                 set(dd(l),'FontSize',ceil(FS*xf),'FontName',PF,...
0119                                     'FontUnits','normalized','Units','normalized')
0120                             end
0121                         elseif strcmpi(get(cc(k),'type'),'uicontrol') && ...
0122                                 ~isempty(find(strcmpi(get(cc(k),'Style'),{'text',...
0123                                 'radiobutton','checkbox'})))
0124                             set(cc(k),'BackgroundColor',color.bg2)
0125                         elseif strcmpi(get(cc(k),'type'),'uicontrol')&& ...
0126                                 ~isempty(find(strcmpi(get(cc(k),'Style'),'pushbutton')))
0127                             set(cc(k),'BackgroundColor',color.fr)
0128                         end
0129                         set(cc(k),'FontUnits','pixel')
0130                         xf=get(cc(k),'FontSize');
0131                         set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0132                             'FontUnits','normalized','Units','normalized')
0133                     end
0134                 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0135                         ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0136                         'radiobutton','checkbox'})))
0137                     set(bb(j),'BackgroundColor',color.bg2)
0138                 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0139                         ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0140                     set(bb(j),'BackgroundColor',color.fr)
0141                 end
0142                 set(bb(j),'FontUnits','pixel')
0143                 xf=get(bb(j),'FontSize');
0144                 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0145                     'FontUnits','normalized','Units','normalized')
0146             end
0147         end
0148     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0149         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0150                 'radiobutton','checkbox'})))
0151             set(aa(i),'BackgroundColor',color.bg1)
0152         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0153             set(aa(i),'BackgroundColor',color.fr)
0154         end
0155     end
0156     if ~strcmpi(get(aa(i),'type'),'uimenu')
0157         set(aa(i),'FontUnits','pixel')
0158         xf=get(aa(i),'FontSize');
0159         if ispc
0160             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0161                 'FontUnits','normalized','Units','normalized')
0162         else
0163             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0164                 'Units','normalized')
0165         end
0166     end
0167 end
0168 
0169 
0170 % Initialize window
0171 % -------------------------------------------------------------------------
0172 if ~isfield(handles,'notinit')
0173     
0174     % Load PRT.mat
0175     PRT     = spm_select(1,'mat','Select PRT.mat',[],pwd,'PRT.mat');
0176     pathdir = regexprep(PRT,'PRT.mat', '');
0177     handles.pathdir = pathdir;
0178     handles.prtdir=fileparts(PRT);
0179     load(PRT);
0180     
0181     % Save PRT
0182     handles.PRT = PRT;
0183     
0184     % Flag to load new weights
0185     handles.noloadw = 0;
0186     
0187     % Load model names
0188     if ~isfield(PRT,'model')
0189         beep
0190         disp('No models found in PRT.mat!')
0191         delete(handles.figure1)
0192         return
0193     end
0194     nmodels = length(PRT.model);
0195     mi  = [];
0196     nmi = 0;
0197     for m = 1:nmodels
0198         if isfield(PRT.model(m),'input') && ~isempty(PRT.model(m).input)
0199             if isfield(PRT.model(m),'output') && ~isempty(PRT.model(m).output)
0200                 nmi = nmi +1;
0201                 model_name{nmi} = PRT.model(m).model_name;
0202                 mi = [mi, m];
0203             else
0204                 beep;
0205                 disp(sprintf('Model %s not estimated! It will not be displayed',PRT.model(m).model_name));
0206             end
0207         else
0208             beep;
0209             disp(sprintf('Model %s not properly specified! It will not be displayed',PRT.model(m).model_name));
0210         end
0211         
0212     end
0213     if ~nmi, error('There are no estimated/good models in this PRT!'); end
0214     
0215     handles.mi = mi;
0216     
0217     % Set model pulldown menu
0218     handles.mnames = model_name;
0219     set(handles.classmenu,'String',handles.mnames);
0220     
0221     % Get folds pulldown menu
0222     m             = get(handles.classmenu,'Value');
0223     handles.nfold = length(PRT.model(mi(m)).output.fold);
0224     folds{1}      = 'All folds / Average';
0225     for f = 1:handles.nfold
0226         folds{f+1} = num2str(f);
0227     end
0228     handles.folds = folds;
0229     set(handles.foldmenu,'String',handles.folds);
0230     
0231     % Set plots menu for first model
0232     if strcmp(PRT.model(mi(m)).input.type,'classification');
0233         if length(PRT.model(mi(m)).output.stats.c_acc) <= 2 ;
0234             plots = {'Predictions','ROC','Histogram','Confusion Matrix'};
0235         else
0236             plots = {'Confusion Matrix'};
0237         end
0238     else
0239         plots = {'Predictions (scatter)', 'Predictions (bar)'};
0240     end
0241     set(handles.plotmenu,'String',plots); 
0242     
0243     % Initialize model utton
0244     handles.model_button = 0;
0245     
0246     % Clear axes
0247     cla(handles.axes5);     
0248 end
0249 end
0250 
0251 % Choose default command line output for prt_ui_results
0252 handles.output = hObject;
0253 
0254 % Update handles structure
0255 guidata(hObject, handles);
0256 
0257 % UIWAIT makes prt_ui_results wait for user response (see UIRESUME)
0258 % uiwait(handles.figure1);
0259 
0260 
0261 % --- Outputs from this function are returned to the command line.
0262 function varargout = prt_ui_results_OutputFcn(hObject, eventdata, handles) 
0263 % varargout  cell array for returning output args (see VARARGOUT);
0264 % hObject    handle to figure
0265 % eventdata  reserved - to be defined in a future version of MATLAB
0266 % handles    structure with handles and user data (see GUIDATA)
0267 
0268 % Get default command line output from handles structure
0269 varargout{1} = handles.output;
0270 
0271 
0272 % --- Executes on button press in originbutton.
0273 function originbutton_Callback(hObject, eventdata, handles)
0274 % hObject    handle to originbutton (see GCBO)
0275 % eventdata  reserved - to be defined in a future version of MATLAB
0276 % handles    structure with handles and user data (see GUIDATA)
0277 
0278 % Reset the crosshairs position
0279 % -------------------------------------------------------------------------
0280 if isfield(handles,'img')
0281     spm_orthviews('Reposition',[0 0 0]);
0282 end
0283 
0284 function mmedit_Callback(hObject, eventdata, handles)
0285 % hObject    handle to mmedit (see GCBO)
0286 % eventdata  reserved - to be defined in a future version of MATLAB
0287 % handles    structure with handles and user data (see GUIDATA)
0288 
0289 % Hints: get(hObject,'String') returns contents of mmedit as text
0290 %        str2double(get(hObject,'String')) returns contents of mmedit as a double
0291 
0292 % Move crosshairs position in mm
0293 % -------------------------------------------------------------------------
0294 if isfield(handles,'img')
0295     mp    = handles.mmedit;
0296     posmm = get(mp,'String');
0297     pos = sscanf(posmm, '%g %g %g');
0298     if length(pos)~=3
0299         pos = spm_orthviews('Pos');
0300     end
0301     spm_orthviews('Reposition',pos);
0302 end
0303 
0304 % --- Executes during object creation, after setting all properties.
0305 function mmedit_CreateFcn(hObject, eventdata, handles)
0306 % hObject    handle to mmedit (see GCBO)
0307 % eventdata  reserved - to be defined in a future version of MATLAB
0308 % handles    empty - handles not created until after all CreateFcns called
0309 
0310 % Hint: edit controls usually have a white background on Windows.
0311 %       See ISPC and COMPUTER.
0312 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0313     set(hObject,'BackgroundColor','white');
0314 end
0315 
0316 
0317 function vxedit_Callback(hObject, eventdata, handles)
0318 % hObject    handle to vxedit (see GCBO)
0319 % eventdata  reserved - to be defined in a future version of MATLAB
0320 % handles    structure with handles and user data (see GUIDATA)
0321 
0322 % Hints: get(hObject,'String') returns contents of vxedit as text
0323 %        str2double(get(hObject,'String')) returns contents of vxedit as a double
0324 
0325 % Move crosshairs position in vx
0326 % -------------------------------------------------------------------------
0327 if isfield(handles,'img')
0328     mp    = handles.vxedit;
0329     posvx = get(mp,'String');
0330     pos   = sscanf(posvx, '%g %g %g');
0331     if length(pos)~=3
0332         pos = spm_orthviews('pos',1);
0333     end
0334     tmp = handles.vols{1}.mat;
0335     pos = tmp(1:3,:)*[pos ; 1];
0336     spm_orthviews('Reposition',pos);
0337 end
0338 
0339 
0340 % --- Executes during object creation, after setting all properties.
0341 function vxedit_CreateFcn(hObject, eventdata, handles)
0342 % hObject    handle to vxedit (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: edit 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 % --- Executes on button press in helpbutton.
0355 function helpbutton_Callback(hObject, eventdata, handles)
0356 % hObject    handle to helpbutton (see GCBO)
0357 % eventdata  reserved - to be defined in a future version of MATLAB
0358 % handles    structure with handles and user data (see GUIDATA)
0359 
0360 disp('Help window for PRoNTo results has been launched.')
0361 prt_ui_results_help;
0362 
0363 % --- Executes on button press in quitbutton.
0364 function quitbutton_Callback(hObject, eventdata, handles)
0365 % hObject    handle to quitbutton (see GCBO)
0366 % eventdata  reserved - to be defined in a future version of MATLAB
0367 % handles    structure with handles and user data (see GUIDATA)
0368 
0369 % Close and clear figure
0370 % -------------------------------------------------------------------------
0371 close(handles.figure1);
0372 
0373 
0374 function loadweight_Callback(hObject, eventdata, handles)
0375 % hObject    handle to loadweight (see GCBO)
0376 % eventdata  reserved - to be defined in a future version of MATLAB
0377 % handles    structure with handles and user data (see GUIDATA)
0378 
0379 % Hints: get(hObject,'String') returns contents of loadweight as text
0380 %        str2double(get(hObject,'String')) returns contents of loadweight as a double
0381 
0382 
0383 % --- Executes during object creation, after setting all properties.
0384 function loadweight_CreateFcn(hObject, eventdata, handles)
0385 % hObject    handle to loadweight (see GCBO)
0386 % eventdata  reserved - to be defined in a future version of MATLAB
0387 % handles    empty - handles not created until after all CreateFcns called
0388 
0389 % Hint: edit controls usually have a white background on Windows.
0390 %       See ISPC and COMPUTER.
0391 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0392     set(hObject,'BackgroundColor','white');
0393 end
0394 
0395 
0396 % --- Executes on button press in weightbutton.
0397 function weightbutton_Callback(hObject, eventdata, handles)
0398 % hObject    handle to weightbutton (see GCBO)
0399 % eventdata  reserved - to be defined in a future version of MATLAB
0400 % handles    structure with handles and user data (see GUIDATA)
0401 
0402 disp('Loading weights...>>')
0403 % Select results (.img) for weight map
0404 % -------------------------------------------------------------------------
0405 if ~isfield(handles,'wmap') || ~handles.noloadw
0406     wmap            = spm_select(1,'image','Select weight map.');
0407     % Remove number in file name
0408     if strcmp(wmap(end-1),',')
0409         wmap = wmap(1:end-2);
0410     end
0411     V               = spm_vol(wmap);
0412     handles.vols{1} = V;
0413     handles.wmap    = wmap;
0414    
0415 end
0416 
0417 spm_orthviews('Reset');
0418 if isfield(handles,'aimg')
0419     anatomicalbutton_Callback(hObject, eventdata, handles);
0420 end
0421 
0422 % Image dimensions
0423 % -------------------------------------------------------------------------
0424 fold          = get(handles.foldmenu,'Value')-1;
0425 Vfolds        = handles.vols{1};
0426 V             = Vfolds(1);
0427 M             = V.mat;
0428 DIM           = V.dim(1:3)'; 
0429 xdim          = DIM(1); ydim  = DIM(2); zdim  = DIM(3);
0430 fdim          = V.private.dat.dim(4);
0431 [xords,yords] = ndgrid(1:xdim,1:ydim);
0432 xords         = xords(:)';  yords = yords(:)';
0433 I             = 1:xdim*ydim;
0434 zords_init    = ones(1,xdim*ydim);
0435 
0436 % Get image values above zero for each fold and all folds
0437 % -------------------------------------------------------------------------
0438 xyz_above = [];
0439 z_above   = [];
0440 if fold == 0,
0441     fold_coord = fdim*ones(1,xdim*ydim);
0442     V = Vfolds(fdim);
0443 else
0444     fold_coord = fold*ones(1,xdim*ydim);
0445     V = Vfolds(fold);
0446 end
0447 
0448 for z = 1:zdim,
0449     zords = z*zords_init;
0450     xyz   = [xords(I); yords(I); zords(I); fold_coord];
0451     zvals = spm_get_data(V,xyz);     
0452     above = find(zvals~=0);
0453     if ~isempty(above)
0454         xyz_above = [xyz_above,xyz(:,above)];
0455         z_above   = [z_above,zvals(above)];
0456     end
0457 end
0458 XYZ   = xyz_above(1:3,:);
0459 Z     = z_above;
0460 
0461 % Set spm_orthviews properties
0462 % -------------------------------------------------------------------------
0463 rotate3d off
0464 global st
0465 
0466 handles.notinit = 1;
0467 handles.img     = 1;
0468 
0469 st.handles  = handles;
0470 st.fig      = handles.figure1;
0471 st.V        = V;
0472 st.callback = 'prt_ui_results(''showpos'')';
0473 
0474 % Display maps
0475 % -------------------------------------------------------------------------
0476 h  = spm_orthviews('Image', handles.wmap,[0.0619 0.0859 0.4196 0.4196]);
0477 handles.wimgh = h;
0478 spm_orthviews('AddContext', h);
0479 spm_orthviews('MaxBB');
0480 spm_orthviews('AddBlobs', h, XYZ, Z, M);
0481 cmap = get(gcf,'Colormap');
0482 if size(cmap,1)~=128
0483       spm_figure('Colormap','jet');
0484 end
0485 spm_orthviews('Redraw');
0486 
0487 % Show positions
0488 % -------------------------------------------------------------------------
0489 prt_ui_results('showpos');
0490 
0491 disp('Done');
0492 
0493 % Reset flag to load weights
0494 handles.noloadw = 1;
0495 
0496 % Show file name
0497 % -------------------------------------------------------------------------
0498 set(handles.loadweight,'String',handles.wmap);
0499 guidata(hObject, handles);
0500 
0501 function loadanatomical_Callback(hObject, eventdata, handles)
0502 % hObject    handle to loadanatomical (see GCBO)
0503 % eventdata  reserved - to be defined in a future version of MATLAB
0504 % handles    structure with handles and user data (see GUIDATA)
0505 
0506 % Hints: get(hObject,'String') returns contents of loadanatomical as text
0507 %        str2double(get(hObject,'String')) returns contents of loadanatomical as a double
0508 
0509 
0510 % --- Executes during object creation, after setting all properties.
0511 function loadanatomical_CreateFcn(hObject, eventdata, handles)
0512 % hObject    handle to loadanatomical (see GCBO)
0513 % eventdata  reserved - to be defined in a future version of MATLAB
0514 % handles    empty - handles not created until after all CreateFcns called
0515 
0516 % Hint: edit controls usually have a white background on Windows.
0517 %       See ISPC and COMPUTER.
0518 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0519     set(hObject,'BackgroundColor','white');
0520 end
0521 
0522 
0523 % --- Executes on button press in anatomicalbutton.
0524 function anatomicalbutton_Callback(hObject, eventdata, handles)
0525 % hObject    handle to anatomicalbutton (see GCBO)
0526 % eventdata  reserved - to be defined in a future version of MATLAB
0527 % handles    structure with handles and user data (see GUIDATA)
0528 
0529 % Check if weight map and anatomical image exist and reset orthviews
0530 % -------------------------------------------------------------------------
0531 if ~isfield(handles,'wmap')
0532     spm_orthviews('Reset');
0533 end
0534 global st
0535 st.fig = handles.figure1;
0536 if ~isfield(handles,'aimg') || ~handles.noloadi
0537     img    = spm_select(1,'image','Select anatomical image.');
0538 else
0539     img = handles.aimg;
0540 end
0541 
0542 % Show anatomical image
0543 % -------------------------------------------------------------------------
0544 rotate3d off
0545 st.fig = handles.figure1;
0546 handle = spm_orthviews('Image', img, [0.5295 0.0859 0.4196 0.4196]);
0547 cmap   = get(gcf,'Colormap');
0548 if size(cmap,1)~=128
0549       spm_figure('Colormap','gray')
0550 end
0551 
0552 handles.aimgh   = handle;
0553 handles.aimg    = img;
0554 handles.img     = 1;
0555 handles.noloadi = 1;
0556 
0557 % Show file name
0558 % -------------------------------------------------------------------------
0559 set(handles.loadanatomical,'String',handles.aimg);
0560 
0561 guidata(hObject, handles);
0562 
0563 
0564 % --- Executes on selection change in foldmenu.
0565 function foldmenu_Callback(hObject, eventdata, handles)
0566 % hObject    handle to foldmenu (see GCBO)
0567 % eventdata  reserved - to be defined in a future version of MATLAB
0568 % handles    structure with handles and user data (see GUIDATA)
0569 
0570 % Hints: contents = cellstr(get(hObject,'String')) returns foldmenu contents as cell array
0571 %        contents{get(hObject,'Value')} returns selected item from foldmenu
0572 
0573 % Change weight map
0574 % -------------------------------------------------------------------------
0575 if ~handles.model_button
0576     if isfield(handles,'vols')
0577         handles.noloadw = 1;
0578         weightbutton_Callback(hObject, eventdata, handles);
0579     end
0580 end
0581 
0582 % Change plot
0583 % -------------------------------------------------------------------------
0584 if isfield(handles,'plot')
0585    plotmenu_Callback(hObject, eventdata, handles); 
0586 end
0587 
0588 % Change stats
0589 % -------------------------------------------------------------------------
0590 if isfield(handles,'stats')
0591     statsbutton_Callback(hObject, eventdata, handles);
0592 end
0593 
0594 % --- Executes during object creation, after setting all properties.
0595 function foldmenu_CreateFcn(hObject, eventdata, handles)
0596 % hObject    handle to foldmenu (see GCBO)
0597 % eventdata  reserved - to be defined in a future version of MATLAB
0598 % handles    empty - handles not created until after all CreateFcns called
0599 
0600 % Hint: popupmenu controls usually have a white background on Windows.
0601 %       See ISPC and COMPUTER.
0602 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0603     set(hObject,'BackgroundColor','white');
0604 end
0605 
0606 
0607 % --- Executes on selection change in plotmenu.
0608 function plotmenu_Callback(hObject, eventdata, handles)
0609 % hObject    handle to plotmenu (see GCBO)
0610 % eventdata  reserved - to be defined in a future version of MATLAB
0611 % handles    structure with handles and user data (see GUIDATA)
0612 
0613 % Hints: contents = cellstr(get(hObject,'String')) returns plotmenu contents as cell array
0614 %        contents{get(hObject,'Value')} returns selected item from plotmenu
0615 
0616 plotm         = get(handles.plotmenu,'Value');
0617 plotchosen    = num2str(plotm);
0618 fold          = get(handles.foldmenu,'Value');
0619 model         = get(handles.classmenu,'Value');
0620 mi            = handles.mi;
0621 model         = mi(model);
0622 PRT           = handles.PRT;
0623 handles.plot  = 1;
0624 nms           = 7;
0625 isyc1         = 0;
0626 isyc2         = 0;
0627 c1            = 0;
0628 c2            = 0;
0629 rotate3d off
0630 
0631 if strcmp(PRT.model(model).input.type,'classification')
0632     mclass        = length(handles.PRT.model(model).output.stats.c_acc);
0633     if mclass == 2
0634         
0635         % All folds
0636         % -----------------------------------------------------------------
0637         classNames{1} = handles.PRT.model(model).input.class(1).class_name;
0638         classNames{2} = handles.PRT.model(model).input.class(2).class_name;
0639         myColours     = {'k','r'};
0640         
0641     else
0642      
0643         multiplot  = 4;
0644         plotchosen = num2str(multiplot(plotm));
0645         
0646     end
0647     
0648     if fold == 1
0649         fVals   = [];
0650         targets = [];
0651         
0652         for f = 1:handles.nfold,
0653             targets = [targets;handles.PRT.model(model).output.fold(f).targets];
0654             if isfield(handles.PRT.model(model).output.fold(f),'func_val')
0655                 fVvals_exist = 1;
0656                 fVals  = [fVals;handles.PRT.model(model).output.fold(f).func_val];
0657             else
0658                 fVvals_exist = 0;
0659                 fVals  = [fVals;...
0660                     handles.PRT.model(model).output.fold(f).predictions];
0661             end
0662         end
0663         targpos = targets == 1;
0664         
0665     else
0666         % if folds wise
0667         targets = handles.PRT.model(model).output.fold(fold-1).targets;
0668         targpos = targets == 1;
0669         if isfield(handles.PRT.model(model).output.fold(fold-1),'func_val')
0670             fVals  = handles.PRT.model(model).output.fold(fold-1).func_val;
0671             fVvals_exist = 1;
0672         else
0673             fVvals_exist = 0;
0674             fVals  = handles.PRT.model(model).output.fold(fold-1).predictions;
0675         end
0676     end
0677     
0678     % Plot
0679     % ---------------------------------------------------------------------
0680     switch plotchosen
0681         
0682         % Predictions
0683         % -----------------------------------------------------------------
0684         case '1'
0685             cla(handles.axes5);
0686             rotate3d off
0687             colorbar('peer',handles.axes5,'off')
0688             set(handles.axes5,'Color',[1,1,1])
0689             % predictions
0690             if fVvals_exist
0691                 if fold == 1
0692                     foldlabels = 1:handles.nfold;
0693                     for f = 2:handles.nfold+1
0694                         targets = handles.PRT.model(model).output.fold(f-1).targets;
0695                         targpos = targets == 1;
0696                         fVals   = handles.PRT.model(model).output.fold(f-1).func_val;
0697                         func_valsc1 = fVals(targpos);
0698                         func_valsc2 = fVals(~targpos);
0699                         yc1 = (f-1)*ones(length(func_valsc1),1);
0700                         yc2 = (f-1)*ones(length(func_valsc2),1);
0701                         if f==2
0702                             maxfv = max(abs([func_valsc1;func_valsc2]));
0703                         else
0704                             maxtmp = max(abs([func_valsc1;func_valsc2]));
0705                             if maxfv < maxtmp, maxfv = maxtmp; end
0706                         end
0707                         pl1 = plot(handles.axes5,func_valsc1,yc1,'kx','MarkerSize',nms);
0708                         hold(handles.axes5,'on');
0709                         if ~isempty(yc1), isyc1 = 1; plot1 = pl1; end
0710                         pl2 = plot(handles.axes5,func_valsc2,yc2,'ro','MarkerSize',nms);
0711                         hold(handles.axes5,'on');
0712                         if ~isempty(yc2), isyc2 = 1; plot2 = pl2; end
0713                     end
0714                 else
0715                     foldlabels  = fold-1;
0716                     func_valsc1 = fVals(targpos);
0717                     func_valsc2 = fVals(~targpos);
0718                     yc1 = (fold-1)*ones(length(func_valsc1),1);
0719                     yc2 = (fold-1)*ones(length(func_valsc2),1);
0720                     maxfv = max(abs([func_valsc1;func_valsc2]));
0721                     pl1 = plot(handles.axes5,func_valsc1,yc1,'kx','MarkerSize',nms);
0722                     hold(handles.axes5,'on');
0723                     if ~isempty(yc1), isyc1 = 1; plot1 = pl1; end
0724                     pl2 = plot(handles.axes5,func_valsc2,yc2,'ro','MarkerSize',nms);
0725                     hold(handles.axes5,'on');
0726                     if ~isempty(yc2), isyc2 = 1; plot2 = pl2; end
0727                 end
0728                 % Change the x axis for gaussian process - change in
0729                 % the future
0730                 y = [0:handles.nfold+1]';
0731                 if strcmp(PRT.model(model).input.machine.function,'prt_machine_gpml');
0732                     x = 0.5*ones(handles.nfold+2,1);
0733                     plot(handles.axes5,x,y,'--','Color',[1 1 1]*.6);
0734                     xlim(handles.axes5,[0 1]);
0735                 else
0736                     x = zeros(handles.nfold+2,1);
0737                     plot(handles.axes5,x,y,'--','Color',[1 1 1]*.6);
0738                     xlim(handles.axes5,[-maxfv-0.5 maxfv+0.5]);
0739                 end
0740                 ylim(handles.axes5,[0 handles.nfold+1.3]);
0741                 xlabel(handles.axes5,'function value','FontWeight','bold');
0742                 h=ylabel(handles.axes5,'fold','FontWeight','bold');
0743                 set(h,'Rotation',90)
0744                 if isyc1 && isyc2
0745                     legend([plot1,plot2],classNames,'Color',[1,1,1]);
0746                 else
0747                     if isyc1
0748                         legend(plot1,classNames{1},'Color',[1,1,1]);
0749                     else
0750                         legend(plot2,classNames{2},'Color',[1,1,1]);
0751                     end
0752                 end
0753                 set(handles.axes5,'YTick',foldlabels)
0754                 hold(handles.axes5,'off');
0755                 set(handles.axes5,'Color',[1,1,1],'Visible','on')
0756 %                 axis normal
0757 %                 axis xy
0758                 title(handles.axes5,'')
0759             else
0760                 set(handles.axes5,'Color',[1,1,1])
0761                 beep
0762                 disp('No function values to display!')
0763             end
0764             
0765             % ROC / AUC
0766             % -------------------------------------------------------------
0767         case '2'
0768             % ROC curve
0769                 rotate3d off
0770                 cla(handles.axes5);
0771                 [y,idx] = sort(fVals);
0772                 targpos = targpos(idx);
0773                 
0774                 fp      = cumsum(single(targpos))/sum(single(targpos));
0775                 tp      = cumsum(single(~targpos))/sum(single(~targpos));
0776                 
0777                 tp      = [0 ; tp ; 1];
0778                 fp      = [0 ; fp ; 1];
0779                 
0780                 n       = size(tp, 1);
0781                 A       = sum((fp(2:n) - fp(1:n-1)).*(tp(2:n)+tp(1:n-1)))/2;
0782 %
0783 %                 axis xy
0784                 plot(handles.axes5,fp,tp,'--ks','LineWidth',1, 'MarkerEdgeColor','k',...
0785                     'MarkerFaceColor','k',...
0786                     'MarkerSize',2);
0787                 title(handles.axes5,sprintf('Receiver Operator Curve / Area Under Curve = %3.1f',A));
0788                 xlabel(handles.axes5,'False positives','FontWeight','bold')
0789                 ylabel(handles.axes5,'True positives','FontWeight','bold')
0790                 set(handles.axes5,'Color',[1,1,1])
0791                 
0792             
0793             % Histograms
0794             % -------------------------------------------------------------
0795         case '3'
0796                 cla(handles.axes5);
0797                 rotate3d off
0798 %                 axis xy
0799                 set(handles.axes5,'Color',[1,1,1])
0800                 % func_val distributions
0801                 if fVvals_exist
0802                     for cl=1:2
0803                         func_vals = fVals(targpos);
0804                         if cl == 2, func_vals=fVals(~targpos); end
0805                         if ~isempty(func_vals)
0806                             if cl==1, c1 = 1; else c2 = 1; end
0807                             if exist('ksdensity','file')==2
0808                                 [f,x] = ksdensity(func_vals,'width',[]);
0809                                 plot(handles.axes5,x,f,myColours{cl},'LineWidth',2);
0810                                 hold(handles.axes5,'on')
0811                             else
0812                                 % can't plot density, be happy with a histogram
0813                                 [myHist,myX]=hist(func_vals,100);
0814                                 bar(handles.axes5,myX,myHist,myColours{cl});
0815                                 hold(handles.axes5,'on')
0816                             end
0817                             if cl == 2, hold(handles.axes5,'off'); end
0818                         end
0819                     end
0820                     if c1 && c2
0821                     legend(handles.axes5,classNames{1},classNames{2});
0822                     else 
0823                         if c1
0824                             legend(handles.axes5,classNames{1});
0825                         else
0826                             legend(handles.axes5,classNames{2});
0827                         end
0828                     end
0829                       xlabel(handles.axes5,'function value','FontWeight','bold');      
0830                 else
0831                     % do nothing, no func_val available
0832                 end
0833             
0834             % Confusion matrix
0835             % -------------------------------------------------------------
0836         case '4'
0837             % confusion matrix
0838                 cla(handles.axes5);
0839                 if fold == 1
0840                     mconmat(:,:) = PRT.model(model).output.stats.con_mat;
0841                 else
0842                     mconmat(:,:) = PRT.model(model).output.fold(fold-1).stats.con_mat;
0843                 end
0844                 myH=bar3(handles.axes5,mconmat,'detached','w');
0845                 rotate3d on
0846                 if fold == 1
0847                     title(handles.axes5,sprintf('Confusion matrix: all folds'),'FontWeight','bold');
0848                 else
0849                     title(handles.axes5,sprintf('Confusion matrix: fold %d',fold-1),'FontWeight','bold');
0850                 end
0851                 xlabel(handles.axes5,'True','FontWeight','bold');
0852                 ylabel(handles.axes5,'Predicted','FontWeight','bold');
0853                 set(handles.axes5,'XTick',[1 2]);
0854                 set(handles.axes5,'XTickLabel',{'1','2'});
0855                 set(handles.axes5,'YTick',[1 2]);
0856                 set(handles.axes5,'YTickLabel',{'1','2'});
0857                 grid(handles.axes5,'on');
0858                 set(handles.axes5,'Color',[0.8 0.8 0.8]);
0859                 axis square; axis vis3d; axis tight;
0860                 % add values
0861                 mconmat
0862                 for foo_row=1:size(mconmat,1)
0863                     for foo_col=1:size(mconmat,2)
0864                         foo_zval=mconmat(foo_row,foo_col);
0865                         if foo_row==foo_col, foo_color='g'; else foo_color='r';end
0866                         text(foo_col,foo_row,foo_zval,num2str(foo_zval),...
0867                             'Color',foo_color);
0868                     end
0869                 end
0870     end
0871     
0872 else
0873     nfolds = length(PRT.model(model).output.fold);
0874     switch plotchosen
0875         case '1'
0876             cla(handles.axes5);
0877             preds = zeros(nfolds,2);
0878             for f = 1:nfolds
0879                 preds(f,1) = PRT.model(model).output.fold(f).targets;
0880                 preds(f,2) = PRT.model(model).output.fold(f).predictions;
0881                 scatter(handles.axes5,preds(:,2),preds(:,1),'filled');
0882                 xlabel(handles.axes5,'predictions','FontWeight','bold');
0883                 ylabel(handles.axes5,'targets','FontWeight','bold');
0884             end
0885         case '2'
0886             cla(handles.axes5);
0887             preds = zeros(nfolds,2);
0888             for f = 1:nfolds
0889                 preds(f,1) = PRT.model(model).output.fold(f).targets;
0890                 preds(f,2) = PRT.model(model).output.fold(f).predictions;
0891                 bar(handles.axes5,preds);
0892                 xlabel(handles.axes5,'subjects','FontWeight','bold');
0893                 ylabel(handles.axes5,'targets and predictions','FontWeight','bold');
0894             end
0895             legend(handles.axes5,{'Target', 'Predicted'});
0896     end
0897 end
0898 
0899 guidata(hObject, handles);
0900 
0901 
0902 % --- Executes during object creation, after setting all properties.
0903 function plotmenu_CreateFcn(hObject, eventdata, handles)
0904 % hObject    handle to plotmenu (see GCBO)
0905 % eventdata  reserved - to be defined in a future version of MATLAB
0906 % handles    empty - handles not created until after all CreateFcns called
0907 
0908 % Hint: popupmenu controls usually have a white background on Windows.
0909 %       See ISPC and COMPUTER.
0910 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0911     set(hObject,'BackgroundColor','white');
0912 end
0913 
0914 
0915 % --- Executes on selection change in classmenu.
0916 function classmenu_Callback(hObject, eventdata, handles)
0917 % hObject    handle to classmenu (see GCBO)
0918 % eventdata  reserved - to be defined in a future version of MATLAB
0919 % handles    structure with handles and user data (see GUIDATA)
0920 
0921 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0922 %        contents{get(hObject,'Value')} returns selected item from classmenu
0923 
0924 % Hints: contents = cellstr(get(hObject,'String')) returns classmenu contents as cell array
0925 %        contents{get(hObject,'Value')} returns selected item from classmenu
0926 
0927 % Get folds
0928 m  = get(handles.classmenu,'Value');
0929 mi = handles.mi;
0930 
0931 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
0932 folds{1}      = 'All folds / Average';
0933 for f = 1:handles.nfold
0934     folds{f+1} = num2str(f);
0935 end
0936 
0937 % Set plots menu for first model
0938 if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
0939     if length(handles.PRT.model(mi(m)).output.stats.c_acc) <= 2 ;
0940         plots = {'Predictions','ROC','Histogram','Confusion Matrix'};
0941     else
0942         plots = {'Confusion Matrix'};
0943     end
0944 else
0945     plots = {'Predictions (scatter)', 'Predictions (bar)'};
0946 end
0947 set(handles.plotmenu,'String',plots);
0948 
0949 % Set folds and call fold function to change plot/stats
0950 handles.folds = folds;
0951 set(handles.foldmenu,'String',handles.folds);
0952 handles.model_button = 1;
0953 
0954 foldmenu_Callback(hObject, eventdata, handles);
0955 
0956 % Update stats if they are being shown
0957 if isfield(handles, 'stats')
0958    statsbutton_Callback(hObject, eventdata, handles);
0959 end
0960 
0961 handles.model_button = 0;
0962 guidata(hObject, handles);
0963 
0964 
0965 % --- Executes during object creation, after setting all properties.
0966 function classmenu_CreateFcn(hObject, eventdata, handles)
0967 % hObject    handle to classmenu (see GCBO)
0968 % eventdata  reserved - to be defined in a future version of MATLAB
0969 % handles    empty - handles not created until after all CreateFcns called
0970 
0971 % Hint: popupmenu controls usually have a white background on Windows.
0972 %       See ISPC and COMPUTER.
0973 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0974     set(hObject,'BackgroundColor','white');
0975 end
0976 
0977 
0978 function repedit_Callback(hObject, eventdata, handles)
0979 % hObject    handle to repedit (see GCBO)
0980 % eventdata  reserved - to be defined in a future version of MATLAB
0981 % handles    structure with handles and user data (see GUIDATA)
0982 
0983 % Hints: get(hObject,'String') returns contents of repedit as text
0984 %        str2double(get(hObject,'String')) returns contents of repedit as a double
0985 
0986 
0987 % --- Executes during object creation, after setting all properties.
0988 function repedit_CreateFcn(hObject, eventdata, handles)
0989 % hObject    handle to repedit (see GCBO)
0990 % eventdata  reserved - to be defined in a future version of MATLAB
0991 % handles    empty - handles not created until after all CreateFcns called
0992 
0993 % Hint: edit controls usually have a white background on Windows.
0994 %       See ISPC and COMPUTER.
0995 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0996     set(hObject,'BackgroundColor','white');
0997 end
0998 
0999 
1000 % --- Executes on button press in permutbutton.
1001 function permutbutton_Callback(hObject, eventdata, handles)
1002 % hObject    handle to permutbutton (see GCBO)
1003 % eventdata  reserved - to be defined in a future version of MATLAB
1004 % handles    structure with handles and user data (see GUIDATA)
1005 
1006 m    = get(handles.classmenu,'Value');
1007 mi   = handles.mi;
1008 reps = str2num(get(handles.repedit,'String'));
1009 if  ~isempty(reps)
1010     if length(reps) ==1
1011         reps = round(reps);
1012         disp('Performing permutation test.........>>')
1013         prt_permutation(handles.PRT, reps, mi(m), handles.pathdir);
1014         % Load new PRT.mat
1015         PRTmat = fullfile(handles.pathdir,'PRT.mat');
1016         load(PRTmat);
1017         perm     = PRT.model(mi(m)).output.stats.permutation;
1018         stats.perm      = perm;
1019         stats.show_perm = 1;
1020         if strcmp(handles.PRT.model(mi(m)).input.type,'classification');
1021             stats.type = 'class';
1022         else
1023             stats.type = 'reg';
1024         end
1025         handles.stats = stats;
1026         
1027         % Update GUI
1028         guidata(hObject, handles);
1029        
1030         % Call stats button
1031         statsbutton_Callback(hObject, eventdata, handles);
1032     else
1033         beep;
1034         disp('Please enter only one value for the number of repetitions!');
1035     end
1036 else
1037     beep;
1038     disp('Repetitions should be a number!');
1039 end
1040 
1041 % --- Executes on button press in statsbutton.
1042 function statsbutton_Callback(hObject, eventdata, handles)
1043 % hObject    handle to statsbutton (see GCBO)
1044 % eventdata  reserved - to be defined in a future version of MATLAB
1045 % handles    structure with handles and user data (see GUIDATA)
1046 
1047 % Reads model and fold
1048 % -------------------------------------------------------------------------
1049 fold  = get(handles.foldmenu,'Value');
1050 mi    = handles.mi;
1051 m     = get(handles.classmenu,'Value');
1052 PRT   = handles.PRT;
1053 
1054 % Check if stats exist
1055 % -------------------------------------------------------------------------
1056 if isfield(handles, 'stats')
1057     stats = handles.stats;
1058 end
1059 
1060 % Read stats
1061 % -------------------------------------------------------------------------
1062 if strcmp(PRT.model(mi(m)).input.type,'classification')
1063     if fold == 1
1064         macc  = PRT.model(mi(m)).output.stats.acc;  % overall acc
1065         mbacc = PRT.model(mi(m)).output.stats.b_acc;
1066         mcacc = PRT.model(mi(m)).output.stats.c_acc;
1067         mcpv  = PRT.model(mi(m)).output.stats.c_pv;
1068         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
1069                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
1070             stats.show_perm=1;
1071             stats.perm.pvalue_b_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_b_acc;
1072             stats.perm.pvalue_c_acc=PRT.model(mi(m)).output.stats.permutation.pvalue_c_acc;
1073         end
1074     else
1075         macc  = PRT.model(mi(m)).output.fold(fold-1).stats.acc;
1076         mbacc = PRT.model(mi(m)).output.fold(fold-1).stats.b_acc;
1077         mcacc = PRT.model(mi(m)).output.fold(fold-1).stats.c_acc;
1078         mcpv  = PRT.model(mi(m)).output.fold(fold-1).stats.c_pv;
1079     end
1080 
1081     stats.macc  = macc;
1082     stats.mbacc = mbacc;
1083     stats.mcacc = mcacc;
1084     stats.mcpv  = mcpv;
1085     stats.type  = 'class';
1086 
1087     prt_ui_stats(stats,handles.prtdir);
1088     
1089 else
1090     if fold == 1
1091         corr  = PRT.model(mi(m)).output.stats.corr;  % overall correlation
1092         mse   = PRT.model(mi(m)).output.stats.mse;  % overall mse
1093         if isfield(PRT.model(mi(m)).output.stats,'permutation') && ...
1094                 ~isempty(PRT.model(mi(m)).output.stats.permutation)
1095             stats.show_perm=1;
1096             stats.perm.pval_corr=PRT.model(mi(m)).output.stats.permutation.pval_corr;
1097             stats.perm.pval_mse=PRT.model(mi(m)).output.stats.permutation.pval_mse;
1098         end
1099     else
1100         corr  = PRT.model(mi(m)).output.fold(fold-1).stats.corr;  % overall correlation
1101         mse   = PRT.model(mi(m)).output.fold(fold-1).stats.mse;  % overall mse
1102     end
1103 
1104     stats.corr = corr;
1105     stats.mse  = mse;
1106     stats.type = 'reg';
1107     
1108     prt_ui_stats(stats,handles.prtdir);
1109     
1110 end
1111     
1112 stats.show_perm = 0;
1113 handles.stats = stats;
1114 guidata(hObject, handles);
1115 
1116 % Show crosshairs position
1117 % -------------------------------------------------------------------------
1118 function showpos()
1119  
1120 global st
1121 
1122 mp13 = st.handles.mmedit;
1123 mp14 = st.handles.vxedit;
1124 tx20 = st.handles.posintensitytext;
1125 
1126 set(mp13,'String',sprintf('%.1f %.1f %.1f',spm_orthviews('Pos')));
1127 pos = spm_orthviews('Pos',1);
1128 set(mp14,'String',sprintf('%.1f %.1f %.1f',pos));
1129 set(tx20,'String',sprintf('%g',spm_sample_vol(st.V,pos(1),pos(2),pos(3),st.hld)));
1130 
1131 cmap = get(gcf,'Colormap');
1132 if size(cmap,1)~=128
1133       spm_figure('Colormap','gray-jet');
1134 end
1135 
1136 
1137 % --- Executes on button press in resetbutton.
1138 function resetbutton_Callback(hObject, eventdata, handles)
1139 % hObject    handle to resetbutton (see GCBO)
1140 % eventdata  reserved - to be defined in a future version of MATLAB
1141 % handles    structure with handles and user data (see GUIDATA)
1142 spm_orthviews('Reset');
1143 if isfield(handles, 'wmap'), handles = rmfield(handles, 'wmap'); end
1144 if isfield(handles, 'aimg'), handles = rmfield(handles,'aimg'); end
1145 handles.noloadw = 0;
1146 guidata(hObject, handles);
1147 
1148 
1149 % Save menu
1150 % -------------------------------------------------------------------------
1151 function savemenu_Callback(hObject, eventdata, handles)
1152 % hObject    handle to savemenu (see GCBO)
1153 % eventdata  reserved - to be defined in a future version of MATLAB
1154 % handles    structure with handles and user data (see GUIDATA)
1155 wd=cd;
1156 cd(handles.prtdir)
1157 [filename, pathname] = uiputfile( ...
1158 {'*.png','Portable Network Graphics (*.png)';...
1159  '*.jpeg','JPEG figure (*.jpeg)';...
1160  '*.tiff','Compressed TIFF figure (*.tiff)';... 
1161  '*.fig','Matlab figure (*.fig)';...
1162  '*.pdf','Color PDF file (*.pdf)';...
1163  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
1164  'Save figure as','.png');
1165 [a,b,c]=fileparts(filename);
1166 ext=['-d',c(2:end)];
1167 
1168 % Set the color of the different backgrounds and figure parameters to white
1169 cf=get(handles.figure1,'Color');
1170 set(handles.figure1,'Color',[1,1,1])
1171 aa=get(handles.figure1,'children');
1172 xc=[];
1173 for i=1:length(aa)
1174     if strcmpi(get(aa(i),'type'),'uipanel')
1175         try
1176             xc=[xc;get(aa(i),'BackgroundColor')];
1177             set(aa(i),'BackgroundColor',[1 1 1])
1178         end
1179         bb=get(aa(i),'children');
1180         if ~isempty(bb)
1181             for j=1:length(bb)
1182                 try
1183                     xc=[xc;get(bb(j),'BackgroundColor')];
1184                     set(bb(j),'BackgroundColor',[1 1 1])
1185                 end
1186                 if strcmpi(get(bb(j),'type'),'uipanel')
1187                     cc=get(bb(j),'children');
1188                     if ~isempty(cc)
1189                         for k=1:length(cc)
1190                             try
1191                                 xc=[xc;get(cc(k),'BackgroundColor')];
1192                                 set(cc(k),'BackgroundColor',[1 1 1])
1193                             end
1194                             if strcmpi(get(cc(k),'type'),'uipanel')
1195                                 dd=get(cc(k),'children');
1196                                 if ~isempty(dd)
1197                                     for l=1:length(dd)
1198                                         try
1199                                             xc=[xc;get(dd(l),'BackgroundColor')];
1200                                             set(dd(l),'BackgroundColor',[1 1 1])
1201                                         end
1202                                     end
1203                                 end
1204                             end
1205                         end
1206                     end
1207                 end
1208             end
1209         end
1210     end
1211     if ~strcmpi(get(aa(i),'type'),'uimenu')
1212         try
1213             xc=[xc;get(aa(i),'BackgroundColor')];
1214             set(aa(i),'BackgroundColor',[1 1 1])
1215         end
1216     end
1217 end
1218 
1219 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
1220 
1221 % Set the color of the different backgrounds and figure parameters to white
1222 set(handles.figure1,'Color',cf)
1223 scount=1;
1224 for i=1:length(aa)
1225     if strcmpi(get(aa(i),'type'),'uipanel')
1226         try
1227             set(aa(i),'BackgroundColor',xc(scount,:))
1228             scount=scount+1;
1229         end
1230         bb=get(aa(i),'children');
1231         if ~isempty(bb)
1232             for j=1:length(bb)
1233                 try
1234                     set(bb(j),'BackgroundColor',xc(scount,:))
1235                     scount=scount+1;
1236                 end
1237                 if strcmpi(get(bb(j),'type'),'uipanel')
1238                     cc=get(bb(j),'children');
1239                     if ~isempty(cc)
1240                         for k=1:length(cc)
1241                             try
1242                                 set(cc(k),'BackgroundColor',xc(scount,:))
1243                                 scount=scount+1;
1244                             end
1245                             if strcmpi(get(cc(k),'type'),'uipanel')
1246                                 dd=get(cc(k),'children');
1247                                 if ~isempty(dd)
1248                                     for l=1:length(dd)
1249                                         try
1250                                             set(dd(l),'BackgroundColor',xc(scount,:))
1251                                             scount=scount+1;
1252                                         end
1253                                     end
1254                                 end
1255                             end
1256                         end
1257                     end
1258                 end
1259             end
1260         end
1261     elseif ~strcmpi(get(aa(i),'type'),'uimenu')
1262         try
1263             set(aa(i),'BackgroundColor',xc(scount,:))
1264             scount=scount+1;
1265         end
1266     end
1267 end
1268 
1269 cd(wd)

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