Editing RT structures ROI names in lua

  • Hey,


    I was writing a simple lua script, that should allow to do modifications on RTSTRUCT ROINames of already existing data within conquest (I don't need this as converter, because this functionality will be accessible from different webapp calling it as web service).


    I have troubles saving the modified RTSTRUCT back to conquest. I was thinking to save it to incoming and let it be reimported, but the Write method does not seem to do the job. Am I missing something?


    One additional question... is there a better way of getting the MAGDevice0 path from lua rather than hardcoding it into a script?


    My script is here:



    I would be glad if somebody can point me to the correct direction for saving data back to conquest.


    best


    Tomas

  • Hi,


    you can call x:AddImage() -- or addimage(x)


    all commands are shown in overview.lua


    To query dicom.ini use gpps:


    print('----- Read any dicom.ini item -----')
    section = 'sscscp'; item = 'MAGDevice0'; default='';
    print(gpps(section, item, default))


    Marcel

  • Thanks for prompt response,


    I was actually running older version of conquest that did not seem to have AddImage method implemented. So I migrated to 14-17d now but I am getting an error on AddImage:


    Code
    Removed file: [MAG0:DD-L036D0E1/233412335242842699416507238827857724766_0003_000002_139382758702b5.v2]
    ***Could not remove IOD /mnt/data1/DD-L036D0E1/233412335242842699416507238827857724766_0003_000002_139382758702b5.v2
    ***Error writing file: /mnt/data1/DD-L036D0E1/233412335242842699416507238827857724766_0003_000002_14498299920000.dcm
    ***[lua addimage] Error entering object into serverlocalhost


    Also now it removes the instance from DB but it does not delete the dcm file. Just an idea... do I need some additional configuration in web dicom.ini file to make use of AddImage method?


    Tomas

  • I was missing some of DB configurations in my web dicom.ini. Now the error is gone, it says:


    Code
    Lua script rewritten file: /mnt/data1/DD-L036D0E1/233412335242842699416507238827857724766_0003_000002_139382758702b5.v2


    however the ROIName is unmodified... is modification of tag within sequences supported?


    BTW my script now looks like this:



    T

  • If I try to change some other tag e.g. PatientName it change the value in SQL database but does not apply it on DICOM lvl, when I dump the file nothing changed there. I have a feeling that I am still missing something in web dicom.ini configuration to allow lua persisting modification on dicom level.


    T

  • Hi,


    if you change the image and rewrite is this is the same as resending an image to conquest. The fact that the database changes suggests that the image is correctly reloaded (it reads it to fill the database). You can change tags in a sequence but .v2 file extensions (implicit coding) and sequences are a bad match. Can you save the image with struct:Save and or struct:Dump to see what is going on?


    Marcel

  • I will try to track down, what is happening there. I am using the default 3 as FileNameSyntax property in my conquest instance. You say that v2 are bad match... do you think it would be wise to switch to the option 4 when I am planning to have more lua scripts modifying DICOM data in a long term?


    T

  • Hmm at the end I got it running but it is a little bit ugly. Seems like when lua script is executed as web service it does not have permission to do certain operations (write, dump, ...). However if I use servercommand('lua:'..script), given that the modification (write logic) is within the composed script string, this is executed with conquest user permission and the file is properly modified.


    The working script is here:


    Tomas

Participate now!

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