<div dir="ltr"><div><div><div><div>Your data has a non-zero intercept:<br>(0028|1052) Rescale Intercept = 0 <br>(0028|1053) Rescale Slope = 3.010012<br><br></div>When ITK reads DICOM images it applies the slope and intercept:<br>
</div>value = slope * pixel + intercept<br><br></div><div>So a short or unsigned short cannot represent the values exactly. But that should only have a small error if you use a signed quantity like short.<br></div><div></div>
<br>If you define your image type as float, everything works correctly.<br><br></div><div>ITK seems to read and convert the data, but is not writing it correctly. <br></div><div><br></div><div>So, there does seem to be a problem with ITK, but at least for now you can declare your image type as float and all should be fine.<br>
</div><div><br></div>Bill<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 5:22 AM, Constantine Zakkaroff <span dir="ltr">&lt;<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Bill,<br>
<br>
I&#39;m wondering if you&#39;ve had a chance to try it out with the data I emailed?<br>
<br>
I&#39;ve tried it out with the &#39;Top to Bottom&#39; dataset from <a href="http://placid.nlm.nih.gov/community/21" target="_blank">http://placid.nlm.nih.gov/<u></u>community/21</a> and it all looks completely legit. But with my data it gets all screwed up... What a strange thing!<br>

<br>
Regards,<br>
Constantine<div class="im HOEnZb"><br>
<br>
<br>
<br>
On 12/08/2013 20:09, Constantine Zakkaroff wrote:<br>
</div><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Bill.<br>
<br>
OK. I actually read and write only once slice in this test.<br>
<br>
Please find it attached: MR.1.3.46.670589.11.38102.5.0.<u></u>7452.rar.<br>
<br>
I get DICOM images without extension.<br>
<br>
I&#39;m also attaching the saved file with changed intensity: file00.rar.<br>
<br>
Many thanks,<br>
Constantine<br>
<br>
On 12/08/2013 19:51, Bill Lorensen wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I also tried VTK3.20 and got the same good results.<br>
<br>
<br>
You could try one of these:<br>
<a href="http://placid.nlm.nih.gov/community/21" target="_blank">http://placid.nlm.nih.gov/<u></u>community/21</a><br>
<br>
If your data is anonymized, perhaps you can send me a link or just a few<br>
slices.<br>
<br>
Bill<br>
<br>
<br>
<br>
On Mon, Aug 12, 2013 at 2:45 PM, Constantine Z &lt;<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a><br>
&lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;&gt; wrote:<br>
<br>
     Thanks. Yes, I can see it all looks completely legit.<br>
<br>
     Perhaps I can send you my data? MR from a Philips scanner. Or maybe<br>
     on Win it might work differently?<br>
<br>
     Regards,<br>
     Constartine<br>
<br>
<br>
     On 12/08/2013 7:38 p.m., Bill Lorensen wrote:<br>
<br>
<br>
         I just tried your code on two different dicom datasets, a ct and<br>
         an mr.<br>
<br>
         Both worked for me.<br>
         ./DICOMTest ~/Data/itkTestcases/Back\ to\ Front/ .<br>
         ITK Version: 4.5<br>
         Stats for file: /home/lorensen/Data/__<u></u>itkTestcases/Back to<br>
         Front//i24389.MRDC.34<br>
         Min: 0, Max: 293, Mean: 28.7654, Sigma: 37.2513, Variance:<br>
         1387.66, Sum:<br>
         1.88517e+06<br>
         Stats for file: ./file00.dcm<br>
         Min: 0, Max: 293, Mean: 28.7654, Sigma: 37.2513, Variance:<br>
         1387.66, Sum:<br>
         1.88517e+06<br>
         [build] ./DICOMTest ~/Data/NAV/CT/ ./<br>
         ITK Version: 4.5<br>
         Stats for file: /home/lorensen/Data/NAV/CT//__<u></u>ct.1<br>
         Min: -1024, Max: 31744, Mean: 6277.24, Sigma: 13249.9, Variance:<br>
         1.75559e+08, Sum: 1.64554e+09<br>
         Stats for file: .//file00.dcm<br>
         Min: -1024, Max: 31744, Mean: 6277.24, Sigma: 13249.9, Variance:<br>
         1.75559e+08, Sum: 1.64554e+09<br>
<br>
<br>
<br>
<br>
         On Mon, Aug 12, 2013 at 11:46 AM, Constantine Zakkaroff<br>
         &lt;<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;<br>
         &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;&gt;&gt; wrote:<br>
