Skip to content

Commit 84d2e02

Browse files
committed
Register a dataset as an atlas based on the image width/height instead of based on keywords in the file path
1 parent 80de8b0 commit 84d2e02

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/murfey/workflows/clem/register_preprocessing_results.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ class CLEMPreprocessingResult(BaseModel):
5151
extent: list[float] # [x0, x1, y0, y1]
5252

5353

54+
def _is_clem_atlas(result: CLEMPreprocessingResult):
55+
# If an image has a width/height of at least 1.5 mm, it should qualify as an atlas
56+
return (
57+
max(result.pixels_x * result.pixel_size, result.pixels_y * result.pixel_size)
58+
>= 0.0015 # In metres
59+
)
60+
61+
5462
def _register_clem_image_series(
5563
session_id: int,
5664
result: CLEMPreprocessingResult,
@@ -142,9 +150,7 @@ def _register_clem_image_series(
142150

143151
# Add metadata for this series
144152
clem_img_series.search_string = str(output_file.parent / "*tiff")
145-
clem_img_series.data_type = (
146-
"atlas" if "Overview_" in result.series_name else "grid_square"
147-
)
153+
clem_img_series.data_type = "atlas" if _is_clem_atlas(result) else "grid_square"
148154
clem_img_series.number_of_members = result.number_of_members
149155
clem_img_series.pixels_x = result.pixels_x
150156
clem_img_series.pixels_y = result.pixels_y
@@ -181,7 +187,7 @@ def _register_dcg_and_atlas(
181187
dcg_name += f"--{result.series_name.split('--')[1]}"
182188

183189
# Determine values for atlas
184-
if "Overview_" in result.series_name: # These are atlas datasets
190+
if _is_clem_atlas(result):
185191
output_file = list(result.output_files.values())[0]
186192
atlas_name = str(output_file.parent / "*.tiff")
187193
atlas_pixel_size = result.pixel_size
@@ -197,7 +203,7 @@ def _register_dcg_and_atlas(
197203
dcg_entry = dcg_search[0]
198204
# Update atlas if registering atlas dataset
199205
# and data collection group already exists
200-
if "Overview_" in result.series_name:
206+
if _is_clem_atlas(result):
201207
atlas_message = {
202208
"session_id": session_id,
203209
"dcgid": dcg_entry.id,

0 commit comments

Comments
 (0)