Skip to content

Commit fa4f009

Browse files
ieivanovclaude
andcommitted
feat: add plate_row and plate_col fields to PositionBase
Add serialized int fields to PositionBase for annotating which well a position belongs to, enabling HCS zarr output from plain stage positions without requiring WellPlatePlan. Also populate these fields in WellPlatePlan.all_well_positions and selected_well_positions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 867e9a1 commit fa4f009

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/useq/_plate.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,37 @@ def _transorm_coords(self, coords: np.ndarray) -> np.ndarray:
335335
def all_well_positions(self) -> Sequence[Position]:
336336
"""Return all wells (centers) as Position objects."""
337337
return [
338-
Position(x=x * 1000, y=y * 1000, name=name) # convert to µm
339-
for (y, x), name in zip(
340-
self.all_well_coordinates, self.all_well_names.reshape(-1), strict=False
338+
Position(
339+
x=x * 1000,
340+
y=y * 1000,
341+
name=name,
342+
plate_row=int(row),
343+
plate_col=int(col),
344+
)
345+
for (y, x), name, (row, col) in zip(
346+
self.all_well_coordinates,
347+
self.all_well_names.reshape(-1),
348+
self.all_well_indices.reshape(-1, 2),
349+
strict=False,
341350
)
342351
]
343352

344353
@cached_property
345354
def selected_well_positions(self) -> Sequence[Position]:
346355
"""Return selected wells (centers) as Position objects."""
347356
return [
348-
Position(x=x * 1000, y=y * 1000, name=name) # convert to µm
349-
for (y, x), name in zip(
350-
self.selected_well_coordinates, self.selected_well_names, strict=False
357+
Position(
358+
x=x * 1000,
359+
y=y * 1000,
360+
name=name,
361+
plate_row=int(row),
362+
plate_col=int(col),
363+
)
364+
for (y, x), name, (row, col) in zip(
365+
self.selected_well_coordinates,
366+
self.selected_well_names,
367+
self.selected_well_indices,
368+
strict=False,
351369
)
352370
]
353371

src/useq/_position.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class PositionBase(MutableModel):
4646
name: str | None = None
4747
sequence: Optional["MDASequence"] = None
4848
properties: list[PropertyTuple] | None = None
49+
plate_row: int | None = None
50+
plate_col: int | None = None
4951

5052
# excluded from serialization
5153
row: int | None = Field(default=None, exclude=True)

tests/fixtures/mda.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
"stage_positions": [
6363
{
6464
"name": null,
65+
"plate_col": null,
66+
"plate_row": null,
6567
"properties": null,
6668
"sequence": null,
6769
"x": 10.0,
@@ -70,6 +72,8 @@
7072
},
7173
{
7274
"name": "test_name",
75+
"plate_col": null,
76+
"plate_row": null,
7377
"properties": null,
7478
"sequence": {
7579
"autofocus_plan": null,

0 commit comments

Comments
 (0)