def attach_to(series)
      raise ArgumentError, "Invalid argument 'series'. Expected ImageSeries, got #{series.class}." unless series.is_a?(Series)
      # Do not bother to attempt this change if we have an image reference and this image instance already belongs to the series:
      if @image && !series.image(@image.uid) or !@image
        # Query the ImageSeries for an Image instance that matches the Plane of this Slice:
        matched_image = series.match_image(plane)
        if matched_image
          @image = matched_image
          @uid = matched_image.uid
        else
          raise "No matching Image was found for this Slice."
        end
      end
    end
def attach_to(series)
      raise ArgumentError, "Invalid argument 'series'. Expected ImageSeries, got #{series.class}." unless series.is_a?(Series)
      # Do not bother to attempt this change if we have an image reference and this image instance already belongs to the series:
      if @image && !series.image(@image.uid) or !@image
        # Query the ImageSeries for an Image instance that matches the Plane of this Slice:
        matched_image = series.match_image(plane)
        if matched_image
          @image = matched_image
          @uid = matched_image.uid
        else
          raise "No matching Image was found for this Slice."
        end
      end
    end
Attaches a Slice to an Image instance belonging to the specified
 ImageSeries, by setting the Image reference of the Slice to an Image
 instance which matches the coordinates of the Slice's Contour(s).

 This method can be useful when you have multiple segmentations based on the same image series
 from multiple raters (perhaps as part of a comparison study), and the rater's software has modified
 the UIDs of the original image series, so that the references of the returned Structure Set does
 not match your original image series. This method uses coordinate information to calculate plane
 equations, which allows it to identify the corresponding image slice even in the case of
 slice geometry being non-perpendicular with respect to the patient geometry (direction cosine values != [0,1]).

 @param [Series] series the new ImageSeries instance which the Slice shall be associated with through its images
 @raise [ArgumentError] if a suitable match is not found for the Slice