yeah, you are right, and mat*[1 1 1 0]' is exactly the voxelsize for
non-angulated images ;-)
But your expression indeed gives it for all angulations.
Chapeau!
Bas
On 11/25/2011 06:15 PM, Michael Erb wrote:
> Hi Han,
> you are right, what Bas calculates is not the voxelsize but the
> position of the corner of one voxel. It is the voxel position 1 1 1
> transformed to mm space ( by the way inv(mat)\[1 1 1 0]' is the same
> as mat*[1 1 1 0]').
>
> you can also use:
>
> voxelsize=sqrt(sum(mat.^2))
>
> Michael
>
> Am 25.11.2011 14:00, schrieb han zhang:
>> Hi all,
>> I try this time in my way, to orthogonize mat matrix, I use:
>> [U S V] = svd(head.mat(1:3, 1:3)), and S give me the voxel size.
>> Hope it helps for other guys.
>> Han
>> 2011/11/25 S.F.W. Neggers <[log in to unmask]
>> <mailto:[log in to unmask]>>
>>
>> __
>> O sorry, I made I typo I see. My reply was what I remembered from
>> some time ago ;-)
>> It should be inv(mat)\[1 1 1 0]' otherwise you will incorporate the
>> translation parameters...
>> Just checked on a few images, and the above works for me. Notice
>> that the order of the voxel size you get is according to voxel
>> space. That is, when you scan saggittally, the first number will be
>> the slice thickness (from ear to ear).
>>
>> Cheers,
>>
>> Bas
>>
>>
>> Op 25-11-11 13:47, han zhang schreef:
>>> Dear Bas,
>>> I followed your suggestion using inv(mat)\[1 1 1 1], but the
>>> output was a 4*1 vector, containing numbers that coundn't be voxel
>>> size:
>>> [219
>>> -156
>>> 19
>>> 1]
>>>
>>> What's wrong with my script?
>>> Han
>>> 2011/11/25 S.F.W. Neggers <[log in to unmask]
>>> <mailto:[log in to unmask]>>
>>>
>>> No this is not wrong, both SPM and MRicron are right. The
>>> diagonol is NOT necessarily equal to the voxel size (it only
>>> is for an image without any angulation). This matrix is a so
>>> called 4D affine transormation matrix, constituting the
>>> voxel-to-world matrix in the Nifti specification from NIH.
>>> Don't try to interpret it when you do not know what is
>>> represents, 4D linear algebra is not for the faint at heart
>>> ;-). See http://nifti.nimh.nih.gov/nifti-1 for more
>>> information on the nii specs.
>>>
>>> When applying a rotation matrix to the original matrix, the
>>> diagonal changes, and this is correct behavior (check your
>>> linear algebra textbooks). When you open your image in spm,
>>> the right window will compute and display the voxel size for
>>> you. This does not change after realignment.
>>>
>>> When you want to compute it yourself do:
>>>
>>> V=spm_vol(spm_select);
>>> inv(V.mat)\[1 1 1 1]'
>>>
>>> Good luck,
>>>
>>> Bas
>>>
>>>
>>> Op 25-11-11 10:56, han zhang schreef:
>>>> Hi Helen,
>>>> This problem is also bothering me. The voxel size as
>>>> indicated in the diagnal of the MAT matrix was sometimes not
>>>> in concordance with MRIcron (as seen from image 'information'
>>>> on the menu of MRIcron).
>>>> For example, my MAT matrix of a head-motion-corrected nifti
>>>> image is :
>>>> -3.4124 0 -0.72 223
>>>> -0.033 3.4263 0.4806 -159
>>>> -0.42 -0.27 5.94 14.7
>>>> The voxel size should be 3.4124* 3.4263*5.94?
>>>> However, MRIcron reported it as 3.5*3.5*7, quite different
>>>> Huh?
>>>> What I thought is that, maybe after realignment (motion
>>>> correction with rigid body transformation), the MAT file had
>>>> been changed, not as diagnal as it should be before. So the
>>>> voxel size should not be taken from the diagnal number of the
>>>> MAT file. Am I right?
>>>> Han
>>>>
>>>> 2011/11/25 Helen Beaumont
>>>> <[log in to unmask]
>>>> <mailto:[log in to unmask]>>
>>>>
>>>> Help please.
>>>>
>>>> I am writing a Matlab matrix (read from a Phillips ParRec
>>>> file) out as nii data.
>>>>
>>>> The voxel size is 3.5 x 3.5 x 5.95 mm, 64 x 64 x 20
>>>> matrix.
>>>>
>>>> N.mat is
>>>>
>>>> 3.5000 0 0 -113.7500
>>>>
>>>> 0 3.5000 0 -113.7500
>>>>
>>>> 0 0 5.9500 -62.4750
>>>>
>>>> 0 0 0 1.0000
>>>>
>>>> When I use SPM to display it, the voxel size is OK, and
>>>> origin is close to AC.
>>>>
>>>> However, if I use MRIcroN with “re-orient on load” box
>>>> checked in preferences,
>>>>
>>>> voxel size is 1 x 1 x 1 mm, and origin is bottom L corner.
>>>>
>>>> Helen Beaumont
>>>>
>>>> ISBE
>>>>
>>>> University of Manchester
>>>>
>>>> Stopford Building, Oxford Rd
>>>>
>>>> Manchester M13 9PT
>>>>
>>>> Tel: 0161 275 1259
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Han ZHANG
>>>> http://publicationslist.org/han_zhang
>>>> Center for Cognition and Brain Disorder, Hangzhou Normal
>>>> University
>>>> Addr: 7th Bldg, Affil Hosp of Hangzhou Normal Univ, Wenzhou
>>>> Rd 126#, Hangzhou 310015
>>>> Fax/Tel: +86-0571-88285651
>>>> Mobile Tel: 15869174768
>>>>
>>>
>>>
>>> --
>>> --------------------------------------------------
>>> Dr. S.F.W. Neggers
>>> Division of Brain Research
>>> Rudolf Magnus Institute for Neuroscience
>>> Utrecht University Medical Center
>>>
>>> Visiting : Heidelberglaan 100, 3584 CX Utrecht
>>> Room B.01.1.03
>>> Mail : Huispost B01.206, P.O. Box 85500
>>> 3508 GA Utrecht, the Netherlands
>>> Tel : +31 (0)88 7559609
>>> Fax : +31 (0)88 7555443
>>> E-mail :[log in to unmask]
>>> <mailto:[log in to unmask]>
>>> Web :http://www.neuromri.nl/people/bas-neggers
>>> :http://www.neuralnavigator.com
>>> <http://www.neuralnavigator.com/> (CEO)
>>> --------------------------------------------------
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> /De informatie opgenomen in dit bericht kan vertrouwelijk zijn
>>> en is uitsluitend bestemd voor de geadresseerde. Indien u dit
>>> bericht onterecht ontvangt, wordt u verzocht de inhoud niet te
>>> gebruiken en de afzender direct te informeren door het bericht
>>> te retourneren. Het Universitair Medisch Centrum Utrecht is
>>> een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
>>> (Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat
>>> geregistreerd bij de Kamer van Koophandel voor
>>> Midden-Nederland onder nr. 30244197. /
>>>
>>> /Denk s.v.p aan het milieu voor u deze e-mail afdrukt. /
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> /This message may contain confidential information and is
>>> intended exclusively for the addressee. If you receive this
>>> message unintentionally, please do not use the contents but
>>> notify the sender immediately by return e-mail. University
>>> Medical Center Utrecht is a legal person by public law and is
>>> registered at the Chamber of Commerce for Midden-Nederland
>>> under no. 30244197. /
>>>
>>> /Please consider the environment before printing this e-mail. /
>>>
>>>
>>>
>>>
>>> --
>>> Han ZHANG
>>> http://publicationslist.org/han_zhang
>>> Center for Cognition and Brain Disorder, Hangzhou Normal University
>>> Addr: 7th Bldg, Affil Hosp of Hangzhou Normal Univ, Wenzhou Rd
>>> 126#, Hangzhou 310015
>>> Fax/Tel: +86-0571-88285651
>>> Mobile Tel: 15869174768
>>>
>>
>>
>> --
>> --------------------------------------------------
>> Dr. S.F.W. Neggers
>> Division of Brain Research
>> Rudolf Magnus Institute for Neuroscience
>> Utrecht University Medical Center
>>
>> Visiting : Heidelberglaan 100, 3584 CX Utrecht
>> Room B.01.1.03
>> Mail : Huispost B01.206, P.O. Box 85500
>> 3508 GA Utrecht, the Netherlands
>> Tel : +31 (0)88 7559609
>> Fax : +31 (0)88 7555443
>> E-mail :[log in to unmask] <mailto:[log in to unmask]>
>> Web :http://www.neuromri.nl/people/bas-neggers
>> :http://www.neuralnavigator.com
>> <http://www.neuralnavigator.com/> (CEO)
>> --------------------------------------------------
>>
>>
>>
>>
>> --
>> Han ZHANG
>> http://publicationslist.org/han_zhang
>> Center for Cognition and Brain Disorder, Hangzhou Normal University
>> Addr: 7th Bldg, Affil Hosp of Hangzhou Normal Univ, Wenzhou Rd 126#,
>> Hangzhou 310015
>> Fax/Tel: +86-0571-88285651
>> Mobile Tel: 15869174768
>>
>
--
--------------------------------------------------
Dr. S.F.W. Neggers
Division of Brain Research
Rudolf Magnus Institute for Neuroscience
Utrecht University Medical Center
Visiting : Heidelberglaan 100, 3584 CX Utrecht
Room B.01.1.03
Mail : Huispost B01.206, P.O. Box 85500
3508 GA Utrecht, the Netherlands
Tel : +31 (0)88 7559609
Fax : +31 (0)88 7555443
E-mail : [log in to unmask]
Web : http://www.neuromri.nl/people/bas-neggers
: http://www.brainsciencetools.com (CEO)
--------------------------------------------------
|