Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # class DicomModification
- # attr_reader :source, :overwrite, :remove
- # def initialize(source:, overwrite: {}, remove: [])
- # @source = source
- # @overwrite = overwrite
- # @remove = remove
- # end
- # def write_changes!
- # # modify_tags(parsed_dicom)
- # # remove_tags(parsed_dicom)
- # tag_list = modify_tags(parsed_dicom) + remove_tags(parsed_dicom)
- # run_dcmodify(tag_list)
- # end
- # private
- # def parsed_dicom
- # @parsed_dicom ||= DICOM::DObject.read(source)
- # end
- # def modify_tags(dicom)
- # # modifications = overwrite
- # # .select { |tag, _| dicom.exists?(tag) }
- # # .flat_map { |tag, value| ["-m", "#{tag}=#{value}"] }
- # # run_dcmodify(modifications) unless modifications.empty?
- # overwrite.flat_map { |tag, value| ["-m", "#{tag}=#{value}"] if dicom.exists?(tag) }
- # end
- # def remove_tags(dicom)
- # # removals = remove
- # # .select { |tag| dicom.exists?(tag) }
- # # .flat_map { |tag| ["-e", tag] }
- # # run_dcmodify(removals) unless removals.empty?
- # remove.flat_map { |tag| ["-e", tag] if dicom.exists?(tag) }
- # end
- # def run_dcmodify(args)
- # system("dcmodify", "+te", *args, source)
- # end
- # end
- # class DicomModification
- # attr_reader :source, :overwrite, :remove
- # def initialize(source:, overwrite: {}, remove: [])
- # @source = source
- # @overwrite = overwrite
- # @remove = remove
- # end
- # def write_changes!
- # tag_list = modify_tags(parsed_dicom) + remove_tags(parsed_dicom)
- # run_dcmodify(tag_list)
- # end
- # private
- # def parsed_dicom
- # @parsed_dicom ||= DICOM::DObject.read(source)
- # end
- # def modify_tags(dicom)
- # overwrite.flat_map { |tag, value| ["-m", "#{tag}=#{value}"] if dicom.exists?(tag) }
- # end
- # def remove_tags(dicom)
- # remove.flat_map { |tag| ["-e", tag] if dicom.exists?(tag) }
- # end
- # def run_dcmodify(args)
- # system("dcmodify", "+te", *args, source)
- # end
- # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement