Skip to content

Commit

Permalink
Merge pull request #24 from NHPatterson/fix-config-write
Browse files Browse the repository at this point in the history
Fix config write
  • Loading branch information
NHPatterson authored Sep 17, 2021
2 parents c664de6 + deec37e commit a15b915
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
35 changes: 35 additions & 0 deletions tests/test_wsireg.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,38 @@ def test_wsireg_run_reg_wmerge_and_indiv(data_out_dir, disk_im_gry):
assert Path(im_fps[2]).exists() is True
assert Path(im_fps[3]).exists() is True
assert merged_im.im_dims == (2, 2048, 2048)


def test_wsireg_run_reg_wattachment(data_out_dir, disk_im_gry):
wsi_reg = WsiReg2D("test_proj-attach", str(data_out_dir))
im1 = np.random.randint(0, 255, (2048, 2048), dtype=np.uint16)
im2 = np.random.randint(0, 255, (2048, 2048), dtype=np.uint16)

wsi_reg.add_modality(
"mod1",
im1,
0.65,
channel_names=["test"],
channel_colors=["red"],
)

wsi_reg.add_modality(
"mod2",
im2,
0.65,
channel_names=["test"],
channel_colors=["red"],
)
wsi_reg.add_attachment_images("mod2", "attached", im2, image_res=0.65)

wsi_reg.add_reg_path(
"mod2", "mod1", reg_params=["rigid_test", "affine_test"]
)

wsi_reg.register_images()
im_fps = wsi_reg.transform_images(transform_non_reg=False)

regim = reg_image_loader(im_fps[0], 0.65)
attachim = reg_image_loader(im_fps[1], 0.65)

assert np.array_equal(regim.image.compute(), attachim.image.compute())
10 changes: 9 additions & 1 deletion wsireg/wsireg2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from wsireg.utils.tform_utils import (
prepare_wsireg_transform_data,
)
from wsireg.utils.im_utils import (
ARRAYLIKE_CLASSES,
)


class WsiReg2D(object):
Expand Down Expand Up @@ -566,11 +569,16 @@ def save_config(self, registered=False):

[rge.pop("reg_transforms", None) for rge in reg_graph_edges]

modalities_out = deepcopy(self.modalities)
for mod, data in modalities_out.items():
if isinstance(data["image_filepath"], ARRAYLIKE_CLASSES):
data["image_filepath"] = "ArrayLike"

config = {
"project_name": self.project_name,
"output_dir": str(self.output_dir),
"cache_images": self.cache_images,
"modalities": self.modalities,
"modalities": modalities_out,
"reg_paths": reg_paths,
"reg_graph_edges": reg_graph_edges
if status == "registered"
Expand Down

0 comments on commit a15b915

Please sign in to comment.