GDCM_NAME_SPACE::Orientation Class Reference

Orientation class for dealing with DICOM image orientation. More...

#include <gdcmOrientation.h>

Inheritance diagram for GDCM_NAME_SPACE::Orientation:

Inheritance graph
[legend]
Collaboration diagram for GDCM_NAME_SPACE::Orientation:

Collaboration graph
[legend]
List of all members.

Public Member Functions

OrientationType GetOrientationType (File *file)
 returns of the most similar basic orientation (Axial, Coronal, Sagital, ...) of the image
std::string GetOrientation (File *file)
 Computes the Patient Orientation relative to the image plane from the 'Image Orientation (Patient)'
  • or from 0020 0035Image Orientation (RET) -
  • The first entry is the direction of the rows, given by the direction of the last pixel in the first row from the first pixel in that row.
  • The second entry is the direction of the columns, given by the direction of the last pixel in the first column from the first pixel in that column. Anatomical direction is designated by the capital letters: A (anterior), P (posterior), R (right),L (left), H (head), F (foot).
  • Refinements in the orientation descriptions are designated by one or two additional letters in each value. Use it when "Patient Orientation" (0020,0020) is not found.

void Delete ()
 Delete the object.
void Register ()
 Register the object.
void Unregister ()
 Unregister the object.
const unsigned long & GetRefCount () const
 Get the reference counting.
virtual void Print (std::ostream &=std::cout, std::string const &="")
 Printer.
void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Static Public Member Functions

static OrientationNew ()
 Constructs a gdcm::Orientation with a RefCounter.
static const char * GetOrientationTypeString (OrientationType const o)
 returns human readable interpretation of the most similar basic orientation (Axial, Coronal, Sagital, ...) of the image

Protected Member Functions

 Orientation ()
 Constructor.
 ~Orientation ()
 Canonical Destructor.

Protected Attributes

int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 gdcmTypeMacro (Orientation)
Res VerfCriterion (int typeCriterion, double criterionNew, Res const &res)
double CalculLikelyhood2Vec (vector3D const &refA, vector3D const &refB, vector3D const &ori1, vector3D const &ori2)
vector3D ProductVectorial (vector3D const &vec1, vector3D const &vec2)
std::string GetSingleOrientation (float *iop)

Detailed Description

Orientation class for dealing with DICOM image orientation.

A gentle reminder for non-medical user: PatientPosition (0x0010,0x5100) tells us the way the patient was introduced in the imager

ImageOrientationPatient (0x0020,0x0037) gives 6 cosines (2 for each plane) Patient Orientation (as found in the optional 0x0020,0x0020, or computed by std::string Orientation::GetOrientation ( File *f ), tells us about the direction of X and Y axes.

The values can be

Example #1: Imagine the patient, in "HFS" position. Full body sagital images are requested. All the cosines will be -1, 0, or +1; "Patient Orientation" (deduced) will be "A/F". Positive X axis is oriented 'towards patient's nose Positive Y axis is oriented 'towards patient's feet

Example #2: Imagine now that patient has a stiffneck and his head is *turned* 30 degrees towards the left. Head sagital images are requested. One of the cosines will be almost 0.5 Deduced "Patient Orientation" will be "AL\F" (main X axis orientation is towards patient's nose, and a little bit towards the left) but the image looks *perfectly* sagital (for the head, not for the patient) !

Imagine the patient's stiffneck causes head to be *bended* 30 degrees towards the left AND *turned* left. Sagital images are requested... You'll probabely have 3 letters for X axis and Y axis, and the image remains *perfectly* sagital ! The values are given within the 'Patient referential', *not* within the 'Organ referential' ...

Definition at line 98 of file gdcmOrientation.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::Orientation::Orientation  )  [inline, protected]
 

Constructor.

Definition at line 112 of file gdcmOrientation.h.

00112 {}

GDCM_NAME_SPACE::Orientation::~Orientation  )  [inline, protected]
 

Canonical Destructor.

Definition at line 114 of file gdcmOrientation.h.

00114 {}


Member Function Documentation

double GDCM_NAME_SPACE::Orientation::CalculLikelyhood2Vec vector3D const &  refA,
vector3D const &  refB,
vector3D const &  ori1,
vector3D const &  ori2
[private]
 

Definition at line 180 of file gdcmOrientation.cxx.

References ProductVectorial(), and GDCM_NAME_SPACE::square_dist().

Referenced by GetOrientationType().

00182 {
00183 
00184    vector3D ori3 = ProductVectorial(ori1,ori2);
00185    vector3D refC = ProductVectorial(refA,refB);
00186    double res = square_dist(refC, ori3);
00187 
00188    return sqrt(res);
00189 }

void GDCM_NAME_SPACE::RefCounter::Delete  )  [inline, inherited]
 

