Skip to content

2. How to use

António Brito edited this page Feb 8, 2024 · 6 revisions

How to use:

NanoPyx can be used as a Python library and included as part of your Python workflows.
It is also distributed as Codeless Jupyter notebooks that can be run locally or through Google Colab. When running NanoPyx through Jupyter notebooks the output of your analysis will be saved in the same path as your input image, adding a suffix to its filename to identify it as the output.

Codeless jupyter notebooks available:

To run the notebooks locally you will need a local Python environment and install NanoPyx along with its notebook requirements:

pip install 'nanopyx[jupyter]'

For more in-depth instructions check this tutorial. Alternatively these notebooks can also be ran through google colab by simply clicking the links in the following table. Instructions for google colab can be found here.

Category Method Last test Notebook Link Colab Link
Registration Channel Registration 20/04/23 ✅ working (BMS) Open in Github Open in Colab
Registration Drift Correction 20/04/23 ✅ working (BMS) Open in Github Open in Colab
Quality Control Image fidelity and resolution metrics 20/04/23 ✅ working (BMS) Open in Github Open in Colab
Super-resolution SRRF 20/04/23 ✅ working (BMS) Open in Github Open in Colab
Tutorial Example Notebook with Example Dataset 20/04/23 ✅ working (BMS) Open In Github Open In Colab

image

napari plugin

We are also developing a napari plugin that implements all nanopyx methods as a single package. It is installed separatelly and requires an installation of NanoPyx in the same environment where you're running napari.

NanoPyx is also available as a napari plugin, which can be installed via pip:

pip install napari-nanopyx

More in-depth intructions can be found on the napari-nanopyx github page wiki or in the tutorial section of this wiki

NanoPyx Python library

Installation

You can install NanoPyx via pip:

pip install nanopyx

or if you want to install dependencies of jupyter notebooks

pip install 'nanopyx[jupyter]'

or if you want to install with all optional dependencies

pip install 'nanopyx[all]'

if you want access to the cupy implementation of 2D convolution you need to install the package version corresponding to your local CUDA installation. Please check the official documentation of cupy for further details. As an example if you wanted to install cupy for CUDA v12.X

pip install cupy-cuda12x

To install latest development version :

pip install "nanopyx @git+https://github.com/HenriquesLab/NanoPyx.git"

Notes for Mac users

If you wish to compile the NanoPyx library from source, you will need to install the following dependencies:

  • Homebrew from https://brew.sh/
  • gcc, llvm and libomp from Homebrew through the command:
brew install gcc llvm libomp

Run in jupyterlab within a docker container

docker run --name nanopyx1 -p 8888:8888 henriqueslab/nanopyx:latest

Using nanopyx as a Python library:

You can check the official developer documentation here.
Most high-level methods are easily accessed through the methods module. As an example eSRRF can simple be used by running:

from nanopyx.methods import eSRRF

output = eSRRF(img, *args, **kwargs)

To know which parameters are available to each method you can refer to the oficial documentation (for example, for eSRRF) or type help(function_name) in your python terminal:

from nanopyx.methods import eSRRF
help(eSRRF)

Which should output the documentation for that method:

eSRRF(image, magnification: int = 5, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, _force_run_type=None)
    Perform eSRRF analysis on an image.
    
    Args:
          image (numpy.ndarray): The input image for eSRRF analysis.
          magnification (int, optional): Magnification factor (default is 5).
          radius (float, optional): Radius parameter for eSRRF analysis (default is 1.5).
          sensitivity (float, optional): Sensitivity parameter for eSRRF analysis (default is 1).
          doIntensityWeighting (bool, optional): Enable intensity weighting (default is True).
          _force_run_type (str, optional): Force a specific run type for the analysis (default is None).
    
    Returns:
          numpy.ndarray: The result of eSRRF analysis, typically representing the localizations.
    
    Example:
          result = eSRRF(image, magnification=5, radius=1.5, sensitivity=1, doIntensityWeighting=True)
    
    Note:
          - eSRRF (enhanced Super-Resolution Radial Fluctuations) is a method for super-resolution localization microscopy.
          - This function sets up a workflow to perform eSRRF analysis on the input image.
          - The workflow includes eSRRF_ST as a step and can be customized with various parameters.
          - The result is typically a numpy array representing the localized points.
    
    See Also:
          - eSRRF_ST: The eSRRF step that performs the actual analysis.

A tutorial showcasing how to run eSRRF analysis using the Python library can be found here.

To find which functions are implemented as part of NanoPyx the official documentation contains a search function that can be used to search for any function.

If you want to take advantage of the Liquid Engine in your own methods, you can follow the instructions in the tutorial section.