[Insight-developers] NIfTI, DiffusionTensor3D Pixels, SymmetricSecondRankTensor

Hans Johnson hans-johnson at uiowa.edu
Thu Mar 12 08:17:21 EDT 2009


Tom,

Thanks!  This will also allow symmetric matrices of any order to be stored.
I think that the current solution will only work for 3x3 matrices.

We are trying to be good citizens by addressing these NIfTI bugs/requests
from the mailing list while we were in their fixing problems that we had.  I
must admit we are doing our best to address the bugs without an explicit
local need to have this functionality.   I see a danger in doing it this way
because all the testing that Kent is doing is artificial (necessary but not
sufficient) and we have not real world cases to test with.

We would appreciate the communities help in verifying that the solutions put
in place work in the real world with real use cases.

Thanks,
Hans

-- 
Hans J. Johnson, Ph.D.
Hans-johnson at uiowa.edu

278 GH
The University of Iowa
Iowa City, IA 52241
(319) 353 8587


> From: Tom Vercauteren <tom.vercauteren at gmail.com>
> Reply-To: <tom.vercauteren at m4x.org>
> Date: Thu, 12 Mar 2009 09:11:51 +0100
> To: Kent Williams <norman-k-williams at uiowa.edu>
> Cc: ITK <insight-developers at itk.org>
> Subject: Re: [Insight-developers] NIfTI, DiffusionTensor3D Pixels,
> SymmetricSecondRankTensor
> 
> Hi Kent,
> 
> Using two loops should make it right. It would avoid constructing an
> ordering vector.
> 
> for i=0:N
>   for j=i:N
>     NIfTIPixel[j*(j+1)/2+i] = ITKPixel[j+i*(2N-i-1)/2];
>   end
> end
> 
> You might want to really check these indexes though. Anyhow it should
> be along these lines.
> 
> IIRC for a lower triangular matrix M stored in C syle order and i>=j you have
>   M(i,j) = M[ j + i(i+1)/2 ]
> 
> Similarly for an upper triangular matrix M stored in C syle order and
> j>=i you have
>   M(i,j) = M[ j + i(2N-i-1)/2 ]
> 
> Here since you have symmetric matrices you also use the fact that
> M(i,j) = M(j,i) to get things right when j>=i instead of i>=j or i>=j
> instead of j>=i.
> 
> Hope this helps,
> Tom
> 
> On Wed, Mar 11, 2009 at 21:08, kent williams
> <norman-k-williams at uiowa.edu> wrote:
>> I've managed to get myself confused and throw myself on the mercy of the
>> more mathematically inclined.
>> 
>> Luke logged this bug http://public.kitware.com/Bug/view.php?id=7485 a while
>> back.  In essence the problem is that ITK and NIfTI disagree about the order
>> of values when storing a DiffusionTensor3D, and one presumes
>> SymmetricSecondRankTensor as well. ITK stores upper-triangular and NIfTI
>> stores lower-triangular.
>> 
>> In the case of DiffusionTensor3D, a symmetric 3x3 matrix, the ordering for a
>> matrix
>> 
>> A B C
>> B D E is A B C D E F for ITK, and A B D C E F for NIfTI.
>> C E F
>> 
>> Given how the NIfTI filter works when it's copying pixels to and from ITK
>> images, I handle this with an ordering array.  In other words I have an
>> array
>>    int niftiorder[9] = { 0,1,3,2,4,5,6 };
>> and in essence, NIfTIPixel[i] = ITKPixel[order[i]];
>> 
>> That's good for DiffusionTensor3D, but the general case of
>> SymmetricSecondRankTensor is baffling me. For a 4x4 symmetric matrix
>>  int niftiorder[10] = { 0, 1, 4, 2, 5, 7, 3, 6, 8, 9 };
>> 
>> and 5x5 is even crazier.
>>  int niftiorder[15] = { 0, 1, 5, 2, 6, 9, 3, 7, 10, 2, 4, 8, 11, 13, 14 };
>> 
>> So I'm not seeing how I would go about deriving this ordering.  I.e. I don't
>> know what general purpose code would handle re-ordering the scalars from an
>> upper triangular to a lower triangular or vice verse.
>> 
>> Does anyone have a suggestion on how to go about this?
>> 
>> And while I'm on the subject, why is the VNL Symmetric Matrix lower
>> triangular, yet ITK is upper triangular?
>> 
>> 
>> 
>> 
>> 
>> Notice: This UI Health Care e-mail (including attachments) is covered by the
>> Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential
>> and may be legally privileged.  If you are not the intended recipient, you
>> are hereby notified that any retention, dissemination, distribution, or
>> copying of this communication is strictly prohibited.  Please reply to the
>> sender that you have received the message in error, then delete it.  Thank
>> you.
>> 
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list