wsinfer#
Run patch-level classification inference on whole slide images.
wsinfer [OPTIONS] COMMAND [ARGS]...
Options
- --backend <backend>#
Backend for loading whole slide images.
- Options:
openslide | tiffslide
- --log-level <log_level>#
Set the loudness of logging.
- Options:
debug | info | warning | error | critical
- --version#
Show the version and exit.
run#
Run model inference on a directory of whole slide images.
This command will create a tissue mask of each WSI. Then patch coordinates will be computed. The chosen model will be applied to each patch, and the results will be saved to a CSV in RESULTS_DIR/model-output.
Example:
CUDA_VISIBLE_DEVICES=0 wsinfer run –wsi-dir slides/ –results-dir results –model breast-tumor-resnet34.tcga-brca –batch-size 32 –num-workers 4
To list all available models and weights, use wsinfer-zoo ls.
wsinfer run [OPTIONS]
Options
- -i, --wsi-dir <wsi_dir>#
Required Directory containing whole slide images. This directory can only contain whole slide images.
- -o, --results-dir <results_dir>#
Required Directory to store results. If directory exists, will skip whole slides for which outputs exist.
- -m, --model <model_name>#
Name of the model to use from WSInfer Model Zoo. Mutually exclusive with –config.
- Options:
breast-tumor-resnet34.tcga-brca | colorectal-resnet34.penn | colorectal-tiatoolbox-resnet50.kather100k | lung-tumor-resnet34.tcga-luad | lymphnodes-tiatoolbox-resnet50.patchcamelyon | pancancer-lymphocytes-inceptionv4.tcga | pancreas-tumor-preactresnet34.tcga-paad | prostate-tumor-resnet34.tcga-prad
- -c, --config <config>#
Path to configuration for the trained model. Use this option if the model weights are not registered in wsinfer. Mutually exclusive with–model
- -p, --model-path <model_path>#
Path to the pretrained model. Use only when –config is passed. Mutually exclusive with –model.
- -b, --batch-size <batch_size>#
Batch size during model inference. If using multiple GPUs, increase the batch size.
- Default:
32
- -n, --num-workers <num_workers>#
Number of workers to use for data loading during model inference (n=0 for single thread). Set this to the number of cores on your machine or lower.
- Default:
2
- --speedup, --no-speedup#
JIT-compile the model and apply inference optimizations. This imposes a startup cost but may improve performance overall.
- Default:
False
- --qupath#
Create a QuPath project containing the inference results
- Default:
False
- --seg-thumbsize <seg_thumbsize>#
The size of the slide thumbnail (in pixels) used for tissue segmentation. The aspect ratio is preserved, and the longest side will have length max(thumbsize).
- --seg-median-filter-size <seg_median_filter_size>#
The kernel size for median filtering. Must be greater than 1 and odd.
- --seg-binary-threshold <seg_binary_threshold>#
The threshold for image binarization.
- --seg-closing-kernel-size <seg_closing_kernel_size>#
The kernel size for binary closing (morphological operation).
- --seg-min-object-size-um2 <seg_min_object_size_um2>#
The minimum size of an object to keep during tissue detection. If a contiguous object is smaller than this area, it replaced with background. The default is 200um x 200um. The units of this argument are microns squared.
- --seg-min-hole-size-um2 <seg_min_hole_size_um2>#
The minimum size of a hole to keep as a hole. If a hole is smaller than this area, it is filled with foreground. The default is 190um x 190um. The units of this argument are microns squared.
- --patch-overlap-ratio <patch_overlap_ratio>#
The ratio of overlap among patches. The default value of 0 produces non-overlapping patches. A value in (0, 1) will produce overlapping patches. Negative values will add space between patches. A value of -1 would skip every other patch. A value of 0.5 will provide 50%% of overlap between patches. Values must be in (-inf, 1).
tosbu#
Convert model outputs to Stony Brook format.
Convert CSVs of patch predictions to .txt and .json formats for use with Stony Brook Biomedical Informatics viewers.
RESULTS_DIR Path to results directory (containing model-outputs dir).
OUTPUT Path to output directory in which to save files.
wsinfer tosbu [OPTIONS] RESULTS_DIR OUTPUT
Options
- --wsi-dir <wsi_dir>#
Required Directory with whole slide images.
- --execution-id <execution_id>#
Required Unique execution ID for this run.
- --study-id <study_id>#
Required Study ID, like TCGA-BRCA.
- --make-color-text, --no-make-color-text#
Make text files with color information for each patch. NOTE: this can add several minutes of processing time per slide.
- --num-processes <num_processes>#
Number of processes to use when –make-color-text is enabled.
Arguments
- RESULTS_DIR#
Required argument
- OUTPUT#
Required argument
patch#
Patch a directory of whole slide iamges.
wsinfer patch [OPTIONS]
Options
- -i, --wsi-dir <wsi_dir>#
Required Directory containing whole slide images. This directory can only contain whole slide images.
- -o, --results-dir <results_dir>#
Required Directory to store patch results. If directory exists, will skip whole slides for which outputs exist.
- --patch-size-px <patch_size_px>#
Required Patch size in pixels.
- --patch-spacing-um-px <patch_spacing_um_px>#
Required Physical spacing of the patch in micrometers per pixel.
- --seg-thumbsize <seg_thumbsize>#
The size of the slide thumbnail (in pixels) used for tissue segmentation. The aspect ratio is preserved, and the longest side will have length max(thumbsize).
- --seg-median-filter-size <seg_median_filter_size>#
The kernel size for median filtering. Must be greater than 1 and odd.
- --seg-binary-threshold <seg_binary_threshold>#
The threshold for image binarization.
- --seg-closing-kernel-size <seg_closing_kernel_size>#
The kernel size for binary closing (morphological operation).
- --seg-min-object-size-um2 <seg_min_object_size_um2>#
The minimum size of an object to keep during tissue detection. If a contiguous object is smaller than this area, it replaced with background. The default is 200um x 200um. The units of this argument are microns squared.
- --seg-min-hole-size-um2 <seg_min_hole_size_um2>#
The minimum size of a hole to keep as a hole. If a hole is smaller than this area, it is filled with foreground. The default is 190um x 190um. The units of this argument are microns squared.