Interactive N-dimensional numpy array viewer with FFT support
Project description
ndslice
Quick interactive visualization for N-dimensional NumPy arrays
A python package for browsing slices, applying FFTs, and inspecting data.
Quickly checking multi-dimensional data usually means writing the same matplotlib boilerplate over and over. This tool lets you just call ndslice(data) and interactively explore what you've got.
Usage
from ndslice import ndslice
import numpy as np
# Create some data
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
z = np.linspace(-5, 5, 50)
X, Y, Z = np.meshgrid(x, y, z, indexing='ij')
mag = np.exp(-(X**2 + Y**2 + Z**2) / 10)
pha = np.pi/4 * (X + Y + Z)
complex_data = mag * np.exp(1j * pha)
ndslice(complex_data, title='3D Complex Gaussian')
Features
Data slicing and dimension selection should be intuitive: click the two dimensions you want to show and slice using the spinboxes.
Centered FFT - Click dimension labels to apply centered 1D FFT transforms. Useful for checking k-space data in MRI reconstructions or analyzing frequency content.
Line plot - See 1D slices through your data. Shift+scroll for Y zoom, Ctrl+scroll for X zoom:
Scaling
Log scaling is often good for k-space visualization. Symmetric log scaling is an extension of the log scale which supports negative values.
Colormap Change colormap:
Ctrl+1GrayscaleCtrl+2ViridisCtrl+3PlasmaCtrl+4Rainbow
Axis flipping Click arrow icons (⬇️/⬆️ and ⬅️/➡️) next to dimension labels to flip axes. Default orientation is image-style (origin lower-left). Flip the primary axis for matrix-style (origin upper-left).
Non-blocking windows
By default, windows open in separate processes, allowing multiple simultaneous views:
ndslice(data1)
ndslice(data2) # Both windows appear
Use block=True to wait for the window to close before continuing:
ndslice(data1, block=True) # Script pauses here
ndslice(data2) # Shown after first closes
Command Line
ndslice data.npy # Numpy file
ndslice --help # Show all options
File support ndslice has CLI support and can conveniently display:
| Format | File suffix | Requirement |
|---|---|---|
| NumPy | .npy, .npz |
NumPy |
| MATLAB | .mat |
scipy |
| HDF5 | .h5, .hdf5 |
h5py |
| BART | .cfl + .hdr |
— |
| Philips REC | .REC + .xml |
— |
| NIfTI | .nii, .nii.gz |
nibabel |
| DICOM (pixel array) | .dcm |
pydicom |
HDF5 files can be compound complex dtype, or real/imag fields.
If there are multiple datasets in the file, a selection GUI appears which highlights arrays supported by ndslice (essentially numeric). Double click to open.
Installation
From PyPI
pip install ndslice
pip install h5py # Optional for HDF5 CLI support
From source
git clone https://github.com/henricryden/ndslice.git
cd ndslice
# Use directly without installing
python -m ndslice data.npy
pip install -e .
Requirements
- Python >= 3.8
- NumPy >= 1.20.0
- PyQtGraph >= 0.12.0
- PyQt5 >= 5.15.0
- h5py >= 3.0.0 (for HDF5 file support in CLI)
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
Built with PyQtGraph for high-performance visualization.
Henric Rydén
Karolinska University Hospital
Stockholm, Sweden
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ndslice-0.3.3.tar.gz.
File metadata
- Download URL: ndslice-0.3.3.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99341a2ce7097310f3911303a4e786d728c97e221222266e542c690ce430be0c
|
|
| MD5 |
e9db9804c0c7a9f52d5045d6dd7a5fa0
|
|
| BLAKE2b-256 |
12b4aee6f5abe13c29a236816bbbb445c34dee05e3214f515a4acade8638c79c
|
File details
Details for the file ndslice-0.3.3-py3-none-any.whl.
File metadata
- Download URL: ndslice-0.3.3-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec09071ff3af552f69912d3f9248e87d426e87f0ba4c31ec9c09543ad7a77225
|
|
| MD5 |
b6b03363338f9b959536038a3fd89d89
|
|
| BLAKE2b-256 |
cdac18c14a478750b913618056cfca5330a7a8558923be47d04b98c80b0d5a7d
|