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!
- Input 4D fMRI or 3D MRI NIfTI file (i.e. brain.nii)
- Rotate orientation of your image
- Automatically creates .png files for every single slice in every volume.
- Automatically renames your images with their slice and volume name (i.e. brain_t001_z001.png, etc)
- Automatically moves all your images into a chosen folder within your working directory.
Unlike other tools out there, this just works.
Environment
- Python 3.7 (or Matlab 2017b)
Matlab Usage
- Add your script to your path. And run it simply by typing this and hitting enter:
nii2png
- Select your working directory.
- Select your NIfTI image.
- Rotate your image if you wish:
>> Would you like to rotate the orientation? (y/n)
>> y
>> OK. By 90° 180° or 270°?
>> 90
- Let it run.
- 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
Modules
- 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.
- Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install Python 3
brew install python3
- Install pip
sudo easy_install pip
- 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
Permissions
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
- 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
- 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/
Metadata
Release files for nii2png 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nii2png-0.3.0.tar.gz | 4.3 kB | Without provenance | Details for nii2png-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nii2png-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for nii2png-0.3.0-py3-none-any.whl |
Total release size: 11.5 kB
Release files / nii2png-0.3.0.tar.gz
| Download URL | nii2png-0.3.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e98011ee859a9db0ab0b2c57c3d4b0ef7919f2c823e45c5303fd304fc097afc
|
|
BLAKE2b-256 checksum How to use checksums |
75eff7cef458e3a52ca5ec9043ee83cb3bdfcd5c43e3f29f11a1b6e2b1845e1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / nii2png-0.3.0-py3-none-any.whl
| Download URL | nii2png-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cc696922d16bca8ba7fd96a10175197346c591b8990607345a285d56811691e
|
|
BLAKE2b-256 checksum How to use checksums |
a476e1142e1e3a40a52479c387f663505b7a758559df3d84c09ea4ec5002c5db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for nii2png 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.