Hi,
I use a Lua RetrieveResultConverter to adapt archived RT data from Helax TMS to newer treatment planning without modifying the archived data.
Now I run into a problem in sequences:
Some sequences like '(300a,00b6)-BeamLimitingDeviceSequence' are of unknown length.
I did not succeed with Lua functions like
'bldmax=#Data.ExposureSequence[ex].BeamLimitingDeviceSequence' or
'bldmax=table.getn(Data.ExposureSequence[ex].BeamLimitingDeviceSequence)'
because of type 'userdata'.
To point out the problem I used this Lua function as RetrieveResultConverter for RTIMAGE from our linac
function rrc0() writedicom(Data,Data.SOPInstanceUID..'-before') if Data.Modality=='RTIMAGE' then print('RTImage from',Data.RadiationMachineName) ex=0 while Data.ExposureSequence and Data.ExposureSequence[ex] and Data.ExposureSequence[ex].BeamLimitingDeviceSequence do print(' Exposure #',ex,' Frame=',Data.ExposureSequence[ex].ReferencedFrameNumber) bld=0 while Data.ExposureSequence[ex].BeamLimitingDeviceSequence and Data.ExposureSequence[ex].BeamLimitingDeviceSequence[bld] and Data.ExposureSequence[ex].BeamLimitingDeviceSequence[bld].RTBeamLimitingDeviceType do print(' BeamLimitingDevice #',bld,'=',Data.ExposureSequence[ex].BeamLimitingDeviceSequence[bld].RTBeamLimitingDeviceType) bld=bld+1 end -- BeamLimitingDeviceSequence ex=ex+1 end -- ExposureSequence end writedicom(Data,Data.SOPInstanceUID..'-after')end
There is no explicit modification of 'Data' in the lua function, but the dump of the dicom file saved at the end of the function shows additional empty sequence elements:
| | | | | (300A,00BE) : DS Len: 112 LeafPositionBoundaries Value: [-200\-135\-125\-115\-105\-95\-85\-75\-65\-55\-45\-35\-25\-15\-5\5\15\25\35\45\55\65\75\85\95\105\115\125\135\200...]
| | | | | (300A,011C) : DS Len: 264 LeafJawPositions Value: [0\0\0\0\0\0\-51\-50.57\-50.57\-50.57\-50.57\-50.57\-50.57\-50.32\-50.32\-50.32\-50.32\-50.32\-50.32\-50.32\-50.08\-50.08\-50.08\0\0\0\0\0\0\0\0\0\0\0\0\56.6\55.71\54.83\53.94\53.06\52.18\51.29\50.41\50.01\50.01\50.01\50.01\50.01\50.01\50.01\50.01\50.01\0\0\0\0\0\0...]
If the receiving system is another conquest, I can't see these empty elements in the header dump of the gui, but they are sent over the network and Masterplan chokes on RTPLANs containing such sequence elements reporting parsing errors.
Access to the not existing 'Data.ExposureSequence[1]' in line 7 of the function doesn't give result 'nil' but generates an empty sequence element as I further tested. It is not possible to destroy the empty element after the loop by 'Data.ExposureSequence[ex]=nil' after line 18.
What is the recomended way to parse sequences without this result?
Gerald