The only coordinate system I care about is the global one. The others appear to be FOV-specific and overlap in Napari, which makes them useless for visualization.
I was wondering whether the global and per-FOV coordinate systems duplicate the underlying data. Is it safe to remove the per-FOV coordinate systems and keep only the global one? If so, how can I do that?
Hi, no data is being duplicated and it is safe to remove coordinate systems (you can use remove_transformation())
There is a similar function, SpatialData.filter_by_coordinate_system(), which filters the elements by keeping only the one that maps to a coordinate system, but it returns unmodified versions of the elements (therefore they will still map to other coordinate systems). We could add an option to this function to keep only the target system.
# Remove all transformations except the global one, to avoid confusion in Napari
for element_collection in [
sdata.images,
sdata.labels,
sdata.points,
sdata.shapes,
]:
for name, element in element_collection.items():
transformations = get_transformation(element, get_all=True)
for coordinate_system in list(transformations):
if coordinate_system != "global":
remove_transformation(element, coordinate_system)