Method: DICOM::DObject#summary
- Defined in:
- lib/dicom/d_object.rb
#summary ⇒ Array<String>
Gathers key information about the DObject as well as some system data, and prints this information to the screen. This information includes properties like encoding, byte order, modality and various image properties.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/dicom/d_object.rb', line 261 def summary # FIXME: Perhaps this method should be split up in one or two separate methods # which just builds the information arrays, and a third method for printing this to the screen. sys_info = Array.new info = Array.new # Version of Ruby DICOM used: sys_info << "Ruby DICOM version: #{VERSION}" # System endian: cpu = (CPU_ENDIAN ? "Big Endian" : "Little Endian") sys_info << "Byte Order (CPU): #{cpu}" # Source (file name): if @source if @source == :str source = "Binary string #{@read_success ? '(successfully parsed)' : '(failed to parse)'}" else source = "File #{@read_success ? '(successfully read)' : '(failed to read)'}: #{@source}" end else source = 'Created from scratch' end info << "Source: #{source}" # Modality: modality = (LIBRARY.uid(value('0008,0016')) ? LIBRARY.uid(value('0008,0016')).name : "SOP Class unknown or not specified!") info << "Modality: #{modality}" # Meta header presence (Simply check for the presence of the transfer syntax data element), VR and byte order: ts_status = self['0002,0010'] ? '' : ' (Assumed)' ts = LIBRARY.uid(transfer_syntax) explicit = ts ? ts.explicit? : true endian = ts ? ts.big_endian? : false = ts ? "" : " (But unknown/invalid transfer syntax: #{transfer_syntax})" info << "Meta Header: #{self['0002,0010'] ? 'Yes' : 'No'}#{}" info << "Value Representation: #{explicit ? 'Explicit' : 'Implicit'}#{ts_status}" info << "Byte Order (File): #{endian ? 'Big Endian' : 'Little Endian'}#{ts_status}" # Pixel data: pixels = self[PIXEL_TAG] unless pixels info << "Pixel Data: No" else info << "Pixel Data: Yes" # Image size: cols = (exists?("0028,0011") ? self["0028,0011"].value : "Columns missing") rows = (exists?("0028,0010") ? self["0028,0010"].value : "Rows missing") info << "Image Size: #{cols}*#{rows}" # Frames: frames = value("0028,0008") || "1" unless frames == "1" or frames == 1 # Encapsulated or 3D pixel data: if pixels.is_a?(Element) frames = frames.to_s + " (3D Pixel Data)" else frames = frames.to_s + " (Encapsulated Multiframe Image)" end end info << "Number of frames: #{frames}" # Color: colors = (exists?("0028,0004") ? self["0028,0004"].value : "Not specified") info << "Photometry: #{colors}" # Compression: compression = (ts ? (ts.compressed_pixels? ? ts.name : 'No') : 'No' ) info << "Compression: #{compression}#{ts_status}" # Pixel bits (allocated): bits = (exists?("0028,0100") ? self["0028,0100"].value : "Not specified") info << "Bits per Pixel: #{bits}" end # Print the DICOM object's key properties: separator = "-------------------------------------------" puts "System Properties:" puts separator + "\n" puts sys_info puts "\n" puts "DICOM Object Properties:" puts separator puts info puts separator return info end |