Class: RTKIT::RTImage
Overview
The RTImage class contains methods that are specific for this modality (RTIMAGE).
Inheritance
-
RTImage inherits all methods and attributes from the Series class.
Instance Attribute Summary collapse
-
#images ⇒ Object
readonly
An array of Plan Verification Images associated with this RTImage Series.
-
#plan ⇒ Object
readonly
The Plan which this RTImage Series belongs to.
Attributes inherited from Series
#class_uid, #date, #description, #modality, #series_uid, #study, #time
Class Method Summary collapse
-
.load(dcm, study) ⇒ Object
Creates a new RTImage (series) instance by loading the relevant information from the specified DICOM object.
-
.plan(dcm, study) ⇒ Object
Identifies the Plan that the RTImage object belongs to.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Returns true if the argument is an instance with attributes equal to self.
-
#add(dcm) ⇒ Object
Registers a DICOM Object to the RTImage series, and processes it to create (and reference) an (RT) Image instance linked to this RTImage series.
-
#add_image(image) ⇒ Object
Adds an Image to this RTImage series.
-
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
-
#initialize(series_uid, plan, options = {}) ⇒ RTImage
constructor
Creates a new RTImage instance.
-
#to_rt_image ⇒ Object
Returns self.
Methods inherited from Series
Constructor Details
#initialize(series_uid, plan, options = {}) ⇒ RTImage
Creates a new RTImage instance.
Parameters
-
series_uid
– The Series Instance UID string. -
plan
– The Plan that this RTImage series belongs to. -
options
– A hash of parameters.
Options
-
:date
– String. The Series Date (DICOM tag ‘0008,0021’). -
:time
– String. The Series Time (DICOM tag ‘0008,0031’). -
:description
– String. The Series Description (DICOM tag ‘0008,103E’). -
:series_uid
– String. The Series Instance UID (DICOM tag ‘0020,000E’).
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rtkit/rt_image.rb', line 97 def initialize(series_uid, plan, ={}) raise ArgumentError, "Invalid argument 'series_uid'. Expected String, got #{series_uid.class}." unless series_uid.is_a?(String) raise ArgumentError, "Invalid argument 'plan'. Expected Plan, got #{plan.class}." unless plan.is_a?(Plan) # Pass attributes to Series initialization: [:class_uid] = '1.2.840.10008.5.1.4.1.1.481.1' # RT Image Storage super(series_uid, 'RTIMAGE', plan.struct.study, ) @plan = plan # Default attributes: @images = Array.new @associated_images = Hash.new # Register ourselves with the Plan: @plan.add_rt_image(self) end |
Instance Attribute Details
#images ⇒ Object (readonly)
An array of Plan Verification Images associated with this RTImage Series.
12 13 14 |
# File 'lib/rtkit/rt_image.rb', line 12 def images @images end |
#plan ⇒ Object (readonly)
The Plan which this RTImage Series belongs to.
14 15 16 |
# File 'lib/rtkit/rt_image.rb', line 14 def plan @plan end |
Class Method Details
.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.
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 |
.plan(dcm, study) ⇒ Object
Identifies the Plan that the RTImage object belongs to. If the referenced instances (Plan, StructureSet, ImageSeries & Frame) does not exist, they are created by this method.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rtkit/rt_image.rb', line 47 def self.plan(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' # Extract the Frame of Reference UID: begin frame_of_ref = dcm.value(FRAME_OF_REF) rescue frame_of_ref = nil end # Extract referenced Plan SOP Instance UID: begin ref_plan_uid = dcm[REF_PLAN_SQ][0].value(REF_SOP_UID) rescue ref_plan_uid = nil end # Create the Frame if it doesn't exist: f = study.patient.dataset.frame(frame_of_ref) f = Frame.new(frame_of_ref, study.patient) unless f # Create the Plan, StructureSet & ImageSeries if the referenced Plan doesn't exist: plan = study.fseries(ref_plan_uid) unless plan # Create ImageSeries (assuming modality CT): is = ImageSeries.new(RTKIT.series_uid, 'CT', f, study) study.add_series(is) # Create StructureSet: struct = StructureSet.new(RTKIT.sop_uid, is) study.add_series(struct) # Create Plan: plan = Plan.new(ref_plan_uid, struct) study.add_series(plan) end return plan end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Returns true if the argument is an instance with attributes equal to self.
113 114 115 116 117 |
# File 'lib/rtkit/rt_image.rb', line 113 def ==(other) if other.respond_to?(:to_rt_image) other.send(:state) == state end end |
#add(dcm) ⇒ Object
Registers a DICOM Object to the RTImage series, and processes it to create (and reference) an (RT) Image instance linked to this RTImage series.
124 125 126 127 128 129 |
# File 'lib/rtkit/rt_image.rb', line 124 def add(dcm) raise ArgumentError, "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm.is_a?(DICOM::DObject) Image.load(dcm, self) #load_patient_setup #load_fields end |
#add_image(image) ⇒ Object
Adds an Image to this RTImage series.
133 134 135 136 137 |
# File 'lib/rtkit/rt_image.rb', line 133 def add_image(image) raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image) @images << image unless @associated_images[image.uid] @associated_images[image.uid] = image end |
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
141 142 143 |
# File 'lib/rtkit/rt_image.rb', line 141 def hash state.hash end |
#to_rt_image ⇒ Object
Returns self.
147 148 149 |
# File 'lib/rtkit/rt_image.rb', line 147 def to_rt_image self end |