Code Monkey home page Code Monkey logo

nifti-image-converter's Introduction

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!

Environment

  • 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:
nii2png
  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

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 https://raw.githubusercontent.com/Homebrew/install/master/install)"
  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 nibabel

pip install numpy

pip install imageio

Download nii2png for Python

You can download the latest version of nii2png through pip.

pip install nii2png

Or alternatively, download the binary files here.

Download Latest Build: Download

Download Stable Release: Download

Permissions

If you didn't install nii2png through pip, you may need to grant nii2png.py permission to execute. On unix systems, Python scripts can be made executable using the following process:

$ chmod +x nii2png.py

Optional: You can also move nii2png.py 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 nii2png.py -i <inputfile> -o <outputfolder>

or

$ python3 nii2png.py --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

Example

with change directory command

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

with full paths

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

with long options

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.