Orthanc receiving each instance of study 5 times from modality

This is the weirdest issue I have ever faced. I have connected Orthanc to a Toshiba CT Scanner and when the service console attached to the modality sends a study Orthanc is receiving each instance of the study 5 times from modality even though the console shows each instance being sent only once.This issue isn’t occurring when I’m sending studies to Orthanc from another PACS installation on the premises.If its any help I’m using the following script to convert to JPEG2000 (i doubt the script has anything to do with it)

function OnStoredInstance(instanceId, tags, metadata, origin)
– Do not compress twice the same file
if origin[‘RequestOrigin’] ~= ‘Lua’ then

– Retrieve the incoming DICOM instance from Orthanc
local dicom = RestApiGet(‘/instances/’ … instanceId … ‘/file’)

– Write the DICOM content to some temporary file
local uncompressed = instanceId … ‘-uncompressed.dcm’
local target = assert(io.open(uncompressed, ‘wb’))

– Compress to JPEG2000 using gdcm
local compressed = instanceId … ‘-compressed.dcm’
os.execute('C:\Orthanc\Tools\GDCM\bin\gdcmconv.exe -U --j2k ’ … uncompressed … ’ ’ … compressed)

– Generate a new SOPInstanceUID for the JPEG2000 file, as
– gdcmconv does not do this by itself
os.execute('C:\Orthanc\Tools\dcmtk\bin\dcmodify.exe --no-backup -gin ’ … compressed)

– Read the JPEG2000 file
local source = assert(io.open(compressed, ‘rb’))
local jpeg2k = source:read(“*all”)

– Upload the JPEG2000 file and remove the uncompressed file
RestApiPost(‘/instances’, jpeg2k)
RestApiDelete(‘/instances/’ … instanceId)

– Remove the temporary DICOM files

I’d say the first step is to disable any scripts you may have and see if it happens when there are none.
I don’t the printrecursive is great also for watching things. For example disable all scripts except a blank and when an instance is received print the SOPID and see if the ID matches with the modality and is only being sent once for example.

Ok ill give it a go tomorrow and get back to you. Thanks as always for your invaluable help.

I did as you said and its not an issue with any script.The modality near the end of the study transfer (usually with 5-10 images remaining) generates a file transfer error(see attached image or console screen) and then starts sending the study again from the beginning so basically an infinite loop is generated.Also the study transfers successfully to another test PACS we are trying KPACS. I have been pulling out my hair trying to get to the bottom of this.

WhatsApp Image 2018-04-16 at 4.18.16 PM.jpeg

Not too much of an error log. Anything in Orthanc logs? if not, may want to try debug and see if you get any errors:

Nothing in the logs

I’m able to import the studies into Orthanc using the web interface but the issue with transfer from the CT modality console persists :frowning:

Hi Rana.

I’m afraid that, at this point, you should contact your CT modality support to get more info on the error message and the exact reason why the transfer failed.



The Orthanc log file I provided doesn’t shed light on this?

haven’t seen any Orthanc log in this thread.

My apologies.Please see attached.

Orthanc.log (4.15 MB)

A very quick analysis shows:

  • no error/no warning

  • there are 5973 occurences of “Incoming Store request from AET TM_CT_CMW_V3.00”

  • there are 5430 occurences of “Already Stored” which is quite self explanatory

so from a quick computation, I would say your modality has sent 11 times the same study of 543 instances and that the problem is in your modality not in Orthanc.

As a general recommandation for this forum: please check the logs by yourself before posting them to the forum and you would realize by yourself that everything is fine with Orthanc.

I think it very much leads to that it is an issue with the modality. Last thing you can check is try loading the study up on a different viewer like Cinkgocadx and send it to Orthanc from there. If that works, images are good and it looks like your modality may be at fault and is failing and re-trying. Check port speed and make sure the modality and switch is either both Auto or both forced, not Auto/Forced for example.

Thank you for the reply.The thing that has me totally confused is that the modality is able to transfer studies to an installation of KPACS we setup to test if the problem would occur there as well.Also when we send the studies from the modality to KPACS then from KPACS to Orthanc the transfer completes successfully without any issues.