LUA binding - documentation

  • Hi,


    Please use the install.lua script from the top post of the forum to install Conquest for the just released ZBS0.39. If you fail to do this, the debugger will not work because socket.lua is replaced with an incompatible version.


    Note: this is fixed in 1.4.17b up.


    Marcel

  • Hi,


    Is there a way to get association information, like callingAE and CalledAE, inside a Exportconverter using LUA?
    I'm using 1.4.17c and I would like to use LUA (based on association information) to decide which destination to use for forwarding images.


    Dave

  • Hi Marcel,


    I've tried the following:

    Code
    ExportConverters = 2
    ExportConverter0 = nop %u;
    [lua]
    ExportConverter1 = print('Calling:', Association.Calling, Association.Called)


    The first ExportConverter is printing the calling AE-title, but the second exportconverter only prints the word: 'Calling:'.
    The association values seems to be empty, possibly because the (incomming) association is already closed?


    I've also tried using the %u variable inside lua and creating global variables, but nothing seems to work. Do you have any suggestions?


    Dave

  • Dear Conquest&Lua users!



    I want to use lua scripting with conquest to process patient datasets (CT/RTDOSE/RTSTRUC/RTPLAN) exported from TPS


    before they are imported in R&V. E.g. I want to delete some help structures used during the planning. I take


    deletebody.lua as example and do the following:




    x = DicomObject:new()
    x.PatientName = ''
    x.PatientID = ''
    x.QueryRetrieveLevel = 'STUDY'
    x.StudyInstanceUID = '' -- you want these returned for the loop
    x.ModalitiesInStudy = ''


    b=dicomquery('CONQUESTSRV1', 'STUDY', x)
    for i=0, #b-1 do
    StudyUID = b[i].StudyInstanceUID
    Modality = b[i].Modality
    Modalities = b[i].ModalitiesInStudy
    print('Found ', b[i].PatientName, ' ', StudyUID, ' Modalities: ', Modalities,
    ' Modality: ', Modality)


    -- try to extract RTS
    if string.find(Modalities, "RTSTRUCT")~=NIL then
    local SeriesInst = dbquery('DICOMSeries', 'SeriesInst', 'StudyInsta = "'..StudyUID..'" and Modality =


    "RTSTRUCT"')[1][1]
    local StructSOP = dbquery('DICOMImages', 'SOPInstanc', 'SeriesInst = "'..SeriesInst..'"')[1][1]
    strucs = newdicomobject()
    strucs:Read(b[i].PatientID..':'..StructSOP);
    strucs:Dump('J:\\strucs0.txt')
    print(' strucs modality: ', strucs.Modality)

    -- loop over RTS
    print('#Structures:', #strucs.StructureSetROISequence)
    local roinumber, index
    for istruc=0, #strucs.StructureSetROISequence-1 do
    print(strucs.StructureSetROISequence[istruc].ROINumber, ' ',
    strucs.StructureSetROISequence[istruc].ROIName);

    -- find help contour

    if strucs.StructureSetROISequence[istruc].ROIName=='HC_Rektum' then
    roinumber = strucs.StructureSetROISequence[istruc].ROINumber
    index = istruc
    print(' Found ', strucs.StructureSetROISequence[istruc].ROIName,
    ' roi# ', roinumber, ' index ', index)
    end; -- if HC found
    end; -- istruc

    -- try to delete help contour
    print(' deleting in StructureSetROISequence')
    print(' before StructureSetROISequence[', index, ']:',
    strucs.StructureSetROISequence[index])
    strucs.StructureSetROISequence[index]=nil
    print(' after StructureSetROISequence[', index, ']:',
    strucs.StructureSetROISequence[index])
    print(' after StructureSetROISequence[', index, ']:',
    strucs.StructureSetROISequence[index])
    print(' after StructureSetROISequence[', index, ']:',
    strucs.StructureSetROISequence[index])

    for istruc=0, #strucs.ROIContourSequence-1 do
    if strucs.ROIContourSequence[istruc].ReferencedROINumber==roinumber then
    index = istruc
    print(' Found roi# ', roinumber, ' in ROIContourSequence, index ', index)
    end;
    end;

    print(' deleting in ROIContourSequence, index: ', index)
    strucs.ROIContourSequence[index]=0

    for istruc=0, #strucs.RTROIObservationsSequence-1 do
    if strucs.RTROIObservationsSequence[istruc].ReferencedROINumber==roinumber then
    index = istruc
    print(' Found roi# ', roinumber, ' in RTROIObservationsSequence, index ', index)
    end;
    end;
    print(' deleting in RTROIObservationsSequence, index: ', index)
    strucs.RTROIObservationsSequence[index]=0

    strucs:Dump('J:\\strucs1.txt')


    end; -- if RTSTRUCT

    end



    Here's the output from CONQUESTSRV1 (1.4.17d):



    [CONQUESTSRV1] UPACS THREAD 41: STARTED AT: Tue Nov 18 08:57:43 2014
    [CONQUESTSRV1] Calling Application Title : "CONQUESTSRV1 "
    [CONQUESTSRV1] Called Application Title : "CONQUESTSRV1 "
    [CONQUESTSRV1] Application Context : "1.2.840.10008.3.1.1.1", PDU length: 16384
    [CONQUESTSRV1] Presentation Context 0 "1.2.840.10008.5.1.4.1.2.2.1" 1
    [CONQUESTSRV1] (StudyRootQuery) search level: STUDY
    [CONQUESTSRV1] C-Find (StudyRoot) located 2 records
    [CONQUESTSRV1] UPACS THREAD 41: ENDED AT: Tue Nov 18 08:57:43 2014
    [CONQUESTSRV1] UPACS THREAD 41: TOTAL RUNNING TIME: 0 SECONDS
    [CONQUESTSRV1] Found HEAD EXP2 1.3.46.670589.5.2.10.2156913941.892665384.993397 Modalities: CT Modality: nil
    [CONQUESTSRV1] Found XXXX 1.3.12.2.1107.5.8.9.1010144715133114222.1008359 Modalities: RTSTRUCT\RTPLAN\RTDOSE\CT


    Modality: nil
    [CONQUESTSRV1] strucs modality: RTSTRUCT
    [CONQUESTSRV1] #Structures: 31
    [CONQUESTSRV1] 1 REF
    [CONQUESTSRV1] 2 1ISO
    [CONQUESTSRV1] 3 NORM
    [CONQUESTSRV1] 4 Rektum
    [CONQUESTSRV1] 5 Bladder
    [CONQUESTSRV1] 6 Hueftkopf li
    [CONQUESTSRV1] 7 Hueftkopf re
    [CONQUESTSRV1] 8 Prostatabett
    [CONQUESTSRV1] 9 Boost
    [CONQUESTSRV1] 10 PTV
    [CONQUESTSRV1] 11 TischModell_10mm
    [CONQUESTSRV1] 12 RV sine PTV
    [CONQUESTSRV1] 13 RV cum PTV
    [CONQUESTSRV1] 14 Blase-PTV
    [CONQUESTSRV1] 15 HC_Deckelung
    [CONQUESTSRV1] 16 HC_Rektum
    [CONQUESTSRV1] Found HC_Rektum roi# 16 index 15
    [CONQUESTSRV1] 17 h
    [CONQUESTSRV1] 18 HC_PTV_1-0
    [CONQUESTSRV1] 19 HC_PTV_2-1
    [CONQUESTSRV1] 20 Outline
    [CONQUESTSRV1] 21 Outline-0.5
    [CONQUESTSRV1] 22 Outline-(PTV+2)
    [CONQUESTSRV1] 23 _Boost-0.5
    [CONQUESTSRV1] 24 _Boost+0.5
    [CONQUESTSRV1] 25 _PTV-Boost
    [CONQUESTSRV1] 26 _(PTV-Boost)-0.5
    [CONQUESTSRV1] 27 _PTV-(Boost+0.5)
    [CONQUESTSRV1] 28 Grad
    [CONQUESTSRV1] 29 Boost-0.5
    [CONQUESTSRV1] 30 (PTV-Boost)-0.5
    [CONQUESTSRV1] 31 PTV-Boost
    [CONQUESTSRV1] deleting in StructureSetROISequence
    [CONQUESTSRV1] before StructureSetROISequence[ 15 ]: userdata:0253F8A0
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:02542D10
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:01278400
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:0128E258
    [CONQUESTSRV1] Found roi# 16 in ROIContourSequence, index 15
    [CONQUESTSRV1] deleting in ROIContourSequence, index: 15
    [CONQUESTSRV1] Found roi# 16 in RTROIObservationsSequence, index 15
    [CONQUESTSRV1] deleting in RTROIObservationsSequence, index: 15



    Questions:
    1) The dumps in strucs0.txt and strucs1.txt are completely identical. The assignments of the kind:


    strucs.StructureSetROISequence[index]=nil


    do not seem to delete objects from memory. What am I doing wrong?


    2) I don't understand the result of consequtive print statements:


    [CONQUESTSRV1] deleting in StructureSetROISequence
    [CONQUESTSRV1] before StructureSetROISequence[ 15 ]: userdata:0253F8A0
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:02542D10
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:01278400
    [CONQUESTSRV1] after StructureSetROISequence[ 15 ]: userdata:0128E258


    What is "02542D10" in "userdata:02542D10"? If this is an object address, why does it differ from print statement to


    print statement?


    Any help and advice is highly appreciated!


    Kostya

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!