Class: RTKIT::Setup
- Inherits:
-
Object
- Object
- RTKIT::Setup
- 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
-
#number ⇒ Object
Patient setup number (Integer).
-
#offset_lateral ⇒ Object
Table top lateral setup displacement (Float).
-
#offset_longitudinal ⇒ Object
Table top longitudinal setup displacement (Float).
-
#offset_vertical ⇒ Object
Table top vertical setup displacement (Float).
-
#plan ⇒ Object
readonly
The Plan that the Setup is defined for.
-
#position ⇒ Object
Patient position (orientation).
-
#technique ⇒ Object
Setup technique.
Class Method Summary collapse
-
.create_from_item(setup_item, plan) ⇒ Object
Creates a new Setup instance from the patient setup item of the RTPlan file.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Returns true if the argument is an instance with attributes equal to self.
-
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
-
#initialize(position, number, plan, options = {}) ⇒ Setup
constructor
Creates a new Setup instance.
-
#to_item ⇒ Object
Creates and returns a Patient Setup Sequence Item from the attributes of the Setup.
-
#to_setup ⇒ Object
Returns self.
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.
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, ={}) 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 = [:technique] if [:technique] self.offset_vertical = [:offset_vertical] if [:offset_vertical] self.offset_longitudinal = [:offset_longitudinal] if [:offset_longitudinal] self.offset_lateral = [:offset_lateral] if [:offset_lateral] # Set references: @plan = plan # Register ourselves with the Plan: @plan.add_setup(self) end |
Instance Attribute Details
#number ⇒ Object
Patient setup number (Integer).
12 13 14 |
# File 'lib/rtkit/setup.rb', line 12 def number @number end |
#offset_lateral ⇒ Object
Table top lateral setup displacement (Float).
14 15 16 |
# File 'lib/rtkit/setup.rb', line 14 def offset_lateral @offset_lateral end |
#offset_longitudinal ⇒ Object
Table top longitudinal setup displacement (Float).
16 17 18 |
# File 'lib/rtkit/setup.rb', line 16 def offset_longitudinal @offset_longitudinal end |
#offset_vertical ⇒ Object
Table top vertical setup displacement (Float).
18 19 20 |
# File 'lib/rtkit/setup.rb', line 18 def offset_vertical @offset_vertical end |
#plan ⇒ Object (readonly)
The Plan that the Setup is defined for.
20 21 22 |
# File 'lib/rtkit/setup.rb', line 20 def plan @plan end |
#position ⇒ Object
Patient position (orientation).
22 23 24 |
# File 'lib/rtkit/setup.rb', line 22 def position @position end |
#technique ⇒ Object
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.
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) = Hash.new # Values from the Patient Setup Item: position = setup_item.value(PATIENT_POSITION) || '' number = setup_item.value(PATIENT_SETUP_NUMBER).to_i [:technique] = setup_item.value(SETUP_TECHNIQUE) [:offset_vertical] = setup_item.value(OFFSET_VERTICAL).to_f [:offset_longitudinal] = setup_item.value(OFFSET_LONG).to_f [:offset_lateral] = setup_item.value(OFFSET_LATERAL).to_f # Create the Setup instance: s = self.new(position, number, plan, ) 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 |
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
94 95 96 |
# File 'lib/rtkit/setup.rb', line 94 def hash state.hash end |
#to_item ⇒ Object
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_setup ⇒ Object
Returns self.
183 184 185 |
# File 'lib/rtkit/setup.rb', line 183 def to_setup self end |