fMRIDiag_WorkBench.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. clear
  2. %replace this path with the DVARS directory on your machine
  3. addpath(genpath('/Users/sorooshafyouni/Home/GitClone/DVARS'))
  4. %replace this path with the path to the nifti/cifti images on your machine
  5. V0=['/Volumes/HCP_S900/HCP_10Unrel_Vols/115320/115320/MNINonLinear/Results/rfMRI_REST1_LR/rfMRI_REST1_LR.nii.gz'];
  6. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. %%%%%%%%%%%%%%%%%%%%%%%EXAMPLE 1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. % This is the simplest form of using DSE variance decomposition and DVARS
  10. % inference on the data. As the example is for HCP data, we used 1/100
  11. % downscaling factor. The scale/norm factors should be changed for other
  12. % data-sets (However, if you have processed your data via FSL, leave the
  13. % scaling 1/100 as it is).
  14. %--NIFTI--------------------------------------------
  15. V1 = load_untouch_nii(V0);
  16. V2 = V1.img;
  17. X0 = size(V2,1); Y0 = size(V2,2); Z0 = size(V2,3); T0 = size(V2,4);
  18. I0 = prod([X0,Y0,Z0]);
  19. Y = reshape(V2,[I0,T0]); clear V2 V1;
  20. % %--CIFTI--------------------------------------------
  21. % addpath /Users/sorooshafyouni/Home/matlab/Ext/cifti-matlab-master
  22. % V1 = ft_read_cifti(V0);
  23. % V2=V1.dtseries;
  24. % I0=size(V2,1); T0=size(V2,2);
  25. % Y=V2; clear V2 V1;
  26. % %
  27. [DVARS,DVARS_Stat]=DVARSCalc(Y,'scale',1/100);
  28. [V,DSE_Stat]=DSEvars(Y,'scale',1/100);
  29. fMRIDiag_plot(V,DVARS_Stat)
  30. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %%%%%%%%%%%%%%%%%%%%%%%EXAMPLE 2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  33. % In this example, you can see how to add BOLD intensity images to your
  34. % figure to have a better understanding the of the effect of spikes/excursions
  35. % in your variance components. Read help section of 'fMRIDiag_plot' for
  36. % further parameters that can be used.
  37. %--NIFTI--------------------------------------------
  38. V1 = load_untouch_nii(V0);
  39. V2 = V1.img;
  40. X0 = size(V2,1); Y0 = size(V2,2); Z0 = size(V2,3); T0 = size(V2,4);
  41. I0 = prod([X0,Y0,Z0]);
  42. Y = reshape(V2,[I0,T0]); clear V2 V1;
  43. % %--CIFTI--------------------------------------------
  44. % addpath /Users/sorooshafyouni/Home/matlab/Ext/cifti-matlab-master
  45. % V1 = ft_read_cifti(V0);
  46. % V2=V1.dtseries;
  47. % I0=size(V2,1); T0=size(V2,2);
  48. % Y=V2; clear V2 V1;
  49. % %
  50. [DVARS,DVARS_Stat]=DVARSCalc(Y,'scale',1/100);
  51. [V,DSE_Stat]=DSEvars(Y,'scale',1/100);
  52. fMRIDiag_plot(V,DVARS_Stat,'BOLD',Y,'ColRng',[0 100])
  53. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54. %%%%%%%%%%%%%%%%%%%%%%%EXAMPLE 3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % In this example, it is assumed that the desplacement information has also
  57. % been provided for a subject. An extra sub-plot, automatically, is added
  58. % to the top of your figure to report the FD and Absolute values of the
  59. % movements acquired via 'FDCalc'.
  60. %--NIFTI--------------------------------------------
  61. V1 = load_untouch_nii(V0);
  62. V2 = V1.img;
  63. X0 = size(V2,1); Y0 = size(V2,2); Z0 = size(V2,3); T0 = size(V2,4);
  64. I0 = prod([X0,Y0,Z0]);
  65. Y = reshape(V2,[I0,T0]); clear V2 V1;
  66. % %--CIFTI--------------------------------------------
  67. % addpath /Users/sorooshafyouni/Home/matlab/Ext/cifti-matlab-master
  68. % V1 = ft_read_cifti(V0);
  69. % V2=V1.dtseries;
  70. % I0=size(V2,1); T0=size(V2,2);
  71. % Y=V2; clear V2 V1;
  72. % %
  73. %--Movement Parameters--------------------------------
  74. %replace this path with the path to the text files with movement regressors
  75. %of the image on your machine
  76. %Note that MovPartextImport only works safe with the HCP files, you have to
  77. %insert the movement regressors mannually (just drag the text file into the
  78. %workspace!) to the Matlab.
  79. MovPar=MovPartextImport(['/Volumes/HCP_S900/HCP_10Unrel_Vols/115320/115320/MNINonLinear/Results/rfMRI_REST1_LR/Movement_Regressors.txt']);
  80. [FDts,FD_Stat]=FDCalc(MovPar);
  81. %
  82. [DVARS,DVARS_Stat]=DVARSCalc(Y,'scale',1/100);
  83. [V,DSE_Stat]=DSEvars(Y,'scale',1/100);
  84. fMRIDiag_plot(V,DVARS_Stat,'BOLD',Y,'FD',FDts,'AbsMov',[FD_Stat.AbsRot FD_Stat.AbsTrans])