sjoerdk / dicomtrolley

Retrieve medical images via WADO, MINT, RAD69 and DICOM-QR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add query for instances when trying to download study- or series-level objects

sjoerdk opened this issue · comments

From the download example at https://github.com/sjoerdk/dicomtrolley#downloading-data:

studies = trolley.find_studies(MintQuery(patientName='B*',
                                         queryLevel=QueryLevels.INSTANCE))
trolley.download(studies, path)                             # all studies

This download will work because the find_studies command is done at QueryLevels.INSTANCE

A very common use case however is querying for many studies at the study level (much faster and lighter query), selecting some from the returned studies, and wanting to download the selection. Something like this:

studies = trolley.find_studies(MintQuery(patientName='B*',
                                         queryLevel=QueryLevels.STUDY))     # query with 1000's of results 
selected = [x for x in studies if x.data['StudyDescription'] == 'StudyA']   # select studies
trolley.download(selected, path)                                            # download selected

The above query would download 0 files however, because the original query is done at QueryLevels.STUDY, meaning no SeriesUIDs or SOPInstanceUIDs have been returned. Both of these are required to download any instance.

trolley.download() should automatically re-query QueryLevels.INSTANCE when this information is missing. The query should be as minimal as possible and only ask for SeriesUIDs and SOPInstanceUIDs

Fixed by commit 7c70c5b