def add(dcm)
      raise ArgumentError, "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm.is_a?(DICOM::DObject)
      @dcm = dcm
      self.scaling = dcm.value(DOSE_GRID_SCALING)
      pixels = dcm.narray
      rows = dcm.value(ROWS)
      cols = dcm.value(COLUMNS)
      image_position = dcm.value(IMAGE_POSITION).split("\\")
      pos_x = image_position[0].to_f
      pos_y = image_position[1].to_f
      frame_origin = image_position[2].to_f
      cosines = dcm.value(IMAGE_ORIENTATION).split("\\").collect {|val| val.to_f} if dcm.value(IMAGE_ORIENTATION)
      spacing = dcm.value(SPACING).split("\\")
      col_spacing = spacing[1].to_f
      row_spacing = spacing[0].to_f
      nr_frames = dcm.value(NR_FRAMES).to_i
      frame_offsets = dcm.value(GRID_FRAME_OFFSETS).split("\\").collect {|value| value.to_f}
      sop_uids = RTKIT.sop_uids(nr_frames)
      # Iterate each frame and create dose images:
      nr_frames.times do |i|
        # Create an Image instance (using an arbitrary UID, as individual dose frames don't really have UIDs in DICOM):
        img = SliceImage.new(sop_uids[i], frame_origin + frame_offsets[i], self)
        # Fill in image information:
        img.columns = cols
        img.rows = rows
        img.pos_x = pos_x
        img.pos_y = pos_y
        img.col_spacing = col_spacing
        img.row_spacing = row_spacing
        img.cosines = cosines
        # Fill in the pixel frame data:
        img.narray = pixels[i, true, true]
      end
    end
def add(dcm)
      raise ArgumentError, "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm.is_a?(DICOM::DObject)
      @dcm = dcm
      self.scaling = dcm.value(DOSE_GRID_SCALING)
      pixels = dcm.narray
      rows = dcm.value(ROWS)
      cols = dcm.value(COLUMNS)
      image_position = dcm.value(IMAGE_POSITION).split("\\")
      pos_x = image_position[0].to_f
      pos_y = image_position[1].to_f
      frame_origin = image_position[2].to_f
      cosines = dcm.value(IMAGE_ORIENTATION).split("\\").collect {|val| val.to_f} if dcm.value(IMAGE_ORIENTATION)
      spacing = dcm.value(SPACING).split("\\")
      col_spacing = spacing[1].to_f
      row_spacing = spacing[0].to_f
      nr_frames = dcm.value(NR_FRAMES).to_i
      frame_offsets = dcm.value(GRID_FRAME_OFFSETS).split("\\").collect {|value| value.to_f}
      sop_uids = RTKIT.sop_uids(nr_frames)
      # Iterate each frame and create dose images:
      nr_frames.times do |i|
        # Create an Image instance (using an arbitrary UID, as individual dose frames don't really have UIDs in DICOM):
        img = SliceImage.new(sop_uids[i], frame_origin + frame_offsets[i], self)
        # Fill in image information:
        img.columns = cols
        img.rows = rows
        img.pos_x = pos_x
        img.pos_y = pos_y
        img.col_spacing = col_spacing
        img.row_spacing = row_spacing
        img.cosines = cosines
        # Fill in the pixel frame data:
        img.narray = pixels[i, true, true]
      end
    end
Registers a DICOM object to the dose volume, and processes it to create
 (and reference) a (dose) image instance (frame) linked to this dose volume.

 @param [DICOM::DObject] dcm an RTDOSE DICOM object