Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions .github/workflows/build-and-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Build and Test Package

on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -19,20 +19,11 @@ jobs:
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
environment-file: stardist/environment-dev.yml
activate-environment: run-stardist-dev
auto-update-conda: true

- name: Remove duplicate OpenMP runtime on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
# This file is where Intel-MKL puts its OpenMP runtime.
# Deleting it here leaves only TensorFlow’s copy, avoiding the dup‐DLL error.
$dll = Join-Path $env:CONDA_PREFIX 'Library\bin\libiomp5md.dll'
if (Test-Path $dll) {
Remove-Item $dll -Force
}
use-mamba: false

- name: Run integration test (via conda run)
run: conda run -n run-stardist-dev pytest -s stardist/tests/test_integration.py
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[format]
quote-style = "preserve"
8 changes: 6 additions & 2 deletions stardist/runstardist/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def either_fit_to_voxel_size_or_rescale_manually(cls, v, values): # pylint: dis
@validator('target_voxel_size')
def target_voxel_size_is_valid(cls, v): # pylint: disable=no-self-argument,no-self-use
if v is not None:
raise NotImplementedError("Please find a `rescale_factor` manually to rescale your data because only nucleus size in absolute pixel matters. Matching voxel size may help PlantSeg but not StarDist.")
raise NotImplementedError(
"Please find a `rescale_factor` manually to rescale your data because only nucleus size in absolute pixel matters. Matching voxel size may help PlantSeg but not StarDist."
)


class ConfigConfig3D(BaseModel):
Expand Down Expand Up @@ -136,7 +138,9 @@ def model_name_is_valid(cls, v, values, config): # pylint: disable=no-self-argu
elif check_models(v, update_files=False, config_only=False):
logger.warning(f"Model is in {path_dir_models}")
else:
raise NotADirectoryError(f"Model directory {v} does not exist, encounterd error when downloading model.")
raise NotADirectoryError(
f"Model directory {v} does not exist, encounterd error when downloading model."
)
elif not (values['model_dir'] / v).is_dir():
raise NotADirectoryError(f"Model {v} does not exist.")
return v
Expand Down
2 changes: 1 addition & 1 deletion stardist/runstardist/dataio/hdf5.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" HDF5 IO functions adapted from PlantSeg
"""HDF5 IO functions adapted from PlantSeg

https://github.com/hci-unihd/plant-seg/blob/master/plantseg/io/h5.py
"""
Expand Down
2 changes: 1 addition & 1 deletion stardist/runstardist/dataio/tiff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" TIFF IO functions adapted from PlantSeg
"""TIFF IO functions adapted from PlantSeg

https://github.com/hci-unihd/plant-seg/edit/master/plantseg/io/tiff.py
"""
Expand Down
8 changes: 6 additions & 2 deletions stardist/runstardist/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def get_volume(image, name=None):
return image


def compare_image_pairs(list_segmentation, list_groundtruth, method='ap', name_segmentation=None, name_groundtruth=None, **kwargs):
def compare_image_pairs(
list_segmentation, list_groundtruth, method='ap', name_segmentation=None, name_groundtruth=None, **kwargs
):
if len(list_segmentation) != len(list_groundtruth):
raise ValueError("Segmentation and ground truth must have the same length.")
list_scores, list_iou_matrix = [], []
Expand All @@ -210,7 +212,9 @@ def apply_compare_image_pair(segmentation_groundtruth_pair):
return compare_image_pair(segmentation, groundtruth, method='ap')


def concurrent_basic_compare_image_pairs(list_segmentation, list_groundtruth, method='ap', name_segmentation=None, name_groundtruth=None):
def concurrent_basic_compare_image_pairs(
list_segmentation, list_groundtruth, method='ap', name_segmentation=None, name_groundtruth=None
):
if len(list_segmentation) != len(list_groundtruth):
raise ValueError("Segmentation and ground truth must have the same length.")
list_scores, list_iou_matrix = [], []
Expand Down
6 changes: 3 additions & 3 deletions stardist/runstardist/resources/zoo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ generic_plant_nuclei_3D:
url_weights: https://zenodo.org/records/8432366/files/stardist_weights.h5
url_rdf: https://zenodo.org/records/8432366/files/rdf.yaml
resolution: [0.2837 0.1268 0.1268]
description: 'A generic 3D StarDist trained to predict the nuclei in plant. Voxel size: (0.1268×0.1268×0.2837 µm^3) (XYZ)'
dimensionality: '3D'
modality: 'confocal'
description: "A generic 3D StarDist trained to predict the nuclei in plant. Voxel size: (0.1268×0.1268×0.2837 µm^3) (XYZ)"
dimensionality: "3D"
modality: "confocal"
2 changes: 1 addition & 1 deletion stardist/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exec(open('runstardist/__version__.py', encoding='utf-8').read()) # pylint: disable=exec-used

setup(
name='run-stardist', # Replace with your own username
name='run-stardist',
version=__version__, # pylint: disable=undefined-variable
author='Qin Yu',
author_email='qin.yu@embl.de',
Expand Down
1 change: 1 addition & 0 deletions stardist/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_train_then_predict(tmp_path):
env = os.environ.copy()
env["KMP_DUPLICATE_LIB_OK"] = "TRUE"
env["CUDA_VISIBLE_DEVICES"] = ""
env["TF_ENABLE_ONEDNN_OPTS"] = "0"

# 1) Train the model (1 epoch, 1 step)
run_entry("train-stardist", cfg, env)
Expand Down
Loading