Package: napari-sim-processor
napari-sim-processorA 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 inthispublication.3D SIM, for resolution enhancement in three dimensions. This is available in the3dSIMbranchThe 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 describedhere.Syntetic raw-image stacks of Structured Illumination Microscopy can be easily simulated using the napariSIMulatorpluging.Thisnapariplugin was generated withCookiecutterusing@napari'scookiecutter-napari-plugintemplate.InstallationYou can installnapari-sim-processorviapip:pip install napari-sim-processorTo install latest development version :pip install git+https://github.com/andreabassi78/napari-sim-processor.gitUsageOpen napari.Launch the reshape and sim-processor widgets.Open your raw image stack (using the napari built-in or your own file opener).If your image is ordered as a 5D stack (angle, phase, z-frame, y, x) go to point 6.In the reshape widget, select the actual number of acquired angles, phases, and frames (red arrow) and pressReshape Stack.
Note that the label axis of the viewer will be updated (green arrow).In the sim-reconstruction widget press the Select image layer button. Note that the number of phases and angles will be updated (blue arrow).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 seehere.Calibrate the SIM processor, pressing theCalibratebutton. This will find the carrier frequencies (red circles if theShow Carriercheckbox is selected), the modulation amplitude and the phase, using cross correlation analysis.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.Napari viewer showing the power spectrum of the raw stack. The pupil circle is in blue. A circle corresponding toetais shown in green.Napari viewer showing the cross-correlation of the raw stack. The red circles indicate the found carrier frequenciesRun 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 theBatch reconstructioncheckbox in order to process an entire stack in one shot. Click on the pytorch checkbox for gpu acceleration.Napari viewer with widgets showing a pseudo-widefield reconstructionNapari viewer with widgets showing a SIM reconstructionGPU processingThe 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.ContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theBSD-3license,
"napari-sim-processor" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.