Skip to content

Commit b6ba908

Browse files
committed
Second atlases are possible, and need to avoid experiment type flip-flops
1 parent dc35e9f commit b6ba908

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/murfey/server/api/workflow.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,24 @@ def register_dc_group(
106106
db.exec(select(Session).where(Session.id == session_id)).one().instrument_name
107107
)
108108
logger.info(f"Registering data collection group on microscope {instrument_name}")
109-
if dcg_murfey := db.exec(
110-
select(DataCollectionGroup)
111-
.where(DataCollectionGroup.session_id == session_id)
112-
.where(DataCollectionGroup.tag == dcg_params.tag)
113-
).all():
109+
if (
110+
dcg_murfey := db.exec(
111+
select(DataCollectionGroup)
112+
.where(DataCollectionGroup.session_id == session_id)
113+
.where(DataCollectionGroup.tag == dcg_params.tag)
114+
).all()
115+
) or (
116+
(
117+
dcg_murfey := db.exec(
118+
select(DataCollectionGroup)
119+
.where(DataCollectionGroup.session_id == session_id)
120+
.where(DataCollectionGroup.sample == dcg_params.sample)
121+
).all()
122+
)
123+
and dcg_params.experiment_type_id == 44
124+
):
125+
# Either switching atlas for a common (atlas or processing) tag
126+
# Or registering a new atlas-type dcg for a sample that is already present
114127
dcg_murfey[0].atlas = dcg_params.atlas or dcg_murfey[0].atlas
115128
dcg_murfey[0].sample = dcg_params.sample or dcg_murfey[0].sample
116129
dcg_murfey[0].atlas_pixel_size = (
@@ -158,7 +171,7 @@ def register_dc_group(
158171
elif dcg_murfey := db.exec(
159172
select(DataCollectionGroup)
160173
.where(DataCollectionGroup.session_id == session_id)
161-
.where(DataCollectionGroup.atlas == dcg_params.atlas)
174+
.where(DataCollectionGroup.sample == dcg_params.sample)
162175
).all():
163176
# Case where we switch from atlas to processing
164177
dcg_murfey[0].tag = dcg_params.tag or dcg_murfey[0].tag

0 commit comments

Comments
 (0)