Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:44

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file medical/DICOM/include/DicomHandler.hh
0028 /// \brief Definition of the DicomHandler class
0029 //
0030 // The code was written by :
0031 //      *Louis Archambault louis.archambault@phy.ulaval.ca,
0032 //      *Luc Beaulieu beaulieu@phy.ulaval.ca
0033 //      +Vincent Hubert-Tremblay at tigre.2@sympatico.ca
0034 //
0035 //
0036 // *Centre Hospitalier Universitaire de Quebec (CHUQ),
0037 // Hotel-Dieu de Quebec, departement de Radio-oncologie
0038 // 11 cote du palais. Quebec, QC, Canada, G1R 2J6
0039 // tel (418) 525-4444 #6720
0040 // fax (418) 691 5268
0041 //
0042 // + Université Laval, Québec (QC) Canada
0043 //*******************************************************//
0044 
0045 #ifndef DicomHandler_h
0046 #define DicomHandler_h 1
0047 
0048 #include "globals.hh"
0049 
0050 #include <cstdio>
0051 #include <fstream>
0052 #include <map>
0053 
0054 //*******************************************************
0055 /// Dicom Handler class
0056 ///        - Handling of DICM images
0057 ///        - Transforming *.dcm to *.g4 ( pixels->density )
0058 ///        - Reading headers and pixels
0059 ///        - Transforming pixel to density and creating *.g4
0060 ///          files
0061 ///        - Functions are in DicomHandler.cc
0062 ///
0063 /// Base on previous code by :
0064 ///        Dragan Tubic <tdragan@gel.ulaval.ca>
0065 //*******************************************************
0066 
0067 class DicomPhantomZSliceHeader;
0068 class DicomPhantomZSliceMerged;
0069 
0070 class DicomHandler
0071 {
0072   public:
0073     ~DicomHandler();
0074 
0075     // static accessor
0076     static DicomHandler* Instance();
0077 
0078     G4int ReadFile(FILE*, char*);
0079     G4int ReadData(FILE*, char*);  // note: always use readHeader
0080     // before readData
0081 
0082     // use ImageMagick to display the image
0083     // G4int displayImage(char[500]);
0084 
0085     void CheckFileFormat();
0086 
0087     static G4String GetDicomDataPath();
0088     static G4String GetDicomDataFile();
0089 
0090   private:
0091     DicomHandler();
0092 
0093     template<class Type>
0094     void GetValue(char*, Type&);
0095 
0096   private:
0097     static DicomHandler* fInstance;
0098 
0099     const G4int DATABUFFSIZE;
0100     const G4int LINEBUFFSIZE;
0101     const G4int FILENAMESIZE;
0102 
0103     void ReadCalibration();
0104     void GetInformation(G4int&, char*);
0105     G4float Pixel2density(G4int pixel);
0106     void ReadMaterialIndices(std::ifstream& finData);
0107     unsigned int GetMaterialIndex(G4float density);
0108     void StoreData(std::ofstream& foutG4DCM);
0109     void StoreData(DicomPhantomZSliceHeader* dcmPZSH);
0110     G4int read_defined_nested(FILE*, G4int);
0111     void read_undefined_nested(FILE*);
0112     void read_undefined_item(FILE*);
0113 
0114     short fCompression;
0115     G4int fNFiles;
0116     short fRows;
0117     short fColumns;
0118     short fBitAllocated;
0119     G4int fMaxPixelValue, fMinPixelValue;
0120 
0121     G4double fPixelSpacingX, fPixelSpacingY;
0122     G4double fSliceThickness;
0123     G4double fSliceLocation;
0124 
0125     G4int fRescaleIntercept, fRescaleSlope;
0126 
0127     G4bool fLittleEndian, fImplicitEndian;
0128     short fPixelRepresentation;
0129 
0130     G4int** fTab;
0131     std::map<G4float, G4String> fMaterialIndices;
0132 
0133     G4int fNbrequali;
0134     G4double* fValueDensity;
0135     G4double* fValueCT;
0136     G4bool fReadCalibration;
0137     DicomPhantomZSliceMerged* fMergedSlices;
0138 
0139     G4String fDriverFile;
0140     G4String fCt2DensityFile;
0141 };
0142 #endif