You are right, I was too sloppy. It has to be: XYZ(:,sub2ind(size(Img),10,20, 6)) Cheers, Michael Am 15.10.2013 12:15, schrieb Tibor Auer: > This may not be correct. Especially, because XYZ is not a 3D matrix, > but a 3 x nVox matrix containing the XYZ coords for the voxels with the > given "index". > Let's assume that we have an nX x nY x nZ image (img) so the XYZ is a 3 > x (nX*nY*nZ) matrix; and we want the "index" for the voxel at X,Y,Z. > There are two options to figure out the "index": > /i//nd = (Z-1)*(nX*nY)//+(Y-1)*nX+X;//% specific/ > or > /ind = 1://length(XYZ); ind = reshape(ind,size(img));//ind = ind(X,Y,Z); > % general/ > and > /XYZ(:,ind) / > gives you the coordinates > Cheers, > Auer, Tibor M.D. Ph.D. > MRC Cognition and Brain Sciences Unit > 15 Chaucer Road > Cambridge > CB2 7EF > United Kingdom > Phone/Work: +44-(0)1223-355294 (ext. 869) > Mail: [log in to unmask] > -----Original Message----- > From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]] > On Behalf Of Michael Erb > Sent: Monday, October 14, 2013 10:00 PM > To: [log in to unmask] > Subject: Re: [SPM] Q) How to figure out the MNI coordinate of matrix x,y,z? > try: > [Img, XYZ]=spm_read_vols(Vol); > XYZ(10,20, 6) will give you the MNI coordinate in mm > How do I know that? > >> help spm_read_vols > Read in entire image volumes > FORMAT [Y,XYZ] = spm_read_vols(V,mask) > V - vector of mapped image volumes to read in (from spm_vol) > mask - implicit zero mask? > Y - 4D matrix of image data, fourth dimension indexes images > XYZ - 3xn matrix of XYZ locations returned (in mm) > > __________________________________________________________________________ > For image data types without a representation of NaN (see spm_type), > implicit zero masking can be used. If mask is set, then zeros are > treated as masked, and returned as NaN. > > __________________________________________________________________________ > Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging > Hope that helps, > Michael > Am 14.10.2013 22:10, schrieb Glen Lee: >> Hello SPM experts, >> >> I'd like to figure out the MNI coordinate that corresponds to matlab's >> matrix of an image. >> For example, I'd like to know what the MNI x,y,z that corresponds to >> 10,20,6 in matrix below. >> >> Vol=spm_vol('tmap.nii'); >> Img=spm_read_vols(Vol); >> >> Img(10,20, 6)-> MNI?? >> >> >> thanks in advance, >> Glen > -- > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > Dr. Michael Erb > Department of Biomedical Magnetic Resonance University of Tübingen > Hoppe-Seyler-Str. 3 > 72076 Tübingen, Germany > Tel.: +49(0)7071/2987753 priv. +49(0)7071/61559 > Fax.: +49(0)7071/294371 > e-mail: <[log in to unmask] > <mailto:[log in to unmask]>> > www: > http://www.medizin.uni-tuebingen.de/Forschung/Kliniken/Radiologie/Biomedizinische+Magnetresonanz.html > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Dr. Michael Erb Department of Biomedical Magnetic Resonance University of Tübingen Hoppe-Seyler-Str. 3 72076 Tübingen, Germany Tel.: +49(0)7071/2987753 priv. +49(0)7071/61559 Fax.: +49(0)7071/294371 e-mail: <[log in to unmask]> www: http://www.medizin.uni-tuebingen.de/Forschung/Kliniken/Radiologie/Biomedizinische+Magnetresonanz.html <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<