NHPatterson / wsireg

multimodal whole slide image registration in a graph structure
MIT License
76 stars 7 forks source link

Output resolution is not respected #70

Open leorrose opened 6 months ago

leorrose commented 6 months ago

Description

When trying to register 3 imaging modalities i want the output resolution to be 1 micron. I state the output_res=1.0 for all modalities but it is not respected for the target modality and it has its original resolution.

What I Did

from wsireg.wsireg2d import WsiReg2D

reg_graph = WsiReg2D("rigid", "./test_reg")

reg_graph.add_modality(
    "modality_1", "./sample_data/mod_1/img.ome.tiff", image_res=0.221,
    preprocessing={"image_type": "BF"}, output_res=1.0
)

reg_graph.add_modality(
    "modality_2", "./sample_data/mod_2/img.ome.tiff", image_res=1.0,
    preprocessing={"image_type": "BF"}, output_res=1.0
)

reg_graph.add_modality(
    "modality_3", "./sample_data/mod_3/img.ome.tiff", image_res=1.6718,
    preprocessing={"image_type": "BF"}, output_res=1.0
)

reg_graph.add_reg_path(
    "modality_2",
    "modality_1",
    thru_modality=None,
    reg_params=["rigid"],
)

reg_graph.add_reg_path(
    "modality_3",
    "modality_1",
    thru_modality=None,
    reg_params=["rigid"],
)

reg_graph.register_images()
reg_graph.save_transformations()
reg_graph.transform_images(file_writer="ome.tiff")
leorrose commented 5 months ago

@NHPatterson Just adding a few more details.

This is how it looks when opening the images after registration in Napari:

image

I've also uploaded the sample data I used to the attached OneDrive link (due its size) if you want to play with it and figure why this happens.

leorrose commented 5 months ago

This issue is solved if I add downsampling to modality_1 when calling add_modality:

reg_graph.add_modality(
    "modality_1", "./sample_data/mod_1/img.ome.tiff", image_res=0.221,
    preprocessing={"image_type": "BF", 'downsampling': 2}, output_res=1.0
)

image

But if I add attachments (geojson) this doesn't solve the issue for example:

reg_graph.add_attachment_shapes(
    'modality_1', 'mod_1-annotations', './sample_data/mod_1/annotations.geojson'
)

image