Script library

  • Hi,

    this topic is aimed at collecting sample scripts provided by users. The first script I received is from Bart Hoekstra in Utrecht: it is an extensive anonymization script with full logging.

    You can download it here:…mserver/DicomAnonymize.cq

    To run it as ImportConverter just store the file in the server directory and add to dicom.ini:

    ImportConverter0 = call DicomAnonymize.cq

    You can also use the same script as default anonimization script. Just rename it to: anonymize_script.cq. Then the windows GUI anonymization commands will use it.


  • # Configuration of rules to modify, log or reject incoming DICOM slices
    ImportConverter0 = ifequal "%V0010,0020[0,3]","ABCD"; set 0010,0020 to "%V0010,0020";
    ImportConverter1 = ifnotequal "%V0010,0020[0,3]","ABCD"; set 0010,0020 to "ABCD%V0010,0020";

    So if you have an old database that has mixed number prefix/no prefix (ie 123456 and ABCD123456)

    These will import the old data, if it has ABCD prefix, it stores and does nothing else.
    If prefix "ABCD" is missing, it will prepend the number with "ABCD" and store

    Set this up in a new instance of conquest then did a find local missing patient. Small DB only 80gb. I did change tcp time out to 600.
    Suppose you could put newuids at the end if you wanted to.

    EDIT.. After going through a couple GBs of data and seeing a few errors regarding instance uids error, I appended newuids to my importconverter. Deleted my database and started over.. No errors now. Best to try stuff with a small subset and make sure everything is working as you intend before going all out. :-)

    I also then do a

    Exportconverters = 1
    ExportConverter0 = forward Series to RADIOLOGYBU (Backup device jk on a 2 TB Fantom USB Drive)

    Changed my export converter because old data needs to be fixed (double MRN for some patient, wrong spelling etc.)
    Since I know that all data after 6/1/2010 is good:

    ExportConverter0 = ifnumgreater "%V0008,0020","20100601" ; forward Series to RADIOLOGYBU

  • Hi,

    here are some example import converters with new options from version 1.4.16:

    60 seconds (should be longer depending on the network speed) after the first received MRI data it merges all series with description T/3D/FFE/*. During the merging the image number (e.g. 12) is prepended with the acquisition number (e.g. 3), to become 3012.

    # Merge MRI dynamic data updating slice numbers (the following line allows testing with drag and drop)
    # ImportExportDragAndDrop = 1
    ImportConverter0 = ifequal "%m", "MR"; merge study study %V0020,000d seriesdesc T/3D/FFE/* after 60
    MergeSeriesConverter0 = set 0020,0013 format "%V0020,0012%%03d" to "%V0020,0013"; set 0008,103e to "T/3D/FFE SENSE"

    The clause "study %V0020,000d" works around a bug in 1.4.16rc2.

  • Sample rules to stop certain stations from sending images:

    ImportConverter0 = ifmatch "%u", "WORKSTATION*"; reject;
    ImportConverter1 = ifequal "%u", "WORKSTATION1"; reject;
    ImportConverter2 = ifequal "%u", "WORKSTATION1"; reject; ifequal "%u", "WORKSTATION2"; reject;
    ImportConverter3 = ifnotequal "%u", "CTSCANNER"; reject; ifnotequal "%u", "MRSCANNER"; reject;

    %u stands for the calling AE (name of sending server). These lines will reject all images from AE WORKSTATION* or WORKSTATION1, or WORKSTATION1 or WORKSTATION1 or not from CTSCANNER or MRSCANNER

  • This takes every CR image and saves it as a jpg to the directory you choose with the patient name and image number.

    Importconverter0 =ifequal "%m","CR";{save jpg to C:\DICOM\Images\%V0010,0010-%V0020,0013.jpg;}
  • Hi,

    here is a nice lua version of the anonymization script posted above. It can be used with 1.4.16i only, though. On earlier versions, the dictionary check is not available, and also empty tags show up as nil.


    edit: avoid using os.execute() as blinks window

  • This lua script (for 1.4.16j) is an ExportConverter that queries CT series data to decide on forwarding of an RTPLAN and RTSTRUCT.

    Exportconverters = 1

    Exportconverter0 = dofile("plan2AlingRT.lua")


  • Hi,

    this script corrects incorrect links of RTDICOM data. It can be used to correct such data after being run through incorrect anonymization tools.

  • This lua script creates a simple WADO viewer when run from within the conquest web server.

  • Not sure,

    I am not a php expert. Just make sure you pass a -wc:\dicomserver parameter as well as the -- command such that it can pickup all files needed to function, where c:\dicomserver is the server location.

    $path = $root . "\dgate.exe" . " " . "-w" . $root . " " . $command;



  • i will try Thank. I am looking to other way I found file_get_contents function
    $homepage = file_get_contents('http://localhost/cgi-bin/dgate.exe?mode=querypatients&port=5678&address=');

  • Hi Marcel,

    For some reason i have some Rx images that arrive to conquest with bad modality.
    I want to rewrite modality in every incoming dicom if modality is not CR.

    Do you think my import converter is OK ?

    ImportConverter1 = ifnotequal "%m", "CR"; set "%m", "CR";

    Besides, i want to change past errors and now it asks for a lua script...

    Could you show me how to change modality of a serie using lua box in the "browse database" tab ?


  • Hi,

    I would use Lua:

    ImportConverter0 = if Data.Modality~='CR' then Data.Modality = CR end

    In the modify box you can put the same statement:

    if Data.Modality~='CR' then Data.Modality = CR end

    And then run it for a patient study series or image at a time. Best use 1.4.19b.


  • Thanks Marcel.

    I added the lua line in dicom.ini but i haven't checked if it works yet.

    When i try to use the code in the lua box, if i hit the "test syntax" button an error occured (lua syntax error... unfinished line...). If i click "start modify", no error but no change in modality.

    Any other suggestion ?

  • Hi

    OK, it was due to missing quotes for the new modality.

    Syntax is
    if Data.Modality~='CR' then Data.Modality = 'CR' end

    Tested the LUA importconverter as well -> perfect.

    Many thanks Marcel, and merry Christmas !

Participate now!

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