Addon namespace

This is addon namespace for some useful SDK methods.

Study namespace

class ambra_sdk.addon.study.Study(api)[source]

Study addon namespace.

anonymize_and_get(engine_fqdn: str, namespace: str, study_uid: str, region: Dict[str, Any], phi_namespace: Optional[str] = None, to_namespace: Optional[str] = None, new_study_uid: Optional[str] = None, keep_image_uids: Optional[str] = None, color: Optional[str] = None, x_ambrahealth_job_id: Optional[str] = None, is_ai: bool = False, only_prepare: bool = False, timeout: float = 200.0, ws_timeout: int = 5) → box.box.Box[source]

Start anonymization wait and get anonymized study.

Parameters
  • engine_fqdn – Engine FQDN (Required).

  • namespace – Namespace (Required).

  • study_uid – Study uid (Required).

  • region – Region (Required).

  • phi_namespace – phi namespace

  • to_namespace – The storage namespace into which the new study should be placed (default same as original).

  • new_study_uid – The Study Instance UID of the new study (default is randomly generated).

  • keep_image_uids – Should SOP Instance UIDs of modified copies be same as originals? (default is false)

  • color – HTML-formatted color (rrggbb) of obscured regions (default is black-and-white checkerboard)

  • x_ambrahealth_job_id – X-AmbraHealth-Job-Id headers argument

  • is_ai – This is request from ai stack flag

  • only_prepare – Get prepared request.

  • timeout – waiting timeout

  • ws_timeout – waiting from ws timeout

Raises

TimeoutError – if job or study not ready by timeout

Returns

new study

anonymize_and_wait(engine_fqdn: str, namespace: str, study_uid: str, region: Dict[str, Any], phi_namespace: Optional[str] = None, to_namespace: Optional[str] = None, new_study_uid: Optional[str] = None, keep_image_uids: Optional[str] = None, color: Optional[str] = None, x_ambrahealth_job_id: Optional[str] = None, is_ai: bool = False, only_prepare: bool = False, timeout: float = 200.0, ws_timeout: int = 5) → str[source]

Start anonymization and wait when it completed.

Parameters
  • engine_fqdn – Engine FQDN (Required).

  • namespace – Namespace (Required).

  • study_uid – Study uid (Required).

  • region – Region (Required).

  • phi_namespace – phi namespace

  • to_namespace – The storage namespace into which the new study should be placed (default same as original).

  • new_study_uid – The Study Instance UID of the new study (default is randomly generated).

  • keep_image_uids – Should SOP Instance UIDs of modified copies be same as originals? (default is false)

  • color – HTML-formatted color (rrggbb) of obscured regions (default is black-and-white checkerboard)

  • x_ambrahealth_job_id – X-AmbraHealth-Job-Id headers argument

  • is_ai – This is request from ai stack flag

  • only_prepare – Get prepared request.

  • timeout – waiting timeout

  • ws_timeout – waiting from ws timeout

Returns

new study uid

dicom(namespace_id: str, study_uid: str, image_uid: str, image_version: str = '*', engine_fqdn: Optional[str] = None, pretranscode: Optional[bool] = None)[source]

Get dicom.

Parameters
  • namespace_id – uploading to namespace

  • study_uid – study_uid

  • image_uid – image_uid

  • image_version – image_version

  • engine_fqdn – fqdn (if None gets namespace fqdn)

  • pretranscode – get pretranscoded

Returns

pydicom object

duplicate_and_get(uuid: str, namespace_id: str, include_attachments: bool = False, timeout: float = 200.0, ws_timeout: int = 5) → box.box.Box[source]

Duplicate study to namespace.

Parameters
  • uuid – study_uuid

  • namespace_id – to namespace_id

  • include_attachments – include attachments

  • timeout – waiting timeout

  • ws_timeout – waiting from ws timeout

Returns

duplicated study

upload(*, study_dir: pathlib.Path, namespace_id: str) → Tuple[str, List[ambra_sdk.addon.dicom.UploadedImageParams]][source]

Upload study to namespace from path.

Parameters
  • study_dir – path to study dir

  • namespace_id – uploading to namespace

Returns

list of image params

upload_and_get(study_dir: pathlib.Path, namespace_id: str, timeout: float = 200.0, ws_timeout: int = 5) → box.box.Box[source]

Upload study from and get.

Parameters
  • study_dir – path to study dir

  • namespace_id – uploading to namespace

  • timeout – time for waiting new study

  • ws_timeout – time for waiting in socket

Returns

Study box object

upload_dicom(dicom_path: pathlib.Path, namespace_id: str, engine_fqdn: Optional[str] = None) → ambra_sdk.addon.dicom.UploadedImageParams[source]

Upload dicom to namespace.

Parameters
  • dicom_path – path to dicom

  • namespace_id – uploading to namespace

  • engine_fqdn – fqdn (if None gets namespace fqdn)

Returns

uploaded image params

upload_dir(*, study_dir: pathlib.Path, namespace_id: str) → Tuple[str, List[ambra_sdk.addon.dicom.UploadedImageParams]][source]

Upload study to namespace from path.

Parameters
  • study_dir – path to study dir

  • namespace_id – uploading to namespace

Raises

ValueError – Study dir is not directory

Returns

list of image params

upload_dir_and_get(*, study_dir: pathlib.Path, namespace_id: str, timeout: float = 200.0, ws_timeout: int = 5) → box.box.Box[source]

Upload study from dir and get.

Parameters
  • study_dir – path to study dir

  • namespace_id – uploading to namespace

  • timeout – time for waiting new study

  • ws_timeout – time for waiting in socket

Returns

Study box object

upload_paths(*, dicom_paths: Iterator[pathlib.Path], namespace_id: str) → Tuple[str, List[ambra_sdk.addon.dicom.UploadedImageParams]][source]

Upload study to namespace from dicoms iterator.

Parameters
  • dicom_paths – iterator of dicom paths

  • namespace_id – uploading to namespace

Raises

ValueError – Study dir is not directory

Returns

list of image params

upload_paths_and_get(*, dicom_paths: Iterator[pathlib.Path], namespace_id: str, timeout: float = 200.0, ws_timeout: int = 5) → box.box.Box[source]

Upload study from dir and get.

Parameters
  • dicom_paths – iterator of dicom paths

  • namespace_id – uploading to namespace

  • timeout – time for waiting new study

  • ws_timeout – time for waiting in socket

Returns

Study box object

wait(*, study_uid: str, namespace_id: str, timeout: float, ws_timeout: int) → box.box.Box[source]

Wait study in namespace.

Parameters
  • study_uid – study_uid

  • namespace_id – namespace

  • timeout – time for waiting new study

  • ws_timeout – time for waiting in socket

Raises

TimeoutError – if study not ready by timeout

Returns

Study box object

wait_job(job_id: str, namespace_id: str, timeout: float, ws_timeout: int)[source]

Wait job.

Parameters
  • job_id – job id

  • namespace_id – job namespace_id

  • timeout – time for waiting new study

  • ws_timeout – time for waiting in socket