### Install Steinbock via Docker Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Install and configure steinbock using Docker for a consistent environment. Aliases are provided for Linux/Mac and Windows PowerShell. ```bash # Linux/Mac - configure the steinbock alias alias steinbock="docker run -v /path/to/data:/data -u $(id -u):$(id -g) ghcr.io/bodenmillergroup/steinbock:latest" ``` ```powershell # Windows PowerShell function steinbock { docker run -v ${PWD}:/data -u 1000:1000 ghcr.io/bodenmillergroup/steinbock:latest @Args } ``` ```bash # Verify installation steinbock --version ``` -------------------------------- ### Install steinbock Python Package Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-python.md Use this command to install the steinbock Python package from PyPI. Ensure you have Python 3.8 or newer installed. ```bash pip install steinbock ``` -------------------------------- ### Run Jupyter Notebook via Steinbock CLI Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/apps.md Starts Jupyter Notebook, typically accessible at http://localhost:8888. Requires the specified port to be exposed and published via Docker. ```bash steinbock apps jupyter ``` -------------------------------- ### Run Steinbock Docker Container Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Execute the default steinbock Docker container. Ensure Docker is installed and configured. ```bash docker run ghcr.io/bodenmillergroup/steinbock ``` -------------------------------- ### Run Jupyter Lab via Steinbock CLI Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/apps.md Starts Jupyter Lab, typically accessible at http://localhost:8888. Requires the specified port to be exposed and published via Docker. ```bash steinbock apps jupyterlab ``` -------------------------------- ### Install Steinbock via pip Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Install the base steinbock package or with optional dependencies for specific functionalities like IMC preprocessing, DeepCell/Mesmer, Cellpose segmentation, or napari visualization. ```bash # Base install pip install steinbock ``` ```bash # With IMC preprocessing support pip install steinbock[imc] ``` ```bash # With DeepCell/Mesmer segmentation pip install steinbock[deepcell] ``` ```bash # With Cellpose segmentation pip install steinbock[cellpose] ``` ```bash # With napari visualization pip install steinbock[napari] ``` -------------------------------- ### Run Steinbock Docker Container with GPU Support (Linux) Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Run the steinbock Docker container with NVIDIA GPU support on Linux. Requires NVIDIA drivers and nvidia-container-runtime to be installed. ```bash docker run --gpus all ghcr.io/bodenmillergroup/steinbock:0.16.1-gpu ``` -------------------------------- ### View Image with Steinbock CLI Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/visualization.md Opens an image file and its corresponding mask in the napari viewer. This command is part of an experimental feature and may require specific graphical environment setups. ```bash steinbock view myimage.tiff ``` -------------------------------- ### DeepCell Preprocessing Configuration Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/segmentation.md Example of a YAML file to configure DeepCell preprocessing parameters for Mesmer, including thresholding, normalization, and watershed segmentation. ```yaml threshold: true percentile: 99.9 normalize: true kernel_size: 128 ``` -------------------------------- ### Run Steinbock Docker Container Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Use this command to run the Steinbock Docker container. Adapt the data path and container version as needed. X forwarding setup is required for graphical interfaces. ```bash docker run -v /path/to/data:/data -u $(id -u):$(id -g) --network host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY ghcr.io/bodenmillergroup/steinbock:0.16.1 ``` -------------------------------- ### Run Steinbock Docker Container with GPU Support Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md This command runs the Steinbock Docker container with NVIDIA GPU support. Ensure you are using the correct Docker image and have the necessary drivers installed. ```bash docker run -v /path/to/data:/data -u $(id -u):$(id -g) --network host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY --gpus all ghcr.io/bodenmillergroup/steinbock:0.16.1-gpu ``` -------------------------------- ### Launch Third-Party GUI Applications Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Launches pre-installed GUI applications within the Steinbock Docker container. Requires X forwarding for graphical applications. ```bash steinbock apps ilastik ``` ```bash steinbock apps cellprofiler ``` ```bash steinbock apps jupyter ``` ```bash steinbock apps jupyterlab ``` -------------------------------- ### Show steinbock CLI help Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/intro.md Use the --help option to display general help about the steinbock command and its subcommands. ```bash steinbock --help ``` -------------------------------- ### Run Ilastik via Steinbock CLI Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/apps.md Launches the Ilastik graphical user interface. Requires X forwarding support for Docker. ```bash steinbock apps ilastik ``` -------------------------------- ### Set up Steinbock DOSKEY Macro on Windows Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md This doskey macro simplifies running the steinbock Docker command from the Windows command line. It is retained for the current session. ```dos doskey steinbock=docker run -p 8888:8888 -v "C:\Data":/data ghcr.io/bodenmillergroup/steinbock:0.16.1 $* ``` -------------------------------- ### Prepare Ilastik Pixel Classification Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Prepare data for Ilastik pixel classification by aggregating channels, extracting crops for training, and creating a project file. ```bash # Prepare Ilastik input: aggregate channels, extract 50×50 crops, create project steinbock classify ilastik prepare --cropsize 50 --seed 123 ``` ```bash # Output: ilastik_img/, ilastik_crops/, pixel_classifier.ilp ``` ```bash # Open Ilastik GUI to train the classifier on the crops steinbock apps ilastik ``` ```bash # After training, run batch classification on all full-size images steinbock classify ilastik run ``` ```bash # Output: ilastik_probabilities/*.tiff (RGB: Red=Nucleus, Green=Cytoplasm, Blue=Background) ``` ```bash # If reusing an existing .ilp project, patch it for compatibility: steinbock classify ilastik fix ``` -------------------------------- ### Run CellProfiler via Steinbock CLI Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/apps.md Launches the CellProfiler graphical user interface. Requires X forwarding support for Docker. ```bash steinbock apps cellprofiler ``` -------------------------------- ### Allow Xhost Access for X Forwarding on Mac OS Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Run this command in the terminal to allow the local root user to access the running XQuartz X server, which is necessary for X forwarding with graphical user interfaces. ```bash xhost +localhost ``` -------------------------------- ### Visualize Image with Napari Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Opens a single image, with an optional mask overlay, in the napari viewer. Channels are loaded as additive grayscale layers, and masks as labels layers. ```bash steinbock view img/sample1.tiff ``` -------------------------------- ### Prepare CellProfiler Measurement Pipeline Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/measurement.md Use this command to prepare a CellProfiler measurement pipeline. It creates a default pipeline file and collects images and masks for processing. ```bash steinbock measure cellprofiler prepare ``` -------------------------------- ### Run Steinbock Docker Container on Windows Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Use this command to run the steinbock Docker container on Windows. Adapt the bind mount path and container version as needed. The DISPLAY variable is for X forwarding. ```bash docker run -v "C:\Data":/data -p 8888:8888 -e DISPLAY=host.docker.internal:0 ghcr.io/bodenmillergroup/steinbock:0.16.1 ``` -------------------------------- ### Tile Images for Mosaics Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/utils.md Splits images into tiles of a specified size, saving them with a convention that includes original filename, tile position, and dimensions. Recommended tile size is 4096x4096. ```bash steinbock utils mosaics tile img_full --size 4096 -o img ``` -------------------------------- ### Create IMC Panel File with Steinbock Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/preprocessing.md Use this command to create a steinbock panel file for IMC data. It can convert an existing IMC panel file or generate a new one from .mcd/.txt files. ```bash steinbock preprocess imc panel ``` -------------------------------- ### Create Steinbock Command Alias Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Set up a command alias to simplify running the Steinbock Docker container. This alias is retained for the current session. ```bash alias steinbock="docker run -v /path/to/data:/data -u $(id -u):$(id -g) --network host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY ghcr.io/bodenmillergroup/steinbock:0.16.1" ``` -------------------------------- ### Create Panel File from External Images Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/preprocessing.md Generates a template panel file based on external image data. This is useful for organizing metadata when using images preprocessed outside of steinbock. ```bash steinbock preprocess external panel ``` -------------------------------- ### Prepare Data for Ilastik Classification Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/classification.md Aggregates, scales, and converts images to Ilastik format, extracts training crops, and creates a default Ilastik project file. Use `--seed` for reproducible crop extraction. ```bash steinbock classify ilastik prepare --cropsize 50 --seed 123 ``` -------------------------------- ### Allow Local Root User Access to X Server Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md This command is necessary to allow the Steinbock Docker container to run graphical user interfaces using X forwarding on Linux. ```bash xhost +local:root ``` -------------------------------- ### Run Steinbock Docker Container on Mac OS Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Use this command to run the steinbock Docker container on Mac OS. Adapt the bind mount path and container version as needed. X forwarding configurations are required for GUIs. ```bash docker run -v /path/to/data:/data --platform linux/amd64 -u $(id -u):$(id -g) -p 8888:8888 -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.Xauthority:/home/steinbock/.Xauthority:ro -e DISPLAY=host.docker.internal:0 ghcr.io/bodenmillergroup/steinbock:0.16.1 ``` -------------------------------- ### Export Measurements to AnnData (h5ad) Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Exports measurements to an AnnData h5ad file. Intensities are mapped to 'X', region properties to 'obs', and neighbors to 'obsp'. ```bash steinbock export anndata \ --intensities intensities \ --data regionprops \ --neighbors neighbors \ -o objects.h5ad ``` -------------------------------- ### File I/O with steinbock.io Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Provides functions for reading and writing different steinbock file formats including panels, images, masks, object data, and neighbor graphs. Images are automatically converted to float32 on load, and masks to uint16. ```APIDOC ## Python API: `steinbock.io` — File I/O The `steinbock.io` module provides typed read/write functions for all steinbock file types: panel CSVs, multi-channel TIFF images, mask TIFFs, object data CSVs, and neighbor CSVs. Images are automatically converted to `float32` on load; masks to `uint16`. ```python import steinbock.io as io import numpy as np # --- Panel --- panel = io.read_panel("panel.csv") # Returns DataFrame with columns: channel, name, keep, (ilastik, deepcell, cellpose, ...) print(panel[["channel", "name"]].head()) # channel name # 141Pr SMA # 142Nd Vimentin # Read panel including rows with keep=0 full_panel = io.read_panel("panel.csv", unfiltered=True) # Write panel back (booleans auto-converted to 0/1) io.write_panel(panel, "panel_modified.csv") # --- Images --- img_files = io.list_image_files("img") # sorted list of Path objects img = io.read_image(img_files[0]) # float32 ndarray, shape (C, Y, X) img_native = io.read_image(img_files[0], native_dtype=True) # keep original dtype io.write_image(img, "img/output.tiff") # Memory-mapped read (efficient for large images) img_mmap = io.mmap_image(img_files[0], mode="r") # --- Masks --- mask_files = io.list_mask_files("masks", base_files=img_files) # matched by name mask = io.read_mask(mask_files[0]) # uint16 ndarray, shape (Y, X) io.write_mask(mask, "masks/output.tiff") # --- Object data --- data_files = io.list_data_files("intensities") data = io.read_data(data_files[0]) # DataFrame indexed by Object ID # Object CD45 CD3 E-Cadherin # 1 0.12 0.03 0.54 io.write_data(data, "intensities/output.csv") # --- Neighbor graphs --- nbr_files = io.list_neighbors_files("neighbors") neighbors = io.read_neighbors(nbr_files[0]) # DataFrame: Object, Neighbor, Distance # Object Neighbor Distance # 1 2 8.246 # 1 3 12.04 io.write_neighbors(neighbors, "neighbors/output.csv") # --- Image info --- image_info = io.read_image_info("images.csv") # image width_px height_px num_channels # sample1.tiff 800 800 40 io.write_image_info(image_info, "images_copy.csv") ``` ``` -------------------------------- ### Create Steinbock Command Alias with GPU Support Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md This alias simplifies running the Steinbock Docker container with NVIDIA GPU support. Adapt the data path and container version as needed. ```bash alias steinbock="docker run -v /path/to/data:/data -u $(id -u):$(id -g) --network host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY --gpus all ghcr.io/bodenmillergroup/steinbock:0.16.1-gpu" ``` -------------------------------- ### Set up Steinbock Command Alias on Mac OS Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md This command alias simplifies running the steinbock Docker command from the Mac OS terminal. It is retained for the current session. ```bash alias steinbock="docker run -v /path/to/data:/data --platform linux/amd64 -u $(id -u):$(id -g) -p 8888:8888 -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.Xauthority:/home/steinbock/.Xauthority:ro -e DISPLAY=host.docker.internal:0 ghcr.io/bodenmillergroup/steinbock:0.16.1" ``` -------------------------------- ### Run Cellpose Segmentation Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/segmentation.md Use this command to perform segmentation using the default Cellpose model (`cpsam`). Ensure you are using the `-cellpose` flavor of the Docker container. Fine-tuning parameters may be necessary. ```bash steinbock segment cellpose ``` -------------------------------- ### Segment Images with CellProfiler Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Prepare and run CellProfiler for image segmentation using probability images generated by the classify step. Optionally tune parameters in the CellProfiler GUI. ```bash # --- CellProfiler (uses probability images from classify step) --- # Prepare a CellProfiler segmentation pipeline steinbock segment cellprofiler prepare ``` ```bash # Optionally open CellProfiler GUI to tune parameters steinbock apps cellprofiler ``` ```bash # Run batch segmentation steinbock segment cellprofiler run ``` ```bash # Output: masks/*.tiff ``` -------------------------------- ### Visualize Images with Steinbock and napari Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Opens multi-channel images and segmentation masks in napari with a calibrated scale bar and channel blending. Can be run blocking or non-blocking to obtain a viewer handle for scripting. ```python import steinbock.io as io from steinbock.visualization import view panel = io.read_panel("panel.csv") img = io.read_image("img/sample1.tiff") # float32 (C, Y, X) mask = io.read_mask("masks/sample1.tiff") # uint16 (Y, X) channel_names = panel["name"].tolist() # Open viewer and block until closed view( img, masks={"cells": mask}, channel_names=channel_names, pixel_size_um=1.0, run=True, # blocks until window is closed ) # Non-blocking: get viewer handle for scripting viewer = view( img, masks={"cells": mask}, channel_names=channel_names, pixel_size_um=1.0, run=False, ) # viewer is a napari.Viewer instance; all channels visible=False by default viewer.layers["CD45"].visible = True import napari napari.run() ``` -------------------------------- ### Prepare CellProfiler Segmentation Pipeline Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/segmentation.md Prepares a default CellProfiler pipeline for segmenting cells in probability images. This pipeline is designed for use with probability images generated by the Ilastik pixel classification step. ```bash steinbock segment cellprofiler prepare ``` -------------------------------- ### Run CellProfiler Measurement Pipeline in Batch Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/measurement.md Apply the configured CellProfiler pipeline to a batch of images and masks. This command processes the data and stores the output in the 'cellprofiler_output' directory. ```bash steinbock measure cellprofiler run ``` -------------------------------- ### Run Ilastik Classification on Batch Images Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/classification.md Apply a trained Ilastik pixel classifier to a batch of full-size images. This command generates probability images by default. ```bash steinbock classify ilastik run ``` -------------------------------- ### Run Specific Steinbock Docker Release Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/install-docker.md Pull and run a specific version of the steinbock Docker container for reproducibility. Replace '0.16.1' with the desired version tag. ```bash docker run ghcr.io/bodenmillergroup/steinbock:0.16.1 ``` -------------------------------- ### Stitch Image Tiles into Mosaics Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/utils.md Assembles mask tiles, following specific naming conventions, back into masks of their original size. Saves the stitched masks to a specified output directory. ```bash steinbock utils mosaics stitch masks -o masks_full ``` -------------------------------- ### Import Steinbock Package Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/python/intro.md Import the steinbock library for use in your Python project. Refer to the API documentation for more details on available functions. ```python import steinbock ``` -------------------------------- ### Export Images to OME-TIFF Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/export.md Use this command to export images to OME-TIFF format. Channel names are determined by the panel file. The default destination directory is 'ome'. ```bash steinbock export ome ``` -------------------------------- ### Fix Existing Training Data for Ilastik Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/classification.md Use this command to patch an existing Ilastik pixel classification project and image crops for compatibility. It creates backups by default. ```bash steinbock classify ilastik fix ``` -------------------------------- ### Export Measurements to AnnData (loom/zarr) Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Exports intensity measurements to AnnData files in loom or zarr format. ```bash steinbock export anndata --intensities intensities --format loom -o objects.loom ``` ```bash steinbock export anndata --intensities intensities --format zarr -o objects.zarr ``` -------------------------------- ### Segment Cells with DeepCell Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/segmentation.md Use this command to segment cells from image data using the Mesmer model. It enables min-max normalization for preprocessing. ```bash steinbock segment deepcell --minmax ``` -------------------------------- ### Export Images and Masks for histoCAT Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/export.md Export images and masks to a folder structure compatible with histoCAT for MATLAB. The default destination directory is 'histocat'. ```bash steinbock export histocat ``` -------------------------------- ### Measure Object Intensities Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/measurement.md Extract mean intensities per channel for each object. This creates CSV files in the 'intensities' directory. The default aggregation method is mean, but can be changed using the --aggr option. ```bash steinbock measure intensities ``` -------------------------------- ### steinbock.visualization Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Opens a multi-channel image and optional segmentation masks in napari with calibrated scale bar, additive channel blending, and labeled mask overlays. ```APIDOC ## steinbock.visualization — napari Image Viewer Opens a multi-channel image and optional segmentation masks in napari with calibrated scale bar, additive channel blending, and labeled mask overlays. ### Usage Examples: ```python import steinbock.io as io from steinbock.visualization import view panel = io.read_panel("panel.csv") img = io.read_image("img/sample1.tiff") # float32 (C, Y, X) mask = io.read_mask("masks/sample1.tiff") # uint16 (Y, X) channel_names = panel["name"].tolist() # Open viewer and block until closed view( img, masks={"cells": mask}, channel_names=channel_names, pixel_size_um=1.0, run=True, # blocks until window is closed ) # Non-blocking: get viewer handle for scripting viewer = view( img, masks={"cells": mask}, channel_names=channel_names, pixel_size_um=1.0, run=False, ) # viewer is a napari.Viewer instance; all channels visible=False by default viewer.layers["CD45"].visible = True import napari napari.run() ``` ``` -------------------------------- ### Read and Write Steinbock File I/O Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Use `steinbock.io` for typed read/write operations on steinbock file types. Images are converted to float32 and masks to uint16 on load. Supports memory-mapped image reading for large files. ```python import steinbock.io as io import numpy as np # --- Panel --- panel = io.read_panel("panel.csv") # Returns DataFrame with columns: channel, name, keep, (ilastik, deepcell, cellpose, ...) print(panel[["channel", "name"]].head()) # channel name # 141Pr SMA # 142Nd Vimentin # Read panel including rows with keep=0 full_panel = io.read_panel("panel.csv", unfiltered=True) # Write panel back (booleans auto-converted to 0/1) io.write_panel(panel, "panel_modified.csv") # --- Images --- img_files = io.list_image_files("img") # sorted list of Path objects img = io.read_image(img_files[0]) # float32 ndarray, shape (C, Y, X) img_native = io.read_image(img_files[0], native_dtype=True) # keep original dtype io.write_image(img, "img/output.tiff") # Memory-mapped read (efficient for large images) img_mmap = io.mmap_image(img_files[0], mode="r") # --- Masks --- mask_files = io.list_mask_files("masks", base_files=img_files) # matched by name mask = io.read_mask(mask_files[0]) # uint16 ndarray, shape (Y, X) io.write_mask(mask, "masks/output.tiff") # --- Object data --- data_files = io.list_data_files("intensities") data = io.read_data(data_files[0]) # DataFrame indexed by Object ID # Object CD45 CD3 E-Cadherin # 1 0.12 0.03 0.54 io.write_data(data, "intensities/output.csv") # --- Neighbor graphs --- nbr_files = io.list_neighbors_files("neighbors") neighbors = io.read_neighbors(nbr_files[0]) # DataFrame: Object, Neighbor, Distance # Object Neighbor Distance # 1 2 8.246 # 1 3 12.04 io.write_neighbors(neighbors, "neighbors/output.csv") # --- Image info --- image_info = io.read_image_info("images.csv") # image width_px height_px num_channels # sample1.tiff 800 800 40 io.write_image_info(image_info, "images_copy.csv") ``` -------------------------------- ### Export Neighbors as Spatial Object Graphs Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/export.md Export neighbors as spatial object graphs with object data as node attributes. Generates .graphml files by default using the networkx package. The default destination directory is 'graphs'. The format can be changed to .gexf or .gml using the --format option. ```bash steinbock export graphs --data intensities ``` -------------------------------- ### Measure Per-Object Intensities Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Calculate per-channel intensities for segmented objects using various aggregation functions. Supports single image processing and batch processing from disk with error handling. ```python import steinbock.io as io from steinbock.measurement.intensities import ( IntensityAggregation, measure_intensites, try_measure_intensities_from_disk, ) # --- Single image --- panel = io.read_panel("panel.csv") channel_names = panel["name"].tolist() img = io.read_image("img/sample1.tiff") # float32 (C, Y, X) mask = io.read_mask("masks/sample1.tiff") # uint16 (Y, X) intensities = measure_intensites( img, mask, channel_names, IntensityAggregation.MEAN ) # Returns DataFrame indexed by Object with channel names as columns: # Object CD45 CD3 E-Cadherin # 1 0.12 0.03 0.54 # 2 0.31 0.22 0.08 # --- Batch processing from disk (with error handling per file) --- img_files = io.list_image_files("img") mask_files = io.list_mask_files("masks", base_files=img_files) for img_file, mask_file, intensities_df in try_measure_intensities_from_disk( img_files, mask_files, channel_names, IntensityAggregation.MEDIAN, mmap=False, # set True to memory-map large files ): print(f"{img_file.name}: {len(intensities_df)} objects") io.write_data(intensities_df, f"intensities/{img_file.stem}.csv") ``` -------------------------------- ### Measure Neighbors by Pixel Expansion Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/measurement.md Identify object neighbors using Euclidean pixel expansion (morphological dilation). Creates CSV files in the 'neighbors' directory. ```bash steinbock measure neighbors --type expansion --dmax 4 ``` -------------------------------- ### Preprocess IMC Data Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Extract and normalize IMC data. First, generate a panel.csv file from .mcd files, then extract TIFF images with optional hot pixel filtering. ```bash # Step 1: Auto-generate panel.csv from .mcd files in raw/ steinbock preprocess imc panel ``` ```bash # panel.csv is created; edit keep=1/0 to select channels, # and add ilastik/deepcell/cellpose group columns as needed ``` ```bash # Step 2: Extract TIFF images from raw/ with hot pixel filtering (threshold=50) steinbock preprocess imc images --hpf 50 ``` ```bash # Output: img/*.tiff, images.csv ``` ```bash # For external pre-processed images in another format: steinbock preprocess external panel # create panel template from external/ steinbock preprocess external images # convert external/ to steinbock TIFFs ``` -------------------------------- ### Segment Images with Cellpose Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Perform image segmentation using the generalist deep learning model Cellpose. Uses default segmentation model. ```bash # --- Cellpose (end-to-end, uses raw images) --- # Segment using default cpsam model steinbock segment cellpose ``` -------------------------------- ### Extract Mean Per-Channel Intensities Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Extracts mean per-channel intensities for each segmented object. Output is saved to intensities/.csv. ```bash steinbock measure intensities ``` ```bash steinbock measure intensities --aggr median ``` -------------------------------- ### Run CellProfiler Segmentation Batch Processing Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/segmentation.md Applies the configured CellProfiler pipeline to a batch of probability images to generate grayscale object masks. The output masks are saved in the 'masks' directory by default. ```bash steinbock segment cellprofiler run ``` -------------------------------- ### Convert External Images to TIFF Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/preprocessing.md Converts external image data into steinbock-supported TIFF files. This command is used when your images are already preprocessed but need to be in a compatible format for steinbock analysis. ```bash steinbock preprocess external images ``` -------------------------------- ### Export Object Data to CSV Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/export.md Export specified object data from all images into a single CSV file. This collects data from the specified directories and creates a table with an additional column indicating the source image. ```bash steinbock export csv intensities regionprops -o objects.csv ``` -------------------------------- ### Export Object Data to AnnData Source: https://github.com/bodenmillergroup/steinbock/blob/main/docs/cli/export.md Export specified object data to an AnnData file (.h5ad). Object intensities are used as main data, regionprops as observation annotations, and neighbors as pairwise observation annotations. The format can be changed to .loom or .zarr using the --format option. ```bash steinbock export anndata --intensities intensities --data regionprops --neighbors neighbors -o objects.h5ad ``` -------------------------------- ### Find Neighbors by Border or Expansion Distance Source: https://context7.com/bodenmillergroup/steinbock/llms.txt Finds neighboring objects based on the distance between their borders or by pixel expansion (morphological dilation). ```bash steinbock measure neighbors --type borders --dmax 4 ``` ```bash steinbock measure neighbors --type expansion --dmax 4 ```