Sha256: 127964a2e742a6fea5da2a84b5584a989bceaba3380d8850a736a13feb8dcceb
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
# encoding: utf-8 # Dicom Additions is a test extension of DICOM to allow for gathering common tags class DicomGroup # Array of DObjects to aggregate attr_accessor :dobjects # Hash of tags shared by all DICOMs in Directory attr_reader :tags # DICOM::DObject containing all common tags of the group attr_reader :common # Initialize with an array of strings or DICOM::DObjects to aggregate def initialize(dicomgroup) if dicomgroup.select {|dcm| dcm.is_a? DICOM::DObject }.empty? @dobjects = dicomgroup.collect {|dcm| DICOM::DObject.new(dcm)} else @dobjects = dicomgroup end end # Return a hash of tags and values of elements common to all DICOMs in the group. def find_common_tags @dobjects.inject(@dobjects.first.to_hash) do |memo, dobj| memo = memo.similar(dobj.to_hash) end end # Return a new DICOM::DObject containing elements common (identical tags and values) to all DICOMs in the group. def find_common_elements @dobjects.inject do |memo, dobj| memo.remove_elements_that_differ_from dobj memo end end end # Reopen DObject to make tag hash class DICOM::DObject # Return hash of {tags => values} def to_hash taghash = {} @tags.each_key {|k| taghash[k] = value(k) } return taghash end # Remove elements from a dobj that aren't identical to self's tags. def remove_elements_that_differ_from(other_dobj) @tags.each_key do |k| unless @tags[k].eql? other_dobj[k] # pp k, [@tags[k].value, other_dobj[k].value] remove k end end end end # Reopen DataElement to compare class DICOM::DataElement # Compare data elements on their tag and value def eql?(other) @tag == other.instance_eval("@tag") && @value == other.value && @bin == other.instance_eval("@bin") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
metamri-0.2.20 | lib/metamri/dicom_additions.rb |
metamri-0.2.19 | lib/metamri/dicom_additions.rb |
metamri-0.2.18 | lib/metamri/dicom_additions.rb |