X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkPartitionEnergyWindowDicomGenericFilter.txx;h=8e8fa33f37f23359d785f9d6531b8e4aab316382;hb=543b72e23ad001ac2a7743b9beacf48e2d0054ac;hp=8b102bf4b349aef9d1c0c59366d90add8620f3f6;hpb=c91252d780814d0d771464cdbce0f0a2cf94e891;p=clitk.git diff --git a/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx b/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx index 8b102bf..8e8fa33 100644 --- a/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx +++ b/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx @@ -136,7 +136,7 @@ void PartitionEnergyWindowDicomGenericFilter::UpdateWithDimAndPixelType() { -#if GDCM_MAJOR_VERSION == 2 +#if GDCM_MAJOR_VERSION >= 2 // ImageTypes typedef itk::Image InputImageType; typedef itk::Image OutputImageType; @@ -182,15 +182,19 @@ PartitionEnergyWindowDicomGenericFilter::UpdateWithDimAndPixelTy series_number_att.SetFromDataSet(dsInput); int nbEnergyWindow = series_number_att.GetValue(); - const gdcm::DataElement &seqRotation = dsInput.GetDataElement(gdcm::Tag(0x54, 0x52)); - gdcm::SmartPointer sqiRotation = seqRotation.GetValueAsSQ(); - gdcm::Item &itemRotation = sqiRotation->GetItem(1); - const gdcm::DataElement &deRotation = itemRotation.GetDataElement(gdcm::Tag(0x54, 0x53)); - unsigned short SamplesPerPixelRotation = *((unsigned short *) deRotation.GetByteValue()->GetPointer()); - std::stringstream s_SamplesPerPixelRotation; - s_SamplesPerPixelRotation << SamplesPerPixelRotation; - std::string p_StrRotation = s_SamplesPerPixelRotation.str(); - int nbRotation = (int)atof(p_StrRotation.c_str()); + int nbRotation; + if (dsInput.FindDataElement(gdcm::Tag(0x54, 0x52))) { + const gdcm::DataElement &seqRotation = dsInput.GetDataElement(gdcm::Tag(0x54, 0x52)); + gdcm::SmartPointer sqiRotation = seqRotation.GetValueAsSQ(); + gdcm::Item &itemRotation = sqiRotation->GetItem(1); + const gdcm::DataElement &deRotation = itemRotation.GetDataElement(gdcm::Tag(0x54, 0x53)); + unsigned short SamplesPerPixelRotation = *((unsigned short *) deRotation.GetByteValue()->GetPointer()); + std::stringstream s_SamplesPerPixelRotation; + s_SamplesPerPixelRotation << SamplesPerPixelRotation; + std::string p_StrRotation = s_SamplesPerPixelRotation.str(); + nbRotation = (int)atof(p_StrRotation.c_str()); + } else + nbRotation = 1; int nbSlicePerEnergy = nbSlice / nbEnergyWindow; if (nbSlicePerEnergy*nbEnergyWindow != nbSlice)