[Marsbar-users] getting the coordinates of voxels in an ROI/ writing to an ROI
Status: Beta
Brought to you by:
matthewbrett
|
From: <Jan...@Al...> - 2008-07-01 02:50:00
|
Dear users (and Matthew), I have two questions about things I'm having trouble with. 1) When you extract timecourse information for each voxel in an ROI using something like getdata.m, you get a matrix with the data for each voxel in a separate column. How can you retrieve the coordinates for the voxel in each column so that you know which voxel each column refers to? 2) I'm trying to write values back to an roi, much like a user posted a question about a couple of months ago (see below). Essentially, we extract the data for all the timepoints in a roi, do some stats, and then want to write back coefficient values for each voxel so that we can view/render them on a brain. When I tried the code Matthew suggested for the last user, the values that end up in the roi image are not the same ones I entered (at least as indicated by the "display" function in SPM). In fact, sometimes they aren't even the same sign. Any advice about what might be going on? Does spm_write_vols do something to the values that I don't know about? Thank you very much for your help! Jana ---------------------------------------------------------------------------------------------------------------- Re: How to *write to* an image file at a given ROI? by Matthew Brett Nov 14, 2007; 07:12am : Hi, > But could someone please tell me how to *write* to a given ROI in the > image? > > For instance, to read the image data, I could do something like > [Y, multv, vXYZ, mat] = getdata(my_roi, my_data_img); > where Y would be the raw image values. > > But can one do the reverse, i.e., write specified values (e.g., % > response change values) to the voxels corresponding to 'my_roi' in > 'my_data_img'? ... [show rest of quote] I guess that would be fairly simple, in a script. Like: [Y, multv, vXYZ, mat] = getdata(my_roi, my_data_img); V = my_data_img; V.fname = 'another_image.img'; dims = V.dim(1:3); img_vals = zeros(dims); elements = elements = vXYZ(1,:) + (vXYZ(2,:)-1) * dims(1) + (vXYZ(3,:)-1) * dims(1)*dims(2); img_vals(elements) = Y; ... spm_write_vol(V, img_vals); Matthew |