Skip to content
Open
Changes from 1 commit
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
54 changes: 54 additions & 0 deletions src/murfey/client/contexts/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
from typing import Optional

import xmltodict

from murfey.client.context import Context
from murfey.client.contexts.spa import _get_source
from murfey.client.contexts.spa_metadata import _atlas_destination
Expand Down Expand Up @@ -49,3 +51,55 @@ def post_transfer(
logger.info(
f"Submitted request to create JPG image of atlas {str(transferred_atlas_name)!r}"
)
elif (
environment
and "Atlas_" in transferred_file.stem
and transferred_file.suffix == ".xml"
):
source = _get_source(transferred_file, environment)
if source:
atlas_mrc = transferred_file.with_suffix(".mrc")
transferred_atlas_name = _atlas_destination(
environment, source, atlas_mrc, self._token
) / atlas_mrc.relative_to(source.parent)

with open(transferred_file, "rb") as atlas_xml:
atlas_xml_data = xmltodict.parse(atlas_xml)
atlas_original_pixel_size = float(
atlas_xml_data["MicroscopeImage"]["SpatialScale"]["pixelSize"][
"x"
]["numericValue"]
)

# need to calculate the pixel size of the downscaled image
atlas_pixel_size = atlas_original_pixel_size * 7.8

for p in transferred_file.parts:
if p.startswith("Sample"):
sample = int(p.replace("Sample", ""))
break
else:
logger.warning(
f"Sample could not be identified for {transferred_file}"
)
return

dcg_data = {
"experiment_type_id": 44, # Atlas
"tag": str(transferred_file.parent),
"atlas": str(transferred_atlas_name),
"sample": sample,
"atlas_pixel_size": atlas_pixel_size,
}
capture_post(
base_url=str(environment.url.geturl()),
router_name="workflow.router",
function_name="register_dc_group",
token=self._token,
visit_name=environment.visit,
session_id=environment.murfey_session,
data=dcg_data,
)
logger.info(
f"Registered data collection group for atlas {str(transferred_atlas_name)!r}"
)
Loading