Skip to content
Skills Library
Science & research · Conversion & formats

nibabel

/nibabel

Read and write neuroimaging file formats: NIfTI, GIFTI, CIFTI, MGH, Minc, Analyze, SPM. Core I/O for fMRI, diffusion MRI, structural MRI pipelines. Use when handling brain imaging data.

Repository
zorai ↗
Licence
MIT
Last repository change
23.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 23.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Read and write neuroimaging file formats: NIfTI, GIFTI, CIFTI, MGH, Minc, Analyze, SPM. Core I/O for fMRI, diffusion MRI, structural MRI pipelines. Use when handling brain imaging data.

Original author description

Read and write neuroimaging file formats: NIfTI, GIFTI, CIFTI, MGH, Minc, Analyze, SPM. Core I/O for fMRI, diffusion MRI, structural MRI pipelines. Use when handling brain imaging data.

How it works

  1. Overview
  2. Installation
  3. Load a NIfTI volume
  4. Save a modified image
  5. 4D fMRI example
  6. Coordinate handling
  7. Workflow
Original SKILL.md headings · 56 lines, 198 words
SKILL.md preview
---
name: nibabel
description: "Read and write neuroimaging file formats: NIfTI, GIFTI, CIFTI, MGH, Minc, Analyze, SPM. Core I/O for fMRI, diffusion MRI, structural MRI pipelines. Use when handling brain imaging data."
tags: [neuroimaging, nifti, fmri, mri, medical-imaging, python, zorai]
---
## Overview

NiBabel is the core Python library for neuroimaging file I/O. Use it to read and write NIfTI, GIFTI, CIFTI, MGH, MINC, and Analyze files, inspect affine metadata, and move data between imaging tools and NumPy.

## Installation

```bash
uv pip install nibabel
```

## Load a NIfTI volume

```python
import nibabel as nib

img = nib.load('brain_t1.nii.gz')
data = img.get_fdata()
affine = img.affine
header = img.header

print(data.shape)
print(header.get_zooms())
print(affine)
```

## Save a modified image

```python
import numpy as np

masked = (data > data.mean()).astype(np.float32)
out = nib.Nifti1Image(masked, affine, header)
nib.save(out, 'brain_mask.nii.gz')
```

## 4D fMRI example

```python
fmri = nib.load('rest_bold.nii.gz')
arr = fmri.get_fdata()   # shape like (x, y, z, t)
tr = fmri.header.get_zooms()[-1]
print(arr.shape, tr)
```

## Coordinate handling

NiBabel stores the affine transform from voxel coordinates to world coordinates. Do not ignore it if you are mixing tools, resampling data, or comparing scans across sessions.

## Workflow

1. Load with `nib.load()`.
2. Inspect shape, affine, voxel spacing, and orientation assumptions.
3. Use `.get_fdata()` when you want floating-point arrays.
4. When saving derived outputs, preserve affine/header unless intentionally changing them.
5. For resampling/reorientation, combine with Nilearn, DIPY, or ANTs/SimpleITK workflows rather than hacking the array blindly.

Versions

The database has no other skills named nibabel.

Database snapshot: 13.11.2026 · package version b9b5d442ebbd (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100mri-research
    The generalist navigator and curated reference hub for MRI research — use it for orientation, cross-domain questions, and the canonical paper / course / dataset / toolbox across the whole MRI pipeline: MR physics and k-space, acquisition, reconstruction, image analysis,…
  • 90neuroscience
    Supports neuroscience research including brain imaging analysis (fMRI, EEG), neural circuit modeling, cognitive experiment design, and neurological disorder investigation; trigger when users discuss brain regions, neural signals, cognitive tasks, or neuroimaging data.
  • 95qwen-mm-plugins-nifti
    Inspect local NIfTI (.nii/.nii.gz) header metadata or render slices with shared intensity normalization and window presets. Use for checking volume geometry, NIfTI viewing, choosing slices or windows, and verifying effective display settings.
  • 90kaggle-medical-imaging
    Plan and improve Kaggle MRI or CT classification pipelines with weak report labels, anatomical crops, multi-series inputs, teacher supervision, and site-aware validation. Use for medical-imaging competition experiments and solution reviews, not clinical diagnosis.
  • 100medical-imaging-review
    Write comprehensive literature reviews for medical imaging AI research. Use when writing survey papers, systematic reviews, or literature analyses on topics like segmentation, detection, classification in CT, MRI, X-ray, ultrasound, or pathology imaging. Triggers on requests f...
  • 100neuroimaging-validity-audit
    Use when a scientist requests a self-critical validity audit of published neuroimaging papers or a research corpus, especially when full imaging reprocessing is impractical. Assess specific claims using documents, code, and available derivatives. Not a generic peer review,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.