Skip to content

Commit 067c1d6

Browse files
committed
Merged recent changes from 'main' branch
2 parents c99618e + 0563c8d commit 067c1d6

File tree

7 files changed

+73
-52
lines changed

7 files changed

+73
-52
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
python-version: ["3.9", "3.10", "3.11"]
1818
services:
1919
mariadb:
20-
image: mariadb:11.6.2 # released 2024-05-06
20+
image: mariadb:11.7.2 # released 2024-05-06
2121
# Pulls image from DockerHub
2222
# Docker images: https://hub.docker.com/_/mariadb
2323
# Previous version(s):

src/murfey/client/contexts/tomo.py

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ class TomographyContext(Context):
7979
ProcessingParameter("pixel_size_on_image", "Pixel Size"),
8080
ProcessingParameter("motion_corr_binning", "Motion Correction Binning"),
8181
ProcessingParameter("frame_count", "Number of image frames"),
82+
ProcessingParameter("tilt_axis", "Stage rotation angle"),
8283
ProcessingParameter("num_eer_frames", "Number of EER Frames"),
8384
]
8485

8586
def __init__(self, acquisition_software: str, basepath: Path):
8687
super().__init__("Tomography", acquisition_software)
8788
self._basepath = basepath
8889
self._tilt_series: Dict[str, List[Path]] = {}
90+
self._tilt_series_with_pjids: List[str] = []
8991
self._tilt_series_sizes: Dict[str, int] = {}
9092
self._completed_tilt_series: List[str] = []
9193
self._aligned_tilt_series: List[str] = []
@@ -116,57 +118,59 @@ def register_tomography_data_collections(
116118
capture_post(dcg_url, json=dcg_data)
117119

118120
for tilt_series in self._tilt_series.keys():
119-
dc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection"
120-
dc_data = {
121-
"experiment_type": "tomography",
122-
"file_extension": file_extension,
123-
"acquisition_software": self._acquisition_software,
124-
"image_directory": image_directory,
125-
"data_collection_tag": tilt_series,
126-
"source": str(self._basepath),
127-
"tag": tilt_series,
128-
}
129-
if (
130-
environment.data_collection_parameters
131-
and environment.data_collection_parameters.get("voltage")
132-
):
133-
# Once mdoc parameters are known register processing jobs
134-
dc_data.update(
135-
{
136-
"voltage": environment.data_collection_parameters[
137-
"voltage"
138-
],
139-
"pixel_size_on_image": environment.data_collection_parameters[
140-
"pixel_size_on_image"
141-
],
142-
"image_size_x": environment.data_collection_parameters[
143-
"image_size_x"
144-
],
145-
"image_size_y": environment.data_collection_parameters[
146-
"image_size_y"
147-
],
148-
"magnification": environment.data_collection_parameters[
149-
"magnification"
150-
],
151-
}
152-
)
153-
capture_post(dc_url, json=dc_data)
154-
155-
proc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/register_processing_job"
156-
for recipe in ("em-tomo-preprocess", "em-tomo-align"):
157-
capture_post(
158-
proc_url,
159-
json={
160-
"tag": tilt_series,
161-
"source": str(self._basepath),
162-
"recipe": recipe,
163-
"experiment_type": "tomography",
164-
},
121+
if tilt_series not in self._tilt_series_with_pjids:
122+
dc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection"
123+
dc_data = {
124+
"experiment_type": "tomography",
125+
"file_extension": file_extension,
126+
"acquisition_software": self._acquisition_software,
127+
"image_directory": image_directory,
128+
"data_collection_tag": tilt_series,
129+
"source": str(self._basepath),
130+
"tag": tilt_series,
131+
}
132+
if (
133+
environment.data_collection_parameters
134+
and environment.data_collection_parameters.get("voltage")
135+
):
136+
# Once mdoc parameters are known register processing jobs
137+
dc_data.update(
138+
{
139+
"voltage": environment.data_collection_parameters[
140+
"voltage"
141+
],
142+
"pixel_size_on_image": environment.data_collection_parameters[
143+
"pixel_size_on_image"
144+
],
145+
"image_size_x": environment.data_collection_parameters[
146+
"image_size_x"
147+
],
148+
"image_size_y": environment.data_collection_parameters[
149+
"image_size_y"
150+
],
151+
"magnification": environment.data_collection_parameters[
152+
"magnification"
153+
],
154+
}
155+
)
156+
capture_post(dc_url, json=dc_data)
157+
158+
proc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/register_processing_job"
159+
for recipe in ("em-tomo-preprocess", "em-tomo-align"):
160+
capture_post(
161+
proc_url,
162+
json={
163+
"tag": tilt_series,
164+
"source": str(self._basepath),
165+
"recipe": recipe,
166+
"experiment_type": "tomography",
167+
},
168+
)
169+
self._tilt_series_with_pjids.append(tilt_series)
170+
else:
171+
logger.info(
172+
"Cannot register data collection yet as no values from mdoc"
165173
)
166-
else:
167-
logger.info(
168-
"Cannot register data collection yet as no values from mdoc"
169-
)
170174

171175
except Exception as e:
172176
logger.error(f"ERROR {e}, {environment.data_collection_parameters}")
@@ -339,6 +343,9 @@ def _add_tilt(
339343
"frame_count": environment.data_collection_parameters.get(
340344
"frame_count", 0
341345
),
346+
"tilt_axis": environment.data_collection_parameters.get(
347+
"tilt_axis", 85
348+
),
342349
"mc_binning": environment.data_collection_parameters.get(
343350
"motion_corr_binning", 1
344351
),
@@ -576,6 +583,7 @@ def gather_metadata(
576583
mdoc_metadata["experiment_type"] = "tomography"
577584
mdoc_metadata["voltage"] = float(mdoc_data["Voltage"])
578585
mdoc_metadata["frame_count"] = int(mdoc_data_block["NumSubFrames"])
586+
mdoc_metadata["tilt_axis"] = float(mdoc_data_block["RotationAngle"])
579587
mdoc_metadata["image_size_x"] = int(mdoc_data["ImageSize"][0])
580588
mdoc_metadata["image_size_y"] = int(mdoc_data["ImageSize"][1])
581589
mdoc_metadata["magnification"] = int(mdoc_data_block["Magnification"])

src/murfey/server/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,7 @@ def feedback_callback(header: dict, message: dict) -> None:
24692469
"dose_per_frame": preproc_params.dose_per_frame,
24702470
"frame_count": preproc_params.frame_count,
24712471
"kv": preproc_params.voltage,
2472+
"tilt_axis": preproc_params.tilt_axis,
24722473
"pixel_size": preproc_params.pixel_size,
24732474
"manual_tilt_offset": -tilt_offset,
24742475
"node_creator_queue": machine_config.node_creator_queue,
@@ -2839,6 +2840,7 @@ def feedback_callback(header: dict, message: dict) -> None:
28392840
voltage=message["voltage"],
28402841
dose_per_frame=message["dose_per_frame"],
28412842
frame_count=message["frame_count"],
2843+
tilt_axis=message["tilt_axis"],
28422844
motion_corr_binning=message["motion_corr_binning"],
28432845
gain_ref=message["gain_ref"],
28442846
eer_fractionation_file=message["eer_fractionation_file"],

src/murfey/server/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ def register_completed_tilt_series(
735735
"dose_per_frame": preproc_params.dose_per_frame,
736736
"frame_count": preproc_params.frame_count,
737737
"kv": preproc_params.voltage,
738+
"tilt_axis": preproc_params.tilt_axis,
738739
"pixel_size": preproc_params.pixel_size,
739740
"manual_tilt_offset": -tilt_offset,
740741
"node_creator_queue": machine_config.node_creator_queue,

src/murfey/util/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ def secure_path(in_path: Path, keep_spaces: bool = False) -> Path:
7878
secure_filename(p) if " " not in p else p for p in in_path.parts
7979
]
8080
else:
81-
secured_parts = [secure_filename(p) for p in in_path.parts]
81+
secured_parts = [
82+
(
83+
secure_filename(part) + ":"
84+
if p == 0 and ":" in part
85+
else secure_filename(part)
86+
)
87+
for p, part in enumerate(in_path.parts)
88+
]
8289
return Path("/".join(secured_parts))
8390

8491

src/murfey/util/db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ class TomographyPreprocessingParameters(SQLModel, table=True): # type: ignore
459459
pixel_size: float
460460
dose_per_frame: float
461461
frame_count: int
462+
tilt_axis: float
462463
voltage: int
463464
eer_fractionation_file: Optional[str] = None
464465
motion_corr_binning: int = 1

src/murfey/util/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ class ProcessFile(BaseModel): # Rename to TomoProcessFile
316316
pixel_size: float
317317
dose_per_frame: float
318318
frame_count: int
319+
tilt_axis: Optional[float]
319320
mc_uuid: Optional[int] = None
320321
voltage: float = 300
321322
mc_binning: int = 1
@@ -351,6 +352,7 @@ class CompletedTiltSeries(BaseModel):
351352
class PreprocessingParametersTomo(BaseModel):
352353
dose_per_frame: float
353354
frame_count: int
355+
tilt_axis: float
354356
gain_ref: Optional[str]
355357
experiment_type: str
356358
voltage: float

0 commit comments

Comments
 (0)