Python scripts for handy operations on XNAT data.
Project description
xnattools
xnattools is a python package for handy operations on XNAT data.
Documentation
The complete documentation is available at https://radiology.gitlab.io/radiomics/xnattools/ . The following example is a small part of tutorials. Please refer to the documentation for additional tutorials, examples, how-to guides, and developer guides.
Prerequisites
Before you begin, make sure you have:
-
Installed
xnattools. For example using pip:pip install xnattools
-
Set up your XNAT credentials using one of these methods:
Option 1: Using
.netrcfile (recommended)Create or edit
~/.netrcwith your XNAT credentials:machine xnat.example.com login your-xnat-username password your-xnat-password
Option 2: Using
.env.localfileCreate a
.env.localfile in your project directory:XNAT_USER=your-xnat-username XNAT_PASS=your-xnat-password
-
Access to an XNAT server with at least one project.
Basic Example: Running dcm2nifti
This example shows how to convert DICOM files to NIfTI format for a specific subject.
Python API
from pathlib import Path
import xnattools as xt
tools = [xt.Dcm2niftiSettings()]
settings = xt.GeneralSettings(
system_url="https://xnat.example.com",
project_id="MY_XNAT_PROJECT",
subjects=["SUBJECT_001"],
output_dir=Path.cwd(),
)
xt.run_tools(tools_to_run=tools, general_settings=settings)
Command Line
xnattools dcm2nifti https://xnat.example.com YOUR_PROJECT_ID \
--subjects SUBJECT_001
Replace YOUR_PROJECT_ID with your actual XNAT project ID and SUBJECT_001 with a valid subject ID from your project.
To use a custom output directory for intermediate files:
Python API
from pathlib import Path
import xnattools as xt
tools = [xt.Dcm2niftiSettings()]
settings = xt.GeneralSettings(
system_url="https://xnat.example.com",
project_id="MY_XNAT_PROJECT",
subjects=["SUBJECT_001"],
output_dir=Path.cwd(),
)
xt.run_tools(tools_to_run=tools, general_settings=settings)
Command Line
xnattools dcm2nifti https://xnat.example.com YOUR_PROJECT_ID \
--subjects SUBJECT_001 \
--output-dir /path/to/temp
Authors
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xnattools-1.0.0.tar.gz.
File metadata
- Download URL: xnattools-1.0.0.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4843b15b726c698c16c786a16eb0915ee615b2850773a8b4bfa47ded53196ebe
|
|
| MD5 |
a7146f7b60016477c330828b772e50b2
|
|
| BLAKE2b-256 |
1903acff686230f195b687e370ec755c0703c2ba286306127a5d5464d04f4592
|
File details
Details for the file xnattools-1.0.0-py3-none-any.whl.
File metadata
- Download URL: xnattools-1.0.0-py3-none-any.whl
- Upload date:
- Size: 60.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d237d4fc5c37423bda19adc6d4f432a6a5e62056b59397cb5c8bf6ff816901b
|
|
| MD5 |
2878aa6a32e774e1130333bf95a8c45d
|
|
| BLAKE2b-256 |
5dcc4d563a5320917d73c33960c7b5bfc4583016d089ba2e61c5755ec15d6c3b
|