I have a directory that is filled with DICOM files that I obtained by using the
Offis DICOM tool kit.
The dictionary file I have is not included in the DICOM file. I have a flat
file that has all of the DICOM fields defined as a python dictionary. In my
initial post I
included only the first section.
dicomdict = {
# meta tags
(0x0002,0x0001):('OB', "FileMetaInformationVersion", '1', ''),
(0x0002,0x0002):('UI', "MediaStorageSOPClassUID",'1', ''),
(0x0002,0x0003):('UI', "MediaStorageSOPInstanceUID", '1', ''),
(0x0002,0x0010):('UI', "TransferSyntaxUID", '1', ''),
(0x0002,0x0012):('UI', "ImplementationClassUID", '1', ''),
(0x0002,0x0013):('SH', "ImplementationVersionName", '1', ''),
(0x0002,0x0016):('AE', "SourceApplicationEntityTitle", '1', ''),
(0x0002,0x0100):('UI', "PrivateInformationCreatorUID", '1', ''),
(0x0002,0x0102):('OB', "PrivateInformation", '1', ''),
# directory tags
(0x0004,0x1130):('CS', "FileSetID", '1', ''),
(0x0004,0x1141):('CS', "FileSetDescriptorFileID",'1-8', ''),
(0x0004,0x1142):('CS', "SpecificCharacterSetOfFileSetDescriptorFile", '1', ''),
(0x0004,0x1200):('UL',
"OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity", '1', ''),
(0x0004,0x1202):('UL',
"OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity", '1', ''),
(0x0004,0x1212):('US', "FileSetConsistencyFlag", '1', ''),
(0x0004,0x1220):('SQ', "DirectoryRecordSequence",'1', ''),
(0x0004,0x1400):('UL', "OffsetOfTheNextDirectoryRecord", '1', ''),
(0x0004,0x1410):('US', "RecordInUseFlag",'1', ''),
(0x0004,0x1420):('UL', "OffsetOfReferencedLowerLevelDirectoryEntity", '1', ''),
(0x0004,0x1430):('CS', "DirectoryRecordType",'1', ''),
(0x0004,0x1432):('UI', "PrivateRecordUID", '1', ''),
(0x0004,0x1500):('CS', "ReferencedFileID", '1-8', ''),
(0x0004,0x1504):('UL', "MRDRDirectoryRecordOffset", '1', ''),
(0x0004,0x1510):('UI', "ReferencedSOPClassUIDInFile",'1', ''),
(0x0004,0x1511):('UI', "ReferencedSOPInstanceUIDInFile", '1', ''),
(0x0004,0x1512):('UI', "ReferencedTransferSyntaxUIDInFile", '1', ''),
(0x0004,0x1600):('UL', "NumberOfReferences", '1', ''),
# data tags
..
..
.}
Correct I have no idea how to use the dictionaries to help me complete my task.
Currently I have the following
#!/usr/bin/python
##
import os,linecache # import the os and linecache module
import string
# First thing is to look at a directory and list
# out its contents.
# open a config file to determine the directory, only use a
# specific line in this case line #7.
dir = linecache.getline('./config',7)
# os.listdir(pathname) will list the pathname.
files = os.listdir(dir[:-1]) # remove the \n from the end of dir.
for file in files:
dfile = dir[:-1]+file
print dfile
dicom_file = open(dfile, "rb")
elem = dicom_file.readlines()
print elem
dicom_file.close() # close DICOM Files
I can open each DICOM file but it reads everything from beginning to end which
is not very efficient. I only want to pop out the elements that I am
interested in.
Hope this makes a little more sense.
Andrew
-Original Message-
From: [EMAIL PROTECTED] on behalf of Bill Sconce
Sent: Thu 2/22/2007 1:07 PM
To: tutor@python.org
Subject: Re: [Tutor] DICOM Header
On Thu, 22 Feb 2007 11:56:19 -0700
"Andrew Liimatta" <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
>
> I am having a hard time figuring something out.
>
> I have Files that are written in DICOM format. I want to be able
> to pull out