Skip to content

Commit dc0e96b

Browse files
committed
Use 'ImagingSite' instead of 'ImageSite'
1 parent b161a26 commit dc0e96b

5 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/murfey/util/db.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Session(SQLModel, table=True): # type: ignore
5353
visit_end_time: Optional[datetime] = Field(default=None)
5454

5555
# Image sites associated with this session
56-
image_sites: List["ImageSite"] = Relationship(
56+
imaging_sites: List["ImagingSite"] = Relationship(
5757
back_populates="session",
5858
sa_relationship_kwargs={"cascade": "delete"},
5959
)
@@ -86,7 +86,7 @@ class Session(SQLModel, table=True): # type: ignore
8686
)
8787

8888

89-
class ImageSite(SQLModel, table=True): # type: ignore
89+
class ImagingSite(SQLModel, table=True): # type: ignore
9090
"""
9191
Table for recording unique imaging sites in the session. These can then be linked
9292
to DataCollectionGroup or GridSquare entries as needed.
@@ -101,7 +101,7 @@ class ImageSite(SQLModel, table=True): # type: ignore
101101

102102
# Link to Session table
103103
session: Optional["Session"] = Relationship(
104-
back_populates="image_series"
104+
back_populates="imaging_sites"
105105
) # Many to one
106106
session_id: Optional[int] = Field(
107107
foreign_key="session.id", default=None, unique=False
@@ -112,15 +112,15 @@ class ImageSite(SQLModel, table=True): # type: ignore
112112

113113
# Link to data collection group
114114
data_collection_group: Optional["DataCollectionGroup"] = Relationship(
115-
back_populates="image_sites"
115+
back_populates="imaging_sites"
116116
)
117117
dcg_id: Optional[int] = Field(
118118
foreign_key="datacollectiongroup.dataCollectionGroupId", default=None
119119
)
120120
dcg_name: Optional[str] = Field(default=None)
121121

122122
# Link to grid squares
123-
grid_square: Optional["GridSquare"] = Relationship(back_populates="image_sites")
123+
grid_square: Optional["GridSquare"] = Relationship(back_populates="imaging_sites")
124124
grid_square_id: Optional[int] = Field(foreign_key="gridsquare.id", default=None)
125125

126126
# Shape and resolution information
@@ -216,7 +216,7 @@ class DataCollectionGroup(SQLModel, table=True): # type: ignore
216216
back_populates="data_collection_group",
217217
sa_relationship_kwargs={"cascade": "delete"},
218218
)
219-
image_sites: List["ImageSite"] = Relationship(
219+
imaging_sites: List["ImagingSite"] = Relationship(
220220
back_populates="data_collection_group",
221221
sa_relationship_kwargs={"cascade": "delete"},
222222
)
@@ -484,7 +484,7 @@ class GridSquare(SQLModel, table=True): # type: ignore
484484
pixel_size: Optional[float] = None
485485
image: str = ""
486486
session: Optional[Session] = Relationship(back_populates="grid_squares")
487-
image_sites: List["ImageSite"] = Relationship(
487+
imaging_sites: List["ImagingSite"] = Relationship(
488488
back_populates="grid_square", sa_relationship_kwargs={"cascade": "delete"}
489489
)
490490
foil_holes: List["FoilHole"] = Relationship(

src/murfey/workflows/clem/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from murfey.util.config import get_machine_config
1212
from murfey.util.db import (
13-
ImageSite,
13+
ImagingSite,
1414
Session as MurfeySession,
1515
)
1616

@@ -88,11 +88,11 @@ def get_db_entry(
8888
# With the database search funcion having been moved out of the FastAPI
8989
# endpoint, the database now has to be explicitly passed within the FastAPI
9090
# endpoint function in order for it to be loaded in the correct state.
91-
table: Type[Union[ImageSite,]],
91+
table: Type[Union[ImagingSite,]],
9292
session_id: int,
9393
file_path: Optional[Path] = None,
9494
series_name: Optional[str] = None,
95-
) -> Union[ImageSite,]:
95+
) -> Union[ImagingSite,]:
9696
"""
9797
Searches the CLEM workflow-related tables in the Murfey database for an entry that
9898
matches the file path or series name within a given session. Returns the entry if

src/murfey/workflows/clem/register_align_and_merge_results.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pydantic import BaseModel, field_validator
1111
from sqlmodel import Session, select
1212

13-
from murfey.util.db import ImageSite
13+
from murfey.util.db import ImagingSite
1414

1515
logger = logging.getLogger("murfey.workflows.clem.register_align_and_merge_results")
1616

