<div dir='auto'><div><br><div class="gmail_extra"><br><div class="gmail_quote">On 11 May 2018 11:37 a.m., David Gobbi <david.gobbi@gmail.com> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Todd,<div><br></div><div>The DICOM patient coordinate system and the NIFTI world coordinate system both follow the right hand rule (there is a sign change along two axes, not just along one axis). </div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Ok. That makes things easy. Good to know.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> Flipping along the z axis will certainly not fix the issue.</div><div><br></div><div> - David</div></div><div><br><div class="elided-text">On Thu, May 10, 2018 at 5:26 PM, Todd <span dir="ltr"><<a href="mailto:nztoddler@yahoo.com">nztoddler@yahoo.com</a>></span> wrote:<br><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div><div><br><div><br><div class="elided-text">On 11 May 2018 5:11 a.m., David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Panos,</div><div><br></div><div>It is possible to display NIFTI and DICOM together in the same program,</div><div>but this isn't something you can achieve simply by adjusting things with</div><div>vtkImageChangeInformation or with FileLowerLeftOn().</div><div><br></div><div>Here are some key points:</div><div><br></div><div>1) NIFTI is fundamentally a 3D, volumetric, oriented image format.  In</div><div>order to properly display a NIFTI file, you must use the orientation info</div><div>embedded in the file (the sform or the qform).</div><div><br></div><div>2) DICOM is fundamentally a 2D image format, but of course the</div><div>meta-data contains info to allow DICOM images to be reconstructed</div><div>into a 3D volume and oriented in 3D space.</div><div><br></div><div>Since DICOM originated as a 2D format, you can ignore the orientation</div><div>meta-data and still display the data reasonably.  For example, if you</div><div>show an axial CT or MR head data set, you can reasonably trust that</div><div>the nose will point to the top of the image, and that the left ear will be</div><div>on the right, even without checking the ImageOrientationPatient info.</div><div><br></div><div>This is not true of NIFTI.  If you don't check the sform or the qform in</div><div>the NIFTI header, you have no way to know whether left is left or</div><div>left is right on the 2D slices, even if you know that the slices are axial.</div><div>There is no way to robustly display NIFTI with the correct orientation</div><div>unless you use the sform or qform info.</div><div><br></div><div>3) The 3D coordinate systems of DICOM and NIFTI differ. The 3D "y"</div><div>direction in NIFTI maps to the 3D "-y" direction in DICOM, and</div><div>similarly "x" maps to "-x".  Note that I'm talking about the the 3D</div><div>directions in the oriented coordinate system, I'm not talking about</div><div>the vertical or horizontal direction in the 2D coordinate system.</div><div>This isn't something that you can properly account for by flipping the</div><div>image.</div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">What you're describing here is a right-handed coordinate system for DICOM and a left-handed coordinate system for NIFTY. In that case, for consistency, it would be simpler just to flip the z axis of one data set. It doesn't really matter which is chosen, provided one is cognicient of what a positive axial rotation means in that CS.</div><div dir="auto"><br></div><div dir="auto">As an engineer I always revert to a right-handed CS, otherwise the mental gymnastics are too onerous.</div><div dir="auto"><div><div class="elided-text"><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>In order to properly map from DICOM coords to NIFTI coords, so</div><div>that you can display DICOM and NIFTI together, you should get the</div><div>orientation info from both the DICOM and the NIFTI, and you should</div><div>account for the difference in the 3D coordinate systems for each.</div><div><br></div><div>If you can be certain that the NIFTI files are from an axial scan, then</div><div>at the very least you must check the sform or qform in order to get</div><div>left/right and up/down correct.</div><div><br></div><div><br></div><div>Read everything that you can find on DICOM and NIFTI orientation,</div><div>it's a tricky subject and goes beyond what can be answered on a</div><div>mailing list.  Here's a few links:</div><div><br></div><div>Here's the Slicer page on coordinate systems:<br></div><div><a href="https://www.slicer.org/wiki/Coordinate_systems">https://www.slicer.org/wiki/<wbr>Coordinate_systems</a><br></div><div><br></div><div>The official NIFTI documentation for orientation:</div><div><a href="https://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html">https://nifti.nimh.nih.gov/<wbr>nifti-1/documentation/<wbr>nifti1fields/nifti1fields_<wbr>pages/qsform.html</a><br></div><div><br></div><div>The official DICOM documentation for orientation:</div><div><a href="http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part03/sect_C.7.6.2.html">http://dicom.nema.org/MEDICAL/<wbr>dicom/current/output/chtml/<wbr>part03/sect_C.7.6.2.html</a><br></div><div><br></div><div><div style="color:rgb( 34 , 34 , 34 );font-family:'arial' , sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">This is a program that I wrote to convert NIFTI images to DICOM,</div><div style="color:rgb( 34 , 34 , 34 );font-family:'arial' , sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">the code isn't easy to follow but it contains all the needed logic:</div><div style="color:rgb( 34 , 34 , 34 );font-family:'arial' , sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://github.com/dgobbi/vtk-dicom/blob/master/Programs/niftitodicom.cxx#L482">https://github.com/dgobbi/vtk-<wbr>dicom/blob/master/Programs/<wbr>niftitodicom.cxx#L482</a><br></div><br></div><div>Hope this helps.</div><div><br></div><div> - David</div></div>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div>