Hi Blaine,
spm_mask sets voxels outside the mask to NaN (not zero, as you might
have thought; the point being that zeros inside the mask can then be
distinguished). Then in the code you're using,
gl(i) = gl(i) + sum(img(:));
sums up all values, and since NaN+anything=NaN, this explains your result.
Either change this line of the code to:
gl(i) = gl(i) + sum(img(isfinite(img)));
Or try using my routine for getting the integral over the image, which
should work fine in your case.
http://www.cs.ucl.ac.uk/staff/gridgway/vbm/get_totals.m
If your mask is a voxelwise match for the image, i.e. not just
registered in world-space, then you could also use
t = get_totals('', '', '')
and select the original unmasked image and the ROI mask, to save you
the spm_mask step. Let me know if there are any problems with this.
Best,
Ged.
Blaine Ames wrote:
> Hello All,
> I am running into an odd problem when attempting to calculate volumes of
> masked ROI's in my VBM data. What I am trying to accomplish is a correlation
> between two different ROI's in my VBM data.
>
> Here's what I have done:
>
> 1) created an sphere ROI mask with a radius of 5 mm in DLPFC using the
> WFU_pickatlas util.
> 2) applied the mask using spm_mask to my smoothed and modulated vbm data.
> This gives me m* files.
> 3) use the script below that was provided on this list-serve to calculate
> volumes
>
>> function gl = get_integrals(P)
>> % Integrate the values in an image.
>> if nargin<1,
>> P = spm_get(Inf,'*.img');
>> end;
>> V = spm_vol(P);
>> gl = zeros(length(V),1);
>> for i=1:length(gl),
>> for z=1:V(i).dim(3),
>> img = spm_slice_vol(V(i),spm_matrix([0 0
> z]),V(i).dim(1:2),0);
>> gl(i) = gl(i) + sum(img(:));
>> fprintf('.');
>> end;
>> gl(i) = gl(i)*(det(V(i).mat)/100^3);
>> fprintf('\n');
>> end;
>
> The result is "ans = NaN"
>
> This is baffling because when I run the scipt above on an unmasked data set
> I get the correct output. I can view the masked data using "Display" within
> SPM and everything looks good. Is there something that spm_masked does to
> the data to alter it in someway, beyond masking?
> Or
> Am I completely misguided in my technique of masking and attempting to
> extract the volume of an ROI.
>
> Thank you for your time,
> blaine
>
|