From 9431f5c6de9a02f6b0403c5bdb9268e8c03ce45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sophia=20M=C3=A4dler?= <15019107+sophiamaedler@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:07:06 +0100 Subject: [PATCH 1/2] truncate image paths in BIAS generated XML --- src/scportrait/tools/stitch/_utils/filewriters.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scportrait/tools/stitch/_utils/filewriters.py b/src/scportrait/tools/stitch/_utils/filewriters.py index 6a55ac0f..e6e49340 100644 --- a/src/scportrait/tools/stitch/_utils/filewriters.py +++ b/src/scportrait/tools/stitch/_utils/filewriters.py @@ -164,6 +164,8 @@ def write_xml(image_paths: list[str], channels: list[str], slidename: str, outdi text(channel) with tag("images"): for i, image_path in enumerate(image_paths): + # truncate image_path to only include the filename + image_path = os.path.basename(image_path) with tag("image", url=str(image_path)): with tag("channel"): text(str(i + 1)) From c4e37894761b6eac01c8a2d709432d0a4f93bb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sophia=20M=C3=A4dler?= <15019107+sophiamaedler@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:22:45 +0100 Subject: [PATCH 2/2] fix rescaling for thumbnail generation during stitching --- src/scportrait/tools/stitch/_stitch.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scportrait/tools/stitch/_stitch.py b/src/scportrait/tools/stitch/_stitch.py index 78821879..c6d27d6c 100644 --- a/src/scportrait/tools/stitch/_stitch.py +++ b/src/scportrait/tools/stitch/_stitch.py @@ -329,7 +329,14 @@ def generate_thumbnail(self, scale=0.05): self.thumbnail = thumbnail.make_thumbnail(self.reader, channel=self.stitching_channel_id, scale=scale) # rescale thumbnail to 0-1 range - self.thumbnail = rescale_image(self.thumbnail, self.rescale_range[self.stitching_channel]) + # if all channels should be rescaled to the same range, initialize dictionary with all channels + if type(self.rescale_range) is tuple: + rescale_range = {k: self.rescale_range for k in self.channel_names} + else: + rescale_range = self.rescale_range[self.stitching_channel] + + # rescale generated thumbnail + self.thumbnail = rescale_image(self.thumbnail, rescale_range) def initialize_aligner(self): """