From 9a743e8d309e2bad72f879d2ab6bb63f6c7805c1 Mon Sep 17 00:00:00 2001 From: Daniel Hatton Date: Mon, 13 Jan 2025 13:26:01 +0000 Subject: [PATCH] The client needs to read metadata from the original location, not the destination --- src/murfey/client/contexts/spa_metadata.py | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/murfey/client/contexts/spa_metadata.py b/src/murfey/client/contexts/spa_metadata.py index 7cd98b4e6..26c3a1813 100644 --- a/src/murfey/client/contexts/spa_metadata.py +++ b/src/murfey/client/contexts/spa_metadata.py @@ -61,23 +61,18 @@ def post_transfer( ]["#text"] visit_index = windows_path.split("\\").index(environment.visit) partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :]) - visitless_path = Path( - str(transferred_file).replace(f"/{environment.visit}", "") - ) - visit_index_of_transferred_file = transferred_file.parts.index( - environment.visit - ) + + source = _get_source(transferred_file, environment) + if not source: + logger.warning( + f"Source could not be indentified for {str(transferred_file)}" + ) + return + + source_visit_dir = source.parent + atlas_xml_path = list( - ( - Path( - "/".join( - transferred_file.parts[ - : visit_index_of_transferred_file + 1 - ] - ) - ) - / partial_path - ).parent.glob("Atlas_*.xml") + (source_visit_dir / partial_path).parent.glob("Atlas_*.xml") )[0] with open(atlas_xml_path, "rb") as atlas_xml: atlas_xml_data = xmltodict.parse(atlas_xml) @@ -88,10 +83,6 @@ def post_transfer( # need to calculate the pixel size of the downscaled image atlas_pixel_size = atlas_original_pixel_size * 7.8 - source = _get_source( - visitless_path.parent / "Images-Disc1" / visitless_path.name, - environment, - ) sample = None for p in partial_path.split("/"): if p.startswith("Sample"): @@ -126,8 +117,7 @@ def post_transfer( ) if registered_grid_squares: gs_pix_positions = _get_grid_square_atlas_positions( - _atlas_destination(environment, source, transferred_file) - / environment.samples[source].atlas + source_visit_dir / partial_path ) for gs in registered_grid_squares: pos_data = gs_pix_positions.get(str(gs["name"]))