scverse/napari-spatialdata

Warn about element/table mismatches. Coloring the background

Opened this issue · 0 comments

Warn about element/table mismatches

A mismatch between the annotation table and instances is sometimes expected (for instance after filtering the table or subsetting the data while maintaining the full table), but other time is the symptom of an incorrect annotation linking.

For instance I just encountered a problem of having assigned the wrong table to a labels object and I realized it was wrong only because I also had a separate table associated to polygonal geometries. Here, a warning in the terminal telling which instances were found only in the elements and which one only in the table, would have helped detecting the issue.

In my case this would have been something like: [12312] indices detected only in the labels but not in the table (12312 is the highest index in this example); this would have suggested that the background had not been removed from the table and all the indices are shifted by one.

Coloring the background

Related, I believe that if the table annotates the background, we should actually show this. Basically:

  • 0 in labels but not in the the table -> transparent
  • 1 in labels but not in the table -> gray
  • 0 in labels and in the table -> colored by table
  • 1 in labels and in table -> colored by table

Currently is as above, except that we don't do

  • 0 in labels and in the table -> colored by table
    but
  • 0 in labels and in the table -> transparent.