GDCM: GetPortionCSAHeader.py

GDCM 3.2.5

GetPortionCSAHeader.py
1
14
15"""
16Usage:
17
18 python GetPortionCSAHeader.py input.dcm
19
20Footnote:
21 SIEMENS is not publishing any information on the CSA header. So any info extracted
22 is at your own risk.
23"""
24
25import sys
26import gdcm
27
28if __name__ == "__main__":
29
30 file = sys.argv[1]
31
32 r = gdcm.Reader()
33 r.SetFileName( file )
34 if not r.Read():
35 sys.exit(1)
36
37 ds = r.GetFile().GetDataSet()
38 csa_t1 = gdcm.CSAHeader()
39 csa_t2 = gdcm.CSAHeader()
40 #print csa
41 t1 = csa_t1.GetCSAImageHeaderInfoTag();
42 print t1
43 t2 = csa_t2.GetCSASeriesHeaderInfoTag();
44 print t2
45 # Let's do it for t1:
46 if ds.FindDataElement( t1 ):
47 csa_t1.LoadFromDataElement( ds.GetDataElement( t1 ) )
48 print csa_t1
49
50 # Now let's pretend we are only interested in B_value and DiffusionGradientDirection entries:
51 bvalues = csa_t1.GetCSAElementByName( "B_value" ) # WARNING: it is case sensitive !
52 print bvalues
53
54 diffgraddir = csa_t1.GetCSAElementByName( "DiffusionGradientDirection" ) # WARNING: it is case sensitive !
55 print diffgraddir
56
57 # repeat for t2 if you like it:
58 if ds.FindDataElement( t2 ):
59 csa_t2.LoadFromDataElement( ds.GetDataElement( t2 ) )
60 # print csa_t2
61
62 gdt = csa_t2.GetCSAElementByName( "GradientDelayTime" )
63 print gdt
64
65 bv = gdt.GetByteValue();
66 #print bv
67 str = bv.GetPointer()
68 print str.split("\\")
gdcm::CSAHeader
Class for CSAHeader.
Definition gdcmCSAHeader.h:64
gdcm::Reader
Reader ala DOM (Document Object Model).
Definition gdcmReader.h:54