<br>
              Hi Brad,<br>
<br>
              Yes, here&#39;s the minimal code:<br>
<br>
<br>
         ******************************<u></u>____**************************<u></u>**__**__************<br>
<br>
              #include &lt;cstdlib&gt;<br>
              #include &lt;itkImage.h&gt;<br>
              #include &lt;itkMetaImageIO.h&gt;<br>
              #include &lt;itkGDCMImageIO.h&gt;<br>
              #include &lt;itkGDCMSeriesFileNames.h&gt;<br>
              #include &lt;itkImageFileReader.h&gt;<br>
              #include &lt;itkImageFileWriter.h&gt;<br>
              #include &lt;itkStatisticsImageFilter.h&gt;<br>
<br>
              int main(int argc, char *argv[])<br>
              {<br>
                       std::clog &lt;&lt; &quot;ITK Version: &quot; &lt;&lt; ITK_VERSION_STRING &lt;&lt;<br>
              std::endl;<br>
<br>
                       typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>
                       typedef itk::Image&lt;short, 3&gt; ImageType;<br>
<br>
                       NamesGeneratorType::Pointer namesGenerator =<br>
              NamesGeneratorType::New();<br>
                       namesGenerator-&gt;____<u></u>SetUseSeriesDetails(true);<br>
                       namesGenerator-&gt;____<u></u>SetInputDirectory(argv[1]);<br>
<br>
                       typedef itk::StatisticsImageFilter&lt;___<u></u>_ImageType&gt;<br>
              StatsFilterType;<br>
                       typedef itk::ImageFileReader&lt;____<u></u>ImageType&gt;<br>
         ImageReaderType;<br>
                       typedef itk::ImageFileWriter&lt;____<u></u>ImageType&gt;<br>
         ImageWriterType;<br>
<br>
<br>
                       ImageReaderType::Pointer imageReader0 =<br>
         ImageReaderType::New();<br>
                       imageReader0-&gt;SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
                       StatsFilterType::Pointer statsFilter0 =<br>
         StatsFilterType::New();<br>
<br>
<br>
         imageReader0-&gt;SetFileName(____<u></u>namesGenerator-&gt;____<u></u>GetInputFileNames()[0]);<br>
                       statsFilter0-&gt;SetInput(____<u></u>imageReader0-&gt;GetOutput());<br>
<br>
                       statsFilter0-&gt;Update();<br>
<br>
                       std::clog &lt;&lt; &quot;Stats for file: &quot; &lt;&lt;<br>
              namesGenerator-&gt;____<u></u>GetInputFileNames()[0] &lt;&lt; std::endl;<br>
<br>
                       std::clog &lt;&lt;<br>
                               &quot;Min: &quot; &lt;&lt; statsFilter0-&gt;GetMinimum() &lt;&lt; &quot;, &quot;<br>
                               &quot;Max: &quot; &lt;&lt; statsFilter0-&gt;GetMaximum() &lt;&lt; &quot;, &quot;<br>
                               &quot;Mean: &quot; &lt;&lt; statsFilter0-&gt;GetMean() &lt;&lt; &quot;, &quot;<br>
                               &quot;Sigma: &quot; &lt;&lt; statsFilter0-&gt;GetSigma() &lt;&lt; &quot;, &quot;<br>
                               &quot;Variance: &quot; &lt;&lt;<br>
         statsFilter0-&gt;GetVariance() &lt;&lt; &quot;, &quot;<br>
                               &quot;Sum: &quot; &lt;&lt; statsFilter0-&gt;GetSum()<br>
                               &lt;&lt; std::endl;<br>
<br>
                       ImageWriterType::Pointer imageWriter0 =<br>
         ImageWriterType::New();<br>
                       imageWriter0-&gt;SetInput(____<u></u>imageReader0-&gt;GetOutput());<br>
                       imageWriter0-&gt;SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
                       std::string fileName0 = std::string(argv[2]) +<br>
         &quot;/file00.dcm&quot;;<br>
                       imageWriter0-&gt;SetFileName(____<u></u>fileName0);<br>
<br>
                       imageWriter0-&gt;Update();<br>
<br>
                       ImageReaderType::Pointer imageReader1 =<br>
         ImageReaderType::New();<br>
                       imageReader1-&gt;SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
                       StatsFilterType::Pointer statsFilter1 =<br>
         StatsFilterType::New();<br>
                       imageReader1-&gt;SetFileName(____<u></u>fileName0);<br>
                       statsFilter1-&gt;SetInput(____<u></u>imageReader1-&gt;GetOutput());<br>
<br>
                       statsFilter1-&gt;Update();<br>
<br>
                       std::clog &lt;&lt; &quot;Stats for file: &quot; &lt;&lt; fileName0 &lt;&lt;<br>
         std::endl;<br>
                       std::clog &lt;&lt;<br>
                               &quot;Min: &quot; &lt;&lt; statsFilter1-&gt;GetMinimum() &lt;&lt; &quot;, &quot;<br>
                               &quot;Max: &quot; &lt;&lt; statsFilter1-&gt;GetMaximum() &lt;&lt; &quot;, &quot;<br>
                               &quot;Mean: &quot; &lt;&lt; statsFilter1-&gt;GetMean() &lt;&lt; &quot;, &quot;<br>
                               &quot;Sigma: &quot; &lt;&lt; statsFilter1-&gt;GetSigma() &lt;&lt; &quot;, &quot;<br>
                               &quot;Variance: &quot; &lt;&lt;<br>
         statsFilter1-&gt;GetVariance() &lt;&lt; &quot;, &quot;<br>
                               &quot;Sum: &quot; &lt;&lt; statsFilter1-&gt;GetSum()<br>
                               &lt;&lt; std::endl;<br>
<br>
                       system(&quot;pause&quot;);<br>
<br>
                       return EXIT_SUCCESS;<br>
              }<br>
