Skip to content

Commit 2a92639

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 2a92639

4 files changed

Lines changed: 27 additions & 16 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: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@
6262
"stage_positions": [
6363
{
6464
"name": null,
65-
"properties": null,
6665
"sequence": null,
6766
"x": 10.0,
6867
"y": 20.0,
6968
"z": null
7069
},
7170
{
7271
"name": "test_name",
73-
"properties": null,
7472
"sequence": {
7573
"autofocus_plan": null,
7674
"axis_order": [
@@ -105,7 +103,6 @@
105103
"step": 1.0
106104
}
107105
},
108-
"properties": null,
109106
"x": 10.0,
110107
"y": 20.0,
111108
"z": 50.0

tests/fixtures/mda.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@ metadata:
2525
stage_positions:
2626
- x: 10.0
2727
y: 20.0
28+
z: null
2829
- name: test_name
2930
sequence:
30-
axis_order:
31-
- t
32-
- p
33-
- g
34-
- c
35-
- z
3631
grid_plan:
3732
columns: 3
38-
mode: row_wise_snake
3933
rows: 2
4034
z_plan:
4135
above: 10.0

0 commit comments

Comments
 (0)