The Agora Connector for Python
Project description
gtagora-connector
gtagora-connector is a python library to access GyroTools' Agora system.
Installation
Use the package manager pip to install gtagora-connector.
pip install gtagora-connector
Currently gtagora-connector supports python 3.6 and 3.7.
Basic usage
from gtagora import Agora
from gtagora.models.dataset import DatasetType
agora = Agora.create('https://your.agora.domain.com', user='test', password='test')
root_folder = agora.get_folders()
subfolders = root_folder.get_folders()
for s in subfolders:
print(f' - {s.name}')
new_folder = root_folder.get_or_create_folder('New Folder')
exam = agora.get_exam_list(filters={'name': 'Wrist'})[0]
for s in exam.get_series():
print(f'Series: {s.name}')
for dataset in s.get_datasets(filters={'type': DatasetType.PHILIPS_RAW}):
for datafile in dataset.get_datafiles():
print(f'{datafile.original_filename}')
agora.import_data('/path/to/directroy', new_folder)
Exmaples
Create an Agora instanace
from gtagora import Agora
agora = Agora.create('https://your.agora.domain.com', user='test', password='test')
Because it's not recommended to ever write down your password in plain text the API is a better alternative. Actiavte the API Key in your Agora profile. The API key is just a random UUID and it can withdrawn or recreated easily.
from gtagora import Agora
agora = Agora.create('https://your.agora.domain.com', api_key='<YOUR_API_KEY>')
Working with folders
Get the root folder of the current user:
root_folder = agora.get_root_folder()
print(f"Root folder ID: {root_folder.id}")
Get a folder by its ID
folder = agora.get_folder(45)
print(f"Folder with ID {folder.name}")
Get sub folders
subfolders = folder.get_folders()
for f in subfolders:
print(f" - {f.name}")
Create a new folder in the root folder (the new folder object is returned)
new_folder = root_folder.create_folder('TestFolder')
print(f"New folder ID: {new_folder.id}")
Delete a folder. Delete a folder is recursive. It deletes all items. The delete operation does not follow links.
folder.delete()
Get all items of a folder. An item could be a exam, series or a dataset
items = folder.get_items()
for item in items:
print(f" - {item}")
Get all exams of a folder. Use the recursive parameter to get all exams
exams = folder.get_exams(recursive=False)
for exam in exams:
print(f" - {exam}")
Working with Agora objects
Get the list of exams
exams = agora.get_exam_list()
Get an exam by ID
exam = agora.get_exam(12)
Link the first Exam to the a folder
exam_item = exam.link_to_folder(folder.id)
Delete the link of an exam (doesn't delete the Exam itself)
exam_item.delete()
Download data
Download all data from a folder
from pathlib import Path
target = Path("c:/temp")
downloaded_files = folder.download(target, recursive=False)
for f in downloaded_files:
print(str(f))
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gtagora_connector-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c11d4488135a7ebf10ff419de676f42b63123f9b8e481493bc25ae6fbcf1e198 |
|
MD5 | 5bcf6a193c9cab0e7b982586df9bf7ed |
|
BLAKE2b-256 | 464c3102c03ffc1d702b5f85b411893cd9d91dc83783c2ebfbca57671cec2b36 |