Method: RTKIT::ImageSeries.load

Defined in:
lib/rtkit/image_series.rb

.load(dcm, study) ⇒ Object

Creates a new ImageSeries instance by loading series information from the specified DICOM object. The Series’ UID string value is used to uniquely identify an ImageSeries.

Parameters

  • dcm – An instance of a DICOM object (DICOM::DObject) with an image type modality (e.g. CT or MR).

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

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rtkit/image_series.rb', line 32

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 an Image Series type modality, got #{dcm.value(MODALITY)}." unless IMAGE_SERIES.include?(dcm.value(MODALITY))
  # Required attributes:

  modality = dcm.value(MODALITY)
  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)
  # Check if a Frame with the given UID already exists, and if not, create one:

  frame = study.patient.dataset.frame(dcm.value(FRAME_OF_REF)) || frame = study.patient.create_frame(dcm.value(FRAME_OF_REF), dcm.value(POS_REF_INDICATOR))
  # Create the ImageSeries instance:

  is = self.new(series_uid, modality, frame, study, :class_uid => class_uid, :date => date, :time => time, :description => description)
  is.add(dcm)
  # Add our ImageSeries instance to its corresponding Frame:

  frame.add_series(is)
  return is
end