Skip to main content

Display NIfTI image information in a tabular format

Project description

nii-info

Display NIfTI image information in a tabular format

PyPI Version

Installation

pip install nii-info

Motivation

This package attempts to provide a quick and easy way to get a high-level overview of a collection of NIfTI images.

Often when dealing with a collection of NIfTI images the metadata describing those images is embeded across multiple files, specifically the nii images themselves, as well as potential JOSN sidecar files.

Of course, one can crack open a NIfTI file to inspect the header, or load a JSON sidecar into an editor to view its contents. However this quickly becomes tedious when one is dealing with many files and many fields of interest.

nii-info collects the values of fields of interest across a set of NIfTI files and aggregates them in a tablular format.

Usage

nii-info exposes a CLI: nii

$ nii --help
usage: nii [-h] [-o OUT_TSV] [-f FIELDS] [-v] [-D]
           path [path ...]

Display NIfTI image information in a tabular format

...

positional arguments:
  path                  nifti files or directories
                        containing nifti files,
                        directories are searched
                        recursively

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_TSV, --out-tsv OUT_TSV
                        file to write info to. (default:
                        stdout)
  -f FIELDS, --fields FIELDS
                        Fields to include in the table.
  -v, --version         show program's version number and
                        exit
  -D, --debug           run program in debug mode

The nii CLI accepts a list of files and/or directories. Directories are searched recursively for *.nii and *.nii.gz files.

Simple usage might look something like:

nii /path/to/nii/file1.nii.gz /path/to/nii/file2.nii.gz /path/to/nii/dir/

Modifying Fields/Columns

This application enables the user to modify which JSON sidecar & NIfTI header fields are included in the generated output via the -f/--fields option.

The -f option can be passed multiple times and uses a special syntax.

The argument for the -f option should be string of comma-separated values, where each value contains the "location", sidecar or nii header "key", and optional "label".

For example, to add the FlipAngle and InversionTime fields from the sidecars as well as the datatype and descrip fields from the NIfTI headers to the default set of outputs, the command could look something like:

nii \
    -f 'sidecar:FlipAngle,sidecar:InversionTime' \
    -f 'header:datatype,header:descrip:Header Description' \
    /path/to/nii/dir/

In the above example, sidecar:FlipAngle tells the application to extract the FlipAngle field from each image's sidecar.

Additionally, header:descrip:Header Description tells the application to extract the descrip field from each image's NIfTI header and use the label Header Descrption as the column heading.

Contributing

  1. Have or install a recent version of poetry (version >= 1.1)
  2. Fork the repo
  3. Setup a virtual environment (however you prefer)
  4. Run poetry install
  5. Run pre-commit install
  6. Add your changes (adding/updating tests is always nice too)
  7. Commit your changes + push to your fork
  8. Open a PR

Project details


Download files

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

Source Distribution

nii-info-1.0.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

nii_info-1.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file nii-info-1.0.1.tar.gz.

File metadata

  • Download URL: nii-info-1.0.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Linux/5.13.0-1022-azure

File hashes

Hashes for nii-info-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e24b08733bcf3d7577dd864e5415e0406028aae86c6dfd54f11cb4b09963d6c2
MD5 0d5a74ddbe61aa283ddc6d3596b80c49
BLAKE2b-256 17aec4fdeaa024dfe93bacea6dda9c907b9c174fab1f6a2b6739e97fdb19ff23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nii_info-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Linux/5.13.0-1022-azure

File hashes

Hashes for nii_info-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 077dd17483d2e93932e29707e1884947af4c9149b3ce0f39275b6a18d8c0e162
MD5 7d90657fba47400305cf28f275c0ed2c
BLAKE2b-256 e1b25a9edf18a84e624553f8047188205dcd6da3d3812ed639014f9f21f21e76

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page