Rework Q-R duplicate flag for multi RDSR

Issue #610 resolved
Ed McDonagh created an issue

Need to start recording Series Instance UID etc

Comments (37)

  1. Ed McDonagh reporter

    Writing thoughts to myself as much as anything:

    For RDSRs (of any flavour):

    • May have multiple RDSRs available in remote node
    • Only tag guaranteed to be returned that will distinguish them is SeriesInstanceUID
    • Therefore:

      • Add series_instance_uid to GeneralStudyModuleAttr model along side the series time and content time already added for ref #114
      • Add recording of SeriesInstanceUID in rdsr.py
      • No point doing any logic with SeriesInstanceUID in rdsr.py because it is already covered by the times and the UID doesn't tell you which one is later
      • In the query function, look for StudyInstanceUID matches, then if found look for SeriesInstanceUID
      • If there is only one RDSR, we can stop there
      • If there are multiple RDSR series, we'll always have additional ones
      • Therefore attempt to get the series time also? Will require SeriesTime to be added to the series C-Find and to the DicomQRRspSeries model
      • If we have the times, we can work out if the one being considered is newer or older and act accordingly
      • If the study in the database does not have SeriesInstanceUID recorded, rely on times?
      • If the study in the database does not have times recorded, we import again
      • If we import again, the logic will cause the existing study to be deleted and the new one to replace it, which will then have the times and SeriesInstanceUID values, preventing a repeat next time!

    I'll do another comment later to consider how this will affect DX and MG images before implementing it.

  2. Ed McDonagh reporter

    Current behaviour for MG and DX images is as follows (extractor modules):

    • Check StudyInstanceUID against database
    • If existing, check SOPInstanceUID against the database in the field projectionxrayradiationdose__irradeventxraydata__irradiation_event_uid (not limited to the same StudyInstanceUID!)
    • When importing new images, SOPInstanceUID is recorded as though it were IrradiationEventUID

    Therefore for C-Find filtering we need to something similar.

    • If StudyInstanceUID in database is true:
    • For each series_rsp if modality is not SR (or is MG or DX or CR):
    • For each images_rsp check if SOPInstanceUID is in database

    Next I need to see what we do for legacy Philips CT...

  3. Ed McDonagh reporter

    For legacy Philips CT (ct_philips.py), we do not consider the possibility of there being more than one 'Dose Info' object for the same study, so we don't need to here either.

    For legacy Toshiba CT (rdsr_toshiba_fct_from_dose_images.py), we are creating the RDSR so there won't be multiple ones. If we come across the same StudyInstanceUID again, I don't think we want to fetch it again to see if it has changed.

  4. Ed McDonagh reporter

    So, to bring it together:

    Do all the normal filtering, then if remove_duplicates:

    • if StudyInstanceUID in database:
      • for series in series_rsp:
        • if series.modality == "SR":
          • if SeriesInstanceUID in database: then delete else
          • if SeriesTime earlier than series_time in database then delete
        • if series.modality in ['MG', 'DX', 'CR']:
          • for image in images_rsp:
            • if SOPInstanceUID in database: (in IrradiationEventUID field), delete

    I'm now thinking it would be best to remove all but the latest date RDSR of a study at the same time? Leave them all in if not remove_duplicates.

  5. Ed McDonagh reporter

    Slight modification - will need to _query_images in order to cater for mammo and DX. Currently this only happens if in _get_toshiba_dose_images or _check_sr_type_in_study.

  6. Ed McDonagh reporter

    Added SeriesInstanceUID to GeneralStudyModuleAttr model. Added SeriesTime to DicomQRRspSeries model. Added SeriesInstanceUID to rdsr extractor. Moved remove_duplicates to much later in process to ensure series level data is available. Started to implement ref #610

    → <<cset 252d8259631e>>

  7. Ed McDonagh reporter
    • changed status to open

    Rethink this now that ref #625 has changed the way duplicates are dealt with. I don't think the logic here allows for continued studies.

  8. Ed McDonagh reporter

    Now appears to function for RDSR. Need to modify the tests, but works with current tests locally. WIP, refs #610. Need also to look at other import objects. [skip ci]

    → <<cset 51a89a0ac629>>

  9. Ed McDonagh reporter

    Added sop instance UID tests for continued studies. Instance UID now added just to applicable study in db. Now to look at other imports. [skip ci] because tested locally. Refs #610

    → <<cset f1c27cb8ad92>>

  10. Ed McDonagh reporter

    Added checking of SOP instance UID to DX _create_event. Also changed logic for multiple studies with the same UID - previous code would have fallen over. Need to add UID stuff to new DX study function. [skip ci] because tested locally. Refs #610

    → <<cset 6cda0dfa4cdd>>

  11. Ed McDonagh reporter

    Added a couple of debug messages; added check that duplicate image import reulsts in debug message, and check uid list is created correctly. [skip ci] because tested locally. Refs #610

    → <<cset 5b51d9523763>>

  12. Ed McDonagh reporter

    Explicitly named mam log for consistency. Added record_sop for new studies. Added tests for importing new event and duplicate vent a second time. Lots of duplication still... for another time! Refs #610, #628

    → <<cset 3bf064fa0fa6>>

  13. Ed McDonagh reporter

    Replaced check duplicates QR code - was based on series instance UID and series time, now based on SOPInstanceUID. Modified tests to provide the new information, and split them up. Refs #610

    → <<cset ac09001e187f>>

  14. Ed McDonagh reporter

    Tested in production. check_uid.check_uid was preventing UIDs to be collected, and isn't needed in extract_common. Removed. Added debug logging to duplicates QR code. Added query stage updates for web interface. Refs #610, #628

    → <<cset 05e0457273b4>>

  15. Log in to comment