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: prt_data_review.m 535 2012-05-17 16:33:57Z mjrosa $
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 PRT.group.hrfoverlap=val;
0354 PRT.group.hrfdelay=del;
0355 save([handles.prtdir,filesep,'PRT.mat'],'PRT')
0356 disp('Design in PRT.mat updated')
0357 if isfield(PRT,'fs')
0358     beep
0359     disp('Feature sets found in the PRT')
0360     disp('These do not correspond to the updated onsets')
0361     disp('Please, compute them anew')
0362 end
0363 handles.PRT=PRT;
0364 % Update handles structure
0365 guidata(hObject, handles);
0366 set(handles.figure1,'CurrentAxes',handles.axes2)
0367 prt_disp_conditions(PRT,handles.ind(cm),handles,hObject)
0368 % Update handles structure
0369 guidata(hObject, handles);
0370 
0371 
0372 % --- Executes during object creation, after setting all properties.
0373 function hrfover_edit_CreateFcn(hObject, eventdata, handles)
0374 % hObject    handle to hrfover_edit (see GCBO)
0375 % eventdata  reserved - to be defined in a future version of MATLAB
0376 % handles    empty - handles not created until after all CreateFcns called
0377 
0378 % Hint: edit controls usually have a white background on Windows.
0379 %       See ISPC and COMPUTER.
0380 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0381     set(hObject,'BackgroundColor','white');
0382 end
0383 
0384 function edit_hrfdel_Callback(hObject, eventdata, handles)
0385 % hObject    handle to edit_hrfdel (see GCBO)
0386 % eventdata  reserved - to be defined in a future version of MATLAB
0387 % handles    structure with handles and user data (see GUIDATA)
0388 
0389 % Hints: get(hObject,'String') returns contents of edit_hrfdel as text
0390 %        str2double(get(hObject,'String')) returns contents of edit_hrfdel as a double
0391 del=str2double(get(handles.edit_hrfdel,'String'));
0392 val=str2double(get(handles.hrfover_edit,'String'));
0393 list=get(handles.modlist,'String');
0394 cm=get(handles.modlist,'Value');
0395 PRT=handles.PRT;
0396 for i=1:length(PRT.group)
0397     for j=1:length(PRT.group(i).subject)
0398         m=find(strcmpi({PRT.masks(:).mod_name},list{cm}));
0399         dess=PRT.group(i).subject(j).modality(m).design;
0400         desn=prt_check_design(dess.conds,dess.TR,dess.unit,val,del);
0401 %         desn.covar=dess.covar;
0402         maxcond=max([desn.conds(:).scans]);
0403         lfiles=size(PRT.group(i).subject(j).modality(m).scans,1);
0404         if lfiles<maxcond
0405             sprintf('Design of subject %d, group %d, modality %d, exceeds time series \n',i,j,m)
0406             disp('Corresponding events were discarded')
0407             for l=1:length(desn.conds)
0408                 ovser=find(desn.conds(l).scans>lfiles);
0409                 inser=find(desn.conds(l).scans<lfiles);
0410                 desn.conds(l).discardedscans=[desn.conds(l).discardedscans, desn.conds(l).scans(ovser)];
0411                 desn.conds(l).scans=desn.conds(l).scans(inser);
0412                 desn.conds(l).blocks=desn.conds(l).blocks(inser);
0413             end
0414         end
0415         PRT.group(i).subject(j).modality(m).design=desn;
0416     end
0417     PRT.group(i).hrfoverlap=val;
0418     PRT.group(i).hrfdelay=del;
0419 end
0420 save([handles.prtdir,filesep,'PRT.mat'],'PRT')
0421 disp('Design in PRT.mat updated')
0422 if isfield(PRT,'fs')
0423     beep
0424     disp('Feature sets found in the PRT')
0425     disp('These do not correspond to the updated onsets')
0426     disp('Please, compute them anew')
0427 end
0428 handles.PRT=PRT;
0429 % Update handles structure
0430 guidata(hObject, handles);
0431 set(handles.figure1,'CurrentAxes',handles.axes2)
0432 prt_disp_conditions(PRT,handles.ind(cm),handles,hObject)
0433 % Update handles structure
0434 guidata(hObject, handles);
0435 
0436 % --- Executes during object creation, after setting all properties.
0437 function edit_hrfdel_CreateFcn(hObject, eventdata, handles)
0438 % hObject    handle to edit_hrfdel (see GCBO)
0439 % eventdata  reserved - to be defined in a future version of MATLAB
0440 % handles    empty - handles not created until after all CreateFcns called
0441 
0442 % Hint: edit controls usually have a white background on Windows.
0443 %       See ISPC and COMPUTER.
0444 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0445     set(hObject,'BackgroundColor','white');
0446 end
0447 
0448 %--------------------------------------------------------------------------
0449 %---------------------- Subfunctions --------------------------------------
0450 %--------------------------------------------------------------------------
0451 function prt_disp_conditions(dat,ind,handles,hObject)
0452 
0453 
0454 mname=dat.group(1).subject(1).modality(ind).mod_name;
0455 nco=length(dat.group(1).subject(1).modality(ind).design.conds);
0456 set(handles.numcond,'String',num2str(nco));
0457 
0458 
0459 meantp=zeros(length(dat.group),nco);
0460 stdtp=zeros(length(dat.group),nco);
0461 meantpdisc=zeros(length(dat.group),nco);
0462 stdtpdisc=zeros(length(dat.group),nco);
0463 mbef=zeros(length(dat.group),1);
0464 stdbef=zeros(length(dat.group),1);
0465 maft=zeros(length(dat.group),1);
0466 stdaft=zeros(length(dat.group),1);
0467 for i=1:length(dat.group)
0468     nsc=zeros(length(dat.group(i).subject),nco);
0469     ndisc=zeros(length(dat.group(i).subject),nco);
0470     overlbe=zeros(length(dat.group(i).subject),1);
0471     overlaf=zeros(length(dat.group(i).subject),1);
0472     for j=1:length(dat.group(i).subject)
0473         indm=find(strcmpi({dat.group(i).subject(j).modality(:).mod_name},mname));
0474         ncond=length(dat.group(i).subject(j).modality(indm).design.conds);
0475         des=dat.group(i).subject(j).modality(indm).design;
0476         for k=1:ncond
0477             nsc(j,k)=length(des.conds(k).scans);
0478             ndisc(j,k)=length(des.conds(k).discardedscans)+length(des.conds(k).hrfdiscardedscans);
0479         end
0480         overlbe(j)=des.stats.meanovl;
0481         overlaf(j)=des.stats.mgoodovl;
0482     end
0483     if size(nsc,1)==1
0484         meantp(i,:)=nsc;
0485         stdtp(i,:)=zeros(size(nsc));
0486         meantpdisc(i,:)=ndisc;
0487         stdtpdisc(i,:)=zeros(size(ndisc));
0488         mbef(i)=overlbe;
0489         stdbef(i)=zeros(size(overlbe));
0490         maft(i)=overlaf;
0491         stdaft(i)=zeros(size(overlaf));
0492     else
0493         meantp(i,:)=mean(nsc);
0494         stdtp(i,:)=std(nsc);
0495         meantpdisc(i,:)=mean(ndisc);
0496         stdtpdisc(i,:)=std(ndisc);
0497         mbef(i)=mean(overlbe);
0498         stdbef(i)=std(overlbe);
0499         maft(i)=mean(overlaf);
0500         stdaft(i)=std(overlaf);
0501     end
0502 end
0503 
0504 %plot the results into bar graphs
0505 set(handles.figure1,'CurrentAxes',handles.axes2)
0506 cla
0507 ncond=size(meantp,2);
0508 vecty=2:2+ncond-1;
0509 y=vecty;
0510 for i=2:size(meantp,1)
0511     vecty=vecty+(ncond+1);
0512     y=[y;vecty];
0513 end
0514 x=mean(y,2);
0515 if length(x)==1
0516     x=2:2+ncond-1;
0517     xl=max(x)+1;
0518     meantp=[meantp; zeros(1,ncond)];
0519     stdtp=[stdtp; zeros(1,ncond)];
0520     meantpdisc=[meantpdisc; zeros(1,ncond)];
0521     stdtpdisc=[stdtpdisc; zeros(1,ncond)];
0522     vecty=2:2+ncond-1;
0523     y=vecty;
0524     for i=2:size(meantp,1)
0525         vecty=vecty+(ncond+1);
0526         y=[y;vecty];
0527     end
0528     x=mean(y,2);
0529 else
0530     xl=max(x)+ncond-1;
0531 end
0532 scmax=max(max(meantp(:)),max(meantpdisc(:)));
0533 bar(handles.axes2,x,meantp,0.9);
0534 hold on
0535 errorbar(handles.axes2,y,meantp,stdtp,'.k')
0536 ylim([0 1.1*scmax])
0537 xlim([1 xl])
0538 h=ylabel('Number of selected scans');
0539 set(h,'Rotation',90)
0540 set(handles.axes2,'XTickLabel',handles.gname)
0541 
0542 set(handles.figure1,'CurrentAxes',handles.axes3)
0543 cla
0544 bar(handles.axes3,x,meantpdisc,0.9);
0545 hold on
0546 errorbar(handles.axes3,y,meantpdisc,stdtpdisc,'.k')
0547 ylim([0 1.1*scmax])
0548 xlim([1 xl])
0549 h=ylabel('Number of discarded scans');
0550 set(h,'Rotation',90)
0551 set(handles.axes3,'XTickLabel',handles.gname)
0552 legend({dat.group(1).subject(1).modality(ind).design.conds(:).cond_name},...
0553     'Location','NorthEast')
0554 
0555 
0556 %set the overlaps before and after HRF correction
0557 set(handles.mbef,'String',num2str(mean(mbef)));
0558 set(handles.stdbef,'String',num2str(mean(stdbef)));
0559 set(handles.maft,'String',num2str(mean(maft)));
0560 set(handles.stdaft,'String',num2str(mean(stdaft)));
0561 
0562 % Update handles structure
0563 guidata(hObject, handles);
0564 
0565 
0566 % --------------------------------------------------------------------
0567 function savemenu_Callback(hObject, eventdata, handles)
0568 % hObject    handle to savemenu (see GCBO)
0569 % eventdata  reserved - to be defined in a future version of MATLAB
0570 % handles    structure with handles and user data (see GUIDATA)
0571 wd=cd;
0572 cd(handles.prtdir)
0573 [filename, pathname] = uiputfile( ...
0574 {'*.png','Portable Network Graphics (*.png)';...
0575  '*.jpeg','JPEG figure (*.jpeg)';...
0576  '*.tiff','Compressed TIFF figure (*.tiff)';... 
0577  '*.fig','Matlab figure (*.fig)';...
0578  '*.pdf','Color PDF file (*.pdf)';...
0579  '*.epsc',  'Encapsulated PostScript (*.eps)'},...
0580  'Save figure as','data_and_design.png');
0581 [a,b,c]=fileparts(filename);
0582 ext=['-d',c(2:end)];
0583 
0584 % Set the color of the different backgrounds and figure parameters to white
0585 cf=get(handles.figure1,'Color');
0586 set(handles.figure1,'Color',[1,1,1])
0587 aa=get(handles.figure1,'children');
0588 c=zeros(length(aa),3);
0589 cb=cell(length(aa));
0590 for i=1:length(aa)
0591     if strcmpi(get(aa(i),'type'),'uipanel')
0592         bb=get(aa(i),'children');
0593         cb{i}=zeros(length(bb),3);
0594         if ~isempty(bb)
0595             for j=1:length(bb)
0596                 try
0597                     cb{i}(j,:)=get(bb(j),'BackgroundColor');
0598                     set(bb(j),'BackgroundColor',[1 1 1]);
0599                 end
0600             end
0601         end
0602     end
0603     if ~strcmpi(get(aa(i),'type'),'uimenu')
0604         try
0605             c(i,:)=get(aa(i),'BackgroundColor');
0606             set(aa(i),'BackgroundColor',[1 1 1]);
0607         end
0608     end
0609 end
0610 
0611 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
0612 
0613 % Set the color of the different backgrounds and figure parameters to white
0614 set(handles.figure1,'Color',cf)
0615 aa=get(handles.figure1,'children');
0616 for i=1:length(aa)
0617     if strcmpi(get(aa(i),'type'),'uipanel')
0618         bb=get(aa(i),'children');
0619         if ~isempty(bb)
0620             for j=1:length(bb)
0621                 set(bb(j),'BackgroundColor',cb{i}(j,:));
0622             end
0623         end
0624     end
0625     if ~strcmpi(get(aa(i),'type'),'uimenu')
0626         try
0627             set(aa(i),'BackgroundColor',c(i,:));
0628         end
0629     end
0630 end
0631 cd(wd)
0632

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