]> Creatis software - gdcm.git/blob - src/gdcmOrientation.h
DOC: Adding comment by JPR, for non-medical user (=me)
[gdcm.git] / src / gdcmOrientation.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmOrientation.h,v $
5   Language:  C++
6   Date:      $Date: 2005/10/01 15:51:42 $
7   Version:   $Revision: 1.8 $
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 "gdcmBase.h"
23 #include <map>
24
25 namespace gdcm 
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 //-----------------------------------------------------------------------------
38 /**
39  * \brief Orientation class for dealing with DICOM image orientation
40  * A gentle reminder for non-medical user:
41  * PatientPosition (0x0010,0x5100) tells us the way the patient was introduced in the imager
42  *  - HFS : Head First Supine
43  *  - FFS : Feet First Supine
44  *  - HFP : Head First Prone
45  *  - FFP : Feet First Prone
46  * Note: HFP and FFP are not very common values, since the position must be pretty unconfortable for the Patient -the patient is lying on his belly; but, if he has handcuffs there is no other way ...-
47  *
48  * ImageOrientationPatient (0x0020,0x0037) gives 6 cosines (2 for each plane)
49  * Patient Orientation (as found in the optional 0x0020,0x0020, or computed by
50  * std::string Orientation::GetOrientation ( File *f ), tells us about the direction of X and Y axes.
51  * 
52  * The values can be
53  *  - A/P anterior/posterior
54  *  - L/R left/right
55  *  - H/F head/feet
56  * One can see it as "values within a 'Patient referential".
57  *
58  * Example #1:
59  * Imagine the patient, in "HFS" position.
60  * Sagital images are requested.
61  * All the cosines will be -1, 0, or +1;
62  * "Patient Orientation" (deduced) will be "A/F".
63  * Positive X axis is oriented 'towards patient's nose
64  * Positive Y axis  is oriented 'towards patient's feet
65  *
66  * Example #2:
67  * Imagine now that patient has a stiffneck and his head is *turned* 30 degrees towards the left.
68  * Sagital images are requested.
69  * One of the cosines will be almost 0.5
70  * Deduced "Patient Orientation" will be "AL\F"
71  * (main X axis orientation is towards patient's nose, and a little bit towards the left)
72  * but the image is *perfectly* sagital !
73  *
74  * Imagine the patient's stiffneck causes head to be *bended* 30 degrees towards the left AND *turned* left.
75  * Sagital images are requested...
76  * You'll probabely have 3 letters for X axis and  Y axis, and the image remains *perfectly* sagital !
77  * The values are given within the 'imager referential', better than within the 'Patient Referential' ...
78  */
79 class GDCM_EXPORT Orientation : public Base
80 {
81 public:
82   Orientation() {}
83   ~Orientation() {}
84
85   double TypeOrientation( File *file );
86   std::string GetOrientation ( File *file );  
87   
88 private:
89    Res VerfCriterion(int typeCriterion, double criterionNew, Res const &res);
90    double CalculLikelyhood2Vec(vector3D const &refA, vector3D const &refB, 
91                                vector3D const &ori1, vector3D const &ori2);
92    vector3D ProductVectorial(vector3D const &vec1, vector3D const &vec2);
93    std::string GetSingleOrientation ( float *iop);
94 };
95 } // end namespace gdcm
96 //-----------------------------------------------------------------------------
97 #endif