From: tbaudier Date: Thu, 15 Mar 2018 10:12:09 +0000 (+0100) Subject: Be sure Number of Frame of Rotation exists in dicom tags X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=78bd7fb31b49e7b7557c062a691f622f6dec58a0;p=clitk.git Be sure Number of Frame of Rotation exists in dicom tags --- diff --git a/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx b/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx index 8b102bf..bf58925 100644 --- a/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx +++ b/tools/clitkPartitionEnergyWindowDicomGenericFilter.txx @@ -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)