On Tue, May 19, 2009 at 2:24 PM, Xiang Wu <[log in to unmask]> wrote: > 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); This should be spm_vol('.img file') > > > 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); you dont need xyz, just Y = spm_read_vols(V); > > > 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); find already returns non zero indices, so just do - what_we_want = Y_con(find(Y_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 > -- Research Associate Gazzaley Lab Department of Neurology University of California, San Francisco