Class: DicomGroup
- Inherits:
-
Object
- Object
- DicomGroup
- Defined in:
- lib/metamri/dicom_additions.rb
Overview
Dicom Additions is a test extension of DICOM to allow for gathering common tags
Instance Attribute Summary collapse
-
#common ⇒ Object
readonly
DICOM::DObject containing all common tags of the group.
-
#dobjects ⇒ Object
Array of DObjects to aggregate.
-
#tags ⇒ Object
readonly
Hash of tags shared by all DICOMs in Directory.
Instance Method Summary collapse
-
#find_common_elements ⇒ Object
Return a new DICOM::DObject containing elements common (identical tags and values) to all DICOMs in the group.
-
#find_common_tags ⇒ Object
Return a hash of tags and values of elements common to all DICOMs in the group.
-
#initialize(dicomgroup) ⇒ DicomGroup
constructor
Initialize with an array of strings or DICOM::DObjects to aggregate.
Constructor Details
#initialize(dicomgroup) ⇒ DicomGroup
Initialize with an array of strings or DICOM::DObjects to aggregate
12 13 14 15 16 17 18 19 |
# File 'lib/metamri/dicom_additions.rb', line 12 def initialize(dicomgroup) if dicomgroup.select {|dcm| dcm.is_a? DICOM::DObject }.empty? @dobjects = dicomgroup.collect {|dcm| DICOM::DObject.read(dcm)} #@dobjects = dicomgroup.collect {|dcm| DICOM::DObject.new(dcm)} # changing from dicom 0.8.0 to 0.9.5 else @dobjects = dicomgroup end end |
Instance Attribute Details
#common ⇒ Object (readonly)
DICOM::DObject containing all common tags of the group
9 10 11 |
# File 'lib/metamri/dicom_additions.rb', line 9 def common @common end |
#dobjects ⇒ Object
Array of DObjects to aggregate
5 6 7 |
# File 'lib/metamri/dicom_additions.rb', line 5 def dobjects @dobjects end |
#tags ⇒ Object (readonly)
Hash of tags shared by all DICOMs in Directory
7 8 9 |
# File 'lib/metamri/dicom_additions.rb', line 7 def @tags end |
Instance Method Details
#find_common_elements ⇒ Object
Return a new DICOM::DObject containing elements common (identical tags and values) to all DICOMs in the group.
29 30 31 32 33 34 |
# File 'lib/metamri/dicom_additions.rb', line 29 def find_common_elements @dobjects.inject do |memo, dobj| memo.remove_elements_that_differ_from dobj memo end end |
#find_common_tags ⇒ Object
Return a hash of tags and values of elements common to all DICOMs in the group.
22 23 24 25 26 |
# File 'lib/metamri/dicom_additions.rb', line 22 def @dobjects.inject(@dobjects.first.to_hash) do |memo, dobj| memo = memo.similar(dobj.to_hash) end end |