Dear Mohit,
no, the order of the voxel is X (fastest), Y, Z
so [ XYZ(1,2) XYZ(2,2) XYZ(3,2) ] is the location of Y(2,1,1,:)
and
[ XYZ(1,VY(1).dim(1)+1) XYZ(2,VY(1).dim(1)+1)) XYZ(3,VY(1).dim(1)+1)) ]
is the location of Y(1,2,1,:)
the index of voxel [Xvox Yvox Zvox] is
((Zvox-1)*VY(1).dim(2)+Yvox-1)*VY(1).dim(1)+Xvox
you can calculate it with the matlab function sub2ind
sub2ind(VY(1).dim,Xvox,Yvox,Zvox)
or
sub2ind(size(Y(:,:,:,1)),Xvox,Yvox,Zvox)
Regards,
Michael
Am 09.04.2016 um 15:10 schrieb MOHIT GOEL:
> Dear Michael,
>
> Thanks for such beautiful explanation. It really helped me a lot. There was just another question that I wanted to clear out.
>
> Q. The coordinates for voxel represented by Y(1,1,1,:) location corresponds to [ XYZ(1,1) XYZ(2,1) XYZ(3,1) ] and coordinates for voxel represented by Y(1,2,1,:) location corresponds to [ XYZ(1,2) XYZ(2,2) XYZ(3,2) ] and so on. Am I correct?
>
> Thanks and regards,
> Mohit
>
> ----- Original Message -----
> From: "Michael Erb" <[log in to unmask]>
> To: "MOHIT GOEL" <[log in to unmask]>, "spm" <[log in to unmask]>
> Sent: Saturday, April 9, 2016 1:49:01 AM
> Subject: Understanding the output of spm_read_vols
>
> Dear Mohit,
>
> see
> >> 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)
>
> This explains you that the 4D matrix Y contains the data (intensity
> values) for each voxel (dim 1 2 3 = X Y Z) and volume number (in your
> case time). For each 3D-voxel you also get the position in mm in XYZ.
> So one thing you can do, if you know the exact position in mm (e.g XYZmm
> = [-10 10 20]), is to search for this coordinate in XYZ:
>
> idx=find(XYZ(1,:)==XYZmm(1) & XYZ(2,:)==XYZmm(2) & XYZ(3,:)==XYZmm(3))
>
> XYZ(:,idx) will give you the mm coordinates XYZmm again.
>
> You can transform the volume index (idx) to x y z voxel coordinates by
> using the matlab function ind2sub:
>
> [Xvox Yvox Zvox]=ind2sub(size(Y(:,:,:,1)),idx)
>
> You can then calculate the intensity time course of this voxel:
>
> tc=Y(Xvox,Yvox,Zvox,:);
>
> But if the mm coordinates does not exactly correspond to a voxel center
> this method will fail and idx will be empty.
>
> What you can do in this case is using the transformation matrix stored
> in the header to calculate the voxel coordinates:
> if you got the data with
>
> [Y,XYZ] = spm_read_vols(VY);
>
> XYZvox=round(VY(1).mat\[XYZmm 1]')
>
> will give you the voxel coordinates of the nearest voxel center and then
> you can calculate the intensity time course of this voxel by
>
> tc=Y(XYZvox(1),XYZvox(2),XYZvox(3),:);
>
> Regards,
>
> Michael
>
>
> Am 08.04.2016 um 18:14 schrieb MOHIT GOEL:
>> Dear SPM users,
>>
>> I am using the 'spm_read_vols' function to extract time-series information for my fMRI data but I do not understand the structure of the output completely. Below mentioned are some of my doubts.
>> I have a vector of multiple images which I give as an input to the command. I got my output in [Y,XYZ].
>>
>> 1. I have an understanding that Y here is a 4D matrix where the 4th dimension represents the intensity. But I am not sure of what does the first three dimensions represent? If they represent the coordinates then are these coordinates in mm or some other representation because I am not getting any negative values in these dimensions and I know that brain coordinates range from -r(-x,-y,-z) to r(x,y,z). If they are in some other representation then how can they be converted to mm.
>>
>> 2. If Y contains the coordinate values then what is XYZ variable for?
>>
>> 3. How can I get the intensity values from Y for some specific coordinate(in mm)?
>>
>>
>> Thanks and regards,
>> Mohit
>>
>>
>
--
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|