Package: napari-LF
napari-LFLight field imaging plugin for napariDeconvolves a 4D light field image into a full 3D focus stack reconstructionhttps://user-images.githubusercontent.com/23206511/236919283-d53ca97a-9bdd-4598-b553-34996f688237.mp4napari-LF contains an analytic and neural net analysis methods for light field images. To download example light field images, see our repositorynapari-LF-docs-samples.LF AnalyzeLF Analyze, the analytic method, provides three basic processes to Calibrate, Rectify, and Deconvolve light field images:TheCalibrateprocess generates a calibration file that represents the optical setup that was used to record the light field images. The same calibration file can be used to rectify and deconvolve all light field images that were recorded with the same optical setup, usually the same microscope and light field camera. The Calibrate process requires as input the radiometry frame, dark frame, optical parameters, and volume parameters to generate the calibration file, which is subsequently used to rectify and deconvolve related light field images. The calibration file includes a point spread function (PSF) derived from the optical and volume parameters and is stored in HDF5 file format.TheRectifyprocess uses the calibration file for an affine transformation to scale and rotate experimental light field images that were recorded with a light field camera whose microlens array was (slightly) rotated with respect to the pixel array of the area detector and whose pixel pitch is not commensurate with the microlens pitch. After rectification, the rectified light field has the same integer number of pixels behind each microlens. When the Deconvolve process is called for an experimental light field image, rectifying the light field image is automatically applied before the iterative deconvolution does begin. However, the rectified light field image is not saved and is not available for viewing. Therefore, by pushing the Rectify button in the middle of the napari-LF widget, only the rectification step is invoked and the rectified light field image is saved to the project directory.TheDeconvolveprocess uses the PSF and a wave optics model to iteratively deconvolve a light field image into a stack of optical sections.TheParameterpanels, located in the lower half of the napari-LF widget, allows the user to specify settings for the reconstruction process. Once the appropriate parameters are selected, the Calibrate button followed by the Deconvolve button can be pushed to complete the reconstruction.Neural NetNeural Netprovides a method of applying a trained neural net model to deconvolve a light field image. Based on Pytorch Lightning and a providedbase class, you can either create your own network, or use the pre-shipped networks (LFMNet, VCDNet, ...).QuickstartInstall the napari-LF plugin into your napari environment, as described below underInstallation.From the napari Plugins menu, select the napari-LF plugin to install its widget into the napari viewer.LF AnalyzeNear the top of the widget, select your project folder containing the following images: light field, radiometry, and dark frame.CalibrationIn the processing panel, navigate toCalibrate, Required(top tabCalibrate, bottom tabRequired), which is the default selection.Selectradiometryanddark frameimages from pull down menus.Write the name of thecalibration fileyou would like to produce, e.g. calibration.lfc.Enter the appropriateoptical parametersaccording to your microscope and sample material.Enter thevolume parametersyou would like for your 3D reconstuction.Push theCalibratebutton.DeconvolutionIn the processing panel, navigate toDeconvolve, Required.Selectlight fieldimage andcalibration filefrom pull down menus.Write the name of theoutput image stackyou would like to produce, e.g. output_stack.tif.Push theDeconvolvebutton.
The 3D focal stack reconstruction will display in the napari viewer and be saved in your original project folder.Neural NetClick on theLF Analyzelogo to toggle to theNeural Netmode.Near the top of the widget, select your project folder containing the light field image and the trained neural net. If you do not already have a trained model, you can train a model using thisJupyter notebook.In the processing panel, select yourlight field imageandneural net model.Write the name of theoutput image stackyou would like to produce, e.g. output_stack.tif.Push theDeconvolvebutton.
The 3D focal stack reconstruction will display in the napari viewer and be saved in your original project folder.Getting HelpFor details about each parameter, hover over each parameter textbox to read the tooltip description.
For additional information about the reconstruction process, see ourUser Guide.InstallationAfter you havenapariinstalled, you can one of the methods below to installnapari-LF.Method 1: You can installnapari-LFviapip:pip install napari-LFMethod 2: Use the napari plugin menu.Open napari from the command line:napariFrom the napari menu, selectPlugins > Install/uninstall Packages.Either (a) scroll through the list of available plugins to findnapari-LF, or (b) drag and drop a downloadednapari-LFdirectory into the bottom bar.SelectInstallto install the light field plugin.Method 3: Install the latest development version from the command line.pip install git+https://github.com/PolarizedLightFieldMicroscopy/napari-LF.gitLastly, to access the installed plugin, open napari from the command line:napariFrom the napari menu, selectPlugins > Main Menu (napari-LF). Note that you may need to close and reopen napari for thenapari-LFto appear.Installation for developersCreate a virtual environment from the command line for napari with the python libraries necessary for the light field plugin:conda create --name napari-lf python==3.9
conda activate napari-lfClone the github repository:conda install git
git clone https://github.com/PolarizedLightFieldMicroscopy/napari-LF.git
cd napari-LF
pip install -e .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-LF" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.