Skip to content
Merged
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
34 changes: 12 additions & 22 deletions src/murfey/client/contexts/spa_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"):
Expand Down Expand Up @@ -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"]))
Expand Down
Loading