Orthanc API wrapper¶
-
class
pyorthanc.orthanc.Orthanc(orthanc_url: str)¶ Bases:
objectWrapper around Orthanc REST API
You need to know if you need credentials before using this object. If yes, you need to set credentials with the method setup_credential.
-
anonymize_patient(patient_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Dict[str, str]¶ Anonymize specified patient
If no error is been raise, then it creates a new anonymous patient. Documentation: http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
patient_identifier – Patient identifier.
data – Precision on the anonymization process
- Returns
Dictionary with the Identifier, Path and PatientID of the new anonymous patient.
- Return type
Dict
Examples
>>> from pyorthanc import Orthanc >>> orthanc = Orthanc('http://localhost:8042') >>> a_patient_identifier = orthanc.get_patients()[0] >>> orthanc.anonymize_patient(a_patient_identifier) {'ID': 'dd41f2f1-24838e1e-f01746fc-9715072f-189eb0a2', 'Path': '/patients/dd41f2f1-24838e1e-f01746fc-9715072f-189eb0a2', 'PatientID': 'dd41f2f1-24838e1e-f01746fc-9715072f-189eb0a2', 'Type': 'Patient'}
-
anonymize_series(series_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Anonymize series
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
series_identifier – Series identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
anonymize_specified_instance(instance_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Anonymize specified instance
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
instance_identifier – Instance identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
anonymize_study(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Anonymize study
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
study_identifier – studies identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
archive_patient(patient_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → bytes¶ Archive patient
Create ZIP and return it.
- Parameters
patient_identifier – Patient identifier.
data – Dictionary to send in the body of request.
- Returns
Bytes of the ZIP file.
- Return type
bytes
Examples
>>> orthanc = Orthanc('http://localhost:8042') >>> zip_content = orthanc.archive_patient('A_PATIENT_IDENTIFIER') >>> with open('file_path', 'wb') as file_handler: ... file_handler.write(zip_content)
-
c_find(data: Union[Dict, str, int, bytes, None] = None) → Any¶ C-Find call
Runs a C-Find call from the REST API
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
cancel_job(job_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Cancel specified job
Cancel the job, tag it as failed
- Parameters
job_identifier – Job identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
create_and_store_dicom(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create and store new DICOM instance
Create and store a new DICOM instance, possibly with an image or a PDF payload
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_archive(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create archive (ZIP) from specified set of DICOM objects
Create a ZIP from a set of unrelated DICOM resources
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_media(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create a ZIP with DICOMDIR from specified DICOM objects
Create a ZIP-with-DICOMDIR from a set of unrelated DICOM resources
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_media_extended_to_type3(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create a ZIP with DICOMDIR from specified DICOM objects (this include type-3 tags)
Create a ZIP-with-DICOMDIR from a set of unrelated DICOM resources, including type-3 tags.
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_patient_archive_for_media_storage(patient_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create patient archive media with DICOMDIR
Create a ZIP archive for media storage with DICOMDIR.
- Parameters
patient_identifier – Patient identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_series_archive_for_media_storage(series_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create archive for media storage
Create archives for media storage with DICOMDIR.
- Parameters
series_identifier – Series identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_series_zip_file(series_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create series zip file
Create a ZIP archive for media storage with DICOMDIR.
- Parameters
series_identifier – Series identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_study_archive_for_media_storage(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create archive for media storage
Create a ZIP archive for media storage with DICOMDIR.
- Parameters
study_identifier – Study identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
create_study_zip_file(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Create study zip file
Create ZIP.
- Parameters
study_identifier – studies identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
delete_attachment_by_name(resource_type: str, identifier: str, name: str) → bool¶ Delete attachment by name
Delete the specified attachment file.
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
- Returns
True if succeeded.
- Return type
bool
-
delete_changes() → bool¶ Delete changes (last, since or with specified limit)
With “last”, “limit” and “since” arguments.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_exports() → bool¶ Delete exports
“last”, “limit” and “since” arguments
- Returns
True if succeeded, else, False.
- Return type
bool
-
delete_instance(instance_identifier: str) → bool¶ Delete specified instance
- Parameters
instance_identifier – Instance identifier.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_metadata_contents_of_specified_name(resource_type: str, identifier: str, name: str) → bool¶ Delete the contents of the specified metadata field/name
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_modality(modality: str) → bool¶ Delete remote modality
- Parameters
modality – Modality (remote PACS server, see pyorthanc.get_modalities()).
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_patient(patient_identifier: str) → bool¶ Delete specified patient
- Parameters
patient_identifier – Patient identifier.
- Returns
True if succeeded, else returns False
- Return type
bool
-
delete_peer(peer_identifier: str) → bool¶ Delete specified peer
- Parameters
peer_identifier – Peer identifier.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_queries() → bool¶ Delete all queries
- Returns
True if all deletion succeeded, else False.
- Return type
bool
-
delete_query(query_identifier: str) → bool¶ Delete specified query
- Parameters
query_identifier – Query identifier.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_request(route: str) → bool¶ DELETE to specified route
- Parameters
route – HTTP route.
- Returns
True if the HTTP DELETE request succeeded (HTTP code 200).
- Return type
bool
-
delete_series(series_identifier: str) → bool¶ Delete specified series
- Parameters
series_identifier – Series identifier.
- Returns
True if succeeded, else False.
- Return type
bool
-
delete_study(study_identifier: str) → bool¶ Delete specified study
- Parameters
study_identifier – studies identifier.
- Returns
True if succeeded, else False.
- Return type
bool
-
echo_to_modality(modality: str) → bool¶ Test connection to remote modality (C-Echo SCU)
C-Echo SCU.
- Parameters
modality – Modality (remote PACS server, see Orthanc.get_modalities()).
- Returns
True if C-Echo succeeded.
- Return type
bool
-
execute_given_script(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Execute given script
Execute the Lua script in the POST body.
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
export_instance_to_filesystem(instance_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Write the DICOM file to filesystem
Write the DICOM file to the filesystem where Orthanc is running.
- Parameters
instance_identifier – Instance identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
find_child_dicom_instances_of_answer(query_identifier: str, index: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Find child dicom instances of answer
- Launch another C-Find SCU to find the child DICOM instances of
the given answer (might not work with all PACS).
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
find_child_dicom_series_of_answer(query_identifier: str, index: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Find child dicom series of answer
Launch another C-Find SCU to find the child series of the given answer.
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
find_child_dicom_studies_of_answer(query_identifier: str, index: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Find child dicom studies of answer
Launch another C-Find SCU to find the child patient of the given answer.
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
generate_uid(params: Dict = None) → Any¶ Generate a DICOM UID
Generate DICOM UID. The “level” GET argument must be “patient”, “study”, “series” or “instance”
- Parameters
params – GET HTTP request’s params.
- Returns
DICOM UID.
- Return type
Any
-
get_attachment_by_name(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment file corresponding to object identifier and attachment’s name
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
Attachment file corresponding to object identifier and attachment’s name
- Return type
Any
-
get_attachment_compressed_data(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment compressed data
Return the (possibly compressed) data, as stored on the disk.
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
The (possibly compressed) data, as stored on the disk.
- Return type
Any
-
get_attachment_compressed_data_md5(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment by name as compressed data in md5
Return the (possibly compressed) data, with md5 encryption. Note that md5 is not a safe encryption and should not be used if real encryption is needed.
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
The (possibly compressed) data, with md5 encryption.
- Return type
Any
-
get_attachment_compressed_size(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment compressed size
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
Attachment compressed size.
- Return type
Any
-
get_attachment_data(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment data
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
Attachment data.
- Return type
Any
-
get_attachment_md5(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment with md5 encoding
Note that md5 is not a safe encryption and should not be used if real encryption is needed.
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
Attachment with md5 encoding.
- Return type
Any
-
get_attachment_size(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Get attachment size
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
Attachment size.
- Return type
Any
-
get_attachments(resource_type: str, identifier: str, params: Dict = None) → Any¶ Get list of files attached to the object identifier
List the files that are attached to this patient, study, series or instance
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
params – GET HTTP request’s params.
- Returns
List of files attached to the object corresponding to the object identifier
- Return type
Any
-
get_changes(params: Dict = None) → Any¶ Get changes (last, since or with specified limit)
With “last”, “limit” and “since” arguments.
- Parameters
params – GET HTTP request’s params.
- Returns
Changes (depends on given params/arguments)
- Return type
Any
-
get_content_of_specified_query_answer(query_identifier: str, index: str, params: Dict = None) → Any¶ Get content of specified answer of C-Find
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
params – GET HTTP request’s params.
- Returns
Specified answer of C-Find SCU operation.
- Return type
Any
-
get_content_of_specified_query_answer_in_simplified_version(query_identifier: str, index: str, params: Dict = None) → Any¶ Get content of specified answer of C-Find in simplified version
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
params – GET HTTP request’s params.
- Returns
Specified answer of C-Find SCU operation in a simplified version.
- Return type
Any
-
get_default_encoding(params: Dict = None) → Any¶ Get default encoding
Get the default encoding used by Orthanc.
- Parameters
params – GET HTTP request’s params.
- Returns
Default Encoding.
- Return type
Any
-
get_dicom_conformance(params: Dict = None) → Any¶ Get DICOM conformance statement of this version of Orthanc
DICOM conformance statement of this version of Orthanc.
- Parameters
params – GET HTTP request’s params.
- Returns
DICOM conformance statement of this version of Orthanc.
- Return type
Any
-
get_exports(params: Dict = None) → Any¶ Get exports
With “last”, “limit” and “since” arguments
- Parameters
params – GET HTTP request’s params.
- Returns
The exports.
- Return type
Any
-
get_if_patient_is_protected(patient_identifier: str) → bool¶ Get if patient is protected against recycling
Protection against recycling: False means unprotected, True protected.
- Parameters
patient_identifier – Patient identifier.
- Returns
False means unprotected, True means protected.
- Return type
bool
-
get_instance_content_by_group_element(instance_identifier: str, group_element: str) → Any¶ Get value of DICOM tags corresponding to a specified group element
Raw access to the value of DICOM tags (comprising the padding character). Group element name should be in the form {tag1}/{index1}/{tag2}/…
- Parameters
instance_identifier – Instance identifier.
group_element – Group element corresponding to targeted DICOM tag.
- Returns
DICOM tag value.
- Return type
Any
Examples
>>> o = Orthanc('http://localhost:8080') >>> o.get_instance_content_by_group_element('0040-a730/6/0040-a730/0/0040-a160')
-
get_instance_file(instance_identifier: str, params: Dict = None) → bytes¶ Get instance DICOM file
Retrieve on local computer the instance file in bytes.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Bytes corresponding to DICOM file.
- Return type
bytes
Examples
>>> orthanc = Orthanc('ORTHANC_URL') >>> dicom_file_bytes = orthanc.get_instance_file('an_instance_identifier') >>> with open('your_path', 'wb') as file_handler: ... file_handler.write(dicom_file_bytes)
Get instance content (first level DICOM tags)
List the first-level DICOM tags
- Parameters
instance_identifier – Instance identifier.
- Returns
Instance’s first level DICOM tags.
- Return type
List[str]
-
get_instance_frame_as_image_uint16(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get instance frame as uint16 image
- Truncated decoded image to the [0;65535] range
(Accepts image/png, image/jpg, image/x-portable-arbitrarymap).
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_instance_frame_as_image_uint8(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get instance frame as uint16 image
- Truncated decoded image to the [0;255] range
(Accepts image/png, image/jpg, image/x-portable-arbitrarymap).
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_instance_frame_as_int16_image(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get instance frame as int16 image
Truncated decoded image to the [-32768;32767] range (Accepts image/png, image/jpg, image/x-portable-arbitrarymap).
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
Instance frame as int16 image.
- Return type
Any
-
get_instance_frame_as_readable_image_by_matlab(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get instance frame as a readable image by matlab
Get a kind of array : a = eval(urlread(‘http://localhost:8042/instances/…/frames/0/matlab’))
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_instance_frames(instance_identifier: str, params: Dict = None) → Any¶ Get Instances’s frames
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Frames of specified instance.
- Return type
Any
-
get_instance_header(instance_identifier: str, params: Dict = None) → Any¶ Get the meta information (header) of the DICOM file
Get the meta information (header) of the DICOM file,
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Meta information (header) of the DICOM file.
- Return type
Any
-
get_instance_header_in_shorter_version(instance_identifier: str, params: Dict = None) → Any¶ Get the meta information (header) of the DICOM file in a shorter version
Get the meta information (header) of the DICOM file,
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Meta information (header) of the DICOM file in a shorter version.
- Return type
Any
-
get_instance_header_in_simplified_version(instance_identifier: str, params: Dict = None) → Any¶ Get the meta information (header) of the DICOM file in a simplified version
Get the meta information (header) of the DICOM file,
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Meta information (header) of the DICOM file in a simplified version.
- Return type
Any
-
get_instance_image_as_int16(instance_identifier: str, params: Dict = None) → Any¶ Get instance image as an int16 image
- Truncated decoded image to the [-32768;32767] range
(Accepts image/png, image/jpg, image/x-portable-arbitrarymap).
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance image as an int16 image.
- Return type
Any
-
get_instance_image_as_readable_image_by_matlab(instance_identifier: str, params: Dict = None) → Any¶ Get instance image that is readable by matlab
a = eval(urlread(‘http://localhost:8042/instances/…/matlab’))
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance image that is readable by matlab.
- Return type
Any
-
get_instance_image_as_uint16(instance_identifier: str, params: Dict = None) → Any¶ Get instance image as an uint16 image
- Truncated decoded image to the [0;65535] range
(Accepts image/png, image/jpg, image/x-portable-arbitrarymap)
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance image as an uint16 image.
- Return type
Any
-
get_instance_image_as_uint8(instance_identifier: str, params: Dict = None) → Any¶ Get instance image as an uint8 image
- Truncated decoded image to the [0;255] range
(Accepts image/png, image/jpg, image/x-portable-arbitrarymap)
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance image as an uint8 image.
- Return type
Any
-
get_instance_information(instance_identifier: str) → Any¶ Get instance information
Instance dictionary with main information.
- Parameters
instance_identifier – Instance identifier.
- Returns
Instance dictionary with main information.
- Return type
Any
-
get_instance_module(instance_identifier: str, params: Dict = None) → Any¶ Get instance module
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance module.
- Return type
Any
-
get_instance_module_in_shorter_version(instance_identifier: str, params: Dict = None) → Any¶ Get instance module in a shorter version
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance module in a shorter version.
- Return type
Any
-
get_instance_module_in_simplified_version(instance_identifier: str, params: Dict = None) → Any¶ Get instance module in a simplified version
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance module in a simplified version.
- Return type
Any
-
get_instance_patient_identifier(instance_identifier: str, params: Dict = None) → Any¶ Get instance’s patient’s identifier
Retrieve the parent patient of this instance.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Patient identifier.
- Return type
Any
-
get_instance_pdf(instance_identifier: str, params: Dict = None) → Any¶ Get the PDF inside the DICOM file, if any.
Return the encapsulated PDF inside the DICOM file, if any.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
PDF inside the DICOM file, if any.
- Return type
Any
-
get_instance_series_identifier(instance_identifier: str, params: Dict = None) → Any¶ Get instance’s series’s identifier
Retrieve the parent series of this instance.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Series’s identifier.
- Return type
Any
Get instance’s simplified DICOM tags
Instance simplified DICOM tags (e.g. “PatientID” instead of “(0010,0020)”).
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s simplified DICOM tags. Should be in the form of a dictionary.
- Return type
Any
-
get_instance_statistics(instance_identifier: str, params: Dict = None) → Any¶ Get instance’s statistics
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s statistics.
- Return type
Any
-
get_instance_study_identifier(instance_identifier: str, params: Dict = None) → Any¶ Get instance’s study’s identifier
Retrieve the parent study of this instance.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s study’s identifier.
- Return type
Any
Get instance’s tags.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s DICOM tags. Should be in the form of a dictionary.
- Return type
Any
Get instance’s tags in a shorter version
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s DICOM tags in a shorter version. Should be in the form of a dictionary.
- Return type
Any
Get instance’s tags in a simplified version.
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
Instance’s DICOM tags in a simplified version. Should be in the form of a dictionary.
- Return type
Any
-
get_instances() → List[str]¶ Get all instances identifiers
- Returns
All instances identifiers.
- Return type
List[str]
-
get_job_information(job_identifier: str, params: Dict = None) → Any¶ Get information of specified job
Get information about specified job.
- Parameters
job_identifier – Job identifier.
params – GET HTTP request’s params.
- Returns
Information about specified job.
- Return type
Any
-
get_job_output(job_identifier: str, key: str, params: Dict = None) → Any¶ Get outputs generated by the job
Retrieve outputs generated by the job (only valid after job is successful).
- Parameters
job_identifier – Job identifier.
key – Key to get output
params – GET HTTP request’s params.
- Returns
Outputs generated by the job.
- Return type
Any
-
get_jobs(params: Dict = None) → Any¶ Get running jobs
List the jobs, “?expand” to get more information
- Parameters
params – GET HTTP request’s params.
- Returns
List of running jobs identifier.
- Return type
Any
-
get_local_time(params: Dict = None) → Any¶ Get local current time
Returns the current local datetime in the ISO 8601 format.
- Parameters
params – GET HTTP request’s params.
- Returns
Local current time.
- Return type
Any
-
get_metadata_contents_of_specified_name(resource_type: str, identifier: str, name: str) → Any¶ Get the contents of the specified metadata field/name
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
- Returns
Contents of specified metadata field.
- Return type
Any
-
get_metrics(params: Dict = None) → Any¶ Get metrics
See whether the collection of metrics is enabled.
- Parameters
params – GET HTTP request’s params.
- Returns
Metrics
- Return type
Any
-
get_metrics_prometheus(params: Dict = None) → Any¶ Get metrics in the Prometheus text-based exposition format
Retrieve the metrics in the Prometheus text-based exposition format.
- Parameters
params – GET HTTP request’s params.
- Returns
Metrics in the Prometheus text-based exposition format.
- Return type
Any
-
get_modalities(params: Dict = None) → Any¶ Get modalities
List registered modalities (remote PACS servers that are connected to Orthanc) See the Orthanc’s config for more details (AET addresses).
- Parameters
params – GET HTTP request’s params.
- Returns
List of modalities.
- Return type
Any
-
get_modality(modality: str, params: Dict = None) → Any¶ Get specified modality
- Parameters
modality – Modality (remote PACS server, see pyorthanc.get_modalities()).
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_object_metadata(resource_type: str, identifier: str, params: Dict = None) → Any¶ Get object’s metadata with specified resource-type and identifier
“?expand” argument
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
params – GET HTTP request’s params.
- Returns
Object Metadata.
- Return type
Any
-
get_patient_archive(patient_identifier: str) → Any¶ Get patient zip archive for media storage with DICOMDIR
Create a ZIP archive for media storage with DICOMDIR.
- Parameters
patient_identifier – Patient identifier.
- Returns
Bytes of archive zip file
- Return type
bytes
Examples
>>> from pyorthanc import Orthanc >>> orthanc = Orthanc('http://localhost:8042') >>> a_patient_identifier = orthanc.get_patients()[0] >>> bytes_content = orthanc.get_patient_archive(a_patient_identifier) >>> with open('patient_archive_zip_file_path.zip', 'wb') as file_handler: ... file_handler.write(bytes_content)
-
get_patient_information(patient_identifier: str) → Dict¶ Get patient main information
- Parameters
patient_identifier – Patient identifier.
- Returns
Dictionary of patient main information.
- Return type
Dict
-
get_patient_instances(patient_identifier: str) → List[Dict]¶ Get patient instances
Retrieve all the instances of this patient in a single REST call.
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient instances main information (list of dict).
- Return type
List[Dict]
Get tags of all patient’s instances
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient instances tags as dictionaries of dictionary.
- Return type
Dict
Get tags of all patient instances in a shorter version
Short version of the tags (with hexadecimal tag name).
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient instances tags as dictionaries of dictionary in a shorter version.
- Return type
Dict
Get tags of all patient’s instances in a simplified version
Simplified instance tags (without hexadecimal tag identifier, readable for humans).
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient instances tags as dictionaries of dictionary in a simplified version.
- Return type
Dict
-
get_patient_module(patient_identifier: str) → Dict¶ Get patient module
The method returns the DICOM patient module (PatientName, PatientID, PatientBirthDate, …)
- Parameters
patient_identifier – Patient identifier.
- Returns
DICOM Patient module.
- Return type
Dict
-
get_patient_module_in_shorter_version(patient_identifier: str) → Dict¶ Get patient module in a shorter version
The method returns the DICOM patient module (PatientName, PatientID, PatientBirthDate, …)
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient module in a shorter version.
- Return type
Dict
-
get_patient_module_in_simplified_version(patient_identifier: str) → Dict¶ Get patient module in a simplified version
The method returns the DICOM patient module (PatientName, PatientID, PatientBirthDate, …)
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient module in a simplified version.
- Return type
Dict
-
get_patient_series(patient_identifier: str) → List[Dict]¶ Get patient series
Retrieve all the series of this patient in a single REST call.
- Parameters
patient_identifier – Patient identifier.
- Returns
List of series main information.
- Return type
List[Dict]
Get patient shared tags
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient shared tags.
- Return type
Dict[str, Dict]
Get patient shared tags in a shorter version
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient shared tags in a shorter version.
- Return type
Dict[str, Any]
Get patient shared tags in a simplified version
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient shared tags in a simplified version.
- Return type
Dict[str, str]
-
get_patient_statistics(patient_identifier: str) → Dict[str, Union[str, int]]¶ Get patient statistics
- Parameters
patient_identifier – Patient identifier.
- Returns
Patient statistics.
- Return type
Dict[str, Union[str, int]]
-
get_patient_studies_information(patient_identifier: str) → List[Dict]¶ Get patient study main information for all patient studies
Retrieve all the studies of this patient in a single REST call.
- Parameters
patient_identifier – Patient identifier.
- Returns
List of patient studies information.
- Return type
List[Dict]
-
get_patient_zip(patient_identifier: str) → bytes¶ Get the bytes of the zip file
Get the .zip file.
- Parameters
patient_identifier – Patient identifier.
- Returns
Bytes of Zip file of the patient.
- Return type
bytes
Examples
>>> from pyorthanc import Orthanc >>> orthanc = Orthanc('http://localhost:8042') >>> a_patient_identifier = orthanc.get_patients()[0] >>> bytes_content = orthanc.get_patient_zip(a_patient_identifier) >>> with open('patient_zip_file_path.zip', 'wb') as file_handler: ... file_handler.write(bytes_content)
-
get_patients() → List[str]¶ Get patient identifiers
“since” and “limit” arguments + “expand” argument to retrieve the content of the patients.
- Returns
List of patient identifiers.
- Return type
List[str]
-
get_peer(peer_identifier: str, params: Dict = None) → Any¶ Get peer
- Parameters
peer_identifier – Peer identifier.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_peers(params: Dict = None) → Any¶ Get peers
- Parameters
params – GET HTTP request’s params.
- Returns
Peers.
- Return type
Any
-
get_plugin(plugin_identifier: str, params: Dict = None) → Any¶ Get specified plugin information
Get information about specified plugin.
- Parameters
plugin_identifier – Plugin identifier.
params – GET HTTP request’s params.
- Returns
Plugin information.
- Return type
Any
-
get_plugins(params: Dict = None) → Any¶ Get plugin names/identifiers
Get the list of all the registered plugins
- Parameters
params – GET HTTP request’s params.
- Returns
List of registered plugin names/identifiers.
- Return type
Any
-
get_plugins_js_code(params: Dict = None) → Any¶ Get the javascript code injected by plugins
Get the JavaScript code that is injected by plugins into Orthanc Explorer.
- Parameters
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_preview_of_instance_frame(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get a preview of an instance frame
Rescaled image (so that all the range [0;255] is used)
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
A rescaled image (so that all the range [0;255] is used) corresponding to specified frame.
- Return type
Any
-
get_preview_of_instance_image(instance_identifier: str, params: Dict = None) → Any¶ Get a preview of an instance image
Rescaled image (so that all the range [0;255] is used).
- Parameters
instance_identifier – Instance identifier.
params – GET HTTP request’s params.
- Returns
A rescaled image (so that all the range [0;255] is used).
- Return type
Any
-
get_queries(params: Dict = None) → Any¶ Get queries
- Parameters
params – GET HTTP request’s params.
- Returns
List of queries.
- Return type
Any
-
get_query_answers(query_identifier: str, params: Dict = None) → Any¶ Get query answers
- List all the answers for this C-Find SCU request
(“?expand” to show content, “&simplify” to simplify output)
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
List all the answers for the specified query.
- Return type
Any
-
get_query_information(query_identifier: str, params: Dict = None) → Any¶ Get query main information
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
Query information.
- Return type
Any
-
get_query_information_in_simplified_version(query_identifier: str, params: Dict = None) → Any¶ Get query information in a simplified version
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
Query information in a simplified version.
- Return type
Any
-
get_query_modality(query_identifier: str, params: Dict = None) → Any¶ Get the modality to which this C-Find SCU request was issued
Get the modality to which this C-Find SCU request was issued (cf. /modalities)
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
Modality to which this C-Find SCU request was issued.
- Return type
Any
-
get_query_retrieve_level(query_identifier: str, params: Dict = None) → Any¶ Get query retrieve level
Get the query retrieve level for this C-Find SCU request.
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
Query retrieve level for this C-Find SCU request
- Return type
Any
-
get_raw_compressed_content_of_instance_frame(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get raw content of an instance frame (compressed using gzip)
Access to the raw content of one frame, compressed using gzip.
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
Raw content of one frame, compressed using gzip
- Return type
Any
-
get_raw_content_of_instance_frame(instance_identifier: str, frame_number: str, params: Dict = None) → Any¶ Get raw content of an instance frame (bypass image decoding)
Access to the raw content of one frame (bypass image decoding).
- Parameters
instance_identifier – Instance identifier.
frame_number – Frame number.
params – GET HTTP request’s params.
- Returns
Raw content of one frame (bypass image decoding).
- Return type
Any
-
get_request(route: str, params: Optional[Dict] = None, return_as_bytes: bool = False) → Any¶ GET request with specified route
- Parameters
route – HTTP route.
params – Params with the HTTP GET request.
return_as_bytes – If True, returns the content as bytes.
- Returns
Response of the HTTP GET request converted to json format.
- Return type
Union[List, Dict, str, bytes, int]
-
get_series(params: Dict = None) → Any¶ Get series identifiers
“since” and “limit” arguments + “expand” argument to retrieve the content of the series.
- Parameters
params – GET HTTP request’s params.
- Returns
List of series identifiers.
- Return type
Any
-
get_series_archives(series_identifier: str, params: Dict = None) → Any¶ Get series media storage with DICOMDIR
Get archives for media storage with DICOMDIR.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_series_information(series_identifier: str, params: Dict = None) → Any¶ Get series information
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series main information in the form of dictionary.
- Return type
Any
-
get_series_instance_information(series_identifier: str, params: Dict = None) → Any¶ Get series instances
Retrieve all the instances of this series in a single REST call.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
List of series instances.
- Return type
Any
Get series instances tags
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
List of series instances tags.
- Return type
Any
Get series instances tags in a shorter version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
List of series instances tags in a shorter version.
- Return type
Any
Get series instances tags in a simplified version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
List of series instances tags in a simplified version.
- Return type
Any
-
get_series_module(series_identifier: str, params: Dict = None) → Any¶ Get series module
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series module.
- Return type
Any
-
get_series_module_in_shorter_version(series_identifier: str, params: Dict = None) → Any¶ Get series module in a shorter version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series module in a shorter version.
- Return type
Any
-
get_series_module_in_simplified_version(series_identifier: str, params: Dict = None) → Any¶ Get series module in simplified version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series module in a simplified version.
- Return type
Any
-
get_series_ordered_slices(series_identifier: str, params: Dict = None) → Any¶ Get series ordered slices
Order the slices of a 2D+t, 3D or 3D+t image.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_series_patient_identifier(series_identifier: str, params: Dict = None) → Any¶ Get series patient identifier
Retrieve the parent patient of this series.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Patient identifier.
- Return type
Any
Get series shared tags
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series shared tags.
- Return type
Any
Get series shared tags in a shorter version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series shared tags in a shorter version.
- Return type
Any
Get series shared tags in a simplified version
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series shared tags in a simplified version.
- Return type
Any
-
get_series_statistics(series_identifier: str, params: Dict = None) → Any¶ Get series statistics
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series statistics.
- Return type
Any
-
get_series_study_identifier(series_identifier: str, params: Dict = None) → Any¶ Get series study identifier
Retrieve the parent study of this series.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series study identifier.
- Return type
Any
-
get_series_zip_file(series_identifier: str, params: Dict = None) → Any¶ Get series zip file
Get a ZIP archive for media storage with DICOMDIR.
- Parameters
series_identifier – Series identifier.
params – GET HTTP request’s params.
- Returns
Series zip file.
- Return type
Any
-
get_statistics(params: Dict = None) → Any¶ Get Orthanc statistics
- Parameters
params – GET HTTP request’s params.
- Returns
Orthanc statistics.
- Return type
Any
-
get_studies() → List[str]¶ Get studies identifiers
“since” and “limit” arguments + “expand” argument to retrieve the content of the studies.
- Returns
List of the studies identifiers.
- Return type
List[str]
-
get_study_archive(study_identifier: str) → bytes¶ Get study archive
- Parameters
study_identifier – studies identifier.
- Returns
- Return type
bytes
-
get_study_information(study_identifier: str) → Dict¶ Get study information
- Parameters
study_identifier – studies identifier.
- Returns
Study main information in the form of a dictionary.
- Return type
Dict
-
get_study_instances(study_identifier: str, params: Dict = None) → Any¶ Get study instances
Retrieve all the instances of this patient in a single REST call.
- Parameters
study_identifier – studies identifier.
params – GET HTTP request’s params.
- Returns
List of study instances.
- Return type
Any
Get study instances tags
- Parameters
study_identifier – studies identifier.
- Returns
Study instances tags
- Return type
Dict
Get study instances tags in a shorter version
- Parameters
study_identifier – studies identifier.
- Returns
Study instances tags in a shorter version.
- Return type
Dict
Get study instances tags in a simplified version
- Parameters
study_identifier – studies identifier.
- Returns
Study instances tags in a simplified version.
- Return type
Dict
-
get_study_module(study_identifier: str, params: Dict = None) → Any¶ Get study module
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study module
- Return type
Any
-
get_study_module_in_shorter_version(study_identifier: str, params: Dict = None) → Any¶ Get study module in a shorter version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study module in a shorter version.
- Return type
Any
-
get_study_module_in_simplified_version(study_identifier: str, params: Dict = None) → Any¶ Get study module in a simplified version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study module in a simplified version.
- Return type
Any
-
get_study_module_patient(study_identifier: str, params: Dict = None) → Any¶ Get study’s module_patient
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s module_patient
- Return type
Any
-
get_study_module_patient_in_shorter_version(study_identifier: str, params: Dict = None) → Any¶ Get study’s module_patient in shorter version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s module_patient in a shorter version
- Return type
Any
-
get_study_module_patient_in_simplified_version(study_identifier: str, params: Dict = None) → Any¶ Get study’s module_patient in a simplified version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s module_patient in a simplified version.
- Return type
Any
-
get_study_patient_identifier(study_identifier: str, params: Dict = None) → Any¶ Get study’s patient identifier
Retrieve the parent patient of this study
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s patient identifier.
- Return type
Any
-
get_study_series_information(study_identifier: str, params: Dict = None) → Any¶ Get study’s series main information
Retrieve all the series of this study in a single REST call.
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
List of study’s series main information.
- Return type
Any
Get study’s shared tags
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s shared tags.
- Return type
Any
Get study’s shared tags in a shorter version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s shared tags in a shorter version.
- Return type
Any
Get study’s shared tags in a simplified version
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study’s shared tags in a simplified version.
- Return type
Any
-
get_study_statistics(study_identifier: str, params: Dict = None) → Any¶ Get study statistics
- Parameters
study_identifier – Study identifier.
params – GET HTTP request’s params.
- Returns
Study statistics.
- Return type
Any
-
get_study_zip_file(study_identifier: str) → bytes¶ Get study zip file
Get ZIP file
- Parameters
study_identifier – studies identifier.
- Returns
Bytes of the zip file.
- Return type
bytes
-
get_system(params: Dict = None) → Any¶ Get system
- Parameters
params – GET HTTP request’s params.
- Returns
- Return type
Any
-
get_universal_time(params: Dict = None) → Any¶ Get universal current time
Returns the current universal datetime (UTC) in the ISO 8601 format.
- Parameters
params – GET HTTP request’s params.
- Returns
Universal current time.
- Return type
Any
-
get_used_information_for_query(query_identifier: str, params: Dict = None) → Any¶ Get specified query information
- Parameters
query_identifier – Query identifier.
params – GET HTTP request’s params.
- Returns
Query information.
- Return type
Any
Invalidate the JSON summary of all DICOM files
Invalidate the JSON summary of all the DICOM files (useful if new private tags are registered).
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
is_attachment_compressed(resource_type: str, identifier: str, name: str, params: Dict = None) → Any¶ Ask Orthanc if attachment is compressed
Is this attachment compressed: “0” means uncompressed, “1” compressed
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
params – GET HTTP request’s params.
- Returns
“0” means uncompressed, “1” compressed
- Return type
Any
-
lookup(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Map DICOM UIDs to Orthanc identifiers
Map DICOM UIDs to Orthanc identifiers
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
merge_study(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Merge study
Merge a study, i.e. move series from another study into this study
- Parameters
study_identifier – Study identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
modify_instance(instance_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Modify instance
See http://book.pyorthanc-server.com/users/anonymization.html .
- Parameters
instance_identifier – Instance identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
modify_patient(patient_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Modify patient
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
patient_identifier – Patient identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
modify_study(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Modify study
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
study_identifier – Study identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
move_from_modality(modality: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Move (C-Move SCU) specified query.
DICOM C-Move SCU (Retrieve).
- Parameters
modality – Modality (remote PACS server, see Orthanc.get_modalities()).
data – Dictionary to send in the body of request.
- Returns
Result of query in the form of { “ID”: “{query-id}”, “Path”: “/queries/{query-id}” }
- Return type
Any
-
move_query_results_to_given_modality(query_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Move (C-Move) what is in the given query results to another modality
C-Move SCU: Send all the results to another modality whose AET is in the body.
- Parameters
query_identifier – Query identifier.
data – Dictionary to send in the body of request.
- Returns
Orthanc Response (probably json)
- Return type
Any
Examples
>>> orthanc = Orthanc('http://localhost:8042') >>> query_id = orthanc.query_on_modality( ... 'modality', ... data={'Level': 'Study', ... 'Query': {'QueryRetrieveLevel': 'Study', ... 'Modality':'SR'}})
>>> orthanc.move_query_results_to_given_modality( ... query_identifier=query_id['ID'], ... data={'TargetAet': 'modality'})
-
pause_job(job_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Pause specified job
Pause the specified job.
- Parameters
job_identifier – Job identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
post_attachment_uncompress(resource_type: str, identifier: str, name: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Post an uncompressed attachment
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
post_attachment_verify_md5(resource_type: str, identifier: str, name: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Post that verify that there is no corruption on the disk
Check that there is no corruption on the disk (HTTP status == 200 iff. no error)
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
data – POST HTTP request’s data.
- Returns
HTTP status == 200 if no error.
- Return type
Any
-
post_compress_attachment(resource_type: str, identifier: str, name: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Compress attachment file
This method should compress the DICOM instance(s).
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
data – Data to send in the request’s body.
- Returns
- Return type
Any
-
post_instances(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Post instances
Add the new DICOM file given in the POST body.
- Parameters
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
post_request(route: str, data: Union[Dict, str, int, bytes, None] = None, return_as_bytes: bool = False) → Any¶ POST to specified route
- Parameters
route – HTTP route.
data – Dictionary to send in the body of request.
return_as_bytes – If True, returns the content as bytes.
- Returns
Response of the HTTP POST request converted to json format.
- Return type
Union[Dict, str, bytes, int]
-
post_series_modify(series_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Modify series
http://book.pyorthanc-server.com/users/anonymization.html
- Parameters
series_identifier – Series identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
put_attachment_by_name(resource_type: str, identifier: str, name: str, data: Union[Dict, str, int, bytes, None] = None) → None¶ Put attachment with given name
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
data – Data to send in the request’s body.
- Returns
Nothing.
- Return type
None
-
put_default_encoding(data: Union[Dict, str, int, bytes, None] = None) → None¶ Change the default encoding
Temporarily change the default encoding until the next restart.
- Parameters
data – Dictionary to send in the body of request.
- Returns
Nothing.
- Return type
None
-
put_metadata_contents_with_specific_name(resource_type: str, identifier: str, name: str, data: Union[Dict, str, int, bytes, None] = None) → None¶ Put the contents with a specified metadata field/name
- Parameters
resource_type – Resource type (‘Patient’, ‘Study’, ‘Series’ or ‘Instance’).
identifier – Object identifier (patient, study, series, instance).
name – Attachment name.
data – PUT HTTP request’s data.
- Returns
Nothing.
- Return type
None
-
put_metrics(data: Union[Dict, str, int, bytes, None] = None) → None¶ Put method
Enable/disable this collection of metrics
- Parameters
data – Dictionary to send in the body of request.
- Returns
Nothing.
- Return type
None
-
put_modality(modality: str, data: Union[Dict, str, int, bytes, None] = None) → None¶ Put remote modality
- Parameters
modality – Modality (remote PACS server, see Orthanc.get_modalities()).
data – Dictionary to send in the body of request.
- Returns
Nothing.
- Return type
None
-
put_peer(peer_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → None¶ Put peer
- Parameters
peer_identifier – Peer identifier.
data – Dictionary to send in the body of request.
- Returns
Nothing.
- Return type
None
-
put_request(route: str, data: Union[Dict, str, int, bytes, None] = None) → None¶ PUT to specified route
- Parameters
route – HTTP route.
data – Dictionary to send in the body of request.
- Returns
Nothing, raise if a problem occurs.
- Return type
None
-
query_on_modality(modality: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Query on remote modalities
DICOM C-Find SCU (Query), with subsequent possibility for Retrieve. See http://book.pyorthanc-server.com/users/rest.html#performing-queries-on-modalities.
- Parameters
modality – Modality (remote PACS server, see pyorthanc.get_modalities()).
data – Dictionary to send in the body of request.
- Returns
Result of query in the form of { “ID”: “{query-id}”, “Path”: “/queries/{query-id}” }
- Return type
Any
Examples
>>> orthanc = Orthanc('http://localhost:8042') >>> orthanc.query_on_modality('modality', ... data={'Level': 'Study', ... 'Query': { ... 'QueryRetrieveLevel': 'Study', ... 'Modality': 'SR'}})
>>> orthanc.move_query_results_to_given_modality('modality')
Reconstruct main DICOM tags
- Reconstructs the main DICOM tags, the JSON summary and metadata of
all the instances stored in Orthanc. Slow operation!
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
Reconstruction of the main DICOM tags of instance
Force reconstruction of the main DICOM tags, JSON summary and metadata.
- Parameters
instance_identifier – Instance identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
Force reconstruction of the main DICOM tags of patient
Force reconstruction of the main DICOM tags, JSON summary and metadata of child instances
- Parameters
patient_identifier – Patient identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
Reconstruction of the main DICOM tags of series
Force reconstruction of the main DICOM tags, JSON summary and metadata of child instances
- Parameters
series_identifier – Series identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
Reconstruct the main DICOM tags of study
Force reconstruction of the main DICOM tags, JSON summary and metadata of child instances
- Parameters
study_identifier – Study identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
reset_orthanc(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Hot restart of Orthanc
Hot restart of Orthanc, the configuration file will be read again
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
resubmit_job(job_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Resubmit job
Resubmit a failed job.
- Parameters
job_identifier – Job identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
resume_job(job_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Resume the specified paused job
Resume a paused job.
- Parameters
job_identifier – Job identifier.
data – POST HTTP request’s data.
- Returns
- Return type
Any
-
send_resource_to_other_modality(query_identifier: str, index: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ (C-Move) Send resource to another modality with AET in request body
C-Move SCU: Send this resource to another modality whose AET is in the body.
- Parameters
query_identifier – Query identifier.
index – Index of wanted answer.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
set_patient_to_not_protected(patient_identifier: str) → None¶ Set patient to not protected state
- Parameters
patient_identifier – Patient identifier.
- Returns
Nothing.
- Return type
None
-
set_patient_to_protected(patient_identifier: str) → None¶ Set patient to protected state
- Parameters
patient_identifier – Patient identifier.
- Returns
Nothing.
- Return type
None
-
setup_credentials(username: str, password: str) → None¶ Set credentials needed for HTTP requests
- Parameters
username – Username.
password – Password.
-
shutdown_orthanc(data: Union[Dict, str, int, bytes, None] = None) → Any¶ Shutdown Orthanc
Stop Orthanc.
- Parameters
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
split_study(study_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Split study
Split a study, i.e. create a new study from a subset of its child series.
- Parameters
study_identifier – Study identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
store_on_modality(modality: str, data: Union[Dict, str, int, bytes, None] = None) → Dict¶ Store data on remote modality (C-Store).
- Parameters
modality – Modality (remote PACS server, see pyorthanc.get_modalities()).
data – Orthanc Identifier of the Series or Instance to be send.
- Returns
Data related to the C-Store operation.
- Return type
Dict
-
store_peer(peer_identifier: str, data: Union[Dict, str, int, bytes, None] = None) → Any¶ Post method
POST body = UUID series, UUID instance, or raw DICOM file
- Parameters
peer_identifier – Peer identifier.
data – Dictionary to send in the body of request.
- Returns
- Return type
Any
-
Remote sub-module¶
-
class
pyorthanc.remote.RemoteModality(orthanc: pyorthanc.orthanc.Orthanc, modality: str)¶ Bases:
objectWrapper around Orthanc API when dealing with a (remote) modality.
-
echo() → bool¶ C-Echo to remote modality
- Returns
True if C-Echo succeeded.
- Return type
bool
-
move(query_identifier: str, cmove_data: Dict) → Dict¶ C-Move query results to another modality
C-Move SCU: Send all the results to another modality whose AET is in the body
- Parameters
query_identifier – Query identifier.
cmove_data – Ex. {‘TargetAet’: ‘target_modality_name’, “Synchronous”: False}
- Returns
Orthanc Response (probably a Dictionary)
- Return type
Dict
Examples
>>> remote_modality = RemoteModality(Orthanc('http://localhost:8042'), 'modality') >>> query_id = remote_modality.query( ... data={'Level': 'Series', ... 'Query': {'PatientID': '', ... 'Modality':'SR'}})
>>> remote_modality.move( ... query_identifier=query_id['ID'], ... cmove_data={'TargetAet': 'TARGETAET'} ... )
-
query(data: Dict) → Dict¶ C-Find (Querying with data)
- Parameters
data – Dictionary to send in the body of request.
- Returns
Dictionary with keys {‘ID’: ‘…’, ‘path’: ‘…’}
- Return type
Dict
Examples
>>> data = {'Level': 'Study', ... 'Query': { ... 'PatientID':'03HD*', ... 'StudyDescription':'*Chest*', ... 'PatientName':'' ... } ... }
>>> remote_modality = RemoteModality( ... orthanc=Orthanc('http://localhost:8042'), ... modality='sample' ... )
>>> remote_modality.query(data)
-
store(instance_or_series_identifier: str) → Dict¶ Store series or instance to remote modality.
- Parameters
instance_or_series_identifier – Instance or Series Orthanc identifier.
- Returns
Information related to the C-Store operation.
- Return type
Dict
-
Util sub-module¶
-
pyorthanc.util.build_patient_forest(orthanc: pyorthanc.orthanc.Orthanc, max_nbr_workers: int = 100, patient_filter: Optional[Callable] = None, study_filter: Optional[Callable] = None, series_filter: Optional[Callable] = None, do_trim_forest_after_construction: bool = True) → List[pyorthanc.patient.Patient]¶ Build a patient forest
Each tree in the forest correspond to a patient. The layers in the tree correspond to:
Patient -> Studies -> Series -> Instances
Note that trees are build concurrently. You may want to change the default values. Increase this number could improve performance, but it will take more memory.
- Parameters
orthanc – Orthanc object.
max_nbr_workers – Number of workers for to build the concurrent tree.
patient_filter – Patient filter (e.g. lambda patient: patient.get_id() == ‘03HDQ99*’)
study_filter – Study filter (e.g. lambda study: study.get_id() == ‘pros’)
series_filter – Series filter (e.g. lambda series: series.get_modality() == ‘SR’)
do_trim_forest_after_construction – If True, trim the forest after its construction.
- Returns
List of patient tree representation.
- Return type
List[Patient]
-
pyorthanc.util.retrieve_and_write_patients(patient_forest: List[pyorthanc.patient.Patient], path: str) → None¶ Retrieve and write patients to given path
- Parameters
patient_forest – Patient forest.
path – Path where you want to write the files.
-
pyorthanc.util.retrieve_instance(instance: pyorthanc.instance.Instance, series_path) → None¶
-
pyorthanc.util.retrieve_patient(patient: pyorthanc.patient.Patient, path: str) → None¶
-
pyorthanc.util.retrieve_series(series: pyorthanc.series.Series, study_path: str) → None¶
-
pyorthanc.util.retrieve_study(study: pyorthanc.study.Study, patient_path: str) → None¶
Patient sub-module¶
-
class
pyorthanc.patient.Patient(patient_identifier: str, orthanc: pyorthanc.orthanc.Orthanc, patient_information: Dict = None)¶ Bases:
objectRepresent an Patient that is in an Orthanc server
This object has many getters that allow the user to retrieve metadata or the entire DICOM file of the Patient
-
anonymize() → pyorthanc.patient.Patient¶ Anonymize patient
If no error is been raise, then it creates a new anonymous patient. Documentation: http://book.pyorthanc-server.com/users/anonymization.html
- Returns
A New anonymous patient.
- Return type
-
build_studies() → None¶ Build a list of the patient’s studies
-
get_id() → str¶ Get patient ID
- Returns
Patient ID
- Return type
str
-
get_identifier() → str¶ Get patient identifier
- Returns
Patient identifier
- Return type
str
-
get_main_information() → Dict¶ Get Patient information
- Returns
Dictionary of patient main information.
- Return type
Dict
-
get_name() → str¶ Get patient name
- Returns
Patient name
- Return type
str
-
get_patient_module() → Dict¶ Get patient module in a simplified version
The method returns the DICOM patient module (PatientName, PatientID, PatientBirthDate, …)
- Returns
DICOM Patient module.
- Return type
Dict
-
get_sex() → str¶ Get patient sex
- Returns
Patient sex
- Return type
str
-
get_studies() → List[pyorthanc.study.Study]¶ Get patient’s studies
- Returns
List of the patient’s studies
- Return type
List[Study]
-
get_zip() → bytes¶ Get the bytes of the zip file
Get the .zip file.
- Returns
Bytes of Zip file of the patient.
- Return type
bytes
Examples
>>> from pyorthanc import Orthanc, Patient >>> a_patient = Patient( ... 'A_PATIENT_IDENTIFIER', ... Orthanc('http://localhost:8042') ... ) >>> bytes_content = a_patient.get_zip() >>> with open('patient_zip_file_path.zip', 'wb') as file_handler: ... file_handler.write(bytes_content)
-
is_empty() → bool¶ Check if studies is empty
- Returns
True if patient has no instance
- Return type
bool
-
is_protected() → bool¶ Get if patient is protected against recycling
Protection against recycling: False means unprotected, True protected.
- Returns
False means unprotected, True means protected.
- Return type
bool
-
set_to_protected()¶ Set patient to protected state
- Returns
Nothing.
- Return type
None
-
set_to_unprotected()¶ Set patient to unprotected state
- Returns
Nothing.
- Return type
None
-
trim() → None¶ Delete empty studies
-
Study sub-module¶
-
class
pyorthanc.study.Study(study_identifier: str, orthanc: pyorthanc.orthanc.Orthanc, study_information: Dict = None)¶ Bases:
objectRepresent an study that is in an Orthanc server
This object has many getters that allow the user to retrieve metadata or the entire DICOM file of the Series
-
build_series() → None¶ Build a list of the study’s series
-
get_date() → datetime.datetime¶ Get study date
The date have precision to the second (if available).
- Returns
Study date
- Return type
datetime
-
get_id() → str¶ Get Study ID
- Returns
Study ID
- Return type
str
-
get_identifier() → str¶ Get Study identifier
- Returns
Study identifier
- Return type
str
-
get_main_information() → Dict¶ Get Study information
- Returns
Dictionary of study information
- Return type
Dict
-
get_parent_patient_identifier() → str¶ Get the Orthanc identifier of the parent patient
- Returns
Parent patient’s identifier.
- Return type
str
-
get_patient_information() → Dict¶ Get patient information
- Returns
Patient general information.
- Return type
Dict
-
get_referring_physician_name() → str¶ Get referring physician name
- Returns
Referring physician Name.
- Return type
str
-
get_series() → List[pyorthanc.series.Series]¶ Get Study series
- Returns
List of study’s Series
- Return type
List[Series]
-
get_uid() → str¶ Get StudyInstanceUID
- Returns
StudyInstanceUID
- Return type
str
-
is_empty() → bool¶ Check if series is empty
- Returns
True if study has no instance
- Return type
bool
-
trim() → None¶ Delete empty series
-
Series sub-module¶
-
class
pyorthanc.series.Series(series_identifier: str, orthanc: pyorthanc.orthanc.Orthanc, series_information: Dict = None)¶ Bases:
objectRepresent an series that is in an Orthanc server
This object has many getters that allow the user to retrieve metadata or the entire DICOM file of the Series
-
build_instances() → None¶ Build a list of the series’s instances
-
get_identifier() → str¶ Get series identifier
- Returns
Series identifier.
- Return type
str
-
get_instances() → List[pyorthanc.instance.Instance]¶ Get series instance
- Returns
List of the series’s Instance.
- Return type
List[Instance]
-
get_main_information() → Dict¶ Get series main information
- Returns
Dictionary of series main information.
- Return type
Dict
-
get_manufacturer() → str¶ Get the manufacturer
- Returns
The manufacturer.
- Return type
str
-
get_modality() → str¶ Get series modality
- Returns
Series modality.
- Return type
str
-
get_parent_study_identifier() → str¶ Get the parent study identifier
- Returns
The parent study identifier.
- Return type
str
-
get_series_number() → str¶ Get series number
- Returns
Series number.
- Return type
str
-
get_uid() → str¶ Get SeriesInstanceUID
- Returns
SeriesInstanceUID
- Return type
str
-
is_empty() → bool¶ Check if series is empty
- Returns
True if series has no instance
- Return type
bool
-
Instance sub-module¶
-
class
pyorthanc.instance.Instance(instance_identifier: str, orthanc: pyorthanc.orthanc.Orthanc, instance_information: Dict = None)¶ Bases:
objectRepresent an instance that is in an Orthanc server
This object has many getters that allow the user to retrieve metadata or the entire DICOM file of the Instance
-
get_content_by_group_element(group_element: str) → Any¶ Get content by group element
Get content by group element like ‘ReferencedStudySequence/0/ReferencedSOPClassUID’ or ‘0008-1110/0/0008-1150’.
- Parameters
group_element – Group element like ‘’ or ‘0008-1110/0/0008-1150’.
- Returns
Content corresponding to specified tag.
- Return type
Any
-
get_content_by_tag(tag: str) → Any¶ Get content by tag
- Parameters
tag – Tag like ‘ManufacturerModelName’ or ‘0008-1090’.
- Returns
Content corresponding to specified tag.
- Return type
Any
-
get_creation_date() → datetime.datetime¶ Get creation date
The date have precision to the second.
- Returns
Creation Date
- Return type
datetime
-
get_dicom_file_content() → bytes¶ Retrieves DICOM file
This method retrieves bytes corresponding to DICOM file.
- Returns
Bytes corresponding to DICOM file
- Return type
bytes
Examples
>>> from pyorthanc import Instance >>> instance = Instance('instance_identifier', ... Orthanc('http://localhost:8042')) >>> dicom_file_bytes = instance.get_dicom_file_content() >>> with open('your_path', 'wb') as file_handler: ... file_handler.write(dicom_file_bytes)
-
get_file_size() → int¶ Get the file size
The output is in bytes. Divide by 1_000_000 to get it in Mb.
- Returns
The file size in bytes.
- Return type
int
Get first level tags
- Returns
First level tags.
- Return type
Any
-
get_identifier() → str¶ Get instance identifier
- Returns
Instance identifier
- Return type
str
-
get_main_information() → Dict¶ Get instance information
- Returns
Dictionary with tags as key and information as value
- Return type
Dict
-
get_parent_series_identifier() → str¶ Get the parent series identifier
- Returns
The parent series identifier.
- Return type
str
Get simplified tags
- Returns
Simplified tags in the form of a dictionary.
- Return type
Dict
Get tags
- Returns
Tags in the form of a dictionary.
- Return type
Dict
-
get_uid() → str¶ Get SOPInstanceUID
- Returns
SOPInstanceUID
- Return type
str
-