Delete the object.

Remarks:
The object is deleted only if its reference counting is to zero

Definition at line 41 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::SerieHelper::AddFileName(), GDCM_NAME_SPACE::Document::Backtrack(), GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements(), GDCM_NAME_SPACE::FileHelper::CheckMandatoryEntry(), GDCM_NAME_SPACE::FileHelper::CopyMandatoryEntry(), GDCM_NAME_SPACE::Dict::DoTheLoadingJob(), GDCM_NAME_SPACE::FillDefaultDataDict(), GDCM_NAME_SPACE::DicomDirObject::FillObject(), vtkGdcmReader::GetFileInformation(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryBinArea(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::DocEntrySet::InsertSeqEntry(), vtkGdcmReader::LoadFileInformation(), GDCM_NAME_SPACE::DicomDir::NewMeta(), GDCM_NAME_SPACE::DicomDirStudy::NewVisit(), GDCM_NAME_SPACE::Document::ReadNextDocEntry(), GDCM_NAME_SPACE::DicomDir::SetElement(), GDCM_NAME_SPACE::FileHelper::SetMandatoryEntry(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToExplicitVR(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToImplicitVR(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG2000(), GDCM_NAME_SPACE::FileHelper::SetWriteToLibido(), GDCM_NAME_SPACE::DicomDir::~DicomDir(), GDCM_NAME_SPACE::DictSet::~DictSet(), and GDCM_NAME_SPACE::Global::~Global().

00041 { Unregister(); }

GDCM_NAME_SPACE::Orientation::gdcmTypeMacro Orientation   )  [private]
 

std::string GDCM_NAME_SPACE::Orientation::GetOrientation File f  ) 
 

Computes the Patient Orientation relative to the image plane from the 'Image Orientation (Patient)'

  • or from 0020 0035Image Orientation (RET) -
  • The first entry is the direction of the rows, given by the direction of the last pixel in the first row from the first pixel in that row.
  • The second entry is the direction of the columns, given by the direction of the last pixel in the first column from the first pixel in that column. Anatomical direction is designated by the capital letters: A (anterior), P (posterior), R (right),L (left), H (head), F (foot).
  • Refinements in the orientation descriptions are designated by one or two additional letters in each value. Use it when "Patient Orientation" (0020,0020) is not found.

Returns:
orientation string as "rowsOrientation\columnsOrientation"

Definition at line 294 of file gdcmOrientation.cxx.

References GDCM_NAME_SPACE::GDCM_UNFOUND, GDCM_NAME_SPACE::File::GetImageOrientationPatient(), and GetSingleOrientation().

00295 {
00296    float iop[6];
00297    if ( !f->GetImageOrientationPatient( iop ) )
00298    return GDCM_UNFOUND;
00299 
00300    std::string orientation;
00301    orientation = GetSingleOrientation ( iop ) 
00302                + "\\" 
00303                + GetSingleOrientation ( iop + 3 );
00304    return orientation;
00305 }

OrientationType GDCM_NAME_SPACE::Orientation::GetOrientationType File file  ) 
 

returns of the most similar basic orientation (Axial, Coronal, Sagital, ...) of the image

Definition at line 85 of file gdcmOrientation.cxx.

References CalculLikelyhood2Vec(), gdcmWarningMacro, GDCM_NAME_SPACE::File::GetImageOrientationPatient(), GDCM_NAME_SPACE::NotApplicable, VerfCriterion(), GDCM_NAME_SPACE::vector3D::x, GDCM_NAME_SPACE::vector3D::y, and GDCM_NAME_SPACE::vector3D::z.

00086 {
00087    float iop[6];
00088    bool succ = f->GetImageOrientationPatient( iop );
00089    if ( !succ )
00090    {
00091       gdcmWarningMacro( "No Image Orientation (0020,0037)/(0020,0032) found in the file, cannot proceed." )
00092       return NotApplicable;
00093    }
00094    vector3D ori1;
00095    vector3D ori2;
00096 
00097    ori1.x = iop[0]; ori1.y = iop[1]; ori1.z = iop[2]; 
00098    ori2.x = iop[3]; ori2.y = iop[4]; ori2.z = iop[5];
00099 
00100    // two perpendicular vectors describe one plane
00101    double dicPlane[6][2][3] =
00102    { {  { 1,   0,    0   },{ 0,      1,     0     }  }, // Axial
00103      {  { 1,   0,    0   },{ 0,      0,    -1     }  }, // Coronal
00104      {  { 0,   1,    0   },{ 0,      0,    -1     }  }, // Sagittal
00105      {  { 0.8, 0.5,  0.0 },{-0.1,    0.1 , -0.95  }  }, // Axial - HEART
00106      {  { 0.8, 0.5,  0.0 },{-0.6674, 0.687, 0.1794}  }, // Coronal - HEART
00107      {  {-0.1, 0.1, -0.95},{-0.6674, 0.687, 0.1794}  }  // Sagittal - HEART
00108    };
00109 
00110    vector3D refA;
00111    vector3D refB;
00112    int i = 0;
00113    Res res;   // [ <result> , <memory of the last succes calcule> ]
00114    res.first = 0;
00115    res.second = 99999;
00116 
00117    for (int numDicPlane=0; numDicPlane<6; numDicPlane++)
00118    {
00119        ++i;
00120        // refA=plane[0]
00121        refA.x = dicPlane[numDicPlane][0][0]; 
00122        refA.y = dicPlane[numDicPlane][0][1]; 
00123        refA.z = dicPlane[numDicPlane][0][2];
00124        // refB=plane[1]
00125        refB.x = dicPlane[numDicPlane][1][0]; 
00126        refB.y = dicPlane[numDicPlane][1][1]; 
00127        refB.z = dicPlane[numDicPlane][1][2];
00128        res=VerfCriterion(  i, CalculLikelyhood2Vec(refA,refB,ori1,ori2), res );
00129        res=VerfCriterion( -i, CalculLikelyhood2Vec(refB,refA,ori1,ori2), res );
00130    }
00131    // res thought looks like is a float value, but is indeed an int
00132    // try casting it to int first then enum value to please VS7:
00133    int int_res = (int)res.first;
00134    gdcmAssertMacro( int_res <= 6 && int_res >= -6);
00135    return (OrientationType)int_res;
00136 }

const char * GDCM_NAME_SPACE::Orientation::GetOrientationTypeString OrientationType const   o  )  [static]
 

returns human readable interpretation of the most similar basic orientation (Axial, Coronal, Sagital, ...) of the image

Definition at line 74 of file gdcmOrientation.cxx.

References GDCM_NAME_SPACE::OrientationTypeStrings.

00075 {
00076   int k = (int)o;
00077   if (k < 0) 
00078        k = -k + 6;
00079 
00080   return OrientationTypeStrings[k];
00081 }

int GDCM_NAME_SPACE::Base::GetPrintLevel  )  [inline, inherited]
 

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

