18 python ManipulateSequence.py input.dcm output.dcm
20 This was tested using:
22 python ManipulateSequence.py gdcmData/D_CLUNIE_CT1_J2KI.dcm myoutput.dcm
24 This is a dummy example on how to modify a value set in a nested-nested dataset
27 Do not use as-is in production, this is just an example
28 This example works in an undefined length Item only (you need to explicitely recompute the length otherwise)
34 if __name__ ==
"__main__":
40 r.SetFileName( file1 )
47 if ds.FindDataElement( tsis ):
48 sis = ds.GetDataElement( tsis )
51 sqsis = sis.GetValueAsSQ()
52 if sqsis.GetNumberOfItems():
53 item1 = sqsis.GetItem(1)
54 nestedds = item1.GetNestedDataSet()
56 if nestedds.FindDataElement( tprcs ):
57 prcs = nestedds.GetDataElement( tprcs )
58 sqprcs = prcs.GetSequenceOfItems()
59 if sqprcs.GetNumberOfItems():
60 item2 = sqprcs.GetItem(1)
61 nestedds2 = item2.GetNestedDataSet()
64 if nestedds2.FindDataElement( tcm ):
65 cm = nestedds2.GetDataElement( tcm )
66 mystr =
"GDCM was here"
67 cm.SetByteValue( mystr,
gdcm.VL( len(mystr) ) )
71 w.SetFileName( file2 )