ery_4a_firstlevel_s3_diagnose_model.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. %% ery_4a_firstlevel_s3_diagnose_model.m
  2. %
  3. % This script will run diagnostics on first level models and publish them
  4. % as an html report using the CANlab function scn_spm_design_check, and
  5. % save variance inflation factors as a .mat file
  6. %
  7. % DOCUMENTATION
  8. % help scn_spm_design_check
  9. %
  10. % USAGE
  11. % Script should be called from LaBGAScore_firstlevel_s1_options_design_struct.m, it
  12. % is not for standalone use
  13. %
  14. %__________________________________________________________________________
  15. %
  16. % authors: Lukas Van Oudenhove
  17. % date: March, 2022
  18. %
  19. %__________________________________________________________________________
  20. % @(#)% LaBGAScore_firstlevel_s3_diagnose_model.m v1.0
  21. % last modified: 2022/03/22
  22. %% VIFS AND DESIGN
  23. vifs = scn_spm_design_check(subjfirstdir,'events_only','vif_thresh',LaBGAS_options.mandatory.vif_thresh);
  24. drawnow, snapnow
  25. save('vifs','vifs');
  26. close all
  27. %% FIRST LEVEL MAPS
  28. if LaBGAS_options.display.plotmontages
  29. load(fullfile(subjfirstdir,'SPM.mat'));
  30. tmapnames = dir(fullfile(subjfirstdir,'spmT_*.nii'));
  31. tmapspaths = cell(1,size(tmapnames,1));
  32. tmapsobj = cell(1,size(tmapnames,1));
  33. montages = cell(1,size(tmapnames,1));
  34. [~,maskname,maskext] = fileparts(LaBGAS_options.display.mask);
  35. mask = [maskname,maskext];
  36. fprintf('\nShowing results at p < %s %s, k = %s, mask = %s\n',num2str(LaBGAS_options.display.input_threshold),LaBGAS_options.display.thresh_type,num2str(LaBGAS_options.display.k),mask);
  37. for tmap = 1:size(tmapnames,1)
  38. tmapspaths{tmap} = fullfile(tmapnames(tmap).folder,tmapnames(tmap).name);
  39. tmapsobj{tmap} = statistic_image('image_names',tmapspaths{tmap},'type','T','dfe',SPM.xX.erdf);
  40. tmapsobj{tmap} = threshold(tmapsobj{tmap},LaBGAS_options.display.input_threshold,LaBGAS_options.display.thresh_type,'k',LaBGAS_options.display.k,'mask',LaBGAS_options.display.mask);
  41. create_figure('fmridisplay');
  42. wh_montage = 5;
  43. axis off
  44. figtitle = DSGN.contrastnames{tmap};
  45. o3 = canlab_results_fmridisplay([],'outline','linewidth',0.5,'montagetype','compact','overlay','mni_icbm152_t1_tal_nlin_sym_09a_brainonly.img');
  46. o3 = addblobs(o3,tmapsobj{tmap},'splitcolor',{[.1 .8 .8] [.1 .1 .8] [.9 .4 0] [1 1 0]});
  47. [o3,title_handle] = title_montage(o3,wh_montage,figtitle);
  48. set(title_handle,'FontSize',18);
  49. fighan = activate_figures(o3);
  50. f3 = fighan{1};
  51. f3.Tag = figtitle;
  52. f3.WindowState = 'maximized';
  53. drawnow,snapnow
  54. close(f3)
  55. clear figtitle o3 title_handle fighan f3
  56. end
  57. end