Class: DicomS::CLI
- Inherits:
-
Thor
- Object
- Thor
- DicomS::CLI
- Defined in:
- lib/dicoms/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #extract(dicom_dir) ⇒ Object
- #pack(dicom_dir) ⇒ Object
- #projection(dicom_dir) ⇒ Object
- #remap(dicom_dir) ⇒ Object
- #stats(dicom_dir) ⇒ Object
-
#unpack(dspack) ⇒ Object
TODO: parameters for dicom regeneration.
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
7 8 9 |
# File 'lib/dicoms/cli.rb', line 7 def self.exit_on_failure? true end |
Instance Method Details
#extract(dicom_dir) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/dicoms/cli.rb', line 91 def extract(dicom_dir)000 DICOM.logger.level = Logger::FATAL settings = {} # TODO: ... unless File.exists?(dicom_dir) raise Error, set_color("Directory not found: #{dicom_dir}", :red) say end raw = .raw if .big raw = true big_endian = true elsif .little raw = true little_endian = true end packer = DicomS.new(settings) packer.extract( dicom_dir, transfer: DicomS.(), output: .output, raw: raw, big_endian: big_endian, little_endian: little_endian ) # rescue => raise Error? 0 end |
#pack(dicom_dir) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dicoms/cli.rb', line 32 def pack(dicom_dir) DICOM.logger.level = Logger::FATAL strategy_parameters = { ignore_min: true } settings = {} # TODO: ... unless File.directory?(dicom_dir) raise Error, set_color("Directory not found: #{dicom_dir}", :red) say end = CommandOptions[ settings: .settings, settings_io: .settings_io, output: .output, tmp: .tmp, reorder: .reorder, dicom_metadata: true ] packer = DicomS.new(settings) packer.pack dicom_dir, # rescue => raise Error? 0 end |
#projection(dicom_dir) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/dicoms/cli.rb', line 149 def projection(dicom_dir) DICOM.logger.level = Logger::FATAL settings = {} # TODO: ... unless File.directory?(dicom_dir) raise Error, set_color("Directory not found: #{dicom_dir}", :red) say end if .settings_io || .settings = CommandOptions[ settings: .settings, settings_io: .settings_io, output: .output, max_x_pixels: .max_x_pixels && .max_x_pixels.to_i, max_y_pixels: .max_y_pixels && .max_y_pixels.to_i, max_z_pixels: .max_z_pixels && .max_z_pixels.to_i, reorder: .reorder, ] else = CommandOptions[ transfer: DicomS.(), output: .output, axial: .axial == 'axial' ? 'mip' : .axial, sagittal: .sagittal == 'sagittal' ? 'mip' : .sagittal, coronal: .coronal == 'coronal' ? 'mip' : .coronal, max_x_pixels: .max_x_pixels && .max_x_pixels.to_i, max_y_pixels: .max_y_pixels && .max_y_pixels.to_i, max_z_pixels: .max_z_pixels && .max_z_pixels.to_i, reorder: .reorder, ] end unless .axial || .sagittal || .coronal raise Error, "Must specify at least one projection (axial/sagittal/coronal)" end packer = DicomS.new(settings) packer.projection(dicom_dir, ) # rescue => raise Error? 0 end |
#remap(dicom_dir) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/dicoms/cli.rb', line 199 def remap(dicom_dir) DICOM.logger.level = Logger::FATAL settings = {} # TODO: ... unless File.directory?(dicom_dir) raise Error, set_color("Directory not found: #{dicom_dir}", :red) say end packer = DicomS.new(settings) packer.remap( dicom_dir, transfer: DicomS.(), output: .output ) # rescue => raise Error? 0 end |
#stats(dicom_dir) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/dicoms/cli.rb', line 120 def stats(dicom_dir) DICOM.logger.level = Logger::FATAL settings = {} # TODO: ... dicoms = DicomS.new(settings) stats = dicoms.stats dicom_dir puts "Aggregate values for #{stats[:n]} DICOM files:" puts " Minimum level: #{stats[:min]}" puts " Next minimum level: #{stats[:next_min]}" puts " Maximum level: #{stats[:max]}" 0 end |
#unpack(dspack) ⇒ Object
TODO: parameters for dicom regeneration
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dicoms/cli.rb', line 60 def unpack(dspack) DICOM.logger.level = Logger::FATAL unless File.file?(dspack) raise Error, set_color("File not found: #{dspack}", :red) say end settings = {} # TODO: ... packer = DicomS.new(settings) packer.unpack( dspack, settings: .settings, settings_io: .settings_io, output: .output, dicom_output: .dicom ) # rescue => raise Error? 0 end |
#version ⇒ Object
13 14 15 |
# File 'lib/dicoms/cli.rb', line 13 def version say "dicoms #{VERSION}" end |