Skip to main content

A plugin to process Structured Illumination Microscopy data with gpu acceleration

Project description

napari-sim-processor

License PyPI Python Version tests codecov napari hub

A Napari plugin for the reconstruction of Structured Illumination Microscopy (SIM) with GPU acceleration (pytorch/cupy if installed). Currently supports:

  • conventional SIM data with a generic number of angles and phases (typically, 3 angles and 3 phases are used for resolution improvement in 2D, but any combination can be processed by the widget)
  • hexagonal SIM data with 7 phases, as used in this publication.
  • 3D SIM, for resolution enhancement in three dimensions. This is available in the 3dSIM branch

The SIM processing widget accepts image stacks organized in 5D (angle,phase,z,y,x).

The reshape widget can be used to easily reshape the data if they are not organized as 5D (angle,phase,z,y,x).

For 3D stacks (raw images) with multiple z-frames, a batch reconstruction method is available, as described here.

Syntetic raw-image stacks of Structured Illumination Microscopy can be easily simulated using the napari SIMulator pluging.


This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.

Installation

You can install napari-sim-processor via pip:

pip install napari-sim-processor

To install latest development version :

pip install git+https://github.com/andreabassi78/napari-sim-processor.git

Usage

  1. Open napari.

  2. Launch the reshape and sim-processor widgets.

  3. Open your raw image stack (using the napari built-in or your own file opener).

raw

  1. If your image is ordered as a 5D stack (angle, phase, z-frame, y, x) go to point 6.

  2. In the reshape widget, select the actual number of acquired angles, phases, and frames (red arrow) and press Reshape Stack. Note that the label axis of the viewer will be updated (green arrow).

raw

  1. In the sim-reconstruction widget press the Select image layer button. Note that the number of phases and angles will be updated (blue arrow).

  2. Choose the correct parameters of the SIM acquisition (NA, pixelsize, M, etc.) and processing parameters (alpha, beta, w, eta, group):

    • w: parameter of the Weiner filter.
    • eta: constant used for calibration. It should be slightly smaller than the carrier frequency (in pupil radius units).
    • group: for stacks with multiple z-frames, it is the number of frames that are used together for the calibration process.

For details on the other parameters see here.

  1. Calibrate the SIM processor, pressing the Calibrate button. This will find the carrier frequencies (red circles if the Show Carrier checkbox is selected), the modulation amplitude and the phase, using cross correlation analysis.

  2. Click on the checkboxes to show the power spectrum of the raw image (Show power spectrum) or the cross-correlation (Show Xcorr), to see if the found carrier frequency is correct.

raw Napari viewer showing the power spectrum of the raw stack. The pupil circle is in blue. A circle corresponding to eta is shown in green.

raw Napari viewer showing the cross-correlation of the raw stack. The red circles indicate the found carrier frequencies

  1. Run the reconstruction of a single plane (SIM reconstruction) or of a stack (Stack reconstruction). After execution, a new image_layer will be added to the napari viewer. Click on the Batch reconstruction checkbox in order to process an entire stack in one shot. Click on the pytorch checkbox for gpu acceleration.

raw Napari viewer with widgets showing a pseudo-widefield reconstruction

raw Napari viewer with widgets showing a SIM reconstruction

GPU processing

The underlying processing classes will use numpy (and FFTW if available) for its calculations. For GPU accelerated processing you need to have either the PyTorch (tested with torch v1.11.0+cu113) or the CuPy (tested with cupy-cuda113 v10.4.0) package installed. Make sure to match the package cuda version to the CUDA library installed on your system otherwise PyTorch will default to CPU and CuPy will not work at all.

Both packages give significant speedup on even relatively modest CUDA GPUs compared to Numpy, and PyTorch running on the CPU only can show improvements relative to numpy and FFTW. Selection of which processing package to use is via a ComboBox in the napari_sim_processor widget. Only available packages are shown.

Other than requiring a CUDA GPU it is advisable to have significant GPU memory available, particularly when processing large datasets. Batch processing is the most memory hungry of the methods, but can process 280x512x512 datasets on a 4GB GPU.

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the BSD-3 license, "napari-sim-processor" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

napari-sim-processor-0.1.1.tar.gz (7.7 MB view details)

Uploaded Source

Built Distribution

napari_sim_processor-0.1.1-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

File details

Details for the file napari-sim-processor-0.1.1.tar.gz.

File metadata

  • Download URL: napari-sim-processor-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for napari-sim-processor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b055e7cfe336bd2b0e1ba409513190ebb62fbc5d34f746a14e311a8f7dd3779f
MD5 a242c168c32064dc788ec56084b66ad0
BLAKE2b-256 b49cc4fff7f713db7a4ed39a57e3a0a13ccaae448ce24b01e0024ba42ecb9d37

See more details on using hashes here.

File details

Details for the file napari_sim_processor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_sim_processor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2c49194bcd62e8d5cb06af87864e6bb0ca65b2bd7fb890409a4935d6c4c8bb
MD5 d077cb5d2f76836224db95a37f10cb61
BLAKE2b-256 76c99f86284e813ad44fa16fab8e6111f60b1ad5a79467452844aa02c4979871

See more details on using hashes here.

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