Skip to main content

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:

  1. Installed xnattools. For example using pip:

    pip install xnattools
    
  2. Set up your XNAT credentials using one of these methods:

    Option 1: Using .netrc file (recommended)

    Create or edit ~/.netrc with your XNAT credentials:

    machine xnat.example.com
     login your-xnat-username
     password your-xnat-password
    

    Option 2: Using .env.local file

    Create a .env.local file in your project directory:

    XNAT_USER=your-xnat-username
    XNAT_PASS=your-xnat-password
    
  3. 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xnattools-1.0.1.tar.gz (48.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xnattools-1.0.1-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

Details for the file xnattools-1.0.1.tar.gz.

File metadata

  • Download URL: xnattools-1.0.1.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for xnattools-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c4786e9542128803386e93eb41c73372a27cf97b69da2626f4e41fe4152e9d21
MD5 96561af4b7d9ba1cfe2bff6c78a0d46a
BLAKE2b-256 dcd5c77a907136aa3fd89aadc73243347ff6c59f430b64b57c03da2ae47cd008

See more details on using hashes here.

File details

Details for the file xnattools-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: xnattools-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for xnattools-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73a765f9e8ad1a6d2122bc834faae8eda915552c3d2350b4b8ee7e54a20efcad
MD5 1885f81802f958baa55b5c9a22d63c3d
BLAKE2b-256 e8d7a3762e3f7ef382412126f1f5c3f31f9dae28852e31f6238a5a0cba4513ee

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page