]> Creatis software - gdcm.git/blob - src/gdcmOrientation.h
ENH: sagital -> sagittal
[gdcm.git] / src / gdcmOrientation.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmOrientation.h,v $
5   Language:  C++
6   Date:      $Date: 2008/08/18 12:27:10 $
7   Version:   $Revision: 1.21 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef _GDCMORIENTATION_H_
20 #define _GDCMORIENTATION_H_
21
22 #include "gdcmRefCounter.h"
23 #include <map>
24
25 namespace GDCM_NAME_SPACE 
26 {
27 typedef struct
28 {
29    double x;
30    double y;
31    double z;
32 } vector3D;
33
34 typedef std::pair<double, double> Res;
35 class File;
36
37 typedef enum {
38    NotApplicable = 0,
39    Axial = 1,
40    AxialInvert = -1,
41    Coronal = 2,
42    CoronalInvert = -2,
43    Sagittal = 3,
44    SagittalInvert = -3,
45    HeartAxial = 4,
46    HeartAxialInvert = -4,
47    HeartCoronal = 5,
48    HeartCoronalInvert = -5,
49    HeartSagittal = 6,
50    HeartSagittalInvert = -6
51 } OrientationType;
52
53 //-----------------------------------------------------------------------------
54 /**
55  * \brief Orientation class for dealing with DICOM image orientation
56  *
57  * A gentle reminder for non-medical user:
58  * PatientPosition (0x0010,0x5100) tells us the way the patient was introduced in the imager
59  *  - HFS : Head First Supine
60  *  - FFS : Feet First Supine
61  *  - HFP : Head First Prone
62  *  - FFP : Feet First Prone
63  * Note: HFP and FFP are not very common values, since the position must
64  *        be pretty unconfortable for the Patient -the patient is lying on his belly; but, if he has handcuffs there is no other way ...-
65  *
66  * ImageOrientationPatient (0x0020,0x0037) gives 6 cosines (2 for each plane)
67  * Patient Orientation (as found in the optional 0x0020,0x0020, or computed by
68  * std::string Orientation::GetOrientation ( File *f ), tells us about the direction of X and Y axes.
69  * 
70  * The values can be
71  *  - A/P anterior/posterior
72  *  - L/R left/right
73  *  - H/F head/feet
74  * One can see it as "values within a 'Patient referential".
75  *
76  * Example #1:
77  * Imagine the patient, in "HFS" position.
78  * Full body sagittal images are requested.
79  * All the cosines will be -1, 0, or +1;
80  * "Patient Orientation" (deduced) will be "A/F".
81  * Positive X axis is oriented 'towards patient's nose
82  * Positive Y axis  is oriented 'towards patient's feet
83  *
84  * Example #2:
85  * Imagine now that patient has a stiffneck and his head is *turned* 30 degrees towards the left.
86  * Head sagittal images are requested.
87  * One of the cosines will be almost 0.5
88  * Deduced "Patient Orientation" will be "AL\F"
89  * (main X axis orientation is towards patient's nose, and a little bit towards the left)
90  * but the image looks *perfectly* sagittal (for the head, not for the patient) !
91  *
92  * Imagine the patient's stiffneck causes head to be *bended* 30 degrees towards the left AND *turned* left.
93  * Sagittal images are requested...
94  * You'll probabely have 3 letters for X axis and  Y axis, and the image remains *perfectly* sagittal !
95  * The values are given within the 'Patient referential', *not* within the 'Organ referential' ...
96  */
97
98 class GDCM_EXPORT Orientation : public RefCounter
99 {
100    gdcmTypeMacro(Orientation);
101 public:
102 /// \brief Constructs a gdcm::Orientation with a RefCounter
103    static Orientation *New() {return new Orientation();}
104
105   OrientationType GetOrientationType( File *file );
106   std::string GetOrientation ( File *file );  
107   
108   static const char* GetOrientationTypeString(OrientationType const o);
109
110 protected:
111 /// \brief Constructor
112   Orientation() {}
113 /// \brief Canonical Destructor
114   ~Orientation() {}
115 private:
116    Res VerfCriterion(int typeCriterion, double criterionNew, Res const &res);
117    double CalculLikelyhood2Vec(vector3D const &refA, vector3D const &refB, 
118                                vector3D const &ori1, vector3D const &ori2);
119    vector3D ProductVectorial(vector3D const &vec1, vector3D const &vec2);
120    std::string GetSingleOrientation ( float *iop);
121 };
122 } // end namespace gdcm
123 //-----------------------------------------------------------------------------
124 #endif