[Insight-users] ImageWriter does not write Orientation(Direction
Cosines)
Stephen R. Aylward
aylward at unc.edu
Fri Jul 15 11:27:48 EDT 2005
Sorry - just catching up...
Is it or is it not working for MetaIO at this time?
Just did a cvs checkout, and reasonable code seems to be there for MetaIO...
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkMetaImageIO.cxx?root=Insight&r1=1.54&r2=1.55
Thanks Karthik !!!
Stephen
Lorensen, William E (Research) wrote:
> We should look further into this. The direction cosines should be stored as columns in the direction matrix. I thought I had verified that when I first did the implementation. Only two image io's currently support directions (nrrd and gdcmdicom). I thought I had done this correctly for dicom. The nrrd stuff is new of course. I'll look further into this.
>
> Bill
>
> -----Original Message-----
> From: insight-users-bounces+lorensen=crd.ge.com at itk.org
> [mailto:insight-users-bounces+lorensen=crd.ge.com at itk.org]On Behalf Of
> Karthik Krishnan
> Sent: Thursday, July 14, 2005 11:37 PM
> To: Gordon Kindlmann
> Cc: insight-users at itk.org; blloyd at bwh.harvard.edu
> Subject: Re: [Insight-users] ImageWriter does not write
> Orientation(Direction Cosines)
>
>
> The MetaImage reader and writers propagate direction cosine information
> now. So I think you should be able to use them fine.
>
> As Gordon mentioned, the transpose was happening outside Nrrd or the
> particular IO mechanism in question. It was due to a bug in
> itkImageFileReader.txx.
>
> This has been fixed in CVS.
>
> Thanks
> Regards
> Karthik
>
> On Thu, 2005-07-14 at 21:19 -0400, Gordon Kindlmann wrote:
>
>>hello,
>>
>>
>>>>Say I set the following direction cosines:
>>>>
>>>>0.286406 0.118831 0.950711
>>>>0.948371 -0.176269 -0.263669
>>>>0.136249 0.977143 -0.16318
>>>>
>>>>then the NRRD IO writes:
>>>>
>>>>space directions:
>>>>(0.24613,0.10212,0.817017)
>>>>(0.815007,-0.151481,-0.22659)
>>>>(0.681244,4.88571,-0.815902)
>>>>
>>>>if I read them with the NRRD IO, I read:
>>>>
>>>>0.286406 0.948371 0.136249
>>>>0.118831 -0.176269 0.977143
>>>>0.950711 -0.263668 -0.163181
>>>
>>>Hmm. Let me investigate this.
>>
>>Okay, now I have looked into this, and I am convinced that something
>>(outside NrrdIO) is transposing the direction cosines somewhere between
>>the read and write. I add some debugging code to the very end of
>>NrrdImageIO::Read like:
>>
>> std::vector<double> dir(3);
>> double spc;
>> for (unsigned int axi=0; axi < 3; axi++) {
>> spc = this->GetSpacing(axi);
>> dir = this->GetDirection(axi);
>> fprintf(stderr, "on read: dir[%d] = %g*(%g %g %g)\n", axi, spc,
>> dir[0], dir[1], dir[2]);
>> }
>>
>>and got (via "bin/itkIOTests itkNrrdImageReadWriteTest", which as far
>>as I can tell does the simplest possible sequence of reading an image
>>and immediately writing it out, with no funny business in the middle):
>>
>>on read: dir[0] = 1*(1 0 0)
>>on read: dir[1] = 1*(0.707107 0.707107 0)
>>on read: dir[2] = 1*(0 0 1)
>>
>>which, by the way, is correct given the field in the NRRD header:
>>
>> space directions: (1,0,0) (0.707107,0.707107,0) (0,0,1)
>>
>>And then, at the start of NrrdImageIO::Write, the same debugging code
>>(except for changing "read" to "write") produces:
>>
>>on write: dir[0] = 1*(1 0.707107 0)
>>on write: dir[1] = 1*(0 0.707107 0)
>>on write: dir[2] = 1*(0 0 1)
>>
>>which is wrong, and which also corresponds to the behavior Bryn
>>observed, whereby the direction cosines seem to have been transformed.
>>
>>Can someone more versed than I in the details of Image IO help resolve
>>where this transposition might be happening?
>>
>>Karthik, can you reproduce the same behavior in the orientation
>>handling that you just added to MetaIO?
>>
>>thanks,
>>Gordon
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list