+ gdcmWarningMacro( "Unfound Imager Pixel Spacing (0018,1164)" );
+ }
+
+ entry = GetDataEntry(0x0028,0x0030);
+ if( entry )
+ {
+ yspacing = (float)entry->GetValue(0);
+
+ if ( yspacing == 0.0 )
+ yspacing = 1.0;
+ return yspacing;
+ }
+ else
+ {
+ gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
+ }
+
+ return yspacing;
+}
+
+/**
+ * \brief gets the info from 0018,0088 : Space Between Slices
+ * else from 0018,0050 : Slice Thickness
+ * else 1.0
+ *
+ * When an element is missing, we suppose slices join together
+ * (no overlapping, no interslice gap) but we have no way to check it !
+ * For *Dicom* images, ZSpacing *should be* calculated using
+ * XOrigin, YOrigin, ZOrigin (of the top left image corner)
+ * of 2 consecutive images, and the Orientation
+ * Computing ZSpacing on a single image is not really meaningfull !
+
+ * @return Z dimension of a voxel-to be
+ */
+float File::GetZSpacing()
+{
+
+ float zspacing = 1.0f;
+
+ // Spacing Between Slices : distance between the middle of 2 slices
+ // Slices may be :
+ // jointives (Spacing between Slices = Slice Thickness)
+ // overlapping (Spacing between Slices < Slice Thickness)
+ // disjointes (Spacing between Slices > Slice Thickness)
+ // Slice Thickness : epaisseur de tissus sur laquelle est acquis le signal
+ // It only concerns the MRI guys, not people wanting to visualize volumes
+ // If Spacing Between Slices is missing,
+ // we suppose slices joint together
+ DataEntry *entry = GetDataEntry(0x0018,0x0088);
+ if( entry )
+ {
+ zspacing = (float)entry->GetValue(0);
+
+ if ( zspacing == 0.0 )
+ zspacing = 1.0;
+ return zspacing;
+ }
+ else
+ gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
+
+ // if no 'Spacing Between Slices' is found,
+ // we assume slices join together
+ // (no overlapping, no interslice gap)
+ entry = GetDataEntry(0x0018,0x0050);
+ if( entry )
+ {
+ zspacing = (float)entry->GetValue(0);
+
+ if ( zspacing == 0.0 )
+ zspacing = 1.0;
+ return zspacing;
+ }
+ else
+ gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
+
+ // if no 'Spacing Between Slices' is found,
+ // we assume slices join together
+ // (no overlapping, no interslice gap)
+ entry = GetDataEntry(0x3004,0x000c);
+ if( entry )
+ {
+ float z1 = (float)entry->GetValue(0);
+ float z2 = (float)entry->GetValue(1);
+ zspacing = z2 - z1; // can be negative...
+
+ if ( zspacing == 0.0 )
+ zspacing = 1.0;
+ return zspacing;
+ }
+
+ return zspacing;
+}
+
+/**
+ * \brief gets the info from 0020,0032 : Image Position Patient
+ * else from 0020,0030 : Image Position (RET)
+ * else 0.
+ * @return up-left image corner X position
+ */
+float File::GetXOrigin()
+{
+ DataEntry *entry = GetDataEntry(0x0020,0x0032);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+ entry = GetDataEntry(0x0020,0x0030);
+ if( !entry )