]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marSimpleDicom.h
#3262 creaMaracasVisu Feature New Normal - Export LookupTable fron ColorLayerImageV...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marSimpleDicom.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28  Program:   wxMaracas
29  Module:    $RCSfile: marSimpleDicom.h,v $
30  Language:  C++
31  Date:      $Date: 2012/11/15 14:15:31 $
32  Version:   $Revision: 1.2 $
33  
34   Copyright: (c) 2002, 2003
35   License:
36   
37    This software is distributed WITHOUT ANY WARRANTY; without even 
38    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
39    PURPOSE.  See the above copyright notice for more information.
40    
41 =========================================================================*/
42
43 #ifndef __MAR__KERNEL__MARSIMPLEDICOM__HXX__
44 #define __MAR__KERNEL__MARSIMPLEDICOM__HXX__
45
46 #include "marDicomBase.h"
47
48 #include "volume.hxx"
49 #include <wx/string.h>
50 #include <wx/gauge.h>
51 // PS -> #include <gdcm.h>
52 // PS -> #include <gdcmHeaderHelper.h>
53 #include <vector>
54 // PS -> #include <gdcmElValSet.h>
55
56 typedef std::vector<wxArrayString> SerieInfo;  //DICOM info for each serie
57                                                                                            /**
58 * Shouldn't we break the dependencies to wx ???
59
60 * We use vector instead of list for efficiency: for access time
61 * futhermore the number of patient is not changing a lot, so we 
62 * might add the number of patient to params.dat, to allocate the right 
63 * number of vector
64 *
65 */
66
67 // EED Borrame 
68 //class MAR_KERNEL_EXPORT marGdcmDicom : public marObject
69
70 class marSimpleDicom : public marFilesBase
71 {
72 public:
73         
74     enum DicomTags
75     {
76                 ID_File_Name = 0                   ,
77                         ID_SOP_Class_UID                   ,//!0008 0016 UI ID SOP Class UID
78                         ID_SOP_Instance_UID                ,//!0008 0018 UI ID SOP Instance UID
79                         ID_Study_Date                      ,//!0008 0020 DA ID Study Date
80                         ID_Series_Date                     ,//!0008 0021 DA ID Series Date
81                         ID_Acquisition_Date                ,//!0008 0022 DA ID Acquisition Date
82                         ID_Image_Date                      ,//!0008 0023 DA ID Image Date
83                         ID_Study_Time                      ,//!0008 0030 TM ID Study Time
84                         ID_Series_Time                     ,//!0008 0031 TM ID Series Time
85                         ID_Acquisition_Time                ,//!0008 0032 TM ID Acquisition Time
86                         ID_Image_Time                      ,//!0008 0033 TM ID Image Time
87                         ID_Modality                        ,//!0008 0060 CS ID Modality
88                         ID_Manufacturer                    ,//!0008 0070 LO ID Manufacturer
89                         ID_Institution_Name                ,//!0008 0080 LO ID Institution Name
90                         ID_Study_Description               ,//!0008 1030 LO ID Study Description
91                         ID_Series_Description              ,//!0008 103e LO ID Series Description
92                         ID_Admitting_Diagnoses_Description ,//!0008 1080 LO ID Admitting Diagnoses Description
93                         ID_Patient_Name                    ,//!0010 0010 PN PAT Patient Name
94                         ID_Patient_ID                      ,//!0010 0020 LO PAT Patient ID
95                         ID_Body_Part_Examined              ,//!0018 0015 CS ACQ Body Part Examined
96                         ID_Scanning_Sequence               ,//!0018 0020 CS ACQ Scanning Sequence
97                         ID_Sequence_Variant                ,//!0018 0021 CS ACQ Sequence Variant
98                         ID_Scan_Options                    ,//!0018 0022 CS ACQ Scan Options
99                         ID_MR_Acquisition_Type             ,//!0018 0023 CS ACQ MR Acquisition Type
100                         ID_Sequence_Name                   ,//!0018 0024 SH ACQ Sequence Name
101                         ID_Slice_Thickness                 ,//!0018 0050 DS ACQ Slice Thickness
102                         ID_Repetition_Time                 ,//!0018 0080 DS ACQ Repetition Time
103                         ID_Echo_Time                       ,//!0018 0081 DS ACQ Echo Time
104                         ID_Inversion_Time                  ,//!0018 0082 DS ACQ Inversion Time
105                         ID_Number_of_Averages              ,//!0018 0083 DS ACQ Number of Averages
106                         ID_Imaging_Frequency               ,//!0018 0084 DS ACQ Imaging Frequency
107                         ID_Imaged_Nucleus                  ,//!0018 0085 SH ACQ Imaged Nucleus
108                         ID_Echo_Number                     ,//!0018 0086 IS ACQ Echo Number
109                         ID_Magnetic_Field_Strength         ,//!0018 0087 DS ACQ Magnetic Field Strength
110                         ID_Spacing_Between_Slices          ,//!0018 0088 DS ACQ Spacing Between Slices
111                         ID_Echo_Train_Length               ,//!0018 0091 IS ACQ Echo Train Length
112                         ID_Percent_Sampling                ,//!0018 0093 DS ACQ Percent Sampling
113                         ID_Percent_Phase_Field_of_View     ,//!0018 0094 DS ACQ Percent Phase Field of View
114                         ID_Receiving_Coil                  ,//!0018 1250 SH ACQ Receiving Coil
115                         ID_Patient_Position                ,//!0018 5100 CS ACQ Patient Position
116                         ID_Study_Instance_UID              ,//!0020 000d UI REL Study Instance UID
117                         ID_Series_Instance_UID             ,//!0020 000e UI REL Series Instance UID
118                         ID_Study_ID                        ,//!0020 0010 SH REL Study ID
119                         ID_Series_Number                   ,//!0020 0011 IS REL Series Number
120                         ID_Acquisition_Number              ,//!0020 0012 IS REL Acquisition Number
121                         ID_Image_Number                    ,//!0020 0013 IS REL Image Number
122                         ID_Patient_Orientation             ,//!0020 0020 CS REL Patient Orientation
123                         ID_Image_Position                  ,//!0020 0030 RET REL Image Position
124                         ID_Image_Position_Patient          ,//!0020 0032 DS REL Image Position Patient
125                         ID_Image_Orientation               ,//!0020 0035 RET REL Image Orientation
126                         ID_Image_Orientation_Patient       ,//!0020 0037 DS REL Image Orientation (Patient)
127                         ID_Location                        ,//!0020 0050 RET REL Location
128                         ID_Frame_of_Reference_UID          ,//!0020 0052 UI REL Frame of Reference UID
129                         ID_Slice_Location                  ,//!0020 1041 DS REL Slice Location
130                         ID_Image_Comments                  ,//!0020 4000 LT REL Image Comments
131                         ID_Pixel_Spacing                   ,//!0028 0030 DS IMG Pixel Spacing
132                         ID_Window_Center                   ,//!0028 1050 DS IMG Window Center
133                         ID_Window_Width                    ,//!0028 1051 DS IMG Window Width
134                         ID_dicom_tags_count
135     };
136         
137 public:
138         void SetVolumeData( int dimX,
139                                                 int dimY,
140                                                 int dimZ, 
141                                 float spacingX, 
142                                                 float spacingY, 
143                                                 float spacingZ, 
144                                                 float rescaleSlope,
145                                                 float rescaleIntercept,
146                                                 unsigned short * pixels);
147         
148     marSimpleDicom( marParameters* p = NULL );
149         
150     virtual ~marSimpleDicom( );
151         
152     /**
153         Function which return an *ordered* array string
154         The string is ordered so that filename are in the right order
155     */
156 // PS ->     wxArrayString getStudyInfo( ) { return( m_DicomInfo[m_ActualStudy][0] ); }
157 // PS ->     int getNumberOfStudies( ) { return m_DicomInfo.size(); }
158 // PS ->     wxArrayString getSerieInfo( ) { return( m_DicomInfo[m_ActualStudy][m_ActualSerie] ); }
159 // PS ->     int getNumberOfSeries( ) { return m_DicomInfo[m_ActualStudy].size(); }
160         
161         
162 // PS ->     int getNumberOfFiles( )
163 // PS ->     {
164 // PS ->                return m_DicomInfo[m_ActualStudy][m_ActualSerie].GetCount();
165 // PS ->     }
166         
167         void SetInvestSliceOrder(bool investSliceOrder);
168
169     void loadActualSerie(wxGauge* gauge );
170         
171 // PS ->     wxArrayString getImageNumbers( )
172 // PS ->     {
173 // PS ->                wxArrayString imageNumbers;
174 // PS ->                std::list<gdcmHeaderHelper*> flist = helper->GetGdcmFileList();
175 // PS ->                for(std::list<gdcmHeaderHelper*>::iterator it = flist.begin(); 
176 // PS ->                it != flist.end(); it++ )
177 // PS ->                {
178 // PS ->                        imageNumbers.Add( wxString::Format("%d", (*it)->GetImageNumber()) );
179 // PS ->                }
180 // PS ->                return( imageNumbers );
181 // PS ->     }
182
183         // PS ->     void loadVolume( bool force = false, wxGauge* gauge = NULL);
184     void loadVolumeDXMM( bool force = false, wxGauge* gauge = NULL);
185         
186 // PS ->        
187 // PS ->     bool setActualStudy( unsigned int studynumber )
188 // PS ->     {
189 // PS ->                m_ActualStudy = studynumber;
190 // PS ->                return true;
191 // PS ->     }
192 // PS ->     bool setActualSerie( unsigned int serienumber )
193 // PS ->     {
194 // PS ->                m_ActualSerie = serienumber;
195 // PS ->                return true;
196 // PS ->     }
197 // PS ->        
198     /** 
199         * General methods
200         */
201     void reset( );
202     void copyFrom( const marObject& from );
203         
204     /**
205         * Persistence methods
206         */
207     bool save( std::ofstream& os );
208     bool load( std::ifstream& is );
209         
210 // PS ->     void FillDicomInfo();
211     
212 // PS ->     wxString GetPatientName()
213 // PS ->        {
214 // PS ->                return wxString( helper->GetGdcmHeader()->GetPubElValByNumber(0x0010,0x0010).c_str()).Trim();//0010 0010 PN PAT Patient Name
215 // PS ->        }
216         
217   private:
218           
219 // PS ->          wxArrayString gdcmGetExamInfo( wxString directoryname );
220           
221           std::vector< SerieInfo > m_DicomInfo;
222           unsigned int m_ActualStudy;
223           unsigned int m_ActualSerie;
224           
225 // PS ->          gdcmSerieHeaderHelper *helper;
226           unsigned short * m_pSlicesPixels;
227           int   m_nX, m_nY, m_nSlices;
228           float m_PixelSpacingColumn,m_PixelSpacingRow,m_PixelSpacingSlice;
229           float m_RescaleSlope, m_RescaleIntercept;
230           bool  _investSliceOrder;
231 };
232
233 #endif // __MAR__KERNEL__MARSIMPLEDICOM__HXX__