Scale transform changes aggregate results
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- documentation
Research direction
Start with the supplied Python example and review the tutorials covering coordinate systems, transformations, and aggregation. Confirm how Scale changes aggregate results for sum and mean, then update the relevant tutorial so the effect of the target coordinate system is explicit and verify the example remains understandable.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 3
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scverse/spatialdata
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
scverse/spatialdata#1256 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
scverse/spatialdata#1249 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: images 🌌 element: labels 🏷️ needs: triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1239 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: shapes ▲ models needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1234 ·
Maintainers usually reply within 2 days
-
bug 🚨 element: labels 🏷️ method: aggregation 🔢 needs: triage priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scverse/spatialdata#1230 ·
Maintainers usually reply within 2 days
All issues in scverse/spatialdata
Similar issues
-
ACK_WAITING HELP_WANTED UPDATE_CS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OWASP/CheatSheetSeries#2458 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
BasedHardware/omi#19711 ·
Maintainers usually reply within 1 day
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=TrueOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/transformers#49172 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vllm-project/vllm-metal#885 ·
Maintainers usually reply within 1 day