0001 function varargout = prt_ui_disp_weights(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 gui_Singleton = 1;
0035 gui_State = struct('gui_Name', mfilename, ...
0036 'gui_Singleton', gui_Singleton, ...
0037 'gui_OpeningFcn', @prt_ui_disp_weights_OpeningFcn, ...
0038 'gui_OutputFcn', @prt_ui_disp_weights_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
0051
0052
0053
0054 function prt_ui_disp_weights_OpeningFcn(hObject, eventdata, handles, varargin)
0055
0056
0057
0058
0059
0060
0061
0062 Tag='WeightResults';
0063 F = findall(allchild(0),'Flat','Tag',Tag);
0064 if length(F) > 1
0065
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 :: Model interpretation')
0074 set(handles.figure1,'MenuBar','figure','WindowStyle','normal');
0075
0076
0077
0078 S0= spm('WinSize','0',1);
0079 if ispc
0080 PF='MS Sans Serif';
0081 else
0082 PF= spm_platform('fonts');
0083 PF=PF.helvetica;
0084 end
0085 tmp = [S0(3)/1280 (S0(4))/800];
0086 ratio=min(tmp)*[1 1 1 1];
0087 FS = 1 + 0.85*(min(ratio)-1);
0088 x=get(handles.figure1,'Position');
0089 set(handles.figure1,'Position',ratio.*x)
0090 set(handles.figure1,'Resize','on')
0091
0092
0093 color=prt_get_defaults('color');
0094 set(handles.figure1,'Color',color.bg1)
0095 aa=get(handles.figure1,'children');
0096 for i=1:length(aa)
0097 if strcmpi(get(aa(i),'type'),'uipanel')
0098 set(aa(i),'BackgroundColor',color.bg2)
0099 bb=get(aa(i),'children');
0100 if ~isempty(bb)
0101 for j=1:length(bb)
0102 if strcmpi(get(bb(j),'type'),'uipanel')
0103 cc=get(bb(j),'children');
0104 set(bb(j),'BackgroundColor',color.bg2)
0105 for k=1:length(cc)
0106 if strcmpi(get(cc(k),'type'),'uipanel')
0107 dd=get(cc(k),'children');
0108 set(cc(k),'BackgroundColor',color.bg2)
0109 for l=1:length(dd)
0110 if strcmpi(get(dd(l),'type'),'uicontrol')
0111 if ~isempty(find(strcmpi(get(dd(l),'Style'),{'text',...
0112 'radiobutton','checkbox'})))
0113 set(dd(l),'BackgroundColor',color.bg2)
0114 elseif ~isempty(find(strcmpi(get(dd(l),'Style'),'pushbutton')))
0115 set(dd(l),'BackgroundColor',color.fr)
0116 end
0117 end
0118 set(dd(l),'FontUnits','pixel')
0119 xf=get(dd(l),'FontSize');
0120 if ispc
0121 set(dd(l),'FontSize',ceil(FS*xf),'FontName',PF,...
0122 'FontUnits','normalized','Units','normalized')
0123 else
0124 set(dd(l),'FontSize',ceil(FS*xf),'FontName',PF,...
0125 'Units','normalized')
0126 end
0127 end
0128 elseif strcmpi(get(cc(k),'type'),'uicontrol') && ...
0129 ~isempty(find(strcmpi(get(cc(k),'Style'),{'text',...
0130 'radiobutton','checkbox'})))
0131 set(cc(k),'BackgroundColor',color.bg2)
0132 elseif strcmpi(get(cc(k),'type'),'uicontrol')&& ...
0133 ~isempty(find(strcmpi(get(cc(k),'Style'),'pushbutton')))
0134 set(cc(k),'BackgroundColor',color.fr)
0135 end
0136 set(cc(k),'FontUnits','pixel')
0137 xf=get(cc(k),'FontSize');
0138 set(cc(k),'FontSize',ceil(FS*xf),'FontName',PF,...
0139 'Units','normalized')
0140 end
0141 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0142 ~isempty(find(strcmpi(get(bb(j),'Style'),{'text',...
0143 'radiobutton','checkbox'})))
0144 set(bb(j),'BackgroundColor',color.bg2)
0145 elseif strcmpi(get(bb(j),'type'),'uicontrol') && ...
0146 ~isempty(find(strcmpi(get(bb(j),'Style'),'pushbutton')))
0147 set(bb(j),'BackgroundColor',color.fr)
0148 end
0149 set(bb(j),'FontUnits','pixel')
0150 xf=get(bb(j),'FontSize');
0151 set(bb(j),'FontSize',ceil(FS*xf),'FontName',PF,...
0152 'Units','normalized')
0153 end
0154 end
0155 elseif strcmpi(get(aa(i),'type'),'uicontrol')
0156 if ~isempty(find(strcmpi(get(aa(i),'Style'),{'text',...
0157 'radiobutton','checkbox'})))
0158 set(aa(i),'BackgroundColor',color.bg1)
0159 elseif ~isempty(find(strcmpi(get(aa(i),'Style'),'pushbutton')))
0160 set(aa(i),'BackgroundColor',color.fr)
0161 end
0162 end
0163 if ~strcmpi(get(aa(i),'type'),'uimenu')
0164 set(aa(i),'FontUnits','pixel')
0165 xf=get(aa(i),'FontSize');
0166 set(aa(i),'FontSize',ceil(FS*xf),'FontName',PF,...
0167 'Units','normalized')
0168 end
0169 end
0170
0171
0172
0173
0174
0175 if ~isfield(handles,'notinit')
0176
0177
0178 PRT = spm_select(1,'mat','Select PRT.mat',[],pwd,'PRT.mat');
0179 if isempty(PRT)
0180 error('prt_ui_disp_weights:NoPRT','No PRT file selected')
0181 end
0182
0183 pathdir = regexprep(PRT,'PRT.mat', '');
0184 handles.pathdir = pathdir;
0185 handles.prtdir=fileparts(PRT);
0186 load(PRT);
0187
0188
0189 handles.PRT = PRT;
0190
0191
0192 handles.noloadw = 0;
0193
0194
0195 if ~isfield(PRT,'model')
0196 error('No models found in PRT.mat!')
0197 end
0198
0199
0200 nmodels = length(PRT.model);
0201 mi = [];
0202 nmi = 0;
0203 nmroi = 0;
0204 for m = 1:nmodels
0205 if isfield(PRT.model(m),'input') && ~isempty(PRT.model(m).input)
0206 if isfield(PRT.model(m),'output') && ~isempty(PRT.model(m).output)
0207 if isfield(PRT.model(m).output,'weight_img') && ~isempty(PRT.model(m).output.weight_img)
0208 nmi = nmi +1;
0209 model_name{nmi} = PRT.model(m).model_name;
0210 mi = [mi, m];
0211 if isfield(PRT.model(m).output,'weight_ROI') && ...
0212 ~isempty(PRT.model(m).output.weight_ROI)
0213 nmroi = nmroi+1;
0214 end
0215 else
0216 disp(sprintf('Weights not computed for model %s ! It will not be displayed',PRT.model(m).model_name));
0217 end
0218 else
0219 beep;
0220 disp(sprintf('Weights not computed for model %s ! It will not be displayed',PRT.model(m).model_name));
0221 end
0222 else
0223 beep;
0224 disp(sprintf('Model %s not properly specified! It will not be displayed',PRT.model(m).model_name));
0225 end
0226
0227 end
0228
0229
0230
0231 if nmi
0232 handles.mi = mi;
0233
0234
0235 handles.mnames = model_name;
0236 set(handles.classmenu,'String',handles.mnames);
0237
0238
0239 m = get(handles.classmenu,'Value');
0240 handles.nfold = length(PRT.model(mi(m)).output.fold);
0241 folds{1} = 'All folds / Average';
0242 for f = 1:handles.nfold
0243 folds{f+1} = num2str(f);
0244 end
0245 handles.folds = folds;
0246 set(handles.foldmenu,'String',handles.folds);
0247 set(handles.foldmenu,'Value',1);
0248
0249 list = handles.PRT.model(mi(m)).output.weight_img;
0250 if ~isempty(list)
0251 set(handles.imagemenu,'String',list)
0252 set(handles.imagemenu,'Value',1)
0253 else
0254 set(handles.imagemenu,'Enable','off')
0255 end
0256
0257
0258 end
0259
0260 handles.model_button = 0;
0261
0262
0263 set(handles.axes1, 'visible','off')
0264 set(handles.ROItable,'visible','off')
0265 handles.selectedcell = [];
0266 handles.labels=cell(nmodels,1);
0267 set(handles.butt_load_labels,'visible','off');
0268 set(handles.saveweight,'visible','off');
0269 set(handles.modtable,'Visible','off')
0270 set(handles.modtable,'Enable','off')
0271
0272 cla(handles.axes1);
0273 end
0274 end
0275 set(handles.disp_voxels,'Value',1)
0276 set(handles.disp_voxels,'Enable','off')
0277 set(handles.disp_regions,'Value',0)
0278 set(handles.disp_regions,'Enable','off')
0279
0280 handles.output = hObject;
0281
0282
0283 guidata(hObject, handles);
0284
0285
0286
0287
0288
0289
0290 function varargout = prt_ui_disp_weights_OutputFcn(hObject, eventdata, handles)
0291
0292
0293
0294
0295
0296
0297 varargout{1} = handles.output;
0298
0299
0300
0301 function originbutton_Callback(hObject, eventdata, handles)
0302
0303
0304
0305
0306
0307
0308 if isfield(handles,'img')
0309 spm_orthviews('Reposition',[0 0 0]);
0310 end
0311
0312 function mmedit_Callback(hObject, eventdata, handles)
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322 if isfield(handles,'img')
0323 mp = handles.mmedit;
0324 posmm = get(mp,'String');
0325 pos = sscanf(posmm, '%g %g %g');
0326 if length(pos)~=3
0327 pos = spm_orthviews('Pos');
0328 end
0329 spm_orthviews('Reposition',pos);
0330 end
0331
0332
0333 function mmedit_CreateFcn(hObject, eventdata, handles)
0334
0335
0336
0337
0338
0339
0340 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0341 set(hObject,'BackgroundColor','white');
0342 end
0343
0344
0345 function vxedit_Callback(hObject, eventdata, handles)
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355 if isfield(handles,'img')
0356 mp = handles.vxedit;
0357 posvx = get(mp,'String');
0358 pos = sscanf(posvx, '%g %g %g');
0359 if length(pos)~=3
0360 pos = spm_orthviews('pos',1);
0361 end
0362 tmp = handles.vols{1}.mat;
0363 pos = tmp(1:3,:)*[pos ; 1];
0364 spm_orthviews('Reposition',pos);
0365 end
0366
0367
0368
0369 function vxedit_CreateFcn(hObject, eventdata, handles)
0370
0371
0372
0373
0374
0375
0376 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0377 set(hObject,'BackgroundColor','white');
0378 end
0379
0380
0381
0382 function quitbutton_Callback(hObject, eventdata, handles)
0383
0384
0385
0386
0387
0388
0389 close(handles.figure1);
0390
0391
0392 function loadweight_Callback(hObject, eventdata, handles)
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402 function loadweight_CreateFcn(hObject, eventdata, handles)
0403
0404
0405
0406
0407
0408
0409 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0410 set(hObject,'BackgroundColor','white');
0411 end
0412
0413
0414
0415 function weightbutton_Callback(hObject, eventdata, handles)
0416
0417
0418
0419
0420 disp('Loading weights...>>')
0421
0422
0423 if ~isfield(handles,'wmap') || ~handles.noloadw
0424 wmap = spm_select(1,'image','Select weight map.');
0425
0426 if strcmp(wmap(end-1),',')
0427 wmap = wmap(1:end-2);
0428 end
0429 V = spm_vol(wmap);
0430 handles.vols{1} = V;
0431 handles.wmap = wmap;
0432
0433 end
0434
0435 spm_orthviews('Reset');
0436 gcfchil = get(gcf,'Children');
0437 for i=1:length(gcfchil)
0438 if strcmpi(get(gcfchil(i),'Type'),'axes')
0439 delete(gcfchil(i))
0440 end
0441 end
0442
0443
0444
0445 fold = get(handles.foldmenu,'Value')-1;
0446 Vfolds = handles.vols{1};
0447 V = Vfolds(1);
0448 M = V.mat;
0449 DIM = V.dim(1:3)';
0450 xdim = DIM(1); ydim = DIM(2); zdim = DIM(3);
0451 if length(V.private.dat.dim) < 4
0452 fdim = 1;
0453 else
0454 fdim = V.private.dat.dim(4);
0455 end
0456 [xords,yords] = ndgrid(1:xdim,1:ydim);
0457 xords = xords(:)'; yords = yords(:)';
0458 I = 1:xdim*ydim;
0459 zords_init = ones(1,xdim*ydim);
0460
0461 if ~isempty(handles.selectedcell)
0462 matroi = NaN * ones(xdim,ydim,zdim);
0463 idroi = handles.idfeat_roi{handles.sort_roi(handles.selectedcell(1))};
0464 matroi(idroi) = 1;
0465 handles.roimatdisp = matroi;
0466 else
0467 matroi = ones(xdim,ydim,zdim);
0468 handles.roimatdisp = matroi;
0469 end
0470
0471
0472
0473 xyz_above = [];
0474 z_above = [];
0475 if fold == 0,
0476 fold_coord = fdim*ones(1,xdim*ydim);
0477 V = Vfolds(fdim);
0478 else
0479 fold_coord = fold*ones(1,xdim*ydim);
0480 V = Vfolds(fold);
0481 end
0482
0483 for z = 1:zdim,
0484 zords = z*zords_init;
0485 xyz = [xords(I); yords(I); zords(I); fold_coord];
0486 zvals = spm_get_data(V,xyz);
0487 if isfield(handles,'roimatdisp') && ~isempty(handles.roimatdisp)
0488 indmask = sub2ind([xdim,ydim,zdim],xords(I)', yords(I)', zords(I)');
0489 mroi = handles.roimatdisp(indmask);
0490 zvals = zvals.*mroi';
0491 end
0492 above = find(~isnan(zvals));
0493 if length(above)==length(zvals)
0494 above = find(zvals~=0);
0495 end
0496 if ~isempty(above)
0497 xyz_above = [xyz_above,xyz(:,above)];
0498 z_above = [z_above,zvals(above)];
0499 end
0500 end
0501 XYZ = xyz_above(1:3,:);
0502 Z = z_above;
0503
0504
0505 xm = round(median(XYZ(1,:)));
0506 ym = round(median(XYZ(2,:)));
0507 zm = round(median(XYZ(3,:)));
0508
0509
0510
0511
0512
0513 rotate3d off
0514 global st
0515
0516 handles.notinit = 1;
0517 handles.img = 1;
0518
0519 st.handles = handles;
0520 st.fig = handles.figure1;
0521 st.V = V;
0522 st.callback = 'prt_ui_results(''showpos'')';
0523
0524
0525
0526 [BB vx] = spm_get_bbox(handles.wmap);
0527 xax = BB(1,1):abs(vx(1)):BB(2,1);
0528 yax = BB(1,2):abs(vx(2)):BB(2,2);
0529 zax = BB(1,3):abs(vx(3)):BB(2,3);
0530
0531 h = spm_orthviews('Image', handles.wmap,[0.0519 0.498 0.4182 0.3951]);
0532 handles.wimgh = h;
0533 spm_orthviews('AddContext', h);
0534 spm_orthviews('MaxBB');
0535 spm_orthviews('AddBlobs', h, XYZ, Z, M);
0536 cmap = get(gcf,'Colormap');
0537 if size(cmap,1)~=128
0538 spm_figure('Colormap','jet');
0539 end
0540 spm_orthviews('Reposition',[sign(vx(1))*xax(xm),sign(vx(2))*yax(ym),sign(vx(3))*zax(zm)])
0541
0542 spm_orthviews('Redraw');
0543
0544 if isfield(handles,'aimg')
0545 anatomicalbutton_Callback(hObject, eventdata, handles);
0546 end
0547
0548
0549
0550 prt_ui_results('showpos');
0551
0552 disp('Done');
0553
0554
0555 handles.noloadw = 1;
0556
0557
0558
0559 set(handles.loadweight,'String',handles.wmap);
0560 guidata(hObject, handles);
0561
0562 function loadanatomical_Callback(hObject, eventdata, handles)
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572 function loadanatomical_CreateFcn(hObject, eventdata, handles)
0573
0574
0575
0576
0577
0578
0579 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0580 set(hObject,'BackgroundColor','white');
0581 end
0582
0583
0584
0585 function anatomicalbutton_Callback(hObject, eventdata, handles)
0586
0587
0588
0589
0590
0591
0592 if ~isfield(handles,'wmap')
0593 spm_orthviews('Reset');
0594 end
0595 global st
0596 st.fig = handles.figure1;
0597 if ~isfield(handles,'aimg') || ~handles.noloadi
0598 img = spm_select(1,'image','Select anatomical image.');
0599 else
0600 img = handles.aimg;
0601 end
0602
0603
0604
0605 rotate3d off
0606 st.fig = handles.figure1;
0607 handle = spm_orthviews('Image', img, [0.5595 0.498 0.4182 0.3951]);
0608 cmap = get(gcf,'Colormap');
0609 if size(cmap,1)~=128
0610 spm_figure('Colormap','gray')
0611 end
0612
0613 handles.aimgh = handle;
0614 handles.aimg = img;
0615 handles.img = 1;
0616 handles.noloadi = 1;
0617
0618
0619
0620 set(handles.loadanatomical,'String',handles.aimg);
0621
0622 guidata(hObject, handles);
0623
0624
0625
0626 function foldmenu_Callback(hObject, eventdata, handles)
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636 if ~handles.model_button
0637 if isfield(handles,'vols')
0638 handles.noloadw = 1;
0639 handles.selectedcell = [];
0640 weightbutton_Callback(hObject, eventdata, handles);
0641 end
0642 end
0643
0644
0645 m = get(handles.classmenu,'Value');
0646 if m==0
0647 m=1;
0648 end
0649 mi = handles.mi;
0650 ffi = get(handles.foldmenu,'Value')-1;
0651 if ffi == -1
0652 ffi = 0;
0653 end
0654 if ffi==0
0655 ffi=length(get(handles.foldmenu,'String'));
0656 end
0657 if isfield(handles.PRT.model(mi(m)).output,'weight_ROI') &&...
0658 ~isempty(handles.PRT.model(mi(m)).output.weight_ROI)
0659 dat = handles.dattable;
0660 weights = handles.PRT.model(mi(m)).output.weight_ROI{handles.class}(:,ffi)*100;
0661 dat(:,2) = num2cell(weights);
0662 [vald,idwroi] = sort(weights,'descend');
0663 dat = dat(idwroi,:);
0664 set(handles.ROItable,'Data',dat);
0665 set(handles.ROItable,'visible','on');
0666 set(handles.butt_load_labels,'visible','on');
0667
0668
0669 set(handles.axes1,'visible','on')
0670 bar(handles.axes1,weights(idwroi));
0671 set(get(handles.axes1,'XLabel'),'FontWeight','demi')
0672 set(get(handles.axes1,'XLabel'),'String','ROI index')
0673 set(get(handles.axes1,'YLabel'),'String','ROI weight')
0674 set(get(handles.axes1,'YLabel'),'FontWeight','demi')
0675
0676 if ~isempty(handles.datmod)
0677 datmod = handles.datmod;
0678 wemod = zeros(length(handles.nmods),handles.nfold+1);
0679 for i=1:length(handles.nmods)
0680 wemod(i,:) = [handles.PRT.model(mi(m)).output.weight_MOD{i}];
0681 end
0682 datmod(:,2) = num2cell(wemod(:,ffi)*100);
0683 [vald,idwmod] = sort(wemod(:,ffi),'descend');
0684 datmod= datmod(idwmod,:);
0685 set(handles.modtable,'Data',datmod)
0686 set(handles.modtable,'Visible','on')
0687 end
0688 end
0689 guidata(hObject, handles);
0690
0691
0692
0693
0694
0695 function foldmenu_CreateFcn(hObject, eventdata, handles)
0696
0697
0698
0699
0700
0701
0702 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0703 set(hObject,'BackgroundColor','white');
0704 end
0705
0706
0707
0708 function classmenu_Callback(hObject, eventdata, handles)
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718 m = get(handles.classmenu,'Value');
0719 if m==0
0720 m=1;
0721 end
0722 mi = handles.mi;
0723
0724
0725 list = handles.PRT.model(mi(m)).output.weight_img;
0726 if ~isempty(list)
0727 set(handles.imagemenu,'String',list)
0728 else
0729 set(handles.imagemenu,'Enable','off')
0730 end
0731 set(handles.imagemenu,'Value',1);
0732 handles.class = 1;
0733
0734
0735
0736 in.fs_name = handles.PRT.model(mi(m)).input.fs(1).fs_name;
0737 fid = prt_init_fs(handles.PRT,in);
0738 handles.fid = fid;
0739 if ~isempty(strfind(handles.PRT.model(mi(m)).input.machine.function,'MKL')) && ...
0740 handles.PRT.fs(fid).multkernel
0741 nmod = length(handles.PRT.fs(fid).modality);
0742 mods = cell(nmod,1);
0743 for i=1:nmod
0744 mods{i} = handles.PRT.fs(fid).modality(i).mod_name;
0745 end
0746 handles.summed = 0;
0747 elseif ~isempty(strfind(handles.PRT.model(mi(m)).input.machine.function,'MKL')) && ...
0748 ~handles.PRT.fs(fid).multkernel
0749 mods{1} = handles.PRT.fs(fid).modality(1).mod_name;
0750 handles.summed = 0;
0751 else
0752 mods{1} = handles.PRT.fs(fid).modality(1).mod_name;
0753 handles.summed = 1;
0754 end
0755 handles.nmods = mods;
0756 guidata(hObject, handles);
0757 imagemenu_Callback(hObject,eventdata,handles)
0758 handles = guidata(hObject);
0759 guidata(hObject, handles);
0760
0761
0762
0763 function classmenu_CreateFcn(hObject, eventdata, handles)
0764
0765
0766
0767
0768
0769
0770 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0771 set(hObject,'BackgroundColor','white');
0772 end
0773
0774
0775 function imagemenu_Callback(hObject, eventdata, handles)
0776
0777
0778
0779
0780
0781
0782
0783 m = get(handles.classmenu,'Value');
0784 if m==0
0785 m=1;
0786 end
0787 mi = handles.mi;
0788 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
0789
0790
0791 folds{1} = 'All folds / Average';
0792 for f = 1:handles.nfold
0793 folds{f+1} = num2str(f);
0794 end
0795
0796
0797 handles.folds = folds;
0798 set(handles.foldmenu,'String',handles.folds);
0799
0800 disp_vox = get(handles.disp_voxels,'Value');
0801 set(handles.disp_voxels,'Enable','on')
0802
0803
0804 ffi = get(handles.foldmenu,'Value')-1;
0805 if ffi == -1
0806 ffi = 0;
0807 end
0808 if ffi==0
0809 ffi=length(get(handles.foldmenu,'String'));
0810 end
0811
0812
0813 handles.class = get(handles.imagemenu,'Value');
0814 if handles.class ==0
0815 handles.class = 1;
0816 end
0817
0818
0819
0820 nim = get(handles.imagemenu,'String');
0821 for i = 1:length(handles.nmods)
0822 if ~isempty(strfind(nim,char(handles.nmods{i})))
0823 mids = i;
0824 end
0825 end
0826
0827
0828
0829
0830
0831 flagmodMKL = 0;
0832
0833
0834 if isfield(handles.PRT.model(mi(m)).output,'weight_ROI') &&...
0835 ~isempty(handles.PRT.model(mi(m)).output.weight_ROI)
0836
0837 in = struct();
0838 in.fs_name = handles.PRT.model(mi(m)).input.fs(1).fs_name;
0839 fid = prt_init_fs(handles.PRT,in);
0840
0841 if handles.PRT.fs(fid).multkernel && ~handles.summed
0842 stm = length(handles.nmods);
0843 else
0844 stm =1;
0845 end
0846 if ~iscell(handles.PRT.fs(fid).atlas_name)
0847 handles.PRT.fs(fid).atlas_name = {handles.PRT.fs(fid).atlas_name};
0848 end
0849
0850 handles.num_roi = [];
0851
0852 for i = 1:stm
0853 if isfield(handles.PRT.fs(fid).modality(i),'num_ROI') && ~handles.summed
0854 num_roi = handles.PRT.fs(fid).modality(i).num_ROI;
0855 atl_name = handles.PRT.fs(fid).atlas_name{i};
0856 else
0857 num_roi = 1:size(handles.PRT.model(mi(m)).output.weight_ROI{handles.class},1);
0858 if isfield(handles.PRT.model(mi(m)).output,'weight_atlas') && ...
0859 ~isempty(handles.PRT.model(mi(m)).output.weight_atlas)
0860 atl_name = handles.PRT.model(mi(m)).output.weight_atlas{i} ;
0861 else
0862 atl_name = [];
0863 end
0864 end
0865 handles.num_roi(:,i) = num_roi;
0866
0867
0868
0869 if ~isempty(atl_name)
0870 [a,b]=fileparts(atl_name);
0871 try
0872 load(fullfile(a,['Labels_',b,'.mat']))
0873 try
0874 handles.labels{mi(m)}{i}=ROI_names;
0875 catch
0876 disp('No variable ROI_names found, generic names used')
0877 end
0878 catch
0879 disp('No file containing the names of the ROIs found, generic names used')
0880 end
0881 if ~isfield(handles,'labels') || ...
0882 isempty(handles.labels{mi(m)}) || ...
0883 isempty(handles.labels{mi(m)}{i})
0884 label=cell(length(num_roi),1);
0885 for j=1:length(num_roi)
0886 label{j} = ['ROI_',num2str(num_roi(j))];
0887 end
0888 else
0889 if isfield(handles.PRT.fs(fid),'igood_kerns') && ...
0890 length(handles.PRT.fs(fid).igood_kerns)==length(num_roi) &&...
0891 ~handles.summed
0892 label = handles.labels{mi(m)}{i}(handles.PRT.fs(fid).igood_kerns);
0893 handles.num_roi(:,i) = handles.PRT.fs(fid).igood_kerns;
0894 else
0895 try
0896 label = handles.labels{mi(m)}{i}(num_roi);
0897 catch
0898 if length(num_roi)==length(handles.labels{mi(m)}{i})
0899 label = handles.labels{mi(m)}{i}(num_roi);
0900 handles.num_roi(:,i) = num_roi;
0901 elseif length(num_roi)==length(handles.labels{mi(m)}{i})+1
0902 handles.labels{mi(m)}{i} = [{'others'};handles.labels{mi(m)}{i}];
0903 label = handles.labels{mi(m)}{i}(num_roi);
0904 handles.num_roi(:,i) = num_roi;
0905 else
0906 warning('prt_ui_disp_weights:LabelsDoNotCorrespondtoROI',...
0907 'Number of labels in .mat does not correspond to number of ROIs');
0908 label=cell(length(num_roi(:,i)),1);
0909 for j=1:length(num_roi(:,i))
0910 label{j} = ['ROI_',num2str(num_roi(j,i))];
0911 end
0912 end
0913 end
0914
0915 end
0916 end
0917 lc = {'ROI label','ROI weight (%)'};
0918 xlabel = 'Index in table';
0919 ylabel = 'Weight';
0920 set(handles.butt_load_labels,'Visible','on')
0921 set(handles.saveweight,'Visible','on')
0922 else
0923 label = cell(length(handles.PRT.fs(fid).modality),1);
0924 for j = 1:length(handles.PRT.fs(fid).modality)
0925 label{j} = char(handles.PRT.fs(fid).modality(j).mod_name);
0926 end
0927 lc = {'Modality','Mod. weight (%)'};
0928 xlabel = 'Index in table';
0929 ylabel = 'Weight';
0930 set(handles.butt_load_labels,'Visible','off')
0931 set(handles.saveweight,'Visible','off')
0932 end
0933 end
0934 dat(:,1) = label;
0935 weights = handles.PRT.model(mi(m)).output.weight_ROI{handles.class}(:,ffi)*100;
0936 dat(:,2) = num2cell(weights);
0937
0938
0939 if ~isempty(strfind(handles.PRT.model(mi(m)).input.machine.function,'MKL')) && ...
0940 handles.PRT.fs(fid).multkernelROI
0941 if isfield(handles.PRT.fs(fid).modality,'idfeat_img')&& ...
0942 ~isempty(handles.PRT.fs(fid).modality(mids).idfeat_img)
0943 lc = [lc,{'ROI size (vox)'}];
0944 for i=1:length(handles.PRT.fas)
0945 if strcmpi(handles.PRT.fs(fid).modality(mids).mod_name,...
0946 handles.PRT.fas(i).mod_name)
0947 mid = i;
0948 end
0949 end
0950 idfeat = handles.PRT.fas(mid).idfeat_img;
0951 if isempty(handles.PRT.fs(fid).modality(mids).idfeat_fas)
0952 idfeat_fas = 1:length(idfeat);
0953 else
0954 idfeat_fas = handles.PRT.fs(fid).modality(mids).idfeat_fas;
0955 end
0956 handles.idfeat_roi = cell(length(handles.PRT.fs(fid).modality(mids).idfeat_img),1);
0957 for i = 1:length(handles.PRT.fs(fid).modality(mids).idfeat_img)
0958 dat(i,3) = {length(handles.PRT.fs(fid).modality(mids).idfeat_img{i})};
0959 handles.idfeat_roi{i} = idfeat(idfeat_fas(handles.PRT.fs(fid).modality(mids).idfeat_img{i}));
0960 end
0961 end
0962 set(handles.disp_regions,'Enable','on')
0963 flagmodMKL = 0;
0964 elseif isfield(handles.PRT.model(mi(m)).output,'weight_idfeatroi') &&...
0965 ~isempty(handles.PRT.model(mi(m)).output.weight_idfeatroi)
0966 lc = [lc,{'ROI size (vox)'}];
0967 handles.idfeat_roi = cell(length(handles.PRT.model(mi(m)).output.weight_idfeatroi{handles.class}),1);
0968 for i = 1:length(handles.PRT.model(mi(m)).output.weight_idfeatroi{handles.class})
0969 dat(i,3) = {length(handles.PRT.model(mi(m)).output.weight_idfeatroi{handles.class}{i})};
0970 handles.idfeat_roi{i} = handles.PRT.model(mi(m)).output.weight_idfeatroi{handles.class}{i};
0971 end
0972 set(handles.disp_regions,'Enable','on')
0973 flagmodMKL = 0;
0974 else
0975 set(handles.disp_regions,'Enable','off')
0976 flagmodMKL = 1;
0977 end
0978
0979
0980 w_all = handles.PRT.model(mi(m)).output.weight_ROI{handles.class}(:,1:handles.nfold)*100;
0981
0982 mw = min(w_all);
0983 mxw = max(w_all);
0984 id0 = find(mw==mxw);
0985 id0 = id0(mw(id0)==0);
0986 id = 1:size(w_all,2);
0987 idtr = setdiff(id,id0);
0988 if isempty(idtr)
0989 erwn=NaN*ones(length(num_roi),1);
0990 else
0991 w_all = w_all(:,idtr);
0992
0993 [d1,d2]=sort(w_all,1,'descend');
0994 isn=find(isnan(w_all(:,1)));
0995 d3=1:length(isn);
0996 d4=length(isn)+1:size(d1,1);
0997 ihn=[d2(d4,:);d2(d3,:)];
0998 [d1,dwn]=sort(ihn);
0999 erwn=zeros(length(num_roi),1);
1000 for i=1:length(num_roi)
1001 for j=1:length(num_roi)
1002 tmp=length(find(dwn(i,1:end-1)==j));
1003 erwn(i)=erwn(i)+j*tmp;
1004 end
1005 end
1006 erwn=erwn/length(idtr);
1007 end
1008
1009 dat = [dat, num2cell(erwn)];
1010 lc = [lc,{'Exp. Ranking'}];
1011 handles.dattable = dat;
1012 [vald,idwroi] = sort(weights,'descend');
1013 handles.sort_roi= idwroi;
1014 else
1015
1016 set(handles.disp_regions,'Enable','off')
1017 end
1018
1019 if ~iscell(handles.PRT.model(mi(m)).output.weight_img)
1020 handles.PRT.model(mi(m)).output.weight_img={handles.PRT.model(mi(m)).output.weight_img};
1021 end
1022
1023
1024 if disp_vox
1025 fntl = handles.PRT.model(mi(m)).output.weight_img{handles.class};
1026 set(handles.disp_voxels,'Value',1)
1027 set(handles.disp_regions,'Value',0)
1028 elseif ~disp_vox && isfield(handles.PRT.model(mi(m)).output,'weight_ROI') &&...
1029 ~isempty(handles.PRT.model(mi(m)).output.weight_ROI{handles.class})
1030 fntl = ['ROI_',handles.PRT.model(mi(m)).output.weight_img{handles.class}];
1031 set(handles.disp_voxels,'Value',0)
1032 set(handles.disp_regions,'Value',1)
1033 else
1034 beep
1035 disp('Weights per region selected, but no ROI_ image found')
1036 disp('Displaying image of weights per voxels')
1037 fntl = handles.PRT.model(mi(m)).output.weight_img{handles.class};
1038 set(handles.disp_voxels,'Value',1)
1039 set(handles.disp_regions,'Value',0)
1040 end
1041
1042
1043 if exist([handles.prtdir,filesep,fntl,'.img'],'file') || ...
1044 exist([handles.prtdir,filesep,fntl],'file')
1045 [a,b] = fileparts(fntl);
1046 handles.wmap = [handles.prtdir,filesep,b,'.img'];
1047 V = spm_vol(handles.wmap);
1048 handles.vols{1} = V;
1049 handles.noloadw = 1;
1050 handles.model_button = 0;
1051 handles.selectedcell = [];
1052
1053 guidata(hObject, handles);
1054 weightbutton_Callback(hObject, eventdata, handles);
1055 end
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084 if isfield(handles.PRT.model(mi(m)).output,'weight_MOD') &&...
1085 ~isempty(handles.PRT.model(mi(m)).output.weight_MOD{handles.class}) && ...
1086 ~flagmodMKL
1087 datmod = cell(length(handles.nmods),3);
1088 datmod(:,1) = handles.nmods;
1089 wemod = zeros(length(handles.nmods),handles.nfold+1);
1090 for i=1:length(handles.nmods)
1091 wemod(i,:) = [handles.PRT.model(mi(m)).output.weight_MOD{i}];
1092 end
1093 datmod(:,2) = num2cell(wemod(:,ffi)*100);
1094
1095
1096 wem = wemod(:,1:handles.nfold);
1097 mw = min(wem);
1098 mxw = max(wem);
1099 id0 = find(mw==mxw);
1100 id0 = id0(mw(id0)==0);
1101 id = 1:size(wem,2);
1102 idtr = setdiff(id,id0);
1103 if isempty(idtr)
1104 erwn2=NaN*ones(length(handles.nmods),1);
1105 else
1106 wem = wem(:,idtr);
1107
1108 [d1,d2]=sort(wem,1,'descend');
1109 isn=find(isnan(wem(:,1)));
1110 d3=1:length(isn);
1111 d4=length(isn)+1:size(d1,1);
1112 ihn=[d2(d4,:);d2(d3,:)];
1113 [d1,dwn]=sort(ihn);
1114 erwn2=zeros(length(handles.nmods),1);
1115 for i=1:size(wem,1)
1116 for j=1:size(wem,1)
1117 tmp=length(find(dwn(i,1:end-1)==j));
1118 erwn2(i)=erwn2(i)+j*tmp;
1119 end
1120 end
1121 erwn2=erwn2/handles.nfold;
1122 end
1123 datmod(:,3) = num2cell(erwn2);
1124 [vald,idwmod] = sort(wemod(:,ffi),'descend');
1125 handles.sort_mod= idwmod;
1126 else
1127 datmod = [];
1128 end
1129 handles.datmod = datmod;
1130
1131
1132
1133 if isfield(handles.PRT.model(mi(m)).output,'weight_ROI') &&...
1134 ~isempty(handles.PRT.model(mi(m)).output.weight_ROI) &&...
1135 isfield(handles,'wmap') && ~isempty(handles.wmap)
1136 handles.dattable = dat;
1137
1138 dat = dat(handles.sort_roi,:);
1139 set(handles.ROItable,'Data',dat);
1140 set(handles.ROItable,'ColumnEditable',false(1,length(lc)));
1141 set(handles.ROItable,'ColumnName',lc);
1142 set(handles.ROItable,'visible','on');
1143
1144
1145 set(handles.axes1,'visible','on')
1146 bar(handles.axes1,weights(idwroi));
1147 set(get(handles.axes1,'XLabel'),'FontWeight','demi')
1148 set(get(handles.axes1,'XLabel'),'String',xlabel)
1149 set(get(handles.axes1,'YLabel'),'String',ylabel)
1150 set(get(handles.axes1,'YLabel'),'FontWeight','demi')
1151
1152
1153 if ~isempty(datmod)
1154 set(handles.modtable,'Visible','on')
1155 set(handles.modtable,'Enable','on')
1156 set(handles.modtable,'Data',datmod(handles.sort_mod,:))
1157 set(handles.modtable,'ColumnEditable',false(1,size(datmod,2)));
1158 set(handles.modtable,'ColumnName',{'Modality','Weight (%)','Exp. Ranking'});
1159 else
1160 set(handles.modtable,'Visible','off')
1161 set(handles.modtable,'Enable','off')
1162 end
1163
1164 else
1165 cla(handles.axes1, 'reset');
1166 set(handles.ROItable,'visible','off');
1167 set(handles.axes1,'visible','off');
1168 set(handles.butt_load_labels,'visible','off');
1169 set(handles.saveweight,'Visible','off')
1170 set(handles.modtable,'Visible','off')
1171 set(handles.modtable,'Enable','off')
1172 end
1173 handles.flagmodMKL = flagmodMKL;
1174 handles.model_button = 0;
1175 guidata(hObject, handles);
1176
1177
1178 function imagemenu_CreateFcn(hObject, eventdata, handles)
1179
1180
1181
1182
1183
1184
1185 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1186 set(hObject,'BackgroundColor','white');
1187 end
1188
1189
1190 function repedit_Callback(hObject, eventdata, handles)
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200 function repedit_CreateFcn(hObject, eventdata, handles)
1201
1202
1203
1204
1205
1206
1207 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1208 set(hObject,'BackgroundColor','white');
1209 end
1210
1211
1212
1213
1214 function showpos()
1215
1216 global st
1217
1218 mp13 = st.handles.mmedit;
1219 mp14 = st.handles.vxedit;
1220 tx20 = st.handles.posintensitytext;
1221
1222 set(mp13,'String',sprintf('%.1f %.1f %.1f',spm_orthviews('Pos')));
1223 pos = spm_orthviews('Pos',1);
1224 set(mp14,'String',sprintf('%.1f %.1f %.1f',pos));
1225 set(tx20,'String',sprintf('%g',spm_sample_vol(st.V,pos(1),pos(2),pos(3),st.hld)));
1226
1227 cmap = get(gcf,'Colormap');
1228 if size(cmap,1)~=128
1229 spm_figure('Colormap','gray-jet');
1230 end
1231
1232
1233
1234 function resetbutton_Callback(hObject, eventdata, handles)
1235
1236
1237
1238 spm_orthviews('Reset');
1239 if isfield(handles, 'wmap'), handles = rmfield(handles, 'wmap'); end
1240 if isfield(handles, 'aimg'), handles = rmfield(handles,'aimg'); end
1241 cla(handles.axes1, 'reset');
1242 set(handles.ROItable,'visible','off');
1243 set(handles.axes1,'visible','off');
1244 set(handles.butt_load_labels,'visible','off');
1245 set(handles.saveweight,'visible','off');
1246 set(handles.modtable,'Visible','off')
1247 set(handles.modtable,'Enable','off')
1248 handles.noloadw = 0;
1249 guidata(hObject, handles);
1250
1251
1252
1253 function savemenu_Callback(hObject, eventdata, handles)
1254
1255
1256
1257 wd=cd;
1258 cd(handles.prtdir)
1259 [filename, pathname] = uiputfile( ...
1260 {'*.png','Portable Network Graphics (*.png)';...
1261 '*.jpeg','JPEG figure (*.jpeg)';...
1262 '*.tiff','Compressed TIFF figure (*.tiff)';...
1263 '*.fig','Matlab figure (*.fig)';...
1264 '*.pdf','Color PDF file (*.pdf)';...
1265 '*.epsc', 'Encapsulated PostScript (*.eps)'},...
1266 'Save figure as','.png');
1267 [a,b,c]=fileparts(filename);
1268 ext=['-d',c(2:end)];
1269
1270
1271 cf=get(handles.figure1,'Color');
1272 set(handles.figure1,'Color',[1,1,1])
1273 aa=get(handles.figure1,'children');
1274 xc=[];
1275 for i=1:length(aa)
1276 if strcmpi(get(aa(i),'type'),'uipanel')
1277 try
1278 xc=[xc;get(aa(i),'BackgroundColor')];
1279 set(aa(i),'BackgroundColor',[1 1 1])
1280 end
1281 bb=get(aa(i),'children');
1282 if ~isempty(bb)
1283 for j=1:length(bb)
1284 try
1285 xc=[xc;get(bb(j),'BackgroundColor')];
1286 set(bb(j),'BackgroundColor',[1 1 1])
1287 end
1288 if strcmpi(get(bb(j),'type'),'uipanel')
1289 cc=get(bb(j),'children');
1290 if ~isempty(cc)
1291 for k=1:length(cc)
1292 try
1293 xc=[xc;get(cc(k),'BackgroundColor')];
1294 set(cc(k),'BackgroundColor',[1 1 1])
1295 end
1296 if strcmpi(get(cc(k),'type'),'uipanel')
1297 dd=get(cc(k),'children');
1298 if ~isempty(dd)
1299 for l=1:length(dd)
1300 try
1301 xc=[xc;get(dd(l),'BackgroundColor')];
1302 set(dd(l),'BackgroundColor',[1 1 1])
1303 end
1304 end
1305 end
1306 end
1307 end
1308 end
1309 end
1310 end
1311 end
1312 end
1313 if ~strcmpi(get(aa(i),'type'),'uimenu')
1314 try
1315 xc=[xc;get(aa(i),'BackgroundColor')];
1316 set(aa(i),'BackgroundColor',[1 1 1])
1317 end
1318 end
1319 end
1320
1321 print(handles.figure1,ext,[pathname,filesep,b],'-r500')
1322
1323
1324 set(handles.figure1,'Color',cf)
1325 scount=1;
1326 for i=1:length(aa)
1327 if strcmpi(get(aa(i),'type'),'uipanel')
1328 try
1329 set(aa(i),'BackgroundColor',xc(scount,:))
1330 scount=scount+1;
1331 end
1332 bb=get(aa(i),'children');
1333 if ~isempty(bb)
1334 for j=1:length(bb)
1335 try
1336 set(bb(j),'BackgroundColor',xc(scount,:))
1337 scount=scount+1;
1338 end
1339 if strcmpi(get(bb(j),'type'),'uipanel')
1340 cc=get(bb(j),'children');
1341 if ~isempty(cc)
1342 for k=1:length(cc)
1343 try
1344 set(cc(k),'BackgroundColor',xc(scount,:))
1345 scount=scount+1;
1346 end
1347 if strcmpi(get(cc(k),'type'),'uipanel')
1348 dd=get(cc(k),'children');
1349 if ~isempty(dd)
1350 for l=1:length(dd)
1351 try
1352 set(dd(l),'BackgroundColor',xc(scount,:))
1353 scount=scount+1;
1354 end
1355 end
1356 end
1357 end
1358 end
1359 end
1360 end
1361 end
1362 end
1363 elseif ~strcmpi(get(aa(i),'type'),'uimenu')
1364 try
1365 set(aa(i),'BackgroundColor',xc(scount,:))
1366 scount=scount+1;
1367 end
1368 end
1369 end
1370
1371 cd(wd)
1372
1373
1374 function disp_weights_CellSelectionCallback(hObject,eventdata,handles)
1375
1376
1377
1378 handles.selectedcell=eventdata.Indices;
1379 if ~isempty(handles.selectedcell) && handles.selectedcell(2)==1 && ...
1380 ~handles.flagmodMKL
1381 weightbutton_Callback(hObject, eventdata, handles);
1382 else
1383 handles.selectedcell = [];
1384 end
1385
1386 guidata(hObject, handles);
1387
1388
1389 function listbox1_Callback(hObject, eventdata, handles)
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399 function listbox1_CreateFcn(hObject, eventdata, handles)
1400
1401
1402
1403
1404
1405
1406 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1407 set(hObject,'BackgroundColor','white');
1408 end
1409
1410
1411 function butt_load_labels_Callback(hObject, eventdata, handles)
1412
1413
1414
1415 mi = handles.mi;
1416 m = get(handles.classmenu,'Value');
1417 if m==0
1418 m=1;
1419 end
1420 mim = get(handles.imagemenu,'Value');
1421 if mim==0
1422 mim=1;
1423 end
1424 fname=spm_select(1,'.mat','Select the file containing the names of the ROIs');
1425 if isempty(fname)
1426 disp('No file containing the names of the ROIs found, generic names used')
1427 handles.labels{mi(m)}{mim}=[];
1428 else
1429 load(fname)
1430 try
1431 handles.labels{mi(m)}{mim}=ROI_names;
1432 catch
1433 disp('No variable ROI_names found, generic names used')
1434 end
1435 end
1436 num_roi = handles.num_roi(:,mim);
1437 try
1438 label = handles.labels{mi(m)}{mim}(num_roi);
1439 catch
1440 if length(num_roi)==length(handles.labels{mi(m)}{mim})
1441 label = handles.labels{mi(m)}{mim}(num_roi);
1442 elseif length(num_roi)==length(handles.labels{mi(m)}{mim})+1
1443 handles.labels{mi(m)}{mim} = [{'others'};handles.labels{mi(m)}{mim}];
1444 label = handles.labels{mi(m)}{mim}(num_roi);
1445 else
1446 warning('prt_ui_disp_weights:LabelsDoNotCorrespondtoROI',...
1447 'Number of labels in .mat does not correspond to number of ROIs');
1448 label = [];
1449 end
1450 end
1451 if ~isempty(handles.labels{mi(m)}{mim}) && ~isempty(label)
1452 dat = handles.dattable;
1453 dat(:,1) = label;
1454 handles.dattable = dat;
1455 dat = dat(handles.sort_roi,:);
1456 set(handles.ROItable,'Data',dat);
1457 set(handles.ROItable,'visible','on');
1458 guidata(hObject, handles);
1459 end
1460
1461
1462
1463
1464
1465
1466 function disp_voxels_Callback(hObject, eventdata, handles)
1467
1468
1469
1470
1471
1472
1473
1474 m = get(handles.classmenu,'Value');
1475 if m==0
1476 m=1;
1477 end
1478 mi = handles.mi;
1479 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
1480 ffi = get(handles.foldmenu,'Value')-1;
1481 if ffi == -1
1482 ffi = 0;
1483 end
1484 if ffi==0
1485 ffi=handles.nfold+1;
1486 end
1487
1488
1489 disp_vox = get(handles.disp_voxels,'Value');
1490 if disp_vox
1491 fntl = handles.PRT.model(mi(m)).output.weight_img{handles.class};
1492 set(handles.disp_regions,'Value',0);
1493 else
1494 fntl = ['ROI_',handles.PRT.model(mi(m)).output.weight_img{handles.class}];
1495 set(handles.disp_regions,'Value',1);
1496 set(handles.disp_voxels,'Value',0);
1497 end
1498
1499
1500 if exist([handles.prtdir,filesep,fntl,'.img'],'file') || ...
1501 exist([handles.prtdir,filesep,fntl],'file')
1502 [a,b] = fileparts(fntl);
1503 handles.wmap = [handles.prtdir,filesep,b,'.img'];
1504 V = spm_vol(handles.wmap);
1505 handles.vols{1} = V;
1506 handles.noloadw = 1;
1507 handles.model_button = 0;
1508 handles.selectedcell = [];
1509
1510 guidata(hObject, handles);
1511 weightbutton_Callback(hObject, eventdata, handles);
1512 else
1513 beep
1514 disp('Weight image does not exist for this model')
1515 end
1516
1517
1518 guidata(hObject, handles);
1519
1520
1521 function disp_regions_Callback(hObject, eventdata, handles)
1522
1523
1524
1525
1526
1527
1528 m = get(handles.classmenu,'Value');
1529 if m==0
1530 m=1;
1531 end
1532 mi = handles.mi;
1533 handles.nfold = length(handles.PRT.model(mi(m)).output.fold);
1534 ffi = get(handles.foldmenu,'Value')-1;
1535 if ffi == -1
1536 ffi = 0;
1537 end
1538 if ffi==0
1539 ffi=handles.nfold+1;
1540 end
1541
1542
1543 disp_reg = get(handles.disp_regions,'Value');
1544 if ~disp_reg
1545 fntl = handles.PRT.model(mi(m)).output.weight_img{handles.class};
1546 set(handles.disp_regions,'Value',0);
1547 set(handles.disp_voxels,'Value',1);
1548 else
1549 fntl = ['ROI_',handles.PRT.model(mi(m)).output.weight_img{handles.class}];
1550 set(handles.disp_regions,'Value',1);
1551 set(handles.disp_voxels,'Value',0);
1552 end
1553
1554
1555 if exist([handles.prtdir,filesep,fntl,'.img'],'file') || ...
1556 exist([handles.prtdir,filesep,fntl],'file')
1557 [a,b] = fileparts(fntl);
1558 handles.wmap = [handles.prtdir,filesep,b,'.img'];
1559 V = spm_vol(handles.wmap);
1560 handles.vols{1} = V;
1561 handles.noloadw = 1;
1562 handles.model_button = 0;
1563 handles.selectedcell = [];
1564
1565 guidata(hObject, handles);
1566 weightbutton_Callback(hObject, eventdata, handles);
1567 else
1568 beep
1569 disp('Weight image does not exist for this model')
1570 end
1571
1572
1573 guidata(hObject, handles);
1574
1575
1576
1577
1578 function ROItable_CellEditCallback(hObject, eventdata, handles)
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590 function edit7_Callback(hObject, eventdata, handles)
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600 function edit7_CreateFcn(hObject, eventdata, handles)
1601
1602
1603
1604
1605
1606
1607 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1608 set(hObject,'BackgroundColor','white');
1609 end
1610
1611
1612
1613 function saveweight_Callback(hObject, eventdata, handles)
1614
1615
1616
1617
1618
1619
1620
1621 mim = get(handles.imagemenu,'Value');
1622 if mim==0
1623 mim=1;
1624 end
1625 num_roi = handles.num_roi(:,mim);
1626
1627 disp('Saving the sorted list of regions to text file.....>>');
1628 modelname = char(strcat(handles.mnames(get(handles.classmenu,'value')),'_RegionList.txt'));
1629 path = fileparts(handles.pathdir);
1630 weightname=fullfile(path,modelname);
1631 disp(weightname);
1632 fid=fopen(weightname,'w');
1633 fprintf(fid,'%23s %20s %20s %23s\r\n','"ROI Label"','"ROI weight (%)"','"ROI size (vox)"','"Exp. Ranking"');
1634 dat = handles.dattable;
1635 dat = dat(handles.sort_roi,:);
1636 for i = 1:size(num_roi)
1637 cellvalue= dat(i,:);
1638 fprintf(fid, '%22s %19f %20d %23f\r\n', cellvalue{:});
1639 end
1640 fclose(fid);
1641 disp('Save Done!');