Napari Workflow Builder
Overview
Create reproducible napari workflows for common microscopy tasks and convert exploratory analysis into runnable Python scripts and notebooks.
Default stack
Prefer:
numpyscipyscikit-imagetifffilepandasmatplotlibnapari
Only add heavier dependencies when the task clearly benefits from them.
Core workflow
1. Start from an explicit problem statement
Translate the request into a concrete workflow goal such as:
- denoise image
- segment nuclei
- create labels
- measure connected components
- overlay masks on raw data
- compare channels
State the intended output before writing code.
2. Build the pipeline in small named steps
Prefer readable steps over monolithic one-liners:
- load
- inspect
- preprocess
- segment or transform
- postprocess
- visualize
- save outputs
Use descriptive variable names and brief comments.
3. Keep napari interactive but reproducible
When using napari:
- create layers with meaningful names
- keep raw and processed data in separate layers
- use labels layers for segmentation masks
- include a non-interactive script path so the workflow can run headlessly when needed
4. Make assumptions explicit
For microscopy tasks, explicitly state:
- whether the workflow is 2D, 3D, or time-lapse
- whether channels are treated independently or jointly
- whether thresholds are global or adaptive
- whether measurements apply to raw intensity, processed intensity, or labels
Preferred algorithm choices
Default to stable, common tools from scikit-image.
Examples:
- denoising: gaussian, median, non-local means when justified
- background correction: rolling-ball style approximations, morphological opening, or subtraction approaches
- segmentation: threshold + morphology + connected components for simple cases
- watershed for touching objects when markers are available
- registration only when explicitly needed
Do not introduce deep learning unless the user asks or a classical method is clearly inadequate.
Deliverables
When the user asks for a complete workflow, produce all of these unless they opt out:
- runnable Python script
- notebook version
- saved intermediate/output filenames
- napari layer creation code
- concise explanation of each step
Output structure
Prefer a response structure like:
- task summary
- assumptions
- pipeline steps
- code
- expected saved outputs
- troubleshooting notes
Troubleshooting guidance
When the first-pass result is poor, suggest targeted adjustments such as:
- smoothing sigma
- thresholding method
- minimum object size
- hole filling
- border object removal
- per-channel normalization
Avoid vague advice like “tune parameters” without naming the likely parameters.
Resources
references/workflow-patterns.md: reusable workflow skeletonsreferences/notebook-outline.md: notebook structurescripts/napari_workflow_demo.py: small reproducible example
微信扫一扫