LUA Help on Import / Export converters

  • Hi Marcel. We're on Conquest Version 1417d. Linux centOS.


    And are developing some custom LUA scripts and are wondering if you might be able to assist with why this doesn't seem to be working.


    This version currently works just fine.

    Code
    #Separate and create unique Series with US Cine's#If called "CQUS" and SOPClassUID equals the SOPClass for US Cine's, then Obtain the last 7 characters from the SOP Instance UID(SOPSubs) and remove 10 characters from SeriesInstanceUID.#If new SeriesInstanceUID ends in a period, remove 11 characters from the original SeriesInstanceUID.#Concatinates the values from the new SeriesInstanceUID and new SOPSubs to make a unique US Cine SeriesInstanceUID.ImportConverter6 = if Association.Called == 'CQUS' and Data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.3.1' then SOPSubs = string.sub(Data.SOPInstanceUID, -7); SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -10); if string.byte(SeriesInstanceUID, -1) == 46 then SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -11) end; Data.SeriesInstanceUID = SeriesInstanceUID..SOPSubs..'.24'; print('ImportConverter6.0 received an US Cine on AETitle CQUS and has modified SeriesInstanceUID to ', Data.SeriesInstanceUID) end


    When we add in a line to rename the SeriesDescription to "CINE"
    , see near the end right before the "print" command: "Data.SeriesDescription = 'CINE';".

    Code
    #Separate and create unique Series with US Cine's#If called "CQUS" and SOPClassUID equals the SOPClass for US Cine's, then Obtain the last 7 characters from the SOP Instance UID(SOPSubs) and remove 10 characters from SeriesInstanceUID.#If new SeriesInstanceUID ends in a period, remove 11 characters from the original SeriesInstanceUID.#Concatinates the values from the new SeriesInstanceUID and new SOPSubs to make a unique US Cine SeriesInstanceUID.#Rename SeriesDescription to "CINE"ImportConverter6 = if Association.Called == 'CQUS' and Data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.3.1' then SOPSubs = string.sub(Data.SOPInstanceUID, -7); SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -10); if string.byte(SeriesInstanceUID, -1) == 46 then SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -11) end; Data.SeriesInstanceUID = SeriesInstanceUID..SOPSubs..'.24'; Data.SeriesDescription = 'CINE'; print('ImportConverter6.0 received an US Cine on AETitle CQUS and has modified SeriesInstanceUID to ', Data.SeriesInstanceUID) end


    Here's the error we get when adding this line and sending a study that matches the ImportConverter6 requirements of CQUS

    Code
    Tue Feb 6 16:19:36 2018 *** lua syntax error [string "if Association.Called == 'CQUS' and Data.SOPClassUID == '1.2.84..."]:1: unfinished string near '<eof>' in 'if Association.Called == 'CQUS' and Data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.3.1' then SOPSubs = string.sub(Data.SOPInstanceUID, -7); SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -10); if string.byte(SeriesInstanceUID, -1) == 46 then SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -11) end; Data.SeriesInstanceUID = SeriesInstanceUID..SOPSubs..'.24'; Data.SeriesDescription = 'CINE'; print('ImportConverter6.0 received an US Cine on AETitle CQUS and has modified SeriesInstanceUID t'


    Any thoughts on why this LUA script might be failing when we add that extra line to rename the SeriesDescription?

  • Hi,


    I think it is simple. The maximum InportConverter length is hardcoded to 512 characters. I would replace it by a


    [lua]
    ImporConverter6=dofile('lua/converter6.lua')


    and put the script into the called file. There would be no limits there.


    regards,


    Marcel

  • Ok thanks for your help.


    We've changed the dicom.ini entry to this:

    Code
    ImportConverter6 = dofile(lua/importconverter6.lua)


    Added a file under the lua folder called: lua/importconverter6.lua


    The file has this inside:

    Code
    #Separate and create unique Series with US Cine's#If called "CQUS" and SOPClassUID equals the SOPClass for US Cine's, then Obtain the last 7 characters from the SOP Instance UID(SOPSubs) and remove 10 characters from SeriesInstanceUID.#If new SeriesInstanceUID ends in a period, remove 11 characters from the original SeriesInstanceUID.#Concatinates the values from the new SeriesInstanceUID and new SOPSubs to make a unique US Cine SeriesInstanceUID.#Rename SeriesDescription to "CINE"if Association.Called == 'CQUS' and Data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.3.1' then SOPSubs = string.sub(Data.SOPInstanceUID, -7) SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -10) if string.byte(SeriesInstanceUID, -1) == 46 then SeriesInstanceUID = string.sub(Data.SeriesInstanceUID, 1, -11) end Data.SeriesInstanceUID = SeriesInstanceUID..SOPSubs..'.24' Data.SeriesDescription = 'CINE' print('ImportConverter6.0 received an US Cine on AETitle CQUS and has modified SeriesInstanceUID to ', Data.SeriesInstanceUID)end


    And getting this error now:

    Code
    Wed Feb 7 15:20:10 2018 *** lua run error [string "dofile(lua/importconverter6.lua)"]:1: attempt to index global 'importconverter6' (a nil value) in 'dofile(lua/importconverter6.lua)'


    Are we missing something? Thanks! --Tim

  • looks like it should be like this....


    instead of:

    Code
    ImportConverter6 = dofile(lua/importconverter6.lua)


    it should have these --> '

    Code
    ImportConverter6 = dofile('lua/importconverter6.lua')


    and inside of the new lua file, instead of using the # symbol for comments, it should be using "--"


    Thanks for your help. --Tim

  • Hi Marcel. We're having trouble getting a lua script to show us the sending device's IP address. With our current lua script, it's simply giving us 0.0.0.0. I think I saw a couple other posts where people were needing the same thing, however, I wasn't able to find a solution.


    Here's the script located at this destination: lua/ic-announcer.lua

    Code
    print ('ImportConverter0 (ic-announcer.lua) Receiving on AETitle:', Association.Called, 'from AETitle: ', Association.Calling, ' IP: ' , Association.ConnectedIP, ' Modality: ', Data.Modality, ' PatientID: ', Data.PatientID, ' PatientName: ', Data.PatientName, 'Accession: ', Data.AccessionNumber, ' StudyUID: ', Data.StudyInstanceUID, ' SeriesUID: ', Data.SeriesInstanceUID, ' SeriesNo: ', Data.SeriesNumber, ' SOPuid: ', Data.SOPInstanceUID)lua/ic-announcer.lua (END)


    And here's the output where it's printing the sending device's IP as 0.0.0.0.

    Code
    Thu Feb 8 12:11:15 2018 ImportConverter0 (ic-announcer.lua) Receiving on AETitle: CONQUESTSRV1 from AETitle: DEVICE01 IP: 0.0.0.0 Modality: DX PatientID: 123456 PatientName: PATIENTLAST^PATIENTFIRST Accession: 7891011 StudyUID: 1.
    2.840.114350.2.431.2.798268.2.46360523.1 SeriesUID: 1.3.12.2.1107.5.3.49.23739.2.201802081203410765 SeriesNo: 2 SOPuid: 1.3.12.2.1107.5.3.49.23739.12.201802081203410765GG


    Do you know how we could get the lua to show us the actual sending modality's IP address? Thanks. --Tim

  • Hi Marcel, we're looking for help using the destroy command within a LUA script.
    We're configuring this in Linux, but using the windowsmanual.pdf file. The only info available that I can find is this...


    Code
    destroy ( ) Special for server events, See e.g. script ('destroy')


    What should be inside the "( )" if we're intending to get rid of some data that we don't want?


    We tried it and it gave us an error.


    Code
    Thu Mar 8 11:14:59 2018 *** lua run error lua/ic-cqus.lua:19: attempt to call global 'destroy' (a nil value) in 'dofile('lua/ic-cqus.lua')'


    I think it needs to be like destroy(filename.dcm) or something, but not sure. Thanks. --Tim

  • For reference to the above question, here's what our LUA script looks like.


Participate now!

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