Method: RTKIT::ROI#attach_to

Defined in:
lib/rtkit/roi.rb

#attach_to(series) ⇒ Object

Attaches a ROI to a specified ImageSeries, by setting the ROIs frame reference to the Frame which the ImageSeries belongs to, and setting the Image reference of each of the Slices belonging to the ROI to an Image instance which matches the coordinates of the Slice’s Contour(s). Raises an exception if a suitable match is not found for any Slice.

Notes

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]).

Raises:

  • (ArgumentError)


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/rtkit/roi.rb', line 151

def attach_to(series)
  raise ArgumentError, "Invalid argument 'series'. Expected ImageSeries, got #{series.class}." unless series.is_a?(Series)
  # Change struct association if indicated:
  if series.struct != @struct
    @struct.remove_roi(self)
    series.struct.add_roi(self)
    @struct = series.struct
  end
  # Change Frame if different:
  if @frame != series.frame
    @frame = series.frame
  end
  # Update slices:
  @slices.each do |slice|
    slice.attach_to(series)
  end
end