Method: RTKIT::RTImage.load

Defined in:
lib/rtkit/rt_image.rb

.load(dcm, study) ⇒ Object

Creates a new RTImage (series) instance by loading the relevant information from the specified DICOM object. The Series Instance UID string value is used to uniquely identify a RTImage (series) instance.

Parameters

  • dcm – An instance of a DICOM object (DICOM::DObject) with modality ‘RTIMAGE’.

  • study – The Study instance that this RTImage belongs to.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rtkit/rt_image.rb', line 24

def self.load(dcm, study)
  raise ArgumentError, "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm.is_a?(DICOM::DObject)
  raise ArgumentError, "Invalid argument 'study'. Expected Study, got #{study.class}." unless study.is_a?(Study)
  raise ArgumentError, "Invalid argument 'dcm'. Expected DObject with modality 'RTIMAGE', got #{dcm.value(MODALITY)}." unless dcm.value(MODALITY) == 'RTIMAGE'
  # Required attributes:
  series_uid = dcm.value(SERIES_UID)
  # Optional attributes:
  class_uid = dcm.value(SOP_CLASS)
  date = dcm.value(SERIES_DATE)
  time = dcm.value(SERIES_TIME)
  description = dcm.value(SERIES_DESCR)
  series_uid = dcm.value(SERIES_UID)
  # Get the corresponding Plan:
  plan = self.plan(dcm, study)
  # Create the RTImage instance:
  rtimage = self.new(series_uid, plan, :class_uid => class_uid, :date => date, :time => time, :description => description)
  rtimage.add(dcm)
  return rtimage
end