Karthik,<br>
<br>
Thanks for this information! My suggestion is to have some kind of
warning message being written when that I/O function is called. Believe
me, it can help avoid a lot of confusion late at night.<br>
<br>
Thanks again,<br><br><div><span class="gmail_quote">On 12/9/05, <b class="gmail_sendername">Karthik Krishnan</b> &lt;<a href="mailto:Karthik.Krishnan@kitware.com">Karthik.Krishnan@kitware.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for verifying. And please ignore the previous mail.<br><br>I don't know if there is a way to specify an origin in Analyse files.<br>This might be a limitation of the file format itself.<br><br> From<br><a href="http://www.mayo.edu/bir/PDF/ANALYZE75.pdf">
http://www.mayo.edu/bir/PDF/ANALYZE75.pdf</a><br>there seems to be no field to specify the origin. The example provided<br>above does not consider it either..<br><br>In fact other software tools like SPM adopt their own heuristics:
<br><br>(From <a href="http://www.mrc-cbu.cam.ac.uk/Imaging/Common/analyze_fmt.shtml">http://www.mrc-cbu.cam.ac.uk/Imaging/Common/analyze_fmt.shtml</a>)<br><br>&quot;SPM modifications of the basic analyze format&quot;<br>
<br>The image origin is specified in the Originator field<br>(data_history.originator - see Mayo/Analyze site). In the basic format,<br>this is meant to be 10 bytes of text. In SPM, this space is used to<br>contain three short (two byte) integers. These numbers describe the
<br>current centre or 'Origin' of the image. Specifically, they give the<br>coordinate of the central voxel, in voxels, in X, then Y then Z. For<br>example, for images that are aligned to the templates, this Origin field<br>
would contain the coordinates of the voxel nearest to the midline of the<br>Anterior Commisure. Note that if the Origin is set to 0 0 0, then SPM<br>routines will assume that the origin is in fact the central voxel of the
<br>image.&quot;<br><br>Thanks<br>Regards<br>karthik<br><br><br><br><br>Gheorghe Postelnicu wrote:<br><br>&gt; Actually I manually created the image (using the RawImageIO) and then<br>&gt; opted at first for .img extension when I was writing the file.
<br>&gt;<br>&gt; Here is my code :<br>&gt;<br>&gt;<br>&gt; -----<br>&gt; template&lt;class T&gt;<br>&gt; static void<br>&gt; convert(VolumePars pars)<br>&gt; {<br>&gt;<br>&gt;&nbsp;&nbsp; // declare types<br>&gt;<br>&gt;&nbsp;&nbsp; typedef T PixelType;
<br>&gt;&nbsp;&nbsp; typedef typename itk::Image&lt;PixelType,Dimension&gt; ImageType;<br>&gt;&nbsp;&nbsp; typedef typename itk::RawImageIO&lt;PixelType,Dimension&gt; ImageIOType;<br>&gt;&nbsp;&nbsp; typedef typename itk::ImageFileReader&lt;ImageType&gt; ReaderType;
<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; typename ReaderType::Pointer reader = ReaderType::New();<br>&gt;&nbsp;&nbsp; typename ImageIOType::Pointer rawIO = ImageIOType::New();<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetFileDimensionality(3);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetOrigin(0, 
pars.originX);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetOrigin(1, pars.originY);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetOrigin(2, pars.originZ);<br>&gt;<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetDimensions(0, pars.dimX);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetDimensions(1, pars.dimY);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetDimensions(2, 
pars.dimZ);<br>&gt;<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetSpacing(0, pars.spacingX);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetSpacing(1, pars.spacingY);<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetSpacing(2, pars.spacingZ);<br>&gt;<br>&gt;&nbsp;&nbsp; rawIO-&gt;SetByteOrderToLittleEndian();
<br>&gt;<br>&gt;&nbsp;&nbsp; reader-&gt;SetFileName(pars.inputBuffer.c_str());<br>&gt;&nbsp;&nbsp; reader-&gt;SetImageIO( rawIO );<br>&gt;<br>&gt;&nbsp;&nbsp; try { reader-&gt;Update(); } catch(itk::ExceptionObject&amp; excp)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Exception caught while reading file &quot; &lt;&lt;
<br>&gt; reader-&gt;GetFileName() &lt;&lt; std::endl<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; excp &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp; std::cout &lt;&lt; &quot;done reading RAW image PARAMETERS\n&quot;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; &quot;sizes = &quot; &lt;&lt;<br>&gt; reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize() &lt;&lt; std::endl<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;&lt; &quot;origin = &quot; &lt;&lt; reader-&gt;GetOutput()-&gt;GetOrigin()
&lt;&lt; std::endl<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;&lt; &quot;spacing = &quot; &lt;&lt;
reader-&gt;GetOutput()-&gt;GetSpacing()&nbsp;&nbsp;&lt;&lt;<br>&gt; std::endl;<br>&gt;<br>&gt;&nbsp;&nbsp; typedef typename itk::ImageFileWriter&lt;ImageType&gt; WriterType;<br>&gt;&nbsp;&nbsp; typename WriterType::Pointer writer = WriterType::New();
<br>&gt;<br>&gt;&nbsp;&nbsp; writer-&gt;SetFileName(pars.outputFileName.c_str());<br>&gt;&nbsp;&nbsp; writer-&gt;SetInput(reader-&gt;GetOutput());<br>&gt;&nbsp;&nbsp; try { writer-&gt;Update(); } catch(itk::ExceptionObject&amp; excp)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Exception caught while writing\n&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; excp &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt; }<br>&gt;<br>&gt; ------<br>&gt;<br>&gt; As you can see, the origin of the image is displayed before the image
<br>&gt; is saved.<br>&gt;<br>&gt; After noticing that I had some placement problems, I wrote another<br>&gt; binary which was just loading an image in ITK and displaying the<br>&gt; information. When using the .img extension, the origin information was
<br>&gt; lost.<br>&gt;<br>&gt; I looked very briefly in the itkAnalyzeImageIO.cxx file and it appears<br>&gt; some origin information is written in some metadata associated with<br>&gt; the image. I have seen on the internet some proposal to include
<br>&gt; orientation information which used the same mechanism.<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; On 12/9/05, *Karthik Krishnan* &lt;<a href="mailto:Karthik.Krishnan@kitware.com">Karthik.Krishnan@kitware.com</a><br>
&gt; &lt;mailto:<a href="mailto:Karthik.Krishnan@kitware.com">Karthik.Krishnan@kitware.com</a>&gt;&gt; wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Please let us know what format you converted from ? The bug might be<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; that the origin data was never read in .
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; I've written analyse images in ITK before and they seem to retain the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; origin information.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; I have observed that InsightApplications/ImageViewer does not respect<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; image origins when it reads files. So are you basing your
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; assumptions on<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; images seen using ImageViewer ? If you use any of the several other<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; viewers, you should find that the origin info is recorded.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; thanks<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; karthik
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Gheorghe Postelnicu wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Hi,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I have recently used ITK to convert some files to the Analyze format<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; and I have noticed that the origin data is lost when writing the
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; volume file. I haven't gone further than this, but is this normal?<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; As far as I am concerned, this is quite annoying when doing<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; registration.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Thanks,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; --<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Gheorghe Postelnicu, PhD<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; MGH, Harvard Medical School<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;------------------------------------------------------------------------
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;_______________________________________________<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;Insight-users mailing list<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a> &lt;mailto:<a href="mailto:Insight-users@itk.org">
Insight-users@itk.org</a>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;<br>&gt;<br>&gt;<br>
&gt;<br>&gt; --<br>&gt; Gheorghe Postelnicu, PhD<br>&gt; MGH, Harvard Medical School<br>&gt;<br>&gt;------------------------------------------------------------------------<br>&gt;<br>&gt;_______________________________________________
<br>&gt;Insight-users mailing list<br>&gt;<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>&gt;<a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users
</a><br>&gt;<br>&gt;<br></blockquote></div><br><br clear="all"><br>-- <br>Gheorghe Postelnicu, PhD<br>MGH, Harvard Medical School