Error when querying for CT

Issue #717 resolved
David Platten created an issue

The following error was thrown when querying PACS for CT using the toshiba switch. I've not seen this error before. Celery default.log file:

[2019-01-08 14:15:05,463: INFO/MainProcess] Association response received
[2019-01-08 14:15:51,434: ERROR/MainProcess] Task remapp.netdicom.qrscu.movescu[75e1b524-25d9-4947-bd46-38f987022226] raised unexpected: AttributeError("'NoneType' object has no attribute 'Release'",)
Traceback (most recent call last):
  File "d:\server_apps\python27\lib\site-packages\celery\app\trace.py", line 368, in trace_task
    R = retval = fun(*args, **kwargs)
  File "d:\server_apps\python27\lib\site-packages\celery\app\trace.py", line 623, in __protected_call__
    return self.run(*args, **kwargs)
  File "D:\Server_Apps\python27\Lib\site-packages\openrem\remapp\netdicom\qrscu.py", line 1151, in movescu
    assoc.Release(0)
AttributeError: 'NoneType' object has no attribute 'Release'

Corresponding entry in openrem_qr.log:

[08/Jan/2019 14:15:01] INFO [remapp.netdicom.qrscu:1205] qrscu script called
[08/Jan/2019 14:15:01] INFO [remapp.netdicom.qrscu:1225] Modalities are ['CT']
[08/Jan/2019 14:15:01] INFO [remapp.netdicom.qrscu:1231] Date from: 2019-01-08
[08/Jan/2019 14:15:01] INFO [remapp.netdicom.qrscu:1234] Date until: 2019-01-08
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:642] b412c9bb-a619-4892-a3be-8db466961d5b: Request association with {'Port': 104, 'AET': 'RWDDBWF01', 'Address': '10.169.226.38'} (10.169.226.38 104 from <AE(OPENREM, stopped daemon 5116)>)
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:829] b412c9bb-a619-4892-a3be-8db466961d5b DICOM Echo ... 
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:839] b412c9bb-a619-4892-a3be-8db466961d5b DICOM FindSCU ... 
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:688] b412c9bb-a619-4892-a3be-8db466961d5b Currently querying for CT studies...
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:871] b412c9bb-a619-4892-a3be-8db466961d5b 0 studies returned, will now process to remove studies that are not useful.
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:900] b412c9bb-a619-4892-a3be-8db466961d5b Pruning study responses based on inc/exc options: 
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:907] b412c9bb-a619-4892-a3be-8db466961d5b Pruning studies based on inc/exc has removed 0 studies, 0 studies remain.
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:911] b412c9bb-a619-4892-a3be-8db466961d5b Querying at series level to get more details about studies
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:168] b412c9bb-a619-4892-a3be-8db466961d5b Getting series and image level information and deleting series we can't use
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:972] b412c9bb-a619-4892-a3be-8db466961d5b 0 CT studies were deleted from query due to no suitable images or reports being found. Of the remaining studies, 0 have RDSR or ESR, 0 have Philips dose images, 0 have been prepared for the Toshiba import option and 0 have been prepared as possibly containing Philips dose images. 
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:978] b412c9bb-a619-4892-a3be-8db466961d5b Pruning series responses removed 0 studies, leaving 0 studies
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:64] b412c9bb-a619-4892-a3be-8db466961d5b Checking to see if any of the 0 studies are already in the OpenREM database
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:113] b412c9bb-a619-4892-a3be-8db466961d5b After removing studies we already have in the db, 0 studies are left
[08/Jan/2019 14:15:05] INFO [remapp.netdicom.qrscu:990] b412c9bb-a619-4892-a3be-8db466961d5b Removing duplicates of previous objects removed 0, leaving 0
[08/Jan/2019 14:15:21] INFO [remapp.netdicom.qrscu:1019] b412c9bb-a619-4892-a3be-8db466961d5b Query complete. Query took 16.0 seconds and we are left with 0 studies to move.<br>Of the original 0 study responses, 0 CT studies were deleted from query due to no suitable images or reports being found. Of the remaining studies, 0 have RDSR or ESR, 0 have Philips dose images, 0 have been prepared for the Toshiba import option and 0 have been prepared as possibly containing Philips dose images. Filtering for Removing duplicates of previous objects removed 0 studies.
[08/Jan/2019 14:15:51] INFO [remapp.netdicom.qrscu:1088] Query_id b412c9bb-a619-4892-a3be-8db466961d5b: Move association requested
[08/Jan/2019 14:15:51] INFO [remapp.netdicom.qrscu:1092] Query_id b412c9bb-a619-4892-a3be-8db466961d5b: Preparing to start move request
[08/Jan/2019 14:15:51] INFO [remapp.netdicom.qrscu:1097] Query_id b412c9bb-a619-4892-a3be-8db466961d5b: Requesting move of 0 studies
[08/Jan/2019 14:15:51] INFO [remapp.netdicom.qrscu:1148] Move complete

Comments (8)

  1. David Platten reporter

    We could probably catch this error (I think it occurs when nothing at all is returned by the query) in qrscu.py lines 1150 onwards. @edmcdonagh what do you think?

        logger.debug(u"Query_id {0}: Releasing move association".format(query_id))
        try:
            assoc.Release(0)
            logger.info(u"Query_id {0}: Move association released".format(query_id))
        except AttributeError:
            logger.info(u"Query_id {0}: Could not release association due to an attribute error: perhaps no studies were present.".format(query_id))
    
  2. Ed McDonagh

    I guess we could. I'm not convinced that that is the correct reason for what is going on. BUT:

    1. I think we should stop as soon as we have no studies in a query, and certainly not bother to attempt to move 0 studies (as we currently do)
    2. This code will be replaced in the nearish future as we upgrade to current pydicom 1.x and new pynetdicom 1.x now it too has been released. In the new pynetdicom, we have access to all sorts of status messages and hopefully more reliable behaviour, so it isn't worth getting too caught up in the vagaries of why the association had quit before we released it.

    So, please put your change in as a PR, and we'll leave it like that for now.

    In the meantime, I need to finish or abandon the hour option addition (tested and working from the command line, getting myself tied up in knots with form logic for the GUI version), and get this release out!

  3. Log in to comment