telenib

Fetch metadata from remote (https) nifti (gzipped or not).


License
MIT
Install
pip install telenib==0.0.2

Documentation

telenib

Read header of remote nifti according to nifti1 spec and nifti2 spec either gzipped or not.

Requirements

server must support RANGE request.

  • requests
  • nibabel

Why?

For large nifti files, it is often not feasible to download the full nifti file in order to access the header.

Installation

  • via pip
pip install telenib

Usage

from telenib import get_nii_header
from nibabel import Nifti1Header, Nifti2Header

# from https://nifti.nimh.nih.gov/nifti-1/data
nii_url="https://nifti.nimh.nih.gov/nifti-1/data/avg152T1_RL_nifti.nii.gz"
tele_header = get_nii_header(nii_url)

assert isinstance(tele_header, Nifti1Header) or isinstance(tele_header, Nifti2Header)

One could also add any custom header

from telenib import get_nii_header

nii_url="https://my.example.co/my/dir/nii.nii.gz"
tele_header = get_nii_header(nii_url, headers={
    'Authorization': f'token my-secret-token'
})

print(tele_header)

License

MIT