Class: RTKIT::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/rtkit/setup.rb

Overview

Contains DICOM data and methods related to a patient Setup item, defined in a Plan.

Relations

  • A Plan has a Setup.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position, number, plan, options = {}) ⇒ Setup

Creates a new Setup instance.

Parameters

  • position – String. The patient position (orientation).

  • number – Integer. The Setup number.

  • plan – The Plan instance that this Beam belongs to.

  • options – A hash of parameters.

Options

  • :technique – String. Setup technique.

  • :offset_vertical – Float. Table top vertical setup displacement.

  • :offset_longitudinal – Float. Table top longitudinal setup displacement.

  • :offset_lateral – Float. Table top lateral setup displacement.

Raises:

  • (ArgumentError)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rtkit/setup.rb', line 66

def initialize(position, number, plan, options={})
  raise ArgumentError, "Invalid argument 'plan'. Expected Plan, got #{plan.class}." unless plan.is_a?(Plan)
  # Set values:
  self.position = position
  self.number = number
  # Set options:
  self.technique = options[:technique] if options[:technique]
  self.offset_vertical = options[:offset_vertical] if options[:offset_vertical]
  self.offset_longitudinal = options[:offset_longitudinal] if options[:offset_longitudinal]
  self.offset_lateral = options[:offset_lateral] if options[:offset_lateral]
  # Set references:
  @plan = plan
  # Register ourselves with the Plan:
  @plan.add_setup(self)
end

Instance Attribute Details

#numberObject

Patient setup number (Integer).



12
13
14
# File 'lib/rtkit/setup.rb', line 12

def number
  @number
end

#offset_lateralObject

Table top lateral setup displacement (Float).



14
15
16
# File 'lib/rtkit/setup.rb', line 14

def offset_lateral
  @offset_lateral
end

#offset_longitudinalObject

Table top longitudinal setup displacement (Float).



16
17
18
# File 'lib/rtkit/setup.rb', line 16

def offset_longitudinal
  @offset_longitudinal
end

#offset_verticalObject

Table top vertical setup displacement (Float).



18
19
20
# File 'lib/rtkit/setup.rb', line 18

def offset_vertical
  @offset_vertical
end

#planObject (readonly)

The Plan that the Setup is defined for.



20
21
22
# File 'lib/rtkit/setup.rb', line 20

def plan
  @plan
end

#positionObject

Patient position (orientation).



22
23
24
# File 'lib/rtkit/setup.rb', line 22

def position
  @position
end

#techniqueObject

Setup technique.



24
25
26
# File 'lib/rtkit/setup.rb', line 24

def technique
  @technique
end

Class Method Details

.create_from_item(setup_item, plan) ⇒ Object

Creates a new Setup instance from the patient setup item of the RTPlan file. Returns the Setup instance.

Parameters

  • setup_item – The patient setup item from the DObject of a RTPlan file.

  • plan – The Plan instance that this Setup belongs to.

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rtkit/setup.rb', line 34

def self.create_from_item(setup_item, plan)
  raise ArgumentError, "Invalid argument 'setup_item'. Expected DICOM::Item, got #{setup_item.class}." unless setup_item.is_a?(DICOM::Item)
  raise ArgumentError, "Invalid argument 'plan'. Expected Plan, got #{plan.class}." unless plan.is_a?(Plan)
  options = Hash.new
  # Values from the Patient Setup Item:
  position = setup_item.value(PATIENT_POSITION) || ''
  number = setup_item.value(PATIENT_SETUP_NUMBER).to_i
  options[:technique] = setup_item.value(SETUP_TECHNIQUE)
  options[:offset_vertical] = setup_item.value(OFFSET_VERTICAL).to_f
  options[:offset_longitudinal] = setup_item.value(OFFSET_LONG).to_f
  options[:offset_lateral] = setup_item.value(OFFSET_LATERAL).to_f
  # Create the Setup instance:
  s = self.new(position, number, plan, options)
  return s
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Returns true if the argument is an instance with attributes equal to self.



84
85
86
87
88
# File 'lib/rtkit/setup.rb', line 84

def ==(other)
  if other.respond_to?(:to_setup)
    other.send(:state) == state
  end
end

#hashObject

Generates a Fixnum hash value for this instance.



94
95
96
# File 'lib/rtkit/setup.rb', line 94

def hash
  state.hash
end

#to_itemObject

Creates and returns a Patient Setup Sequence Item from the attributes of the Setup.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/rtkit/setup.rb', line 166

def to_item
  item = DICOM::Item.new
  item.add(DICOM::Element.new(ROI_COLOR, @color))
  s = DICOM::Sequence.new(CONTOUR_SQ)
  item.add(s)
  item.add(DICOM::Element.new(REF_ROI_NUMBER, @number.to_s))
  # Add Contour items to the Contour Sequence (one or several items per Slice):
  @slices.each do |slice|
    slice.contours.each do |contour|
      s.add_item(contour.to_item)
    end
  end
  return item
end

#to_setupObject

Returns self.



183
184
185
# File 'lib/rtkit/setup.rb', line 183

def to_setup
  self
end