/usr/share/pyshared/dicom/examples/DicomInfo.py is in python-dicom 0.9.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # DicomInfo.py
"""
Read a DICOM file and print some or all of its values.
Usage: python DicomInfo.py imagefile [-v]
-v (optional): Verbose mode, prints all DICOM data elements
Without the -v option, a few of the most common dicom file
data elements are printed: some info about the patient and about
the image.
"""
# Copyright (c) 2008-2011 Darcy Mason
# This file is part of pydicom, released under an MIT license.
# See the file license.txt included with this distribution, also
# available at http://pydicom.googlecode.com
import sys
import dicom
# check command line arguments make sense
if not 1 < len(sys.argv) < 4:
print __doc__
sys.exit()
# read the file
filename = sys.argv[1]
dataset = dicom.read_file(filename)
# Verbose mode:
if len(sys.argv) == 3:
if sys.argv[2]=="-v": #user asked for all info
print dataset
else: # unknown command argument
print __doc__
sys.exit()
# Normal mode:
print
print "Filename.........:", filename
print "Storage type.....:", dataset.SOPClassUID
print
pat_name = dataset.PatientsName
display_name = pat_name.family_name + ", " + pat_name.given_name
print "Patient's name...:", display_name
print "Patient id.......:", dataset.PatientID
print "Modality.........:", dataset.Modality
print "Study Date.......:", dataset.StudyDate
if 'PixelData' in dataset:
print "Image size.......: %i x %i, %i bytes" % (dataset.Rows, dataset.Columns, len(dataset.PixelData))
if 'PixelSpacing' in dataset:
print "Pixel spacing....:", dataset.PixelSpacing
# use .get() if not sure the item exists, and want a default value if missing
print "Slice location...:", dataset.get('SliceLocation', "(missing)")
|