spm_resels.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. function [R] = spm_resels(FWHM,L,SPACE)
  2. % Returns the RESEL counts of a search volume
  3. % FORMAT [R] = spm_resels(FWHM,L,SPACE)
  4. % FWHM - smoothness of the component fields {FWHM - voxels}
  5. % L - space definition {in voxels}
  6. % L = radius {Sphere}
  7. % L = [height width length] {Box}
  8. % L = XYZ pointlist {Discrete voxels}
  9. % L = Mapped image volume {Image}
  10. % SPACE - Search space
  11. % 'S' - Sphere
  12. % 'B' - Box
  13. % 'V' - Discrete voxels
  14. % 'I' - Image VOI
  15. %
  16. % R - RESEL counts {adimensional}
  17. %
  18. %__________________________________________________________________________
  19. % For one or two dimensional spaces the appropriate manifold is
  20. % used (e.g. sphere -> disc -> line).
  21. %
  22. % Reference : Worsley KJ et al 1996, Hum Brain Mapp. 4:58-73
  23. %
  24. %__________________________________________________________________________
  25. % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
  26. % Karl Friston & Matthew Brett
  27. % $Id: spm_resels.m 3899 2010-05-25 15:36:40Z guillaume $
  28. % Dimensionality
  29. %--------------------------------------------------------------------------
  30. switch SPACE
  31. case 'S' % Sphere
  32. %----------------------------------------------------------------------
  33. s = L(:)./FWHM(:);
  34. s = s(s > 0);
  35. if length(s) == 2, SPACE = 'D'; end
  36. if length(s) == 1, SPACE = 'L'; end
  37. case 'B' % Box
  38. %----------------------------------------------------------------------
  39. s = L(:)./FWHM(:);
  40. s = s(s > 0);
  41. if length(s) == 2, SPACE = 'R'; end
  42. if length(s) == 1, SPACE = 'L'; end
  43. end
  44. % Default {sphere - assuming L = volume i.e. number of voxels)
  45. %--------------------------------------------------------------------------
  46. if nargin < 3
  47. SPACE = 'S';
  48. L = (L*(3/4)/pi)^(1/3);
  49. end
  50. % RESEL Counts (R)
  51. %==========================================================================
  52. switch SPACE
  53. case 'S' % Sphere
  54. %----------------------------------------------------------------------
  55. s = prod(s).^(1/3);
  56. R = [1 4*s 2*pi*s^2 (4/3)*pi*s^3];
  57. case 'D' % Disc
  58. %----------------------------------------------------------------------
  59. s = prod(s).^(1/2);
  60. R = [1 pi*s pi*s^2 0];
  61. case 'B' % Box
  62. %----------------------------------------------------------------------
  63. R = [1 sum(s) (s(1)*s(2) + s(2)*s(3) + s(1)*s(3)) prod(s)];
  64. case 'R' % Rectangle
  65. %----------------------------------------------------------------------
  66. R = [1 sum(s) prod(s) 0];
  67. case 'L' % Line
  68. %----------------------------------------------------------------------
  69. R = [1 s 0 0];
  70. case 'V' % Voxels
  71. %----------------------------------------------------------------------
  72. %R = spm_Pec_resels(L,FWHM);
  73. V = zeros(max(L,[],2)');
  74. LL = mat2cell(L,ones(1,size(L,1)),size(L,2));
  75. V(sub2ind(size(V),LL{:})) = 1;
  76. R = spm_resels_vol(V,FWHM)';
  77. case 'I' % Image
  78. %----------------------------------------------------------------------
  79. R = spm_resels_vol(L,FWHM)';
  80. end