Voxel-counting script

Sometimes we just want to count the number of voxels whose values are more than zero.
My friend showed me a script which can do that easily. SPM functions are used, so you need to install SPM first.

%%%%%countvx.m
%a script which counts voxels whose values are more than zero.
file = spm_select;
vol = spm_vol(file);
img = spm_read_vols(vol);
sum(img(:)>0)

If you change the value of the last line from 0 to 0.1, you will count the number of voxels whose values are more than 0.1.

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください