Just to let people know, there are typos in the code I sent out and I didn't really test it. So if you use it be ready to do some editing... ;)
a clean version is coming out in another context later.
Robert
>>> Robert Welsh <[log in to unmask]> 08/10/01 10:46AM >>>
Andreas,
Here is what you need to do:
have nX, nY, nZ defined to be the size of you image in voxels. rX, rY, rZ and ampT are the taliarach coordinates and amplitude of the voxel.
you will also need a translation/rotation matrix, which we'll call VOL.iM (look in the header file of an image. If you are wanting to get these voxels into the same space a a current image then do the following. I just wrote this, but it should work, it is based on an roi builder toolbox plug-in that I am preparing for SPM.
Let me know if this does or does not work.
Robert Welsh.
%
% a little script cobbled together to take a list of points in taliarach and
% put into an image.
%
% Robert C. Welsh
% Univ of Michigan
% Aug 10.2001
%
aHdr = spm_vol('yourimagehere.img');
%calcuate the transformation from taliarach to voxel space.
iM = (aHdr.mat)^-1;
% get the number of points.
nPnts = length(rZ);
aVol = zeros(nX,nY,nZ);
% Now loop on each point and drop into image.
for iPnt = 1:nPnts
iVX = floor(VOL.iM * [ rX(iPnt); rY(iPnt); rZ(iPnt); 1];
aVal(iVX(1),iVX(2),iVX(3)) = ampT(iPnt);
end
% now write the image out.
aHdr.fname = 'your new file name here.img';
spm_write_vol(aHdr,aVol);
%
% all done.
%
>>> "Meyer-Lindenberg, Andreas (NIMH)" <[log in to unmask]> 08/10/01 09:37AM >>>
Hi all,
from the output of another matlab program I have a list of voxel values and
a corresponding list of the Talairach coordinates of these voxels in an XYZ
variable. I can look at them using spm_orthviews. What I need to do now is
to create an Analyze-formatted volume that contains these values at the
given coordinates. Does someone have matlab code to do that? I'd be most
grateful.
In any case thanks,
and a nice weekend,
Andreas
Andreas Meyer-Lindenberg, M.D., Ph.D. (PD Dr. med. Dr. med. habil.)
Unit on Integrative Neuroimaging, Clinical Brain Disorders Branch,
National Institute of Mental Health
Bldg. 10 Room 4C101, 9000 Rockville Pike, Bethesda, MD 20892-1365, USA
email: [log in to unmask], phone: 301-496-9672, fax: 301-496-7437
|