Open tcompa opened 2 months ago
I think the reason is that our ngff models include
class Channel(BaseModel):
"""
Model for an element of `Omero.channels`.
See https://ngff.openmicroscopy.org/0.4/#omero-md.
"""
window: Optional[Window] = None
label: Optional[str] = None
family: Optional[str] = None
color: str
active: Optional[bool] = None
class Omero(BaseModel):
"""
Model for `NgffImageMeta.omero`.
See https://ngff.openmicroscopy.org/0.4/#omero-md.
"""
channels: list[Channel]
where wavelength_id
is not present.
The reason why this was not an issue in previous versions is that we had
# Replicate image attrs
old_image_group = zarr.open_group(
f"{zarrurl_old}/{well_path}/{image_path}", mode="r"
)
new_image_group = zarr.group(
f"{zarrurl_new}/{well_path}/{image_path}"
)
new_image_group.attrs.put(old_image_group.attrs.asdict())
while we now have
new_image_group.attrs.put(ngff_image.dict(exclude_none=True))
Let's review whether we can get our models more consistent for this (e.g. having FractalChannels inherited from Channels etc.)
I put back a version of just using the attrs of the old image for the moment with https://github.com/fractal-analytics-platform/fractal-tasks-core/commit/4aac820bf45f7b56afbe33f872b7e486593edc78
It's slightly less elegant, as we have to load the metadata twice now (once for the NGFF model for things like number of pyramid levels, once for adding it to the new image). But with that, it's hopefully not a blocker for V2 anymore but something we can address carefully when we get a chance.
[I still think we should find a good way of using those very useful Pydantic models for this purpose, e.g. having Fractal pydantic models we can use. Just wanted to make the registration testing work ;)]
Within #671, it appears that the MIP-images zattrs do not include
wavelength_id
in theomero
metadata.Here is how this leads to a cellpose-task error: