[Insight-users] accessing the HEADER of a DICOM file

Evelyne Balteau e . balteau at ulg . ac . be
Fri, 12 Sep 2003 17:44:28 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_00B1_01C37955.83676BC0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_00B2_01C37955.83676BC0"


------=_NextPart_001_00B2_01C37955.83676BC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Here you are !!
That is just a simple adaptation from the itkDICOMImageSeriesTest (I am =
just beginning with all that stuff, so it is supposed to be simple:-))
I didn't change anything for the DICOM reader part... The test worked =
fine !!
For viewing you need to link the OpenGL and the FLTK libraries...

Hope it helps...

Anyway... I still have a problem about the DICOM headers...
Has anyone an idea that could help me ????

Evelyne

  ----- Original Message -----=20
  From: jiang=20
  To: Evelyne Balteau=20
  Cc: ITK=20
  Sent: Friday, September 12, 2003 5:09 PM
  Subject: AW: [Insight-users] accessing the HEADER of a DICOM file


  Hi Evelyne,
  You said your code based on itkDICOMImageSeriesTest can build a 3D =
volume from a series of DICOM files...
  However I tried to do the same work as you but always failed. Can you =
give me your code that I can learn how to build a 3D volume from a =
series of DICOM files.
  Thank you very much!


  Chunyan
    -----Urspr=FCngliche Nachricht-----
    Von: insight-users-admin at itk . org =
[mailto:insight-users-admin at itk . org]Im Auftrag von Evelyne Balteau
    Gesendet: Mittwoch, 10. September 2003 16:38
    An: insight-users at itk . org
    Betreff: [Insight-users] accessing the HEADER of a DICOM file


    Hello !

    I have written a code based on the GLSliceView.h header =
(InsightApplications) and=20
    the itkDICOMImageSeriesTest, to view slices of a 3D volume from a =
series of DICOM files...
    I successfully tested it on a wide range of (magnitude) images, but =
I had some problems with phase data.
    I finally found the solution : the phase data are "rescaled" by =
substracting 4096 and multiplying by 2 (keeping unsigned short type) !!!
    Well...
    To write a code that could take this into account WHEN REQUIRED (for =
phase but not for magnitude images), I need to access the header of the =
DICOM files.
    There are two fields (RescaleIntercept=3D-4096 and RescaleSlope=3D2) =
in this header giving informations on the rescaling factors.
    I could read it with matlab, but I don't know how to do with ITK...
    Is there some method to do so ??

    Thanks for any help !!

    Evelyne
------=_NextPart_001_00B2_01C37955.83676BC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Here you are !!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>That is just a simple adaptation from =
the=20
itkDICOMImageSeriesTest (<FONT face=3DArial size=3D2>I am just beginning =
with all=20
that stuff, so it is supposed to be simple:-))</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I didn't change anything for the DICOM =
reader=20
part... The test worked fine !!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For viewing y</FONT><FONT face=3DArial =
size=3D2>ou need=20
to link the OpenGL and the FLTK libraries...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Hope it helps...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway... I still have a problem about =
the DICOM=20
headers...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Has anyone an idea that could help me=20
????</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Evelyne</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Djiang at TI . Uni-Trier . DE =
href=3D"mailto:jiang at TI . Uni-Trier . DE">jiang</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3De . balteau at ulg . ac . be=20
  href=3D"mailto:e . balteau at ulg . ac . be">Evelyne Balteau</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Cc:</B> <A =
title=3Dinsight-users at itk . org=20
  href=3D"mailto:insight-users at itk . org">ITK</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, September 12, =
2003 5:09=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> AW: [Insight-users] =
accessing=20
  the HEADER of a DICOM file</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT><BR></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D453080615-12092003>Hi=20
  Evelyne,</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D453080615-12092003>You=20
  said your code based on itkDICOMImageSeriesTest can build a 3D volume =
from a=20
  series of DICOM files...</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D453080615-12092003>However I tried to do the same work as you =
but always=20
  failed. Can you give me your code that I can learn how to build a 3D =
volume=20
  from a series of DICOM files.</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D453080615-12092003>Thank you very much!</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D453080615-12092003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D453080615-12092003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D453080615-12092003>Chunyan</SPAN></FONT></DIV>
  <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
    <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
    size=3D2>-----Urspr=FCngliche Nachricht-----<BR><B>Von:</B> <A=20
    =
href=3D"mailto:insight-users-admin at itk . org">insight-users-admin at itk . org</=
A>=20
    [mailto:insight-users-admin at itk . org]<B>Im Auftrag von </B>Evelyne=20
    Balteau<BR><B>Gesendet:</B> Mittwoch, 10. September 2003 =
