fractal-analytics-platform / fractal-tasks-core

Main tasks for the Fractal analytics platform
https://fractal-analytics-platform.github.io/fractal-tasks-core/
BSD 3-Clause "New" or "Revised" License
12 stars 6 forks source link

Running Cellpose on an empty ROI table leads to concatenate ValueError during ROI table creation #561

Closed jluethi closed 10 months ago

jluethi commented 10 months ago

While running some tests, I had one well that lead to empty ROI tables (because no primary objects where found). When I then wanted to run cellpose within this ROI table, I ran into the following error:

2023-10-10 19:48:49,548; INFO; Now starting loop over 0 ROIs
2023-10-10 19:48:49,548; INFO; End cellpose_segmentation task for /tungstenfs/scratch/gliberal/Users/luetjoel/20230626_deployment_130/fractal-demos/examples/10_2D_to_3D_workflow/output_2D_to_3D_workflow_2/20200812-CardiomyocyteDifferentiation14-Cycle1.zarr/B/03/0, now building pyramids.
2023-10-10 19:48:49,595; INFO; End building pyramids
Traceback (most recent call last):
  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib/python3.9/site-packages/fractal_tasks_core/tasks/cellpose_segmentation.py", line 657, in <module>
    run_fractal_task(
  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib64/python3.9/site-packages/fractal_tasks_core/tasks/_utils.py", line 79, in run_fractal_task
    metadata_update = task_function(**pars)
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
    from contextlib import _GeneratorContextManager
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call

  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute

  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib/python3.9/site-packages/fractal_tasks_core/tasks/cellpose_segmentation.py", line 619, in cellpose_segmentation
    df_well = pd.concat(bbox_dataframe_list, axis=0, ignore_index=True)
  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib64/python3.9/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib64/python3.9/site-packages/pandas/core/reshape/concat.py", line 368, in concat
    op = _Concatenator(
  File "/path/to/FRACTAL_TASK_DIR/.fractal/fractal-tasks-core0.12.0/venv/lib64/python3.9/site-packages/pandas/core/reshape/concat.py", line 425, in __init__
    raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate

Steps to reproduce:

Goal: No ValueError is created, but the task just creates an empty label image and an empty ROI table.