@@ -84,12 +84,12 @@ def register_align_and_merge_result(
8484
try:
8585
if not (
8686
clem_img_series := murfey_db.exec(
87-
select(ImageSite)
88-
.where(ImageSite.session_id == session_id)
89-
.where(ImageSite.series_name == result.series_name)
87+
select(ImagingSite)
88+
.where(ImagingSite.session_id == session_id)
89+
.where(ImagingSite.series_name == result.series_name)
9090
).one_or_none()
9191
):
92-
clem_img_series = ImageSite(
92+
clem_img_series = ImagingSite(
9393
session_id=session_id, series_name=result.series_name
9494
)
9595
clem_img_series.composite_created = True

src/murfey/workflows/clem/register_preprocessing_results.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,19 @@ def _get_color_flags(
8686
return color_flags
8787

8888

89-
def _register_clem_image_site(
89+
def _register_clem_imaging_site(
9090
session_id: int,
9191
result: CLEMPreprocessingResult,
9292
murfey_db: Session,
9393
):
9494
if not (
9595
clem_img_site := murfey_db.exec(
96-
select(MurfeyDB.ImageSite)
97-
.where(MurfeyDB.ImageSite.session_id == session_id)
98-
.where(MurfeyDB.ImageSite.site_name == result.series_name)
96+
select(MurfeyDB.ImagingSite)
97+
.where(MurfeyDB.ImagingSite.session_id == session_id)
98+
.where(MurfeyDB.ImagingSite.site_name == result.series_name)
9999
).one_or_none()
100100
):
101-
clem_img_site = MurfeyDB.ImageSite(
101+
clem_img_site = MurfeyDB.ImagingSite(
102102
session_id=session_id, series_name=result.series_name
103103
)
104104

@@ -281,12 +281,12 @@ def _register_dcg_and_atlas(
281281

282282
if not (
283283
clem_img_site := murfey_db.exec(
284-
select(MurfeyDB.ImageSite)
285-
.where(MurfeyDB.ImageSite.session_id == session_id)
286-
.where(MurfeyDB.ImageSite.site_name == result.series_name)
284+
select(MurfeyDB.ImagingSite)
285+
.where(MurfeyDB.ImagingSite.session_id == session_id)
286+
.where(MurfeyDB.ImagingSite.site_name == result.series_name)
287287
).one_or_none()
288288
):
289-
clem_img_site = MurfeyDB.ImageSite(
289+
clem_img_site = MurfeyDB.ImagingSite(
290290
session_id=session_id, series_name=result.series_name
291291
)
292292

@@ -314,10 +314,10 @@ def _register_grid_square(
314314
# Check if an atlas has been registered
315315
if not (
316316
atlas_entry := murfey_db.exec(
317-
select(MurfeyDB.ImageSite)
318-
.where(MurfeyDB.ImageSite.session_id == session_id)
319-
.where(MurfeyDB.ImageSite.dcg_name == dcg_name)
320-
.where(MurfeyDB.ImageSite.data_type == "atlas")
317+
select(MurfeyDB.ImagingSite)
318+
.where(MurfeyDB.ImagingSite.session_id == session_id)
319+
.where(MurfeyDB.ImagingSite.dcg_name == dcg_name)
320+
.where(MurfeyDB.ImagingSite.data_type == "atlas")
321321
).one_or_none()
322322
):
323323
logger.info(
@@ -327,10 +327,10 @@ def _register_grid_square(
327327

328328
# Check if there are CLEM entries to register
329329
if clem_img_site_to_register := murfey_db.exec(
330-
select(MurfeyDB.ImageSite)
331-
.where(MurfeyDB.ImageSite.session_id == session_id)
332-
.where(MurfeyDB.ImageSite.dcg_name == dcg_name)
333-
.where(MurfeyDB.ImageSite.data_type == "grid_square")
330+
select(MurfeyDB.ImagingSite)
331+
.where(MurfeyDB.ImagingSite.session_id == session_id)
332+
.where(MurfeyDB.ImagingSite.dcg_name == dcg_name)
333+
.where(MurfeyDB.ImagingSite.data_type == "grid_square")
334334
).all():
335335
if (
336336
atlas_entry.x0 is not None
@@ -521,7 +521,7 @@ def run(message: dict, murfey_db: Session) -> dict[str, bool]:
521521
return {"success": False, "requeue": False}
522522
try:
523523
# Register items in Murfey database
524-
_register_clem_image_site(
524+
_register_clem_imaging_site(
525525
session_id=session_id,
526526
result=result,
527527
murfey_db=murfey_db,

tests/workflows/clem/test_register_preprocessing_results.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
COLOR_FLAGS_MURFEY_TO_ISPYB,
1616
_determine_collection_mode,
1717
_get_color_flags,
18-
_register_clem_image_site,
18+
_register_clem_imaging_site,
1919
_register_dcg_and_atlas,
2020
_register_grid_square,
2121
_snake_to_camel_case,
@@ -173,8 +173,8 @@ def test_get_color_flags(test_params: tuple[list[str], dict[str, bool]]):
173173
assert _get_color_flags(colors) == expected_result
174174

175175

176-
def test_register_clem_image_site():
177-
_register_clem_image_site
176+
def test_register_clem_imaging_site():
177+
_register_clem_imaging_site
178178

179179

180180
@pytest.mark.parametrize(
@@ -243,7 +243,7 @@ def test_run(
243243

244244
# Mock the registration helper functions
245245
mock_register_clem_series = mocker.patch(
246-
"murfey.workflows.clem.register_preprocessing_results._register_clem_image_site"
246+
"murfey.workflows.clem.register_preprocessing_results._register_clem_imaging_site"
247247
)
248248
mock_register_dcg_and_atlas = mocker.patch(
249249
"murfey.workflows.clem.register_preprocessing_results._register_dcg_and_atlas"

0 commit comments

Comments
 (0)