proknow.Uploads¶
Uploads¶
-
class
proknow.Uploads.
Uploads
(proknow, requestor)¶ This class should be used to interact with the uploads in a ProKnow organization. It is instantiated for you as an attribute of the
proknow.ProKnow.ProKnow
class.-
upload
(workspace, path_or_paths, overrides=None)¶ Initiates an upload or series of uploads to the API.
Parameters: - workspace (str) – An id or name of the workspace in which to create the uploads.
- path_or_paths (str or list) – A path or list of paths such that each path is a directory of files to upload or a path to a file to upload.
- overrides (dict, optional) – A dictionary of overrides to use when creating uploads. The
object may contain an optional key
"patient"
, which in turn may contain the optional override parameters"mrn"
,"name"
,"birth_date"
, and"sex"
.
Returns: An object used to manage a batch of uploads.
Return type: Raises: AssertionError
– If the input parameters are invalid.proknow.Exceptions.HttpError
– If the HTTP request generated an error.proknow.Exceptions.InvalidPathError
– If the provided file path is invalid.proknow.Exceptions.WorkspaceLookupError
– If the workspace with the given name or id could not be found.proknow.Exceptions.TimeoutExceededError
– If the timeout was exceeded while waiting for the uploads to complete.
Example
This example shows how to upload a directory of files:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.uploads.upload("Upload Test", "./DICOM")
You may also provide the path to each file:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.uploads.upload("Upload Test", [ "./DICOM/img000001.dcm", "./DICOM/img000002.dcm", "./DICOM/img000003.dcm", "./DICOM/img000004.dcm", "./DICOM/img000005.dcm", ])
Lists containing both directories and file paths are also permitted:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.uploads.upload("Upload Test", [ "./DICOM/CT/", "./DICOM/structures.dcm", "./DICOM/plan.dcm", "./DICOM/dose.dcm", ])
-
UploadBatch¶
-
class
proknow.Uploads.
UploadBatch
(uploads, workspace_id, files)¶ This class is instantiated by the
proknow.Uploads.Uploads.upload()
method and is used as an interface for looking up patients and entities within a batch of resolved uploads.- Attributes
- patients (list): A list of
proknow.Uploads.UploadPatientSummary
items.
-
find_entity
(path)¶ Find the entity associated with the given file.
Parameters: path (str) – An absolute file path.
Returns: A summary representation of the entity.
Return type: Raises: AssertionError
– If the input parameters are invalid.proknow.Exceptions.InvalidPathError
– If the provided file path is invalid.
Example
This example shows how to find an entity associated with a given file upload:
from proknow import ProKnow import os pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") batch = pk.uploads.upload("Upload Test", "./DICOM") path = os.path.abspath("./DICOM/plan.dcm") entity_summary = batch.find_entity(path)
-
find_patient
(path)¶ Find the patient associated with the given file.
Parameters: path (str) – An absolute file path.
Returns: A summary representation of the patient.
Return type: Raises: AssertionError
– If the input parameters are invalid.proknow.Exceptions.InvalidPathError
– If the provided file path is invalid.
Example
This example shows how to find a patient associated with a given file upload:
from proknow import ProKnow import os pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") batch = pk.uploads.upload("Upload Test", "./DICOM") path = os.path.abspath("./DICOM/plan.dcm") patient_summary = batch.find_patient(path)
UploadPatientSummary¶
-
class
proknow.Uploads.
UploadPatientSummary
(uploads, workspace_id, patient)¶ This class provides a summary view of a patient as returned as part of an upload.
-
id
¶ The id of the patient (readonly).
Type: str
-
data
¶ The summary representation of the patient as returned from the API for an upload (readonly).
Type: dict
-
entities
¶ A list of
proknow.Uploads.UploadEntitySummary
items.Type: list
-
add_entity
(entity)¶ Adds an entity to patient summary.
Parameters: entity ( proknow.Uploads.UploadEntitySummary
) – An entity summary to add to the patient summary.
-
get
()¶ Gets the complete representation of the patient.
Returns: an object representing a patient in the organization. Return type: proknow.Patients.PatientItem
Raises: proknow.Exceptions.HttpError
– If the HTTP request generated an error.Example
This example shows how to get a list of patient items associated with a batch of uploads:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") batch = pk.uploads.upload("Upload Test", "./DICOM") patients = [patient.get() for patient in batch.patients]
-
UploadEntitySummary¶
-
class
proknow.Uploads.
UploadEntitySummary
(uploads, workspace_id, patient_id, entity)¶ This class provides a summary view of a entity as returned as part of an upload.
-
id
¶ The id of the entity (readonly).
Type: str
-
data
¶ The summary representation of the entity as returned from the API for an upload (readonly).
Type: dict
-
get
()¶ Gets the complete representation of the entity.
Returns: One of ( proknow.Patients.ImageSetItem
,proknow.Patients.StructureSetItem
,proknow.Patients.PlanItem
,proknow.Patients.DoseItem
) based on the entity summary type.Raises: proknow.Exceptions.HttpError
– If the HTTP request generated an error.Example
This example shows how to get a list of entity items associated with a batch of uploads:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") batch = pk.uploads.upload("Upload Test", "./DICOM") entities = [entity.get() for patient in batch.patients for entity in patient.entities]
-