If your ROI is a binary mask image, something like this should work:
V = spm_vol(mask)
[Y XYZ] = spm_read_vols(V)
voxs = find(Y==1) %only find voxels with value '1'; gives linear
indices of the matrix Y
for i=1:length(voxs),
vXYZmm(:,i) = XYZ(:, voxs(i)); % gives 3xn matrix of locations
in mm
end
M = inv(V.mat)
for i=1:size(vXYZmm,2),
vXYZ(:,i) = vXYZmm(:,i)'*M(1:3,1:3) + M(1:3,4)' % gives 3xn
matrix of locations in voxel number
end
Vcon = spm_vol(con_image)
Ycon = spm_read_vols(Vcon)
for i=1:size(vXYZ,2),
con_vals(j) = Ycon(vXYZ(1,j), vXYZ(2,j), vXYZ(3,j)) %get the
con values for those voxels
end
Xiang Wu wrote:
> hi all
>
> Given a roi (defined by marsbar or perhaps with other ways) and a
> con*.image, how to extract the values in the ROI from the con*.image?
>
> I hope a simple way to do this, since this should be a simple thing itself.
> (I read some threads in this and marsbar lists, but those ways involve
> design matrix, which is not necessary to my simple situation since the
> statistic analysis resulting in the con*.images has been done by SPM iteslf)
>
> Thanks
> xiang
>
>
>
|