Skip to content

Apply registration task fails on all non-reference images with ngio.utils._errors.NgioValueError: Incompatible shapes for patch and slice. #1044

Description

@jluethi

An error occurred for Kelvin at the Pelkmans lab when using the new apply registration task (version 2.0.0):

An error occurred.
Original error:
Traceback (most recent call last):
  File "/redacted/fractal-server-env/lib/python3.12/site-packages/fractal_server/runner/executors/call_command_wrapper.py", line 62, in call_command_wrapper
    raise TaskExecutionError(
fractal_server.runner.exceptions.TaskExecutionError: Task failed with returncode=1.
STDERR: 2026-04-21 15:32:57,733; run_fractal_task; INFO; START apply_registration_to_image task
2026-04-21 15:32:57,733; apply_registration_to_image; INFO; Running `apply_registration_to_image` on zarr_url='/redacted/cycle1.zarr/B/05/1', registered_roi_table='registered_well_ROI_table' and reference_acquisition=0. Using overwrite_input=True and register_labels=True
2026-04-21 15:32:58,213; apply_registration_to_image; INFO; Write the registered Zarr image to disk
Traceback (most recent call last):
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/fractal_tasks_core/apply_registration_to_image.py", line 311, in <module>
    run_fractal_task(task_function=apply_registration_to_image)
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/fractal_task_tools/task_wrapper.py", line 99, in run_fractal_task
    metadata_update = task_function(**pars)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 39, in wrapper_function
    return wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 136, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/fractal_tasks_core/apply_registration_to_image.py", line 210, in apply_registration_to_image
    new_ome_zarr = _write_registered_ngio_image(acq_ome_zarr, new_zarr_url, roi_pairs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/fractal_tasks_core/apply_registration_to_image.py", line 75, in _write_registered_ngio_image
    new_image.set_roi(ref_roi, patch)
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/images/_image.py", line 400, in set_roi
    self._set_roi(
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/images/_abstract_image.py", line 500, in _set_roi
    roi_numpy_setter(patch)
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/io_pipes/_io_pipes.py", line 171, in __call__
    return self.set(patch)
           ^^^^^^^^^^^^^^^
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/io_pipes/_io_pipes.py", line 311, in set
    set_slice_as_numpy(
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/io_pipes/_ops_slices.py", line 224, in set_slice_as_numpy
    _check_compatibility_of_shapes(zarr_array.shape, patch.shape, slice_tuple)
  File "/redacted/FRACTAL_TASKS_DIR/6/fractal-tasks-core/2.0.0/venv/lib/python3.11/site-packages/ngio/io_pipes/_ops_slices.py", line 209, in _check_compatibility_of_shapes
    raise NgioValueError(
ngio.utils._errors.NgioValueError: Incompatible shapes for patch and slice.
- Patch shape: (4, 1, 11964, 11993)
- Zarr array shape: (4, 1, 12000, 12000)
- Slice tuple: (slice(None, None, None), slice(0, 1, None), slice(0, 11965, None), slice(8, 12000, None))
- Expected shape: (4, 1, 12000, 12000)[(slice(None, None, None), slice(0, 1, None), slice(0, 11965, None), slice(8, 12000, None))] (4, 1, 11965, 11992)

In an example workflow, it occurred on all the non-reference cycle images, while the reference cycle images were processed successfully.

It looks like something goes wrong with the patch size vs. whole zarr array. We should see if we can reproduce this on a smaller example case @lorenzocerrone

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions