Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkGEDicomDiffusionImageHeaderReader.h"
00020
00021 #include "gdcmGlobal.h"
00022
00023
00024 #if GDCM_MAJOR_VERSION >= 2
00025 #define DGDCM2
00026 #endif
00027
00028 #ifndef DGDCM2
00029
00030 #include "gdcm.h"
00031
00032
00033 const gdcm::DictEntry GEDictBValue( 0x0043, 0x1039, "IS", "1", "B Value of diffusion weighting" );
00034 const gdcm::DictEntry GEDictXGradient( 0x0019, 0x10bb, "DS", "1", "X component of gradient direction" );
00035 const gdcm::DictEntry GEDictYGradient( 0x0019, 0x10bc, "DS", "1", "Y component of gradient direction" );
00036 const gdcm::DictEntry GEDictZGradient( 0x0019, 0x10bd, "DS", "1", "Z component of gradient direction" );
00037
00038 #else
00039
00040 #include "gdcmDict.h"
00041 #include "gdcmDicts.h"
00042 #include "gdcmDictEntry.h"
00043 #include "gdcmDictEntry.h"
00044 #include "gdcmDict.h"
00045 #include "gdcmFile.h"
00046 #include "gdcmSerieHelper.h"
00047
00048
00049
00050
00051
00052 #endif
00053
00054 mitk::GEDicomDiffusionImageHeaderReader::GEDicomDiffusionImageHeaderReader()
00055 {
00056 }
00057
00058 mitk::GEDicomDiffusionImageHeaderReader::~GEDicomDiffusionImageHeaderReader()
00059 {
00060 }
00061
00062
00063 void mitk::GEDicomDiffusionImageHeaderReader::Update()
00064 {
00065
00066
00067 if(m_DicomFilenames.size())
00068 {
00069
00070
00071
00072 VolumeReaderType::DictionaryArrayRawPointer inputDict
00073 = m_VolumeReader->GetMetaDataDictionaryArray();
00074
00075 #ifndef DGDCM2
00076 if(gdcm::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GEDictBValue.GetKey()) == 0)
00077 gdcm::Global::GetDicts()->GetDefaultPubDict()->AddEntry(GEDictBValue);
00078 if(gdcm::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GEDictXGradient.GetKey()) == 0)
00079 gdcm::Global::GetDicts()->GetDefaultPubDict()->AddEntry(GEDictXGradient);
00080 if(gdcm::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GEDictYGradient.GetKey()) == 0)
00081 gdcm::Global::GetDicts()->GetDefaultPubDict()->AddEntry(GEDictYGradient);
00082 if(gdcm::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GEDictZGradient.GetKey()) == 0)
00083 gdcm::Global::GetDicts()->GetDefaultPubDict()->AddEntry(GEDictZGradient);
00084 #endif
00085
00086 ReadPublicTags();
00087
00088
00089
00090
00091 float x0, y0, z0;
00092 float x1, y1, z1;
00093 std::string tag;
00094 tag.clear();
00095 itk::ExposeMetaData<std::string> ( *(*inputDict)[0], "0020|0032", tag );
00096 sscanf( tag.c_str(), "%f\\%f\\%f", &x0, &y0, &z0 );
00097 std::cout << "Slice 0: " << tag << std::endl;
00098 tag.clear();
00099
00100
00101
00102 itk::ExposeMetaData<std::string> ( *(*inputDict)[1], "0020|0032", tag );
00103 sscanf( tag.c_str(), "%f\\%f\\%f", &x1, &y1, &z1 );
00104 std::cout << "Slice 1: " << tag << std::endl;
00105 x1 -= x0; y1 -= y0; z1 -= z0;
00106 x0 = x1*this->m_Output->xSlice + y1*this->m_Output->ySlice + z1*this->m_Output->zSlice;
00107 if (x0 < 0)
00108 {
00109 m_SliceOrderIS = false;
00110 }
00111
00112 ReadPublicTags2();
00113
00114 int nSliceInVolume;
00115 int nVolume;
00116
00117 nSliceInVolume = m_sliceLocations.size();
00118 nVolume = m_nSlice/nSliceInVolume;
00119
00120
00121 std::cout << "Number of Slices: " << m_nSlice << std::endl;
00122 std::cout << "Number of Volume: " << nVolume << std::endl;
00123 std::cout << "Number of Slices in each volume: " << nSliceInVolume << std::endl;
00124
00125 for (int k = 0; k < m_nSlice; k += nSliceInVolume)
00126 {
00127 tag.clear();
00128 bool exist = itk::ExposeMetaData<std::string> ( *(*inputDict)[k], "0043|1039", tag);
00129 float b = atof( tag.c_str() );
00130 this->m_Output->bValue = b;
00131
00132 vnl_vector_fixed<double, 3> vect3d;
00133 if (!exist || b == 0)
00134 {
00135 vect3d.fill( 0 );
00136 this->m_Output->DiffusionVector = vect3d;
00137 continue;
00138 }
00139
00140 vect3d.fill( 0 );
00141 tag.clear();
00142 itk::ExposeMetaData<std::string> ( *(*inputDict)[k], "0019|10bb", tag);
00143 vect3d[0] = atof( tag.c_str() );
00144
00145 tag.clear();
00146 itk::ExposeMetaData<std::string> ( *(*inputDict)[k], "0019|10bc", tag);
00147 vect3d[1] = atof( tag.c_str() );
00148
00149 tag.clear();
00150 itk::ExposeMetaData<std::string> ( *(*inputDict)[k], "0019|10bd", tag);
00151 vect3d[2] = atof( tag.c_str() );
00152
00153 vect3d.normalize();
00154 this->m_Output->DiffusionVector = vect3d;
00155 }
00156
00157 TransformGradients();
00158
00159 }
00160 }
00161
00162
00163
00164
00165
00166
00167