0

I am using a modified version of this pynetdicom script (the second example on this page) to download DICOM images to an office computer. Here is what the script does:

  1. Opens a connection with PACS
  2. Searches for DICOM images that match the current date for a given patient's medical record number and accession number.
  3. If DICOM images are found that match the given criteria, then an SCP server connection is started to initiate the downloading of images to a folder on the local computer.

The script works when it is run using the Spyder IDE. I have created a scheduled task with Windows Task Scheduler and it works correctly if the script has first been run with the Spyder IDE and only if Spyder remains open and all variables have not been cleared.

However, if Spyder is closed or the Spyder kernel is restarted, then when the script is run through task scheduler, it will run correctly until it gets to the part where the SCP server calls the handle_store function that downloads images from PACS. The script does not call the handle_store function and the connection eventually times out.

I thought the solution would be changing the default working directory in Task Scheduler, but that did not work. Any ideas what is going on and how to fix this?

  • What does the debug log say? – scaramallion Aug 25 '21 at 01:49
  • In winevt/Logs I found 2 event files. They are TaskScheduler%4Maintenance.evtx and TaskScheduler%4Operational.evtx. Both events give the error Access is denied. – bullFrog51 Aug 25 '21 at 13:25
  • I was looking back at the original code and realized that I had the debug_log() commented out. When the script is run with the debug_log, I see the message "DIMSE timeout reached while waiting for message request". It also gives an Abort A-About PDU that says "Abort Source: DUL server-user" and "Abort Reason: No reason given". – bullFrog51 Aug 25 '21 at 15:34
  • Which port do you use? It might be that task scheduler doesn't have high enough permissions to open something like 104 – scaramallion Aug 25 '21 at 22:03
  • I am using port 11112. Does Task Scheduler need special privileges? Python and the Anaconda environment which is run through the Spyder IDE already has the proper permissions to connect to our PACS and query and retrieve service C-Get requests. I would expect these permissions to still be in place when Task Scheduler starts Python in the Anaconda environment. – bullFrog51 Aug 26 '21 at 11:31

1 Answers1

0

Okay, I did some more digging and found the source of the problem. In order to get images to download to my computer Python needs to be allowed through our corporate firewall. I had already allowed pythonw.exe through the firewall but not python.exe. Once both of these Python files were allowed through the firewall the script will run as expected when started with Windows Task Scheduler.