This repository contains Python scripts for generating reports from XNAT instances. The scripts can be run directly with Python or using the provided Docker setup.
- Docker installed on your system
- Input files placed in your current working directory
- Clone this repository
- Navigate to the repository directory
- Run scripts using the provided wrapper:
./run.sh <script_name> [script_arguments]Run users per project report:
./run.sh users_per_project --xnat_url https://xnat.health-ri.nlRun users per project report for specific project:
./run.sh users_per_project --xnat_url https://xnat.health-ri.nl --project sandboxRun disk usage report:
./run.sh disk_usages --xnat_url https://xnat.health-ri.nl --report_path ./input_disk_usage_report.txt --study_overview ./studyoverview.csvThe run.sh script will automatically:
- Build the Docker image
- Mount your current directory into the container
- Execute the specified script with your arguments
- Output files will be created in your current directory
You can also run the scripts directly with Python if you have the dependencies installed.
Run in the terminal with:
python scripts/users_per_project.py --xnat_url https://xnat.health-ri.nlto query the whole XNAT. Run the following to query only 'sandbox'
python scripts/users_per_project.py --xnat_url https://xnat.health-ri.nl --project sandboxYou need to have 'Owner' or 'Site admin' priviliges to run this script on a project. This script returns a CSV file "./{today}_XNAT_users_per_project.csv", with the columns:
- project
- user_login_name
- user_first_name
- user_last_name
- user_email
- access_level
- group
- pi_firstname
- pi_lastname
- pi_title
- pi_email
- pi_institution
Run in the terminal with:
python scripts/disk_usages.py --xnat_url https://xnat.health-ri.nl --report_path ./input_disk_usage_report.txt --study_overview ./studyoverview.csvto query the whole XNAT.
report_path is the du output from the server.
study_overview is a CSV file with a column 'main_study' and 'substudy' to link main studies to their substudies.
This script returns a CSV file "./{today}_XNAT_disk_usage.csv", with the columns:
- project_id
- main_study
- project_path
- data_usage (MB)
- xnat_project_name
- xnat_project_id
- pi_firstname
- pi_lastname
- pi_title
- pi_email
- pi_institution
To add a new Python script to this repository:
-
Create your Python script following these guidelines:
- Use argparse for command-line arguments
- Include proper error handling
- Write output files to the current working directory
- Add dependencies to
requirements.txtif needed
-
Place your
.pyfile in thescripts/directory -
The script will automatically be available in the Docker image after rebuilding
-
Update this README.md with documentation for your script
- Must be a standalone Python file (
.pyextension) - Should handle authentication through user prompts (getpass)
- Input and output files should use the current working directory
- Follow the existing pattern of the current scripts