Loading...
Searching...
No Matches
DicomFilePET.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26#include "DicomFilePET.hh"
27#include "DicomFileStructure.hh"
28#include "DicomROI.hh"
29
30#include "G4GeometryTolerance.hh"
31
32#include "dcmtk/dcmdata/dcfilefo.h"
33#include "dcmtk/dcmdata/dcdeftag.h"
34#include "dcmtk/dcmdata/dcpixel.h"
35#include "dcmtk/dcmdata/dcpxitem.h"
36#include "dcmtk/dcmdata/dcpixseq.h"
37#include "dcmtk/dcmrt/drtimage.h"
38
39#include <set>
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48{
49}
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53{
54 G4int fCompress = theFileMgr->GetCompression();
55 if( fNoVoxelsX%fCompress != 0 || fNoVoxelsY%fCompress != 0 ) {
56 G4Exception("DicompFileMgr.:BuildMaterials",
57 "DFC004",
58 FatalException,
59 ("Compression factor = " + std::to_string(fCompress)
60 + " has to be a divisor of Number of voxels X = " + std::to_string(fNoVoxelsX)
61 + " and Y " + std::to_string(fNoVoxelsY)).c_str());
62 }
63
64 // if( DicomVerb(debugVerb) ) G4cout << " BuildMaterials " << fFileName << G4endl;
65 double meanHV = 0.;
66 for( int ir = 0; ir < fNoVoxelsY; ir += fCompress ) {
67 for( int ic = 0; ic < fNoVoxelsX; ic += fCompress ) {
68 meanHV = 0.;
69 int isumrMax = std::min(ir+fCompress,fNoVoxelsY);
70 int isumcMax = std::min(ic+fCompress,fNoVoxelsX);
71 for( int isumr = ir; isumr < isumrMax; isumr ++ ) {
72 for( int isumc = ic; isumc < isumcMax; isumc ++ ) {
73 meanHV += fHounsfieldV[isumc+isumr*fNoVoxelsX];
74 }
75 }
76 meanHV /= (isumrMax-ir)*(isumcMax-ic);
77 fActivities.push_back(meanHV);
78 }
79 }
80
81}
82
83//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85{
86 G4int fCompress = theFileMgr->GetCompression();
87 if( DicomFileMgr::verbose >= warningVerb ) G4cout << fLocation << " DumpDensitiesToTextFile "
88 << fFileName << " " << fActivities.size() << G4endl;
89
90 G4int copyNo = 0;
91 for( int ir = 0; ir < fNoVoxelsY/fCompress; ir++ ) {
92 for( int ic = 0; ic < fNoVoxelsX/fCompress; ic++ ) {
93 fout << fActivities[ic+ir*fNoVoxelsX/fCompress];
94 if( ic != fNoVoxelsX/fCompress-1) fout << " ";
95 if( copyNo%8 == 7 ) fout << G4endl;
96 copyNo++;
97 }
98 if( copyNo%8 != 0 ) fout << G4endl;
99 }
100
101}
102
@ warningVerb
static G4int verbose
G4int GetCompression() const
void BuildActivities()
void DumpActivitiesToTextFile(std::ofstream &fout)
std::vector< size_t > fActivities
DicomFileMgr * theFileMgr
std::vector< int > fHounsfieldV
G4String fFileName
Definition DicomVFile.hh:55

Applications | User Support | Publications | Collaboration