<br>
         ******************************<u></u>____**************************<u></u>**__**__************<br>
<br>
<br>
              Many thanks,<br>
              Constantine<br>
<br>
<br>
              On 12/08/2013 14:48, Bradley Lowekamp wrote:<br>
<br>
<br>
                  Do you have the code to share so that it can be easily<br>
         reproduced?<br>
<br>
<br>
                  Thanks,<br>
                  Brad<br>
<br>
                  On Aug 12, 2013, at 9:33 AM, Constantine Zakkaroff<br>
                  &lt;<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;<br>
         &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> &lt;mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>&gt;&gt;&gt; wrote:<br>
<br>
                      Hello ALL,<br>
<br>
                      I&#39;m wondering if anyone can explain what&#39;s going on<br>
         with the<br>
                      changing image intensities in a read-write-read<br>
         round-trip.<br>
                      I think it&#39;s a bug, but the <a href="http://issues.itk.org" target="_blank">issues.itk.org</a><br>
         &lt;<a href="http://issues.itk.org" target="_blank">http://issues.itk.org</a>&gt;<br>
                      &lt;<a href="http://issues.itk.org" target="_blank">http://issues.itk.org</a>&gt; is unresponsive at the moment.<br>
<br>
                      Another bug? ;)<br>
<br>
                      Anyhow, the strange thing is that the results for<br>
         the round<br>
                      trip read-write-read test are very different for<br>
         ITK 3.20<br>
                      and ITK 4.4.1.<br>
<br>
                      I use to StatisticsImageFilter to examine the intensity<br>
                      values. Here&#39;s what happens, when I simply read a DICOM<br>
                      image, print stats, save the image and read it again,<br>
                      followed by printing the stats:<br>
<br>
                      ITK Version: 3.20<br>
                      Stats for original file:<br>
                      Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
         Variance:<br>
                      65904.7, Sum: 1.40371e+007<br>
                      Stats for saved file:<br>
                      Min: 0, Max: 2471, Mean: 167.132, Sigma: 256.125,<br>
         Variance:<br>
                      65600.1, Sum: 1.38626e+007<br>
<br>
                      ITK Version: 4.4<br>
                      Stats for original file:<br>
                      Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
         Variance:<br>
                      65904.7, Sum: 1.40371e+007<br>
                      Stats for saved file:<br>
                      Min: 0, Max: 7446, Mean: 509.114, Sigma: 772.59,<br>
         Variance:<br>
                      596895, Sum: 4.22279e+007<br>
<br>
                      In both cases the code is identical. Just compiled<br>
         against<br>
                      different versions of ITK. The images are read and<br>
         written<br>
                      as itk::Image&lt;unsigned short, 3&gt;, with no<br>
         processing, no<br>
                      changes to any aspect of the images.<br>