const unsigned long& GDCM_NAME_SPACE::RefCounter::GetRefCount  )  const [inline, inherited]
 

Get the reference counting.

Returns:
Reference count

Definition at line 59 of file gdcmRefCounter.h.

00060    {
00061       return RefCount;
00062    }

std::string GDCM_NAME_SPACE::Orientation::GetSingleOrientation float *  iop  )  [private]
 

Definition at line 308 of file gdcmOrientation.cxx.

Referenced by GetOrientation().

00309 {
00310    std::string orientation;
00311 
00312    char orientationX = iop[0] < 0 ? 'R' : 'L';
00313    char orientationY = iop[1] < 0 ? 'A' : 'P';
00314    char orientationZ = iop[2] < 0 ? 'F' : 'H';
00315 
00316    double absX = iop[0];
00317    if (absX < 0) absX = -absX;
00318       double absY = iop[1];
00319    if (absY < 0) absY = -absY;
00320       double absZ = iop[2];
00321    if (absZ < 0) absZ = -absZ;
00322 
00323    for (int i=0; i<3; ++i) 
00324    {
00325       if (absX>.0001 && absX>absY && absX>absZ) 
00326       {
00327          orientation = orientation + orientationX;
00328          absX=0;
00329        }
00330        else if (absY>.0001 && absY>absX && absY>absZ) 
00331        {
00332           orientation = orientation + orientationY;
00333           absY=0;
00334        }
00335        else if (absZ>.0001 && absZ>absX && absZ>absY) 
00336        {
00337            orientation = orientation + orientationZ;
00338            absZ=0;
00339        }
00340        else 
00341           break;
00342      }
00343    return orientation;
00344 } 

static Orientation* GDCM_NAME_SPACE::Orientation::New  )  [inline, static]
 

Constructs a gdcm::Orientation with a RefCounter.

Definition at line 103 of file gdcmOrientation.h.

00103 {return new Orientation();}

virtual void GDCM_NAME_SPACE::Base::Print std::ostream &  = std::cout,
std::string const &  = ""
[inline, virtual, inherited]
 

Printer.

