]> Creatis software - clitk.git/commitdiff
Be sure Number of Frame of Rotation exists in dicom tags
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 15 Mar 2018 10:12:09 +0000 (11:12 +0100)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 15 Mar 2018 10:12:09 +0000 (11:12 +0100)
tools/clitkPartitionEnergyWindowDicomGenericFilter.txx

index 8b102bf4b349aef9d1c0c59366d90add8620f3f6..bf589259cb012c7de5b0ce7102fc8370dbcfd48c 100644 (file)
@@ -182,15 +182,19 @@ PartitionEnergyWindowDicomGenericFilter<args_info_type>::UpdateWithDimAndPixelTy
   series_number_att.SetFromDataSet(dsInput);
   int nbEnergyWindow = series_number_att.GetValue();
 
-  const gdcm::DataElement &seqRotation = dsInput.GetDataElement(gdcm::Tag(0x54, 0x52));
-  gdcm::SmartPointer<gdcm::SequenceOfItems> 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<gdcm::SequenceOfItems> 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)