<br>
                      So, ITK 3.20 introduces a small change, which I&#39;m<br>
         pretty<br>
                      sure shouldn&#39;t be there. But in ITK 4.4.1 the scale of<br>
                      intensities changes three-fold.<br>
<br>
                      I&#39;d not be surprised by a change of this magnitude<br>
         if I was<br>
                      photocopying those images, but not when using digital<br>
                      software and hardware. :^) Is there something I&#39;m not<br>
                      understanding here?<br>
<br>
                      None of this happens with<br>
                      read(DICOM)-write(MHD)-read(__<u></u>__MHD), where the<br>
         original and<br>
<br>
                      round-trip values are identical:<br>
                      Stats for saved file: file0.mhd<br>
                      Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
         Variance:<br>
                      65904.7, Sum: 1.40371e+007<br>
<br>
                      Many thanks,<br>
                      Constantine<br>
<br>
                      ______________________________<u></u>___________<br>
<br>
                      Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> &lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
         &lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
<br>
                      Visit other Kitware open-source projects at<br>
         <a href="http://www.kitware.com/____opensource/opensource.html" target="_blank">http://www.kitware.com/____<u></u>opensource/opensource.html</a><br>
         &lt;<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a>&gt;<br>
<br>
<br>
         &lt;<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a><br>
         &lt;<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a>&gt;&gt;<br>
<br>
                      Kitware offers ITK Training Courses, for more<br>
         information visit:<br>
         <a href="http://www.kitware.com/____products/protraining.php" target="_blank">http://www.kitware.com/____<u></u>products/protraining.php</a><br>
         &lt;<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a>&gt;<br>
<br>
                      &lt;<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a><br>
         &lt;<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<u></u>products/protraining.php</a>&gt;&gt;<br>
<br>
                      Please keep messages on-topic and check the ITK FAQ at:<br>
         <a href="http://www.itk.org/Wiki/ITK_____FAQ" target="_blank">http://www.itk.org/Wiki/ITK___<u></u>__FAQ</a><br>
         &lt;<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a>&gt;<br>
<br>
                      &lt;<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a><br>
         &lt;<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<u></u>FAQ</a>&gt;&gt;<br>
<br>
                      Follow this link to subscribe/unsubscribe:<br>
         <a href="http://www.itk.org/mailman/____listinfo/insight-users" target="_blank">http://www.itk.org/mailman/___<u></u>_listinfo/insight-users</a><br>
         &lt;<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a>&gt;<br>
<br>
         &lt;<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a><br>
         &lt;<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/<u></u>listinfo/insight-users</a>&gt;&gt;<br>
<br>
<br>
              ______________________________<u></u>___________<br>
<br>
              Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> &lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
         &lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
<br>
              Visit other Kitware open-source projects at<br>
         <a href="http://www.kitware.com/____opensource/opensource.html" target="_blank">http://www.kitware.com/____<u></u>opensource/opensource.html</a><br>
         &lt;<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a>&gt;<br>
<br>
              &lt;<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a><br>
         &lt;<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a>&gt;&gt;<br>
<br>
              Kitware offers ITK Training Courses, for more information<br>
         visit:<br>
         <a href="http://www.kitware.com/____products/protraining.php" target="_blank">http://www.kitware.com/____<u></u>products/protraining.php</a><br>
         &lt;<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a>&gt;<br>
<br>
              &lt;<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a><br>
         &lt;<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<u></u>products/protraining.php</a>&gt;&gt;<br>
<br>
              Please keep messages on-topic and check the ITK FAQ at:<br>
         <a href="http://www.itk.org/Wiki/ITK_____FAQ" target="_blank">http://www.itk.org/Wiki/ITK___<u></u>__FAQ</a><br>
         &lt;<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a>&gt;<br>
         &lt;<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a><br>
         &lt;<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<u></u>FAQ</a>&gt;&gt;<br>
<br>
<br>
              Follow this link to subscribe/unsubscribe:<br>
         <a href="http://www.itk.org/mailman/____listinfo/insight-users" target="_blank">http://www.itk.org/mailman/___<u></u>_listinfo/insight-users</a><br>
         &lt;<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a>&gt;<br>
<br>
              &lt;<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a><br>
         &lt;<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/<u></u>listinfo/insight-users</a>&gt;&gt;<br>
<br>
<br>
<br>
<br>
         --<br>
         Unpaid intern in BillsBasement at noware dot com<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</blockquote></blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>