class_docstr: DicomSeries
  This class represents a serie of dicom files (SimpleDicomReader
  objects) that belong together. If these are multiple files, they
  represent the slices of a volume (like for CT or MRI).
class_docstr_tok: ["DicomSeries","This","class","represents","a","serie","of","dicom","files","(","SimpleDicomReader","objects",")","that","belong","together",".","If","these","are","multiple","files",",","they","represent","the","slices","of","a","volume","(","like","for","CT","or","MRI",")","."]
docstr: Evaluate the series of dicom files. Together they should make up
  a volumetric dataset. This means the files should meet certain
  conditions. Also some additional information has to be calculated,
  such as the distance between the slices. This method sets the
  attributes for "shape", "sampling" and "info".
  
  This method checks:
    * that there are no missing files
    * that the dimensions of all images match
    * that the pixel spacing of all images match
docstr_tok: ["Evaluate","the","series","of","dicom","files",".","Together","they","should","make","up","a","volumetric","dataset",".","This","means","the","files","should","meet","certain","conditions",".","Also","some","additional","information","has","to","be","calculated",",","such","as","the","distance","between","the","slices",".","This","method","sets","the","attributes","for","``","shape","''",",","``","sampling","''","and","``","info","''",".","This","method","checks",":","*","that","there","are","no","missing","files","*","that","the","dimensions","of","all","images","match","*","that","the","pixel","spacing","of","all","images","match"]
code: def _finish(self):
      """
      Evaluate the series of dicom files. Together they should make up
      a volumetric dataset. This means the files should meet certain
      conditions. Also some additional information has to be calculated,
      such as the distance between the slices. This method sets the
      attributes for "shape", "sampling" and "info".
  
      This method checks:
        * that there are no missing files
        * that the dimensions of all images match
        * that the pixel spacing of all images match
      """
  
      # The datasets list should be sorted by instance number
      L = self._entries
      if len(L) == 0:
          return
      elif len(L) == 1:
          self._info = L[0].info
          return
  
      # Get previous
      ds1 = L[0]
      # Init measures to calculate average of
      distance_sum = 0.0
      # Init measures to check (these are in 2D)
      dimensions = ds1.Rows, ds1.Columns
      # sampling = float(ds1.PixelSpacing[0]), float(ds1.PixelSpacing[1])
      sampling = ds1.info["sampling"][:2]  # row, column
  
      for index in range(len(L)):
          # The first round ds1 and ds2 will be the same, for the
          # distance calculation this does not matter
          # Get current
          ds2 = L[index]
          # Get positions
          pos1 = float(ds1.ImagePositionPatient[2])
          pos2 = float(ds2.ImagePositionPatient[2])
          # Update distance_sum to calculate distance later
          distance_sum += abs(pos1 - pos2)
          # Test measures
          dimensions2 = ds2.Rows, ds2.Columns
          # sampling2 = float(ds2.PixelSpacing[0]), float(ds2.PixelSpacing[1])
          sampling2 = ds2.info["sampling"][:2]  # row, column
          if dimensions != dimensions2:
              # We cannot produce a volume if the dimensions match
              raise ValueError("Dimensions of slices does not match.")
          if sampling != sampling2:
              # We can still produce a volume, but we should notify the user
              self._progressIndicator.write(
                  "Warn: sampling does not match."
              )
          # Store previous
          ds1 = ds2
  
      # Finish calculating average distance
      # (Note that there are len(L)-1 distances)
      distance_mean = distance_sum / (len(L) - 1)
  
      # Set info dict
      self._info = L[0].info.copy()
  
      # Store information that is specific for the serie
      self._info["shape"] = (len(L),) + ds2.info["shape"]
      self._info["sampling"] = (distance_mean,) + ds2.info["sampling"]
  
imports: import sys
  import os
  import struct
  import logging
  import numpy
label_desc: Use image node_id 14 for calling the DicomSeries obj's underlying member method code with example usage: obj._finish() without return types