scverse / scverse/spatialdata

registration got unmatched images

Open
#712 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
394
Forks
95
Avg merge
4d 3h
Merged PRs (30d)
7

Description

Hi, here I tried to register the DAPI staining images between nanostring and xenium, and apply that transformation to the segmentation masks, the images aligns well in the napari, however, when I extracted the registered images and plot with matplotlib, I found they were not matched, do you have any suggestions? Thanks!

```python
      xenium_sdata = SpatialData(images=img_xenium,shapes=shape_xenium)
      nano_sdata = SpatialData(images=img_nano,shapes=shape_nano)
      affine = align_elements_using_landmarks(
          references_coords=xenium_sdata["landmarks"],
          moving_coords=nano_sdata["landmarks"],
          reference_element=xenium_sdata["DAPI"],
          moving_element=nano_sdata["DAPI"],
          reference_coordinate_system="global",
          moving_coordinate_system="global",
          new_coordinate_system="aligned",
      )
      affine
      def postpone_transformation(
          sdata: SpatialData,
          transformation: BaseTransformation,
          source_coordinate_system: str,
          target_coordinate_system: str,
      ):
          for element_type, element_name, element in sdata._gen_elements():
              old_transformations = get_transformation(element, get_all=True)
              if source_coordinate_system in old_transformations:
                  old_transformation = old_transformations[source_coordinate_system]
                  sequence = Sequence([old_transformation, transformation])
                  set_transformation(element, sequence, target_coordinate_system)
      
      postpone_transformation(
          sdata=nano_sdata,
          transformation=affine,
          source_coordinate_system="global",
          target_coordinate_system="aligned",
      )
      img_nano_aligned = nano_sdata.transform_element_to_coordinate_system('DAPI','aligned',True)
      img_xenium_aligned = xenium_sdata.images['DAPI']
```

Here are the images that I got with matplotlib
Screenshots
img_nano_aligned
img_nano_aligned
img_xenium_aligned
img_xenium_aligned
aligned images in napri(nanostring DAPI is colored with red and xenium DAPI is colored with blue)
图片 3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing align_elements_using_landmarks and transform_element_to_coordinate_system for the DAPI image path, then compare the coordinate systems and transformations used by the napari and matplotlib outputs. The issue is done when the extracted registered images match the alignment shown in napari, with a reproducible example or a documented explanation if the behavior is expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
computer-vision, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.