16:38<BR><B>An:</B>=20
    insight-users at itk . org<BR><B>Betreff:</B> [Insight-users] accessing =
the=20
    HEADER of a DICOM file<BR><BR></FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>Hello !</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>I have written a code based on the=20
    GLSliceView.h header (InsightApplications) and </FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>the itkDICOMImageSeriesTest, to =
view slices of=20
    a 3D volume from a series of DICOM files...</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>I successfully tested it on a wide =
range of=20
    (magnitude) images, but I had some problems with phase =
data.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>I finally found the solution : the =
phase data=20
    are "rescaled" by substracting 4096 and multiplying by 2 (keeping =
unsigned=20
    short type) !!!</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>Well...</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>To write a code that could take =
this into=20
    account WHEN REQUIRED (for phase but not for magnitude images), I =
need to=20
    access the header of the DICOM files.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>There are two fields =
(RescaleIntercept=3D-4096=20
    and RescaleSlope=3D2) in this header giving informations on the =
rescaling=20
    factors.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>I could read it with matlab, but I =
don't know=20
    how to do with ITK...</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>Is there some method to do so =
??</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Thanks for any help !!</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial=20
size=3D2>Evelyne</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_001_00B2_01C37955.83676BC0--

------=_NextPart_000_00B1_01C37955.83676BC0
Content-Type: application/octet-stream;
	name="itkDICOMImageSeriesTest.cxx"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="itkDICOMImageSeriesTest.cxx"

/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
=0A=
 ...based on the itkDICOMImageSeriesTest...=0A=
=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/=0A=
#if defined(_MSC_VER)=0A=
#pragma warning ( disable : 4786 )=0A=
#endif=0A=
#include "itkDICOMImageIO2Factory.h"=0A=
#include "itkDICOMImageIO2.h"
#include "itkImageSeriesReader.h"=0A=
#include "itkDICOMSeriesFileNames.h"
#include "SliceView.h"
#include "GLSliceView.h"
#include <FL/Fl_Window.H>

int main(int ac, char* av[])=0A=
{=0A=
=0A=
  if(ac < 3)=0A=
  {=0A=
    std::cerr << "Usage: " << av[0] << " DicomDirectory =
ReverseOrder(0/1)\n";=0A=
    return EXIT_FAILURE;=0A=
  }=0A=
=0A=
  typedef itk::Image<unsigned short,3> DICOMImageType;=0A=
  typedef itk::ImageSeriesReader<DICOMImageType> ReaderType;=0A=
  typedef =
itk::GLSliceView<DICOMImageType::PixelType,DICOMImageType::PixelType> =
ViewerType;
  typedef itk::ImageRegionIterator<DICOMImageType> IteratorType;

  itk::DICOMImageIO2::Pointer io =3D itk::DICOMImageIO2::New();=0A=
=0A=
  // Get the DICOM filenames from the directory=0A=
  itk::DICOMSeriesFileNames::Pointer names =3D =
itk::DICOMSeriesFileNames::New();=0A=
  names->SetDirectory(av[1]);=0A=
  =0A=
  ReaderType::Pointer reader =3D ReaderType::New();=0A=
  reader->SetFileNames(names->GetFileNames());=0A=
  reader->SetImageIO(io);=0A=
  std::cout << names;=0A=
=0A=
  try=0A=
    {=0A=
    if (atoi(av[2]))=0A=
      {=0A=
      reader->ReverseOrderOn();=0A=
      }=0A=
    reader->Update();=0A=
    reader->GetOutput()->Print(std::cout);=0A=
    }=0A=
  catch (itk::ExceptionObject &ex)=0A=
    {=0A=
    std::cout << ex;=0A=
    return EXIT_FAILURE;=0A=
    }=0A=

 =20
  // this is to get the right values from phase image...
  // ...not necessary for simple magnitude images=20
  DICOMImageType::Pointer image =3D reader->GetOutput();
  /*IteratorType it( image,image->GetLargestPossibleRegion() );
  for ( it.GoToBegin();!it.IsAtEnd(); ){
	  it.Set( (unsigned short(it.Get()+4096))/2 );
	  ++it;
  };*/


  //...create a main window for viewing, and a SliceViewer...
  Fl_Window main_window( 20, 20, 800, 800, "SliceView" );
  ViewerType viewer =3D ViewerType( 20, 20, 760, 760, "Test_DICOM_3D");
  main_window.add_resizable( viewer );
  main_window.show();

  viewer.SetInputImage( image );
  viewer.show();
 =20
  Fl::run();

  return EXIT_SUCCESS;=0A=
=0A=
}=0A=

------=_NextPart_000_00B1_01C37955.83676BC0--