Skip to content

Registration task not finding reference image in some cases #958

@jluethi

Description

@jluethi

We need to improve the _get_matching_ref_acquisition_path_heuristic in the apply registration task.

In a scenario where there are images: [0, 0_illum_corr, 1, 1_illum_corr] and the illum_corr images should be processed, it works for 1_illum_corr. But it fails for 0_illum_corr. The traceback is:

2025-06-03 10:27:35,179; WARNING; No heuristic reference acquisition match found, defaulting to first option 0.
2025-06-03 10:27:35,180; WARNING; Running registration when there are multiple images of the same acquisition in a well. Using a heuristic to match the reference acquisition. Using 0 as the reference image.
Traceback (most recent call last):
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/fractal_tasks_core/tasks/apply_registration_to_image.py", line 400, in <module>
    run_fractal_task(
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/fractal_task_tools/task_wrapper.py", line 66, in run_fractal_task
    metadata_update = task_function(**pars)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/pydantic/validate_call_decorator.py", line 60, in wrapper_function
    return validate_call_wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 96, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/fractal_tasks_core/tasks/apply_registration_to_image.py", line 121, in apply_registration_to_image
    ROI_table_ref = ad.read_zarr(
                    ^^^^^^^^^^^^^
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/anndata/_io/zarr.py", line 66, in read_zarr
    f = zarr.open(store, mode="r")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/homes/fractal/20230627_joel_fractal/fractal-demos/examples/server/FRACTAL_TASKS_DIR/6/fractal-tasks-core/1.5.1/venv/lib/python3.11/site-packages/zarr/convenience.py", line 139, in open
    raise PathNotFoundError(path)
zarr.errors.PathNotFoundError: nothing found at path ''

The likely culprit:

# Never return the input `path`
if path in sorted_path_list:
sorted_path_list.remove(path)

We don't allow the heuristic to find the image itself and default to 0. Defaulting to 0 worked for many cases, but isn't an overall solution.

I'll investigate if we can just drop this limitation, because I think allowing it to reference itself makes sense here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions