# HG changeset patch # User bgruening # Date 1742059435 0 # Node ID e5370bb716333da60736b28dabd734834b9a6e00 # Parent 1857781df226105cd906b6852adae28e62eac0a1 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/cellpose commit 5846f23282167df28e6cc00e1bda31523b66b5b4 diff -r 1857781df226 -r e5370bb71633 cellpose.xml --- a/cellpose.xml Tue Feb 11 14:47:54 2025 +0000 +++ b/cellpose.xml Sat Mar 15 17:23:55 2025 +0000 @@ -2,7 +2,7 @@ <description>with Cellpose</description> <macros> <token name="@TOOL_VERSION@">3.1.0</token> - <token name="@VERSION_SUFFIX@">0</token> + <token name="@VERSION_SUFFIX@">1</token> <xml name="channel"> <option value="0" selected="true">grayscale/None</option> <option value="1">red</option> @@ -19,6 +19,7 @@ <version_command>echo "@VERSION@"</version_command> <command detect_errors="exit_code"> <![CDATA[ + export MKL_NUM_THREADS=1 && export CELLPOSE_LOCAL_MODELS_PATH='cellpose_models' && mkdir -p segmentation && ln -s '${img_in}' ./image.${img_in.ext} && @@ -34,7 +35,7 @@ <inputs name="inputs" /> </configfiles> <inputs> - <param name="img_in" type="data" format="ome.tiff,tiff,jpeg,png" label="Choose the image file for segmention (usually after registration)"/> + <param name="img_in" type="data" format="ome.tiff,tiff,jpg,png" label="Choose the image file for segmention (usually after registration)"/> <param name="model_type" type="select" label="Choose the pre-trained model type"> <option value="nuclei" selected="true">nuclei</option> <option value="cyto">cyto</option> @@ -115,7 +116,9 @@ <param name="model_type" value="cyto"/> <param name="chan" value="2"/> <param name="chan2" value="3"/> - <param name="diameter" value="50"/> + <section name="options"> + <param name="diameter" value="50"/> + </section> <output name="cp_mask" file="img02_cp_masks_diameter.tif" compare="image_diff"/> <output name="cp_segm" file="img02_cp_segm_diameter.png" compare="image_diff"/> </test> diff -r 1857781df226 -r e5370bb71633 cp_segmentation.py --- a/cp_segmentation.py Tue Feb 11 14:47:54 2025 +0000 +++ b/cp_segmentation.py Sat Mar 15 17:23:55 2025 +0000 @@ -3,11 +3,24 @@ import os import warnings +# Make sure, that `MKL_NUM_THREADS` is set to 1, to ensure reproducibility: +# https://forum.image.sc/t/reproducibility-how-we-spent-years-building-containers-and-then-mkl-decided-to-screw-our-results/109599 +if str(os.environ['MKL_NUM_THREADS']) != '1': + warnings.warn('MKL_NUM_THREADS must be set to 1 to ensure reproducibility, and will be adjusted accordingly for now.') + os.environ['MKL_NUM_THREADS'] = '1' + +# Load the remaining packages *after* adjusting `MKL_NUM_THREADS` (this likely necessary for it to take effect) import matplotlib.pyplot as plt import numpy as np import skimage.io +import torch from cellpose import models, plot, transforms +# Apply PyTorch guidelines for reproducibility +torch.backends.cudnn.benchmark = True +torch.backends.cudnn.deterministic = True +torch.manual_seed(0) + def main(inputs, img_path, img_format, output_dir): """ diff -r 1857781df226 -r e5370bb71633 test-data/img02_cp_masks_rescale.tif Binary file test-data/img02_cp_masks_rescale.tif has changed diff -r 1857781df226 -r e5370bb71633 test-data/img02_cp_segm_cyto.png Binary file test-data/img02_cp_segm_cyto.png has changed diff -r 1857781df226 -r e5370bb71633 test-data/img02_cp_segm_diameter.png Binary file test-data/img02_cp_segm_diameter.png has changed diff -r 1857781df226 -r e5370bb71633 test-data/img02_cp_segm_gpu.png Binary file test-data/img02_cp_segm_gpu.png has changed