Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Scale transform changes aggregate results

Abierto Apto para principiantes
#1,028 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
68/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Comienza con el ejemplo de Python proporcionado y revisa los tutoriales que cubren sistemas de coordenadas, transformaciones y agregación. Confirma cómo Scale cambia los resultados agregados para sum y mean; después, actualiza el tutorial relevante para que el efecto del sistema de coordenadas de destino sea explícito y verifica que el ejemplo siga siendo comprensible.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs: triage priority: low

Hey everyone,
as mentioned on Zulip I am using macsima data, where the macsima reader by default adds the Scale transformation to the coordinate system. I noticed that when I remove this my aggregation results are slightly different. This is most prominent for small signals, for larger signals it is not so pronounced. My original use case was for the mean intensity. For sum its very obvious that the absolute values change due to the transform, but the ratios stay similar.

Of course I understand that it makes sense to apply the transform before doing the aggregation, since they are intended for example for aligning my labels with the image. Still it was a bit unintuitive for me that this happens as a new user. Maybe this could be highlighted also a bit more in the tutorials. As requested below is a small example.

import spatialdata as sd
from spatialdata.datasets import blobs
from spatialdata.transformations import set_transformation, Scale

sdata = blobs()
# set scale transformation to new coordinate system. global coord system has Identity transform
scale_transform = Scale([0.1, 0.1], ("x", "y"))
set_transformation(sdata["blobs_image"], transformation=scale_transform, to_coordinate_system="scaled")
set_transformation(sdata["blobs_labels"], transformation=scale_transform, to_coordinate_system="scaled")

global_sum = sdata.aggregate(values="blobs_image", by="blobs_labels", target_coordinate_system="global")

print(global_sum["table"].X[:1])
#<Compressed Sparse Row sparse matrix of dtype 'float64'
#	with 3 stored elements and shape (1, 3)>
#  Coords	Values
#  (0, 0)	1309.3692551660652
#  (0, 1)	1587.8641823936478
#  (0, 2)	3125.1190857645483

scaled_sum = sdata.aggregate(values="blobs_image", by="blobs_labels", target_coordinate_system="scaled")

print(scaled_sum["table"].X[:1])
#<Compressed Sparse Row sparse matrix of dtype 'float64'
#	with 3 stored elements and shape (1, 3)>
#  Coords	Values
#  (0, 0)	12.758250581405642
#  (0, 1)	15.427204091295
#  (0, 2)	31.23271691509622


global_mean = sdata.aggregate(values="blobs_image", by="blobs_labels", agg_func="mean", target_coordinate_system="global")

print(global_mean["table"].X[:1])
#<Compressed Sparse Row sparse matrix of dtype 'float64'
#	with 3 stored elements and shape (1, 3)>
#  Coords	Values
#  (0, 0)	0.08696083251418378
#  (0, 1)	0.10545687603066001
#  (0, 2)	0.20755257260839133

scaled_mean = sdata.aggregate(values="blobs_image", by="blobs_labels", agg_func="mean", target_coordinate_system="scaled")

print(scaled_mean["table"].X[:1])
#<Compressed Sparse Row sparse matrix of dtype 'float64'
#	with 3 stored elements and shape (1, 3)>
#  Coords	Values
#  (0, 0)	0.08449172570467313
#  (0, 1)	0.10216691451188742
#  (0, 2)	0.2068391848681869

Lenguaje dominante
Python
Estrellas
394
Forks
95
Merge medio
5 d 9 h
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de scverse/spatialdata

Todos los issues de scverse/spatialdata

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.