GDCM
2.2.6
Main Page
Related Pages
Namespaces
Classes
Files
Examples
RemovePrivateTags.py
1
############################################################################
2
#
3
# Program: GDCM (Grassroots DICOM). A DICOM library
4
#
5
# Copyright (c) 2006-2011 Mathieu Malaterre
6
# All rights reserved.
7
# See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
#
9
# This software is distributed WITHOUT ANY WARRANTY; without even
10
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11
# PURPOSE. See the above copyright notice for more information.
12
#
13
############################################################################
14
15
"""
16
Usage:
17
18
python RemovePrivateTags.py input.dcm output.dcm
19
"""
20
21
import
sys
22
import
gdcm
23
24
25
if
__name__ ==
"__main__"
:
26
27
file1 = sys.argv[1]
28
file2 = sys.argv[2]
29
30
# Instanciate the reader.
31
r =
gdcm.Reader
()
32
r.SetFileName( file1 )
33
if
not
r.Read():
34
sys.exit(1)
35
36
# Remove private tags
37
ano =
gdcm.Anonymizer
()
38
ano.SetFile( r.GetFile() )
39
if
not
ano.RemovePrivateTags():
40
sys.exit(1)
41
42
# Write DICOM file
43
w =
gdcm.Writer
()
44
w.SetFile( ano.GetFile() )
45
#w.CheckFileMetaInformationOff() # Do not attempt to check meta header
46
w.SetFileName( file2 )
47
if
not
w.Write():
48
sys.exit(1)
49
50
# It is usually a good idea to exit the script with an error, as gdcm does not remove partial (incorrect) DICOM file
51
# (application level)
Generated on Sat Dec 21 2013 05:56:15 for GDCM by
1.8.5