Web server

  • I did some changes to run but I am getting an error:


    Code
    [CONQUESTSRV1] 9999,0400 826 LO ConquestConsoleComma "lua: local ofile='86557:1.3.46.670589.30.1.6.1.116520970982.1481396381703.2';\n local osize='128';\n local ographic='jpg';\n local otemp='.jpg'\n local outfile = tempfile(otemp)\n local x = DicomObject:new()\n x:Read(ofile)\n\n local c = (x.WindowCenter or"
    [CONQUESTSRV1] Query Tables: DICOMImages
    [CONQUESTSRV1] Columns : ObjectFile, DeviceName
    [CONQUESTSRV1] Where : SOPInstanc = '1.3.46.670589.30.1.6.1.116520970982.1481396381703.2' AND ImagePat = '86557'
    [CONQUESTSRV1] Order : (null)
    [CONQUESTSRV1] Locating file:MAG0 86557\1.3.46.670589.30.1.6.1.116520970982.1481396381781.1_0001_000001_16575404220007.dcm
    [CONQUESTSRV1] *** lua run error [string " local ofile='86557:1.3.46.670589.30.1.6.1..."]:24: attempt to concatenate global 'frame' (a nil value) in ' local ofile='86557:1.3.46.670589.30.1.6.1.116520970982.1481396381703.2'; local osize='128'; local ographic='jpg'; local otemp='.jpg' local outfile = tempfile(otemp) local x = DicomObject:new() x:Read(ofile) local c = (x.WindowCenter or 0) if c=='' then c=0 end local w = (x.WindowWidth or 0) if w=='' then w=0 end local s = (x.RescaleSlope or 1) if s=='' then s=1 end local i = (x.RescaleIntercept or 0) if i=='' then i=0 end if string.find(c, '%\\') then c = string.match(c, '(.-)\\') end if string.find(w, '%\\') then w = string.match(w, '(.-)\\') end w = tonumber(w)/tonumber(s) c = tonumber(c)/tonumber(s) x:Script('save '..ographic..' level '..math.floor(c)..' window '..(math.ceil(w/2))..' size 512 frame '..frame..' to '..outfile) returnfile = outfile '
  • Hi,


    I looked at the node.js interface. It is nice and compact. I think the lua interface is more flexible. Some ideas:


    also do echo from lua

    cache MAGDevice values

    do not add * to ID and name, leave that to caller

    reduce number of endpoints, you can pass query to as json string


    To convert a json string to a dicom object you need the latest dgate exe from githib, and then you can do:


    q = DicomObject:new(json_string)


    Marcel

  • Hi, Marcel

    Convert to jpeg result is going to console stdout right now.

    I´d like to do same thing to dicom images of the patients.

    Can you complete this code?

  • This should do it. all the Script commands are documented as ImportConverters in the manual

  • Is this ok as well?


  • sure.

    Hi, Marcel

    All lua scripts returning plain text are working.


    I still have problems with images.


    I create a lua script and run it using nodejs exec child process.


    Right into script, I save the original dicom file to debug. I can see it is a valid dicom file.


    But, in node js, after I save the stdout from child process, it results in a invalid dicom file.

    I suspect about something binary output, but until now I didn´t solve it.

    I attached the dicom file original and the other saved from lua script stdout console


    --lua script


    -- executing lua script in node


  • Hm,


    The output is written in text mode by Lua. In Conquest cgi mode I execute setmode(console, O_BINARY) to fix that, I had forgotten about that. I am afraid this requires a source code change in dgate, e.g. adding a parameter to do this. For testing here is a dgate.exe that adds -$ as parameter to do this:


    dgate.zip


    It is 7zipped and than zipped to fit as attachment here.


    Marcel

  • Hi, Marcel


    Your new dgate add on works if I add '0x00' to stdout.

    I find it comparing the binary dcm file saved by lua script and the binary dcm file saved using the stdout output.

    They are differents because the last one doesn´t have a '0x00' more.

    What do you think to add it into date?


    Sample:


    Code
    const nulBuf = new Uint8Array([0x00]);
    const newBuffer = Buffer.concat([
    Buffer.from(stdout, "binary"),
    nulBuf,
    ]);
    fs.writeFileSync("test21.dcm", Buffer.from(newBuffer, "binary")); --> here I get a valid dicom

    Working now with thumbnails via API:


  • Hi,


    The zero byte is stripped by servercommand, because data transmitted in a DICOM element must be even length so often a zero byte is added. So the temporary fix would be to add a zero byte if the returned data has odd lenght.


    I will think of a better solution.


    Marcel

  • Hi, Marcel


    When a slice is multiframe and I´m going to save to gif, what can I change into this code to save all frames to gif?


  • Hi, Marcel,

    I´d like to know if conquest is up.

    I created the next script and it returns a json. How know if it´s up? If I get a response?

    Code
    F:\Programas\AppProg\dicomserver150c>dgate64 "--dolua:dofile([[echo.lua]])"
    {AffectedSOPClassUID="1.2.840.10008.1.1",CommandField=32816,MessageIDBeingRespondedTo=2,DataSetType=257,Status=0,TransferSyntaxUID="1.2.840.10008.1.2"}
  • #73 pass 10000+fps as frame to generate animated gif, e.g. 10005


    #74 dicomecho does not return a file; say e.g. if (dicomecho(ae)) then return 1 else return 0 end


    Marcel

    Thank you, but if I try the next I get an error:


    F:\Programas\AppProg\dicomserver150c>dgate64 "--dolua:dofile([[echo.lua]])"

    *** lua run error echo.lua:10: bad argument #1 to 'write' (string expected, got nil) in 'dofile([[echo.lua]])'


  • I get the same error:


Participate now!

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