1
14
15"""
16Usage:
17
18 python MergeFile.py input1.dcm input2.dcm
19
20 It will produce a 'merge.dcm' output file, which contains all meta information from input1.dcm
21 and copy the Stored Pixel values from input2.dcm
22 This script even works when input2.dcm is a Secondary Capture and does not contains information
23 such as IOP and IPP...
24"""
25
26import sys
27import gdcm
28
29if __name__ == "__main__":
30
31 file1 = sys.argv[1]
32 file2 = sys.argv[2]
33
35 r1.SetFileName( file1 )
36 if not r1.Read():
37 sys.exit(1)
38
40 r2.SetFileName( file2 )
41 if not r2.Read():
42 sys.exit(1)
43
44
45
46
47 r1.GetImage().SetDataElement( r2.GetImage().GetDataElement() )
48
50 w.SetFile( r1.GetFile() )
51
52 w.SetImage( r1.GetImage() )
53
54 w.SetFileName( "merge.dcm" )
55 if not w.Write():
56 sys.exit(1)
57
58 sys.exit(0)
ImageReader.
Definition gdcmImageReader.h:34
ImageWriter.
Definition gdcmImageWriter.h:33