Module 07

So you want to use napari and mAIcrobe

napari gives you an interactive way to inspect image data, and the napari-mAIcrobe plugin adds a workflow aimed at microbial image analysis without forcing everything through a notebook first.

Estimated time: 30 to 45 min Prerequisite: one active environment

Create or activate the napari environment

Using conda:

conda create -n napari-env python=3.11
conda activate napari-env
python -m pip install "napari[all]"

Using venv:

python -m venv napari-env
source napari-env/bin/activate
python -m pip install --upgrade pip
python -m pip install "napari[all]"

A dedicated environment helps keep GUI dependencies separate from your lighter notebook or scripting environments.

That separation is often worth it because GUI tools can be more demanding than general scripting environments.

Quick verification step

python -c "import napari; print(napari.__version__)"

Install the mAIcrobe plugin

After napari is installed, add the plugin in the same active environment:

python -m pip install napari-mAIcrobe

You can also install plugins from napari's plugin manager later, but starting from the terminal makes it easier to reproduce the setup.

python -c "import importlib; print(importlib.import_module('napari_mAIcrobe'))"

Launch napari

napari

Once the viewer opens, use the menus to load sample data or your own microscopy images. To explore plugin features, look for the plugin widgets menu and the napari-mAIcrobe entry.

First orientation inside the viewer

  • Find the layers list and see how each loaded item appears there.
  • Adjust contrast and notice that appearance changes without altering the raw data.
  • Notice how multiple channels or labels can live in the same viewer session.

Simple Python launch example

import napari
import numpy as np

image = np.random.random((128, 128))

viewer = napari.Viewer()
viewer.add_image(image, name="random image")
napari.run()

What mAIcrobe is useful for

The plugin is aimed at microbial image analysis and can help learners move from a viewer-centered workflow toward segmentation, measurements, filtering, and report-style outputs.

First guided activity

  1. Launch napari in the environment where you installed the plugin.
  2. Open sample data or a small test image from your own project.
  3. Find the mAIcrobe widget and identify the main controls.
  4. Adjust at least one viewer setting such as contrast or layer visibility.
  5. Write down what biological structure or pattern you are trying to inspect.

What researchers should pay attention to

  • Which structures are clear and which remain ambiguous?
  • Do the visible patterns match what you expected biologically?
  • Would a notebook summary alone have hidden something obvious in the image?

What to point out during teaching

  • The viewer is for inspection and interaction, not just static display.
  • Layer names matter when learners work with multiple channels.
  • GUI tools are still part of a reproducible workflow when the environment is documented.
  • Short exploratory sessions in napari can guide what to measure later in notebooks.

Troubleshooting

  • If napari does not launch, confirm the environment is active.
  • If the plugin does not appear, reinstall it in the same environment as napari.
  • If the GUI feels unstable, try a fresh environment rather than stacking more packages into an old one.
  • If learners are overwhelmed, begin with viewer basics before introducing plugin-specific analysis.

Stop here for today if needed

A successful first session can be as simple as opening napari, loading one image, and understanding the layers and contrast tools. The plugin workflow can come in a later sitting.

Where this fits in the bigger workflow

A common pattern is to inspect images in napari, test ideas in a notebook, then move reusable logic into a package once the analysis becomes stable enough to share with collaborators.