Skip to main content

A lightweight neuroimaging .nii to .png converter

Project description

NIfTI Image Converter (nii2png) for Python and Matlab

Rejoice OpenCV users, a lightweight neuroimaging .nii to .png converter that actually works.

Now supports both Python3 and Matlab 2017b!

  1. Input 4D fMRI or 3D MRI NIfTI file (i.e. brain.nii)
  2. Rotate orientation of your image
  3. Automatically creates .png files for every single slice in every volume.
  4. Automatically renames your images with their slice and volume name (i.e. brain_t001_z001.png, etc)
  5. Automatically moves all your images into a chosen folder within your working directory.

Unlike other tools out there, this just works.


  • Python 3.7 (or Matlab 2017b)

Matlab Usage

  1. Add your script to your path. And run it simply by typing this and hitting enter:
  1. Select your working directory.
  2. Select your NIfTI image.
  3. Rotate your image if you wish:
>> Would you like to rotate the orientation? (y/n)
>> y
>> OK. By 90° 180° or 270°? 
>> 90
  1. Let it run.
  2. Your png files are now in the png folder of your working directory.

Download nii2png for Matlab 2017b

Download Latest Build: Download

Download Stable Release: Download

Python Setup


  • scipy
  • shutil
  • os
  • nibabel
  • numpy

Basic Setup

For those without Python, Pip or the modules, simply open Terminal and type in the following commands and hit enter.

  1. Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL"
  1. Install Python 3
brew install python3
  1. Install pip
sudo easy_install pip
  1. Install plugins
pip install scipy

pip install shutil

pip install os

pip install nibabel

pip install numpy

Download nii2png for Python

Download Latest Build: Download

Download Stable Release: Download


On unix systems, Python scripts can be made executable using the following process:

$ chmod +x

Optional: You can also move into your bin directory, and it will be runnable from anywhere.

Python Usage

  1. Let's run the file and start converting images! Please ensure that your output folder ends with a slash to avoid errors.
$ python3 -i <inputfile> -o <outputfolder>


$ python3 --input <inputfile> --ouput <outputfolder>

Tip: You can drag and drop the file/folder into the terminal window instead of typing the path

  1. Rotate the images if you wish
$ Would you like to rotate the orientation? (y/n) y
$ OK. By 90° 180° or 270°? 90


with change directory command

$ cd ~/images/
$ python3 -i brain.nii -o png/

with full paths

$ python3 /users/ernie/images/ -i /users/ernie/images/brain.nii -o /users/ernie/images/png/

with long options

$ python3 /users/ernie/images/ --input /users/ernie/images/brain.nii --output /users/ernie/images/png/

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

nii2png-0.3.0.tar.gz (4.3 kB view hashes)

Uploaded source

Built Distribution

nii2png-0.3.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded py3

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