Metadata-Version: 2.4
Name: xnattools
Version: 1.0.0
Summary: Python scripts for handy operations on XNAT data.
Project-URL: Documentation, https://radiology.gitlab.io/radiomics/xnattools/
Project-URL: Homepage, https://gitlab.com/radiology/radiomics/xnattools
Project-URL: Issues, https://gitlab.com/radiology/radiomics/xnattools/-/issues
Author-email: "Martijn P. A. Starmans" <m.starmans@erasmusmc.nl>, "Erik H.M. Kemper" <e.h.m.kemper@erasmusmc.nl>, Frederik Hartmann <f.hartmann@erasmusmc.nl>
License: Copyright (c) 2026-present Biomedical Imaging Group Rotterdam, Department of Radiology and Nuclear Medicine, Erasmus MC, Rotterdam, The Netherlands
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords:  data,medical imaging,research,science,xnat
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: click<9.0.0,>=8.1.7
Requires-Dist: dcm2niix<2.0.0,>=1.0.20241211
Requires-Dist: dicom2nifti==2.4.11
Requires-Dist: matplotlib<4.0.0,>=3.10.1
Requires-Dist: numpy<3.0.0,>=2.2.4
Requires-Dist: pandas>=2.3.3
Requires-Dist: pydantic>=2.12.3
Requires-Dist: pydicom<3.0.2,>=2.4.4
Requires-Dist: pytest-mock>=3.15.1
Requires-Dist: pytest>=9.0.2
Requires-Dist: python-dotenv>=1.1.1
Requires-Dist: simpleitk<3.0.0,>=2.4.1
Requires-Dist: tk>=0.1.0
Requires-Dist: tox<5.0.0,>=4.25.0
Requires-Dist: tqdm>=4.67.1
Requires-Dist: urllib3>=2.7.0
Requires-Dist: xnat<0.8.0,>=0.7.1
Provides-Extra: dev
Requires-Dist: bump-my-version>=1.2.7; extra == 'dev'
Requires-Dist: ruff>=0.15.4; extra == 'dev'
Provides-Extra: docs
Requires-Dist: furo>=2025.12.19; extra == 'docs'
Requires-Dist: myst-parser>=4.0.1; extra == 'docs'
Requires-Dist: sphinx-autoapi>=3.7.0; extra == 'docs'
Requires-Dist: sphinx-copybutton>=0.5.2; extra == 'docs'
Requires-Dist: sphinx-design>=0.6.1; extra == 'docs'
Requires-Dist: sphinx>=8.1.3; extra == 'docs'
Provides-Extra: test
Requires-Dist: pytest-cov>=7.0.0; extra == 'test'
Requires-Dist: pytest>=9.0.2; extra == 'test'
Requires-Dist: requests>=2.33.1; extra == 'test'
Requires-Dist: xnat4tests>=0.4.1; extra == 'test'
Description-Content-Type: text/markdown

# 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/](https://radiology.gitlab.io/radiomics/xnattools/) . The following example is a small part of [tutorials](https://radiology.gitlab.io/radiomics/xnattools/tutorials.html). 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:
    ```shell
    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:

   ```text
   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:

   ```text
   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

```python
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

```shell
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

```python
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

```shell
xnattools dcm2nifti https://xnat.example.com YOUR_PROJECT_ID \
    --subjects SUBJECT_001 \
    --output-dir /path/to/temp
```
# Authors
- [Martijn P. A. Starmans](https://gitlab.com/MStarmans91) : [m.starmans@erasmusmc.nl](mailto:m.starmans@erasmusmc.nl)
- [Erik Kemper](https://gitlab.com/EHMKemper) : [e.h.m.kemper@erasmusmc.nl](mailto:e.h.m.kemper@erasmusmc.nl@erasmusmc.nl)
- [Frederik Hartmann](https://gitlab.com/Frederik-Hartmann) : [f.hartmann@erasmusmc.nl](mailto:f.hartmann@erasmusmc.nl)