Reimplemented in GDCM_NAME_SPACE::CommandManager, GDCM_NAME_SPACE::DataEntry, GDCM_NAME_SPACE::DicomDir, GDCM_NAME_SPACE::DicomDirElement, GDCM_NAME_SPACE::DicomDirImage, GDCM_NAME_SPACE::DicomDirMeta, GDCM_NAME_SPACE::DicomDirPatient, GDCM_NAME_SPACE::DicomDirPrivate, GDCM_NAME_SPACE::DicomDirSerie, GDCM_NAME_SPACE::DicomDirStudy, GDCM_NAME_SPACE::DicomDirVisit, GDCM_NAME_SPACE::DicomEntry, GDCM_NAME_SPACE::Dict, GDCM_NAME_SPACE::DictEntry, GDCM_NAME_SPACE::DictGroupName, GDCM_NAME_SPACE::DictSet, GDCM_NAME_SPACE::DirList, GDCM_NAME_SPACE::DocEntry, GDCM_NAME_SPACE::ElementSet, GDCM_NAME_SPACE::FileHelper, GDCM_NAME_SPACE::JPEGFragment, GDCM_NAME_SPACE::PixelReadConvert, GDCM_NAME_SPACE::RLEFrame, GDCM_NAME_SPACE::SeqEntry, GDCM_NAME_SPACE::SerieHelper, GDCM_NAME_SPACE::SQItem, and GDCM_NAME_SPACE::VR.

Definition at line 42 of file gdcmBase.h.

00043                                                {};

vector3D GDCM_NAME_SPACE::Orientation::ProductVectorial vector3D const &  vec1,
vector3D const &  vec2
[private]
 

Definition at line 200 of file gdcmOrientation.cxx.

References GDCM_NAME_SPACE::vector3D::x, GDCM_NAME_SPACE::vector3D::y, and GDCM_NAME_SPACE::vector3D::z.

Referenced by CalculLikelyhood2Vec().

00201 {
00202    vector3D vec3;
00203    vec3.x =    vec1.y*vec2.z - vec1.z*vec2.y;
00204    vec3.y = -( vec1.x*vec2.z - vec1.z*vec2.x);
00205    vec3.z =    vec1.x*vec2.y - vec1.y*vec2.x;
00206 
00207    return vec3;
00208 }

void GDCM_NAME_SPACE::RefCounter::Register  )  [inline, inherited]
 

Register the object.

Remarks:
It increments the reference counting

Definition at line 46 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::SQItem::AddEntry(), GDCM_NAME_SPACE::SeqEntry::AddSQItem(), GDCM_NAME_SPACE::SeqEntry::Copy(), GDCM_NAME_SPACE::DicomDir::Copy(), GDCM_NAME_SPACE::FileHelper::FileHelper(), GDCM_NAME_SPACE::DocEntrySet::GetDictEntry(), GDCM_NAME_SPACE::DocEntry::GetName(), GDCM_NAME_SPACE::DocEntry::GetVM(), GDCM_NAME_SPACE::DocEntrySet::InsertEntryString(), GDCM_NAME_SPACE::CommandManager::InSetCommand(), GDCM_NAME_SPACE::DocEntryArchive::Push(), and GDCM_NAME_SPACE::SeqEntry::SetDelimitationItem().

00046 { RefCount++; }

void GDCM_NAME_SPACE::Base::SetPrintLevel int  level  )  [inline, inherited]
 

Sets the print level for the Dicom Header Elements.

Note:
0 for Light Print; 1 for 'medium' Print, 2 for Heavy Print

Definition at line 47 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::FileHelper::Print(), and GDCM_NAME_SPACE::DicomDir::Print().

00047 { PrintLevel = level; }

void GDCM_NAME_SPACE::RefCounter::Unregister  )  [inline, inherited]
 

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 50 of file gdcmRefCounter.h.

Referenced by GDCM_NAME_SPACE::Document::ReadNextDocEntry(), GDCM_NAME_SPACE::SQItem::RemoveEntry(), GDCM_NAME_SPACE::ElementSet::RemoveEntry(), and GDCM_NAME_SPACE::FileHelper::~FileHelper().

00051    {
00052 //std::cout <<"================Unreg " << typeid(*this).name() << std::endl;
00053       RefCount--;
00054       if(RefCount<=0)
00055         delete this;
00056    }

Res GDCM_NAME_SPACE::Orientation::VerfCriterion int  typeCriterion,
double  criterionNew,
Res const &  res
[private]
 

Definition at line 139 of file gdcmOrientation.cxx.

Referenced by GetOrientationType().

00140 {
00141    Res res;
00142    double type = in.first;
00143    double criterion = in.second;
00144    if (/*criterionNew < 0.1 && */criterionNew < criterion)
00145    {
00146       type      = typeCriterion;
00147       criterion = criterionNew;
00148    }
00149    res.first  = type;
00150    res.second = criterion;
00151    return res;
00152 } 


Member Data Documentation

int GDCM_NAME_SPACE::Base::PrintLevel [protected, inherited]
 

Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Definition at line 55 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), GDCM_NAME_SPACE::FileHelper::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::DicomDir::Print(), and GDCM_NAME_SPACE::DataEntry::Print().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:51 2007 for gdcm by  doxygen 1.4.6