Print

Print


Thanks a lot, I checked the usages of spm_vol and spm_read_vols. I figure
your sample script could be simplify further as below: 

Say the roi file is roi.hdr (img, or in nii format) and con* image is
con_0001.hdr (img).

step 1: read the imformation of the roi and the con image
V_roi = spm_read(roi.hdr);
V_con = spm_read(con_0001.hdr);

step 2: get the values stored in the roi and the con image
(note, if use marsbar to define roi, export the roi mat file to images, and
remember to use the con file as space during the exportation, so that
xyz_roi=xyz_con)
[Y_roi, xyz_roi] = spm_read_vols(V_roi);
[Y_con, xyz_con] = spm_read_vols(V_con);

step 3: find the non-zero pixels in roi image, and extract these pixels
values in con image
pixel_non_zero_in_roi = find(Y_roi~=0);
what_we_want = Y_con(pixel_non_zero_in_roi);

In addition, from the help file it seems the mask (roi file here) can be
input into spm_read_vol, but I failed because I can't find the the format of
that. Otherwise step 2 and step 3 can be combined and simplified further.

Thanks Chris again.
xiang