Skip to main content

Reusable PyQt6 browser dialog for Nikon ND2 image files.

Project description

nikon-browser-qt

A reusable PyQt6 browser dialog and viewer for Nikon ND2 microscopy files.


Features

  • File browser dialog — navigate directories, preview images, select one or multiple ND2 files
  • Zoomable viewer — pan/zoom canvas with channel toggles, contrast controls, Z / T / S sliders, and projection modes (Slice, MIP, Sum, Mean, Median)
  • Full dimension support — X · Y · Z (z-stack) · T (time) · C (channels) · S (multi-position / tiles)
  • Channel colors — read from ND2 metadata (colorRGB or emission wavelength); per-channel toggle buttons
  • Scale bar — auto-scaling overlay based on pixel size
  • Metadata summary — Name, Date, Dimensions, Pixel size, FOV size, Image size, Pixel type shown in the browser
  • CLI entry pointsnikon_browser (headless JSON output) and nikon_viewer (interactive viewer)

Installation

pip install nikon-browser-qt

Or install from source:

git clone https://github.com/your-org/nikon-browser-qt
cd nikon-browser-qt
pip install -e .

Requirements: Python ≥ 3.10, PyQt6, numpy, nd2.


Quick start

Open the viewer from the command line

nikon_viewer                          # open empty viewer
nikon_viewer path/to/images/          # open with a folder pre-loaded
nikon_viewer file.nd2                 # open a specific file

Launch the browser dialog and print selected metadata

nikon_browser                         # single-select, prints JSON to stdout
nikon_browser --multiple              # multi-select mode
nikon_browser path/to/images/

Python API

Single image selection

from PyQt6.QtWidgets import QApplication
from nikon_browser_qt import NikonBrowserDialog

app = QApplication([])
ctx = NikonBrowserDialog.select_image_context()
if ctx is not None:
    print(ctx.name, ctx.size_x, ctx.size_y, ctx.size_z)
    print(ctx.to_dict())

Multi-image selection

from PyQt6.QtWidgets import QApplication
from nikon_browser_qt import NikonBrowserDialog

app = QApplication([])
contexts = NikonBrowserDialog.select_image_contexts()
for ctx in contexts:
    print(ctx.name, ctx.container_path)

Pre-load a folder or file

ctx = NikonBrowserDialog.select_image_context(roots=["path/to/data/"])

Embed the browser dialog in your own application

from nikon_browser_qt import NikonBrowserDialog

dialog = NikonBrowserDialog(roots=["data/"], selection_mode="single", parent=self)
if dialog.exec():
    ctx = dialog.selected_context()

Open the viewer programmatically

from PyQt6.QtWidgets import QApplication
from nikon_browser_qt.nikon_viewer import NikonViewerWindow

app = QApplication([])
win = NikonViewerWindow(roots=["data/"])
win.show()
app.exec()

Reading pixel data

NikonImageContext provides three pixel-reading methods via open():

ctx = NikonBrowserDialog.select_image_context()
if ctx is not None:
    handle = ctx.open()

    plane = handle.read_plane(z=0, c=0, t=0)          # 2-D numpy array (Y × X)
    stack = handle.read_stack(c=0, t=0)                # 3-D array (Z × Y × X)
    arr   = handle.read_array()                        # 5-D array (T × C × Z × Y × X)

For multi-position files pass s=<position_index> (0-based) or set ctx.selected_s before calling.


NikonImageContext fields

Field Type Description
name str Image name (ND2 file stem)
container_path Path Path to the .nd2 file
internal_path str "<filename>/<image_name>"
image_id str | None File stem used as identifier
kind str "nikon-image"
size_x / size_y int | None Width / height in pixels
size_z int | None Number of z-planes (1 if no z-stack)
size_c int | None Number of channels
size_t int | None Number of time points
size_s int | None Number of positions (P dimension)
pixel_size_x_um float | None Pixel width in µm
pixel_size_y_um float | None Pixel height in µm
pixel_size_z_um float | None Z-step in µm
selected_s int | None Fixed position index (None = all)
channel_names list[str] Channel names from ND2 metadata
metadata dict Raw metadata dict

Dimension mapping (ND2 → nikon-browser-qt)

ND2 f.sizes key Field Slider
X size_x
Y size_y
Z size_z Z slider
C size_c Channel buttons
T size_t T slider
P (positions) size_s S slider

The S slider is visible only for multi-position files (size_s > 1). In the browser dialog the S control lets you fix a position or pass selected_s=None to export all positions together.


Viewer controls

Control Action
Scroll wheel Zoom in / out
Left-drag Pan
Fit button Fit image to window
100% button 1:1 pixel view
Channel buttons Toggle channels on/off
Lo / Hi spinboxes Percentile contrast limits
Z slider Select z-plane
T slider Select time point
S slider Select position (multi-position files)
Projection combo Slice · MIP · Sum · Mean · Median

Development

pip install -e ".[dev]"

Run the viewer directly from the repo:

run_viewer.cmd
run_viewer.cmd path\to\data\

License

Apache-2.0

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

nikon_browser_qt-0.1.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nikon_browser_qt-0.1.0-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file nikon_browser_qt-0.1.0.tar.gz.

File metadata

  • Download URL: nikon_browser_qt-0.1.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for nikon_browser_qt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 32ea248454d08153f7bad23496100615c69d6cb2677a9d4e90622258adbcd6d9
MD5 d3f96840deab375748e8154a8bbb0369
BLAKE2b-256 ad55f994d3269be1655f5adcad92db51582f50af35c0973c3a267ac258f304a7

See more details on using hashes here.

File details

Details for the file nikon_browser_qt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nikon_browser_qt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbc59b403da85694ead43f4f0190a2b6dd34d908a081287b4f1a23c423a249c9
MD5 cffdcb623cc8c42ad21d95a9df6cf51b
BLAKE2b-256 0a9266dd2a9fecfa8fd3717f67821c49b50b3adfa67fbb66048befea5d17cfc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page