API and usage examples
You can find the example scripts from the examples/ folder.
Make sure the PACS system you want to interact with is running before moving forward.
Check connectivity
Check your access to a PACS. If failed, check if the status of your PACS.
- pypacs.verify_connectivity(server_port)
Verify connectivity of the target PACS server
- Parameters
server_ip (string) – IP address of the target PACS
server_port (string) – port number of the target PACS
- Returns
connectivity status
- Return type
string
Note
Usage example: see examples/check_connectivity.py
.
Query and save metadata
- pypacs.get_metadata(server_port, aec, query_settings)
get metadata beased on query settings
- Parameters
server_ip (string) – IP address of the target PACS
server_port (string) – port number of the target PACS
aec (string) – the called AE title
query_settings (dict) – query
- Returns
metadata
- Return type
dict
- pypacs.create_custom_report(fields=None, custom_fields=None)
Create custom report for the metadata
- Parameters
metadata (dict) – metadata/query result
fields (dict) – fields for different query levels (patient, study or series)
custom_fields (list) – a list of custom fields which do not provided by the metadata directly might need to be calculated or queried separately.
- Returns
- Return type
- pypacs.save_metadata(save_path)
Write metadata to file
- Parameters
metadata (dict) – metadata
save_path (string) – path to the target file
- Returns
- Return type
Note
Usage example:
The example script examples/query_and_save_metadata.py
shows you how to query by most of the dicom tags. The metadata will be saved in <pypacs>/examples/out/metadata.json
Please search for the variable query_settings
and change it to make your owm query.
The example script examples/query_and_save_metadata_advanced.py
shows how to make advanced queries such as NumberOfSeriesRelatedInstances > 100
In this script, please update the variables query_settings
for normal query conditions and extra_query
for the advanced options.
Download files
- pypacs.move_files(server_port, aec, aet, query_settings)
Download files
- Parameters
server_ip (string) – IP address of the target PACS
server_port (string) – port number of the target PACS
aec (string) – the called AE title
aet (string) – the calling AE title
query_settings (dict) – query
- Returns
- Return type
Note
Usage example:
With download_files.py
, you can download the images to a dicom node (a folder).
Please update the query_settings
variable.
This is a dictionary variable and you need to provide values for the keys StudyInstanceUID
and SeriesInstanceUID
.
You can download the images to the mounted eResearch drive on either eResearch VM or on your local machine.