Automated particle detection and scan planning for the HXN (Hard X-ray Nanoprobe) beamline at NSLS-II.
At HXN, samples are scanned with X-rays to produce element maps (XRF images) showing where different elements like Ni, Fe, Cu are concentrated. Scientists often want to do a quick coarse scan first, then automatically identify interesting particles and queue up detailed high-resolution scans of just those regions.
This tool:
- Loads XRF element maps (TIFF files) from a coarse scan
- Overlays up to 3 elements as RGB channels for visualization
- Detects particles using blob detection or deep learning (cellpose)
- Finds "union" regions where multiple elements overlap (e.g., particles containing both Ni and Fe)
- Exports scan coordinates that can be sent to the beamline queue server for automated fine scanning
- Python 3.11 or 3.12
- Platforms: Linux (x86_64), macOS (Intel or Apple Silicon)
- pixi for dependency management
pixi install
pixi run python src/automap_hxn/main.py- Load images: Select a directory with XRF element TIFFs, pick 3 elements (mapped to RGB)
- Configure: Set microns-per-pixel scale and stage origin coordinates
- Detect: Adjust intensity/area thresholds to identify particles
- Find unions: Locate regions where multiple elements overlap
- Queue scans: Send selected regions to the beamline queue server
simple- OpenCV SimpleBlobDetector (default)contours,hough,watershed- Traditional CV methodscellpose- Deep learning segmentation for complex shapes (seedocs/CELLPOSE_INTEGRATION_GUIDE.md)
Export XRF intensity arrays as publication-ready SVG figures with contour lines. See examples/svg_export.py for a working example (uses xrf_to_svg from automap_hxn.export):
pixi run python examples/svg_export.pyprecomputed_blobs.pkl- Cached detection resultsunion_blobs.json- Union boxes with real-world coordinatesscans/*.json- Individual scan parameters for queue server
- tiled - Remote data access to NSLS-II data
- bluesky-queueserver-api - Beamline queue server integration
- cellpose - Deep learning segmentation
- hxntools - HXN beamline utilities
- opencv, scikit-image - Image processing
- PyQt5 - GUI framework