0001 function varargout = prt_ui_results_ROI(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 gui_Singleton = 1;
0037 gui_State = struct('gui_Name', mfilename, ...
0038 'gui_Singleton', gui_Singleton, ...
0039 'gui_OpeningFcn', @prt_ui_results_ROI_OpeningFcn, ...
0040 'gui_OutputFcn', @prt_ui_results_ROI_OutputFcn, ...
0041 'gui_LayoutFcn', [] , ...
0042 'gui_Callback', []);
0043 if nargin && ischar(varargin{1})
0044 gui_State.gui_Callback = str2func(varargin{1});
0045 end
0046
0047 if nargout
0048 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0049 else
0050 gui_mainfcn(gui_State, varargin{:});
0051 end
0052
0053
0054
0055
0056 function prt_ui_results_ROI_OpeningFcn(hObject, eventdata, handles, varargin)
0057
0058
0059
0060
0061
0062
0063
0064 handles.output = hObject;
0065
0066
0067 Tag='ResROI';
0068 F = findall(allchild(0),'Flat','Tag',Tag);
0069 if length(F) > 1
0070
0071 close(F(2:end))
0072 F = F(1);
0073 uistack(F,'top')
0074 elseif length(F)==1
0075 uistack(F,'top')
0076 else
0077 set(handles.figure1,'Tag',Tag)
0078
0079 set(handles.figure1,'Name','PRoNTo :: ROI weights')
0080
0081 S0= spm('WinSize','0',1);
0082 if ispc
0083 PF ='MS Sans Serif';
0084 else
0085 PF = spm_platform('fonts');
0086 PF = PF.helvetica;
0087 end
0088 tmp = [S0(3)/1280 (S0(4))/800];
0089 ratio=min(tmp)*[1 1 1 1];
0090 FS = 1 + 0.85*(min(ratio)-1);
0091 x=get(handles.figure1,'Position');
0092 set(handles.figure1,'DefaultTextFontSize',FS*12,...
0093 'DefaultUicontrolFontSize',FS*12,...
0094 'DefaultTextFontName',PF,...
0095 'DefaultAxesFontName',PF,...
0096 'DefaultUicontrolFontName',PF)
0097 set(handles.figure1,'Position',ratio.*x)
0098 set(handles.figure1,'Resize','on')
0099
0100
0101 color=prt_get_defaults('color');
0102 set(handles.figure1,'Color',color.bg1)
0103 aa=get(handles.figure1,'children');
0104 for i=1:length(aa)
0105 if strcmpi(get(aa(i),'type'),'uipanel')
0106 set(aa(i),'BackgroundColor',color.bg2)
0107 bb=get(aa(i),'children');
0108 if ~isempty(bb)
0109 for j=1:length(bb)
0110 if ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0111 'radiobutton','checkbox'})))
0112 set(bb(j),'BackgroundColor',color.bg2)
0113 elseif ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0114 set(bb(j),'BackgroundColor',color.fr)
0115 end
0116 set(bb(j),'FontUnits','pixel')
0117 xf=get(bb(j),'FontSize');
0118 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0119 'FontUnits','normalized','Units','normalized')
0120 end
0121 end
0122 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0123 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0124 'radiobutton','checkbox','listbox'})))
0125 set(aa(i),'BackgroundColor',color.bg1)
0126 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0127 set(aa(i),'BackgroundColor',color.fr)
0128 end
0129 end
0130 set(aa(i),'FontUnits','pixel')
0131 xf=get(aa(i),'FontSize');
0132 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0133 'Units','normalized')
0134 end
0135
0136
0137 if ~isempty(varargin) && strcmpi(varargin{1},'UserData')
0138 LR=varargin{2}{1};
0139 pHN=varargin{2}{2};
0140 drwn=varargin{2}{3};
0141 erwn=varargin{2}{4};
0142 SN=varargin{2}{5};
0143 P_oth=varargin{2}{6};
0144 oth_w=varargin{2}{7};
0145 else
0146 f=spm_select(1,'.mat','Select .mat created from atlas weights');
0147 if ~isempty(f)
0148 load(f);
0149 try
0150 pHN=NW_roi;
0151 catch
0152 error('PRoNTo:prt_ui_results_ROI:Nodata',...
0153 'No ROI names or weight values found')
0154 end
0155 else
0156 error('PRoNTo:prt_ui_results_ROI:Nomat',...
0157 'No file selected')
0158 end
0159
0160 end
0161 szn=length(LR);
0162 dat=cell(szn,4);
0163 for i=1:szn
0164 dat{i,1}=LR{i};
0165 dat{i,2}=pHN(i,end);
0166 dat{i,3}=erwn(i);
0167 dat{i,4}=SN(i,end);
0168 end
0169 handles.LR=LR;
0170 handles.pHN=pHN;
0171 handles.SN=SN;
0172 handles.rwn=erwn;
0173 handles.dat=dat;
0174 set(handles.ROItable,'Data',dat);
0175 set(handles.ROItable,'ColumnName',{'ROI Name','NW_roi (in %)',...
0176 'Ranking','Pos weights (in %)'});
0177 set(handles.ROItable,'ColumnEditable',[false,false,false,false]);
0178 set(handles.ROItable,'ColumnWidth',{130,80,80,80});
0179 set(handles.ROItable,'ColumnFormat',{'char','numeric',...
0180 'numeric','numeric'});
0181
0182
0183 handles.P_oth=P_oth;
0184 handles.oth_w=oth_w;
0185 set(handles.vol_oth,'String',num2str(P_oth*100))
0186 set(handles.w_oth,'String',num2str(oth_w))
0187
0188
0189 handles.nfolds=size(pHN,2)-1;
0190 list=get(handles.foldp,'String');
0191 for ii=1:handles.nfolds
0192 list=[list,{['Fold ',num2str(ii)]}];
0193 end
0194 set(handles.foldp,'String',list)
0195 set(handles.foldp,'Value',1)
0196
0197
0198 set(handles.figure1, 'Currentaxes',handles.axes1)
0199 H1 = bar(1:size(dat,1),pHN(:,end));
0200 set(H1,'BarWidth',0.8)
0201 set(gca,'xlim',[0 size(dat,1)+1])
0202 title('Histogram of normalized weights per region','FontWeight','bold')
0203 set(gca,'XTickLabel',{''})
0204 set(gca,'XTick',0)
0205 legend('NW_{roi}','Location','NorthEast')
0206
0207
0208 set(handles.figure1, 'Currentaxes',handles.axes2)
0209 h=bar(handles.axes2,drwn');
0210 set(get(handles.axes2,'Title'),'String','Ranking distance to average across folds',...
0211 'Fontweight','bold')
0212 xlabel(handles.axes2,'Folds','Fontweight','bold')
0213 set(handles.axes2,'Xtick',1:handles.nfolds)
0214 set(handles.axes2,'XTickLabel',{''})
0215 end
0216
0217 guidata(hObject, handles);
0218
0219
0220
0221 function varargout = prt_ui_results_ROI_OutputFcn(hObject, eventdata, handles)
0222
0223
0224
0225
0226
0227 varargout{1} = handles.output;
0228
0229
0230
0231
0232 function ROItable_CellEditCallback(hObject, eventdata, handles)
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 guidata(hObject, handles);
0244
0245
0246 function foldp_Callback(hObject, eventdata, handles)
0247
0248
0249
0250
0251
0252
0253 v=get(handles.foldp,'Value');
0254 if v==0 || isempty(v)
0255 v=1;
0256 end
0257
0258 szn=length(handles.LR);
0259 dat=cell(szn,4);
0260 for i=1:szn
0261 dat{i,1}=handles.LR{i};
0262 if v==1
0263 dat{i,2}=handles.pHN(i,end);
0264 dat{i,4}=handles.SN(i,end);
0265 else
0266 dat{i,2}=handles.pHN(i,v-1);
0267 dat{i,4}=handles.SN(i,v-1);
0268 end
0269 dat{i,3}=handles.rwn(i);
0270 end
0271 set(handles.ROItable,'Data',dat)
0272
0273
0274 set(handles.figure1, 'Currentaxes',handles.axes1)
0275 H1 = bar(1:size(dat,1),[dat{:,2}]);
0276 set(H1,'BarWidth',0.8)
0277 set(gca,'xlim',[0 size(dat,1)+1])
0278 title('Histogram of normalized weights per region','FontWeight','bold')
0279 set(gca,'XTickLabel',{''})
0280 set(gca,'XTick',0)
0281 legend('NW_{roi}','Location','NorthEast')
0282
0283
0284 guidata(hObject, handles);
0285
0286
0287 function foldp_CreateFcn(hObject, eventdata, handles)
0288
0289
0290
0291
0292
0293
0294 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0295 set(hObject,'BackgroundColor','white');
0296 end
0297
0298
0299
0300 function sortHN_Callback(hObject, eventdata, handles)
0301
0302
0303
0304 v=get(handles.foldp,'Value');
0305 if v==0 || isempty(v)
0306 v=1;
0307 end
0308 if v==1
0309 [d1,d2]=sort(handles.pHN(:,end),'descend');
0310 else
0311 [d1,d2]=sort(handles.pHN(:,v-1),'descend');
0312 end
0313 isn=find(isnan(handles.pHN(:,1)));
0314 d3=1:length(isn);
0315 d4=length(isn)+1:size(d1,1);
0316 ihn=[d2(d4,:);d2(d3,:)];
0317 szn=length(handles.LR);
0318 dat=cell(szn,4);
0319 for i=1:szn
0320 dat{i,1}=handles.LR{i};
0321 if v==1
0322 dat{i,2}=handles.pHN(i,end);
0323 dat{i,4}=handles.SN(i,end);
0324 else
0325 dat{i,2}=handles.pHN(i,v-1);
0326 dat{i,4}=handles.SN(i,v-1);
0327 end
0328 dat{i,3}=handles.rwn(i);
0329 end
0330 dat=dat(ihn,:);
0331 set(handles.ROItable,'Data',dat)
0332
0333
0334 set(handles.figure1, 'Currentaxes',handles.axes1)
0335 H1 = bar(1:size(dat,1),[dat{:,2}]);
0336 set(H1,'BarWidth',0.8)
0337 set(gca,'xlim',[0 size(dat,1)+1])
0338 title('Histogram of normalized weights per region','FontWeight','bold')
0339 set(gca,'XTickLabel',{''})
0340 set(gca,'XTick',0)
0341 legend('NW_{roi}','Location','NorthEast')
0342
0343
0344 guidata(hObject, handles);
0345
0346
0347
0348 function quitbutt_Callback(hObject, eventdata, handles)
0349
0350
0351
0352
0353 if isfield(handles,'figure1')
0354 delete(handles.figure1);
0355 end
0356
0357
0358
0359 function vol_oth_Callback(hObject, eventdata, handles)
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370 function vol_oth_CreateFcn(hObject, eventdata, handles)
0371
0372
0373
0374
0375
0376
0377 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0378 set(hObject,'BackgroundColor','white');
0379 end
0380
0381
0382
0383 function w_oth_Callback(hObject, eventdata, handles)
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393 function w_oth_CreateFcn(hObject, eventdata, handles)
0394
0395
0396
0397
0398
0399
0400 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0401 set(hObject,'BackgroundColor','white');
0402 end