Punervasu Vyas wrote:
> Hi guys
> Is there a way we can calculate SNR from mri images using SPM5.
> Regards
> Punervasu Vyas
Hi,
If you want a voxelwise mean over a voxelwise standard deviation for a
bunch of images, i.e. you want an SNR image, then use spm_imcalc_ui as
in this post:
http://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind0608&L=SPM&P=R45864
If you want mean over std of the voxels of a single image, then the
attached should do the trick. And if you want something else, please
ask again!
Best,
Ged.
function snr = img_snr(files)
% snr = img_snr
% returns image Signal-to-Noise Ratio (mean/stdev)
% check spm version:
if exist('spm_select','file') % should be true for spm5
spm5 = 1;
select = @(msg) spm_select(inf, 'image', msg);
elseif exist('spm_get','file') % should be true for spm2
spm5 = 0;
select = @(msg) spm_get(inf, 'img', msg);
else
error('Failed to locate spm_get or spm_select; please add SPM to Matlab path')
end
if ( ~exist('files', 'var') || isempty(files) )
files = select('choose segmentations');
end
vols = spm_vol(files);
N = length(vols);
snr = zeros(N,1);
for n = 1:N
img = spm_read_vols(vols(n));
snr(n) = mean(img(~isnan(img))) / std(img(~isnan(img)));
end
|