Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate image paths in XMLs for BIAS import #93

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/scportrait/tools/stitch/_stitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 2 additions & 0 deletions src/scportrait/tools/stitch/_utils/filewriters.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change worked. XML output can now be used directly as long as the XML file is kept in the same folder as the stitched images.

Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading