imaging_api.services.retrieval

Attributes

XNATAuthHeaders

Functions

retrieve_images_for_project(→ bool)

Queues an import request for the images associated with the given project.

get_import_status(...)

Returns information about the status of study imports:

retry_retrieve_images_for_project(→ bool)

Queues an import request for the images which have failed to import.

Module Contents

imaging_api.services.retrieval.XNATAuthHeaders
async imaging_api.services.retrieval.retrieve_images_for_project(project_id: str, query: str, headers: XNATAuthHeaders) bool

Queues an import request for the images associated with the given project.

Steps:

  1. Encrypt project ID to send to the data access API

  2. Fetch the cohort’s accession IDs from the data access API

  3. Query PACS to find study for each accession ID -> put into a list

  4. Make a ImportStudyRequest object with the list of studies

  5. Check response gives all to QUEUED

Parameters:
  • project_id (str) – The imaging project ID to retrieve the data about.

  • query (str) – The cohort query (raw SQL).

  • headers (XNATAuthHeaders) – The headers containing XNAT authentication details.

Returns:

True if all studies were successfully queued, False otherwise.

Return type:

bool

Raises:

HTTPException – If the request cannot be processed.

async imaging_api.services.retrieval.get_import_status(project_id: str, query: str, headers: XNATAuthHeaders) imaging_api.routers.schemas.ImportStatus

Returns information about the status of study imports:

  • Successful: Studies (i.e. accession numbers) successfully imported into XNAT

  • Processing: Studies currently being processed

  • Failed: Studies that failed to import

  • Queued: Studies waiting in the queue

  • QueueFailed: Studies that couldn’t be queued for import

  1. Fetch the cohort’s accession IDs from the data access API

  2. Get project experiments

  3. Get project import status

Parameters:
  • project_id (str) – The imaging project ID to retrieve the data about.

  • query (str) – The cohort query.

  • headers (XNATAuthHeaders) – The headers containing XNAT authentication details.

Returns:

An object containing the status of study imports.

Return type:

ImportStatus

Raises:

HTTPException – If the request cannot be processed.

async imaging_api.services.retrieval.retry_retrieve_images_for_project(project_id: str, query: str, headers: XNATAuthHeaders) bool

Queues an import request for the images which have failed to import.

Steps:

  1. Get import status

  2. If none have status failed (Failed or QueueFailed), return

  3. Create list of accession numbers that have failed.

  4. Unencrypt the accession numbers

  5. Use Pacs Query request to find study for each accession ID -> put into a list

  6. Make a ImportStudyRequest object with the list of studies

  7. Check response gives all to QUEUED

  8. Return success or failure

Parameters:
  • project_id (str) – The imaging project ID to retrieve the data about.

  • query (str) – The cohort query (raw SQL).

  • headers (XNATAuthHeaders) – The headers containing XNAT authentication details.

Returns:

True if all studies were successfully queued, False otherwise.

Return type:

bool

Raises:

HTTPException – If the request cannot be processed.