Skip to content

Make fractal-tasks-core library functions handle ngio ROI tables #947

@jluethi

Description

@jluethi

There was a minor change in how ngio writes masking ROI tables & maybe other ROI tables: The label column now is the index column of obs, not a column in the obs dataframe itself. Different tools like the masking functionality used in the Cellpose task rely on a column "label" being present in the obs dataframe.

For one of @nrepina 's tasks, we could work around this by changing the masked wrapper code here (

if column_name not in ROI_table.obs.columns:
) to:

# Check that ROI_table.obs has the right column and extract label_value
if column_name not in ROI_table.obs.columns:
    if ROI_table.obs.index.name == column_name:
        # Workaround for new ngio table
        ROI_table.obs[column_name] = ROI_table.obs.index
    else:
        raise ValueError(
            f"In _preprocess_input, {column_name=} "
            f" missing in {ROI_table.obs.columns=}"
        )
label_value = int(float(ROI_table.obs[column_name].iloc[ROI_positional_index]))

We should review whether it's simple to add this workaround to different places where this could occur to ensure our tasks keep working with the new ngio ROI tables without requiring an overall update to ngio yey.

cc @lorenzocerrone

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