comparison Resources/DicomConformanceStatement.py @ 1073:01414536c930

complete DICOM conformance
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Jul 2014 10:24:09 +0200
parents
children de54c19fc44d
comparison
equal deleted inserted replaced
1072:1dffa9f44a94 1073:01414536c930
1 #!/usr/bin/python
2
3 # This file injects the UID information into the DICOM conformance
4 # statement of Orthanc
5
6 import re
7
8 # Read the conformance statement of Orthanc
9 with open('DicomConformanceStatement.txt', 'r') as f:
10 statements = f.readlines()
11
12 # Create an index of all the DICOM UIDs that are known to DCMTK
13 uids = {}
14 with open('/usr/include/dcmtk/dcmdata/dcuid.h', 'r') as dcmtk:
15 for l in dcmtk.readlines():
16 m = re.match(r'#define UID_(.+?)\s*"(.+?)"', l)
17 if m != None:
18 uids[m.group(1)] = m.group(2)
19
20 # Loop over the lines of the statement, looking for the "|" separator
21 with open('/tmp/DicomConformanceStatement.txt', 'w') as f:
22 for l in statements:
23 m = re.match(r'(\s*)(.*?)(\s*)\|.*$', l)
24 if m != None:
25 name = m.group(2)
26 uid = uids[name]
27 f.write('%s%s%s| %s\n' % (m.group(1), name, m.group(3), uid))
28
29 else:
30 # No "|" in this line, just output it
31 f.write(l)