Home > . > prt_data_review.m

prt_data_review

PURPOSE ^

PRT_DATA_REVIEW M-file for prt_data_review.fig

SYNOPSIS ^

function varargout = prt_data_review(varargin)

DESCRIPTION ^

 PRT_DATA_REVIEW M-file for prt_data_review.fig

 PRT_DATA_REVIEW, by itself, creates a new PRT_DATA_REVIEW or raises the 
 existing singleton*.

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

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

 PRT_DATA_REVIEW('Property','Value',...) creates a new PRT_DATA_REVIEW or 
 raises the existing singleton*.  Starting from the left, property value 
 pairs are applied to the GUI before prt_data_review_OpeningFcn gets 
 called.  An unrecognized property name or invalid value makes property 
 application stop.  All inputs are passed to prt_data_review_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_data_review(varargin)
0002 % PRT_DATA_REVIEW M-file for prt_data_review.fig
0003 %
0004 % PRT_DATA_REVIEW, by itself, creates a new PRT_DATA_REVIEW or raises the
0005 % existing singleton*.
0006 %
0007 % H = PRT_DATA_REVIEW returns the handle to a new PRT_DATA_REVIEW or the
0008 % handle to the existing singleton*.
0009 %
0010 % PRT_DATA_REVIEW('CALLBACK',hObject,eventData,handles,...) calls the local
0011 % function named CALLBACK in PRT_DATA_REVIEW.M with the given input arguments.
0012 %
0013 % PRT_DATA_REVIEW('Property','Value',...) creates a new PRT_DATA_REVIEW or
0014 % raises the existing singleton*.  Starting from the left, property value
0015 % pairs are applied to the GUI before prt_data_review_OpeningFcn gets
0016 % called.  An unrecognized property name or invalid value makes property
0017 % application stop.  All inputs are passed to prt_data_review_OpeningFcn
0018 % via varargin.
0019 %
0020 % *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0021 %  instance to run (singleton)".
0022 %
0023 % See also: GUIDE, GUIDATA, GUIHANDLES
0024 %_______________________________________________________________________
0025 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0026 
0027 % Written by J.Schrouff
0028 % $Id$
0029 
0030 % Edit the above text to modify the response to help prt_data_review
0031 
0032 % Last Modified by GUIDE v2.5 28-Mar-2012 13:11:14
0033 
0034 % Begin initialization code - DO NOT EDIT
0035 gui_Singleton = 1;
0036 gui_State = struct('gui_Name',       mfilename, ...
0037                    'gui_Singleton',  gui_Singleton, ...
0038                    'gui_OpeningFcn', @prt_data_review_OpeningFcn, ...
0039                    'gui_OutputFcn',  @prt_data_review_OutputFcn, ...
0040                    'gui_LayoutFcn',  [] , ...
0041                    'gui_Callback',   []);
0042 if nargin && ischar(varargin{1})
0043     gui_State.gui_Callback = str2func(varargin{1});
0044 end
0045 
0046 if nargout
0047     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0048 else
0049     gui_mainfcn(gui_State, varargin{:});
0050 end
0051 % End initialization code - DO NOT EDIT
0052 
0053 
0054 % --- Executes just before prt_data_review is made visible.
0055 function prt_data_review_OpeningFcn(hObject, eventdata, handles, varargin)
0056 % This function has no output args, see OutputFcn.
0057 % hObject    handle to figure
0058 % eventdata  reserved - to be defined in a future version of MATLAB
0059 % handles    structure with handles and user data (see GUIDATA)
0060 % varargin   command line arguments to prt_data_review (see VARARGIN)
0061 
0062 % Choose default command line output for prt_data_review
0063 handles.output = hObject;
0064 
0065 %if window already exists, just put it as the current figure
0066 Tag='DDrev';
0067 F = findall(allchild(0),'Flat','Tag',Tag);
0068 if length(F) > 1
0069     % Multiple Graphics windows - close all but most recent
0070     close(F(2:end))
0071     F = F(1);
0072     uistack(F,'top')
0073 elseif length(F)==1
0074     uistack(F,'top')
0075 else
0076     set(handles.figure1,'Tag',Tag)
0077     
0078 set(handles.figure1,'Name','PRoNTo :: Review data and design')
0079 %set size of the window, taking screen resolution and platform into account
0080 S0= spm('WinSize','0',1);   %-Screen size (of the current monitor)
0081 if ispc
0082     PF='MS Sans Serif';
0083 else
0084     PF= spm_platform('fonts');     %-Font names (for this platform)
0085     PF=PF.helvetica;
0086 end
0087 tmp  = [S0(3)/1280 (S0(4))/800];
0088 ratio=min(tmp)*[1 1 1 1];
0089 FS = 1 + 0.85*(min(ratio)-1);  %factor to scale the fonts
0090 x=get(handles.figure1,'Position');
0091 set(handles.figure1,'Position',ratio.*x)
0092 set(handles.figure1,'Resize','on')
0093 
0094 % Choose the color of the different backgrounds and figure parameters
0095 color=prt_get_defaults('color');
0096 set(handles.figure1,'Color',color.bg1)
0097 aa=get(handles.figure1,'children');
0098 for i=1:length(aa)
0099     if strcmpi(get(aa(i),'type'),'uipanel')
0100         set(aa(i),'BackgroundColor',color.bg2)
0101         bb=get(aa(i),'children');
0102         if ~isempty(bb)
0103             for j=1:length(bb)
0104                 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0105                         'radiobutton','checkbox'}))) 
0106                     set(bb(j),'BackgroundColor',color.bg2)
0107                 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0108                     set(bb(j),'BackgroundColor',color.fr)
0109                 end
0110                 set(bb(j),'FontUnits','pixel')
0111                 xf=get(bb(j),'FontSize');
0112                 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0113                     'FontUnits','normalized','Units','normalized')
0114             end
0115         end
0116     elseif strcmpi(get(aa(i),'type'),'uicontrol')
0117         if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0118                 'radiobutton','checkbox','listbox'})))
0119             set(aa(i),'BackgroundColor',color.bg1)
0120         elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0121             set(aa(i),'BackgroundColor',color.fr)
0122         end
0123     end
0124     if ~strcmpi(get(aa(i),'type'),'uimenu')
0125         set(aa(i),'FontUnits','pixel')
0126         xf=get(aa(i),'FontSize');
0127         if ispc
0128             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0129                 'FontUnits','normalized','Units','normalized')
0130         else
0131             set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0132                 'Units','normalized')
0133         end
0134     end
0135 end
0136 
0137 
0138 if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0139     %get number of groups and subjects/group
0140     PRT=varargin{2}{1};
0141     handles.prtdir=varargin{2}{2};
0142     ng=length(PRT.group);
0143     if ng==0
0144         beep
0145         disp('No group found at this point')
0146         disp('Please enter at least one completed group before reviewing')
0147         return
0148     end
0149     ns=zeros(ng,1);
0150     gname=cell(ng);
0151     handles.gname=gname;
0152     for i=1:ng
0153         if ~isfield(PRT.group(i),'subject')
0154             disp(['Group ' num2str(i) ' has no subject'])
0155             disp('Please enter at least one completed group before reviewing')
0156             return
0157         end
0158         ns(i)=length(PRT.group(i).subject);
0159         gname{i}=PRT.group(i).gr_name;
0160     end
0161     %get number of modalities and the index of those having design
0162     if ~isfield(PRT.group(1).subject(1),'modality')
0163         disp(['No modality has been defined.'])
0164         disp('Please enter at least one completed group before reviewing')
0165         return
0166     end
0167     nm=length(PRT.group(1).subject(1).modality);
0168     ind=[];
0169     list={};
0170     for i=1:nm
0171         % XXX should we check on the existence of 'design' field ?
0172         if isstruct(PRT.group(1).subject(1).modality(i).design)
0173             ind=[ind, i];
0174             list=[list, {PRT.group(1).subject(1).modality(i).mod_name}];
0175         end
0176     end   
0177 else
0178     beep
0179     disp('No data structure found at this point')
0180     disp('Please enter at least one completed group before reviewing')
0181     return
0182 end
0183 
0184 %Set the texts of the different fields
0185 set(handles.numgr,'String',num2str(ng))
0186 set(handles.nummod,'String',num2str(nm));
0187 if isempty(ind)
0188     set(handles.des,'String','No')
0189     set(handles.modlist,'String',{'None'})
0190     set(handles.modlist,'Visible','off')
0191     set(handles.condask,'Visible','off')
0192     set(handles.text10,'Visible','off')
0193     set(handles.axes2,'Visible','off')
0194     set(handles.axes3,'Visible','off')
0195     set(handles.numcond,'Visible','off')
0196     set(handles.pm1,'Visible','off')
0197     set(handles.pm2,'Visible','off')
0198     set(handles.intsc,'Visible','off')
0199     set(handles.befcor,'Visible','off')
0200     set(handles.aftcor,'Visible','off')
0201     set(handles.mbef,'Visible','off')
0202     set(handles.stdbef,'Visible','off')
0203     set(handles.maft,'Visible','off')
0204     set(handles.stdaft,'Visible','off')
0205     set(handles.hrfover_txt,'Visible','off')
0206     set(handles.hrfover_edit,'Visible','off')
0207     set(handles.txthrfdel,'Visible','off')
0208     set(handles.edit_hrfdel,'Visible','off')
0209     set(handles.uipanel4,'Visible','off')
0210     %Only displays the number of subjects per group when no design:
0211     x=get(handles.axes3,'Position');
0212     set(handles.axes1,'Position',[x(1),x(2)*1.5,x(3),3*x(4)]);
0213     x=get(handles.uipanel4,'Position');
0214     w=get(handles.uipanel3,'Position');
0215     set(handles.uipanel3,'Position',[x(1),x(2)*1.5,w(3),2.7*w(4)]);
0216     w=get(handles.figure1,'Position');
0217     set(handles.figure1,'Position',[w(1),w(2)+(2*w(4)/2.5),w(3),w(4)/2.5])
0218     w=get(handles.axes1,'Position');
0219     x=get(handles.text1,'Position');
0220     set(handles.text1,'Position',[x(1),(w(4)+x(4))*1.1,x(3),x(4)*3])
0221 else
0222     def=prt_get_defaults('datad');
0223     if isfield(PRT.group,'hrfoverlap')
0224         set(handles.hrfover_edit,'String',num2str(PRT.group(1).hrfoverlap))
0225     else
0226         set(handles.hrfover_edit,'String',num2str(def.hrfw))
0227     end
0228     if isfield(PRT.group,'hrfdelay')
0229         set(handles.edit_hrfdel,'String',num2str(PRT.group(1).hrfdelay))
0230     else
0231         set(handles.edit_hrfdel,'String',num2str(def.hrfd))
0232     end
0233     set(handles.des,'String','Yes')
0234     set(handles.modlist,'String',list)
0235     set(handles.modlist,'Value',1)
0236     handles.ind=ind;
0237     set(handles.figure1,'CurrentAxes',handles.axes2)
0238     % Update handles structure
0239     guidata(hObject, handles);
0240     prt_disp_conditions(PRT,ind(1),handles,hObject);   
0241 end
0242 
0243 %Display the bar graph for the number of subjects/group
0244 set(handles.figure1,'CurrentAxes',handles.axes1)
0245 x=2:2:2*ng;
0246 bar(handles.axes1,x,ns);
0247 ylim([0 max(ns)+1])
0248 xlim([1 max(x)+1])
0249 set(handles.axes1,'XTickLabel',gname)
0250 h=ylabel('Number of subjects');
0251 set(h,'Rotation',90)
0252 handles.PRT=PRT;
0253 end
0254 % Update handles structure
0255 guidata(hObject, handles);
0256 
0257 % UIWAIT makes prt_data_review 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_data_review_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 % Get default command line output from handles structure
0270 if isfield(handles,'output') && ~isempty(handles.output)
0271     varargout{1} = handles.output;
0272 else
0273     varargout{1}=[];
0274 end
0275 
0276 
0277 % --- Closing the figure
0278 function figure1_DeleteFcn(hObject,eventdata,handles)
0279 % hObject    handle to datastruct (see GCBO)
0280 % eventdata  reserved - to be defined in a future version of MATLAB
0281 % handles    structure with handles and user data (see GUIDATA)
0282 delete(handles.figure1);
0283 
0284 % --- Executes on selection change in modlist.
0285 function modlist_Callback(hObject, eventdata, handles)
0286 % hObject    handle to modlist (see GCBO)
0287 % eventdata  reserved - to be defined in a future version of MATLAB
0288 % handles    structure with handles and user data (see GUIDATA)
0289 
0290 % Hints: contents = get(hObject,'String') returns modlist contents as cell array
0291 %        contents{get(hObject,'Value')} returns selected item from modlist
0292 warning('off','MATLAB:hg:uicontrol:ParameterValuesMustBeValid')
0293 list=get(handles.modlist,'String');
0294 %handle particular bug with matlab(7.10.0499) and mac (OSX 10.6.4)
0295 if length(list)==1
0296     set(handles.modlist,'Value',1)
0297 end
0298 
0299 val=get(handles.modlist,'Value');
0300 set(handles.figure1,'CurrentAxes',handles.axes2)
0301 prt_disp_conditions(handles.PRT,handles.ind(val),handles,hObject);
0302 
0303 % Update handles structure
0304 guidata(hObject, handles);
0305 
0306 
0307 % --- Executes during object creation, after setting all properties.
0308 function modlist_CreateFcn(hObject, eventdata, handles)
0309 % hObject    handle to modlist (see GCBO)
0310 % eventdata  reserved - to be defined in a future version of MATLAB
0311 % handles    empty - handles not created until after all CreateFcns called
0312 
0313 % Hint: popupmenu controls usually have a white background on Windows.
0314 %       See ISPC and COMPUTER.
0315 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0316     set(hObject,'BackgroundColor','white');
0317 end
0318 
0319 function hrfover_edit_Callback(hObject, eventdata, handles)
0320 % hObject    handle to hrfover_edit (see GCBO)
0321 % eventdata  reserved - to be defined in a future version of MATLAB
0322 % handles    structure with handles and user data (see GUIDATA)
0323 
0324 % Hints: get(hObject,'String') returns contents of hrfover_edit as text
0325 %        str2double(get(hObject,'String')) returns contents of hrfover_edit as a double
0326 val=str2double(get(handles.hrfover_edit,'String'));
0327 del=str2double(get(handles.edit_hrfdel,'String'));
0328 list=get(handles.modlist,'String');
0329 cm=get(handles.modlist,'Value');
0330 PRT=handles.PRT;
0331 for i=1:length(PRT.group)
0332     for j=1:length(PRT.group(i).subject)
0333         m=find(strcmpi({PRT.masks(:).mod_name},list{cm}));
0334         dess=PRT.group(i).subject(j).modality(m).design;
0335         desn=prt_check_design(dess.conds,dess.TR,dess.unit,val,del);
0336 %         desn.covar=dess.covar;
0337         maxcond=max([desn.conds(:).scans]);
0338         lfiles=size(PRT.group(i).subject(j).modality(m).scans,1);
0339         if lfiles<maxcond
0340             sprintf('Design of subject %d, group %d, modality %d, exceeds time series \n',i,j,m)
0341             disp('Corresponding events were discarded')
0342             for l=1:length(desn.conds)
0343                 ovser=find(desn.conds(l).scans>lfiles);
0344                 inser=find(desn.conds(l).scans<lfiles);
0345                 desn.conds(l).discardedscans=[desn.conds(l).discardedscans, desn.conds(l).scans(ovser)];
0346                 desn.conds(l).scans=desn.conds(l).scans(inser);
0347                 desn.conds(l).blocks=desn.conds(l).blocks(inser);
0348             end
0349         end
0350         PRT.group(i).subject(j).modality(m).design=desn;
0351     end
0352 end
0353 for g = 1:length(PRT.group)
0354     PRT.group(g).hrfoverlap=val;
0355     PRT.group(g).hrfdelay=del;
0356 end
0357 save([handles.prtdir,filesep,'PRT.mat'],'PRT')
0358 disp('Design in PRT.mat updated')
0359 if isfield(PRT,'fs')
0360     beep
0361     disp('Feature sets found in the PRT')
0362     disp('These do not correspond to the updated onsets')
0363     disp('Please, compute them anew')
0364 end
0365 handles.PRT=PRT;
0366 % Update handles structure
0367 guidata(hObject, handles);
0368 set(handles.figure1,'CurrentAxes',handles.axes2)
0369 prt_disp_conditions(PRT,handles.ind(cm),handles,hObject)
0370 % Update handles structure
0371 guidata(hObject, handles);
0372 
0373 
0374 % --- Executes during object creation, after setting all properties.
0375 function hrfover_edit_CreateFcn(hObject, eventdata, handles)
0376 % hObject    handle to hrfover_edit (see GCBO)
0377 % eventdata  reserved - to be defined in a future version of MATLAB
0378 % handles    empty - handles not created until after all CreateFcns called
0379 
0380 % Hint: edit controls usually have a white background on Windows.
0381 %       See ISPC and COMPUTER.
0382 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0383     set(hObject,'BackgroundColor','white');
0384 end
0385 
0386 function edit_hrfdel_Callback(hObject, eventdata, handles)
0387 % hObject    handle to edit_hrfdel (see GCBO)
0388 % eventdata  reserved - to be defined in a future version of MATLAB
0389 % handles    structure with handles and user data (see GUIDATA)
0390 
0391 % Hints: get(hObject,'String') returns contents of edit_hrfdel as text
0392 %        str2double(get(hObject,'String')) returns contents of edit_hrfdel as a double
0393 del=str2double(get(handles.edit_hrfdel,'String'));
0394 val=str2double(get(handles.hrfover_edit,'String'));
0395 list=get(handles.modlist,'String');
0396 cm=get(handles.modlist,'Value');
0397 PRT=handles.PRT;
0398 for i=1:length(PRT.group)
0399     for j=1:length(PRT.group(i).subject)
0400         m=find(strcmpi({PRT.masks(:).mod_name},list{cm}));
0401         dess=PRT.group(i).subject(j).modality(m).design;
0402         desn=prt_check_design(dess.conds,dess.TR,dess.unit,val,del);
0403 %         desn.covar=dess.covar;
0404         maxcond=max([desn.conds(:).scans]);
0405         lfiles=size(PRT.group(i).subject(j).modality(m).scans,1);
0406         if lfiles<maxcond
0407             sprintf('Design of subject %d, group %d, modality %d, exceeds time series \n',i,j,m)
0408             disp('Corresponding events were discarded')
0409             for l=1:length(desn.conds)
0410                 ovser=find(desn.conds(l).scans>lfiles);
0411                 inser=find(desn.conds(l).scans<lfiles);
0412                 desn.conds(l).discardedscans=[desn.conds(l).discardedscans, desn.conds(l).scans(ovser)];
0413                 desn.conds(l).scans=desn.conds(l).scans(inser);
0414                 desn.conds(l).blocks=desn.conds(l).blocks(inser);
0415             end
0416         end
0417         PRT.group(i).subject(j).modality(m).design=desn;
0418     end
0419     PRT.group(i).hrfoverlap=val;
0420     PRT.group(i).hrfdelay=del;
0421 end
0422 save([handles.prtdir,filesep,'PRT.mat'],'PRT')
0423 disp('Design in PRT.mat updated')
0424 if isfield(PRT,'fs')
0425     beep
0426     disp('Feature sets found in the PRT')
0427     disp('These do not correspond to the updated onsets')
0428     disp('Please, compute them anew')
0429 end
0430 handles.PRT=PRT;
0431 % Update handles structure
0432 guidata(hObject, handles);
0433 set(handles.figure1,'CurrentAxes',handles.axes2)
0434 prt_disp_conditions(PRT,handles.ind(cm),handles,hObject)
0435 % Update handles structure
0436 guidata(hObject, handles);
0437 
0438 % --- Executes during object creation, after setting all properties.
0439 function edit_hrfdel_CreateFcn(hObject, eventdata, handles)
0440 % hObject    handle to edit_hrfdel (see GCBO)
0441 % eventdata  reserved - to be defined in a future version of MATLAB
0442 % handles    empty - handles not created until after all CreateFcns called
0443 
0444 % Hint: edit controls usually have a white background on Windows.
0445 %       See ISPC and COMPUTER.
0446 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0447     set(hObject,'BackgroundColor','white');
0448 end
0449 
0450 %--------------------------------------------------------------------------
0451 %---------------------- Subfunctions --------------------------------------
0452 %--------------------------------------------------------------------------
0453 function prt_disp_conditions(dat,ind,handles,hObject)
0454 
0455 
0456 mname=dat.group(1).subject(1).modality(ind).mod_name;
0457 nco=length(dat.group(1).subject(1).modality(ind).design.conds);
0458 set(handles.numcond,'String',num2str(nco));
0459 
0460 
0461 meantp=zeros(length(dat.group),nco);
0462 stdtp=zeros(length(dat.group),nco);
0463 meantpdisc=zeros(length(dat.group),nco);
0464 stdtpdisc=zeros(length(dat.group),nco);
0465 mbef=zeros(length(dat.group),1);
0466 stdbef=zeros(length(dat.group),1);
0467 maft=zeros(length(dat.group),1);
0468 stdaft=zeros(length(dat.group),1);
0469 for i=1:length(dat.group)
0470     nsc=zeros(length(dat.group(i).subject),nco);
0471     ndisc=zeros(length(dat.group(i).subject),nco);
0472     overlbe=zeros(length(dat.group(i).subject),1);
0473     overlaf=zeros(length(dat.group(i).subject),1);
0474     for j=1:length(dat.group(i).subject)
0475         indm=find(strcmpi({dat.group(i).subject(j).modality(:).mod_name},mname));
0476         ncond=length(dat.group(i).subject(j).modality(indm).design.conds);
0477         des=dat.group(i).subject(j).modality(indm).design;
0478         for k=1:ncond
0479             nsc(j,k)=length(des.conds(k).scans);
0480             ndisc(j,k)=length(des.conds(k).discardedscans)+length(des.conds(k).hrfdiscardedscans);
0481         end
0482         overlbe(j)=des.stats.meanovl;
0483         overlaf(j)=des.stats.mgoodovl;
0484     end
0485     if size(nsc,1)==1
0486         meantp(i,:)=nsc;
0487         stdtp(i,:)=zeros(size(nsc));
0488         meantpdisc(i,:)=ndisc;
0489         stdtpdisc(i,:)=zeros(size(ndisc));
0490         mbef(i)=overlbe;
0491         stdbef(i)=zeros(size(overlbe));
0492         maft(i)=overlaf;
0493         stdaft(i)=zeros(size(overlaf));
0494     else
0495         meantp(i,:)=mean(nsc);
0496         stdtp(i,:)=std(nsc);
0497         meantpdisc(i,:)=mean(ndisc);
0498         stdtpdisc(i,:)=std(ndisc);
0499         mbef(i)=mean(overlbe);
0500         stdbef(i)=std(overlbe);
0501         maft(i)=mean(overlaf);
0502         stdaft(i)=std(overlaf);
0503     end
0504 end
0505 
0506 %plot the results into bar graphs
0507 set(handles.figure1,'CurrentAxes',handles.axes2)
0508 cla
0509 ncond=size(meantp,2);
0510 vecty=2:2+ncond-1;
0511 y=vecty;
0512 for i=2:size(meantp,1)
0513     vecty=vecty+(ncond+1);
0514     y=[y;vecty];
0515 end
0516 x=mean(y,2);
0517 if length(x)==1
0518     x=2:2+ncond-1;
0519     xl=max(x)+1;
0520     meantp=[meantp; zeros(1,ncond)];
0521     stdtp=[stdtp; zeros(1,ncond)];
0522     meantpdisc=[meantpdisc; zeros(1,ncond)];
0523     stdtpdisc=[stdtpdisc; zeros(1,ncond)];
0524     vecty=2:2+ncond-1;
0525     y=vecty;
0526     for i=2:size(meantp,1)
0527         vecty=vecty+(ncond+1);
0528         y=[y;vecty];
0529     end
0530     x=mean(y,2);
0531 else
0532     xl=max(x)+ncond-1;
0533 end
0534 scmax=max(max(meantp(:)),max(meantpdisc(:)));
0535 bar(handles.axes2,x,meantp,0.9);
0536 hold on
0537 errorbar(handles.axes2,y,meantp,stdtp,'.k')
0538 ylim([0 1.1*scmax])
0539 xlim([1 xl])
0540 h=ylabel('Number of selected scans');
0541 set(h,'Rotation',90)
0542 set(handles.axes2,'XTickLabel',handles.gname)
0543 
0544 set(handles.figure1,'CurrentAxes',handles.axes3)
0545 cla
0546 bar(handles.axes3,x,meantpdisc,0.9);
0547 hold on
0548 errorbar(handles.axes3,y,meantpdisc,stdtpdisc,'.k')
0549 ylim([0 1.1*scmax])
0550 xlim([1 xl])
0551 h=ylabel('Number of discarded scans');
0552 set(h,'Rotation',90)
0553 set(handles.axes3,'XTickLabel',handles.gname)
0554 legend({dat.group(1).subject(1).modality(ind).design.conds(:).cond_name},...
0555     'Location','NorthEast')
0556 
0557 
0558 %set the overlaps before and after HRF correction
0559 set(handles.mbef,'String',num2str(mean(mbef)));
0560 set(handles.stdbef,'String',num2str(mean(stdbef)));
0561 set(handles.maft,'String',num2str(mean(maft)));
0562 set(handles.stdaft,'String',num2str(mean(stdaft)));
0563 
0564 % Update handles structure
0565 guidata(hObject, handles);
0566 
0567 
0568 % --------------------------------------------------------------------
0569 function savemenu_Callback(hObject, eventdata, handles)
0570 % hObject    handle to savemenu (see GCBO)
0571 % eventdata  reserved - to be defined in a future version of MATLAB
0572 % handles    structure with handles and user data (see GUIDATA)
0573 wd=cd;
0574 cd(handles.prtdir)
0575 [filename, pathname] = uiputfile( ...
0576 {'*.png','Portable Network Graphics (*.png)';...
0577  '*.jpeg','JPEG figure (*.jpeg)';...
0578  '*.tiff','Compressed TIFF figure (*.tiff)';... 
0579  '*.fig','Matlab figure (*.fig)';...
0580  '*.pdf','Color PDF file (*.pdf)';...
0581  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0582  'Save figure as','data_and_design.png');
0583 [a,b,c]=fileparts(filename);
0584 ext=['-d',c(2:end)];
0585 
0586 % Set the color of the different backgrounds and figure parameters to white
0587 cf=get(handles.figure1,'Color');
0588 set(handles.figure1,'Color',[1,1,1])
0589 aa=get(handles.figure1,'children');
0590 c=zeros(length(aa),3);
0591 cb=cell(length(aa));
0592 for i=1:length(aa)
0593     if strcmpi(get(aa(i),'type'),'uipanel')
0594         bb=get(aa(i),'children');
0595         cb{i}=zeros(length(bb),3);
0596         if ~isempty(bb)
0597             for j=1:length(bb)
0598                 try
0599                     cb{i}(j,:)=get(bb(j),'BackgroundColor');
0600                     set(bb(j),'BackgroundColor',[1 1 1]);
0601                 end
0602             end
0603         end
0604     end
0605     if ~strcmpi(get(aa(i),'type'),'uimenu')
0606         try
0607             c(i,:)=get(aa(i),'BackgroundColor');
0608             set(aa(i),'BackgroundColor',[1 1 1]);
0609         end
0610     end
0611 end
0612 
0613 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0614 
0615 % Set the color of the different backgrounds and figure parameters to white
0616 set(handles.figure1,'Color',cf)
0617 aa=get(handles.figure1,'children');
0618 for i=1:length(aa)
0619     if strcmpi(get(aa(i),'type'),'uipanel')
0620         bb=get(aa(i),'children');
0621         if ~isempty(bb)
0622             for j=1:length(bb)
0623                 set(bb(j),'BackgroundColor',cb{i}(j,:));
0624             end
0625         end
0626     end
0627     if ~strcmpi(get(aa(i),'type'),'uimenu')
0628         try
0629             set(aa(i),'BackgroundColor',c(i,:));
0630         end
0631     end
0632 end
0633 cd(wd)
0634

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