pymmcore-plus / useq-schema

An implementation agnostic schema for describing a sequence of events during a multi-dimensional imaging acquisition.
https://pymmcore-plus.github.io/useq-schema/
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

feat: add well-plate model #166

Closed tlambert03 closed 3 months ago

tlambert03 commented 3 months ago
import numpy as np

import useq

pp = useq.WellPlatePlan(
    # plate object, string key, or number of wells
    plate=96,
    a1_center_xy=(100, 200),
    # rotation can be expressed as a string or number (degrees)
    # or a rotation matrix if desired... but not necessary
    rotation=-10,
    # selected_wells is any 1-2D indexing expression.
    # Here we select each well with a %20 chance
    selected_wells=np.where(np.random.rand(8, 12) > 0.8),
    well_points_plan=useq.RandomPoints(
        num_points=10, fov_height=0.85, fov_width=1, allow_overlap=False
    ),
)
pp.plot()

Figure_1

tlambert03 commented 3 months ago

@fdrgsp, I touched this up a bit. ~It still needs well_points_plan to be implemented~ ... (added)

tlambert03 commented 3 months ago

@fdrgsp, I just added a way to register plates: useq.register_well_plates()

it takes either kwargs, or a mapping, and values can either be a dict, or a WellPlate instance

    useq.register_well_plates(
        {
            "silly": useq.WellPlate(
                rows=1, columns=1, well_spacing=1, circular_wells=False
            )
        },
        myplate={"rows": 8, "columns": 8, "well_spacing": 9},
    )

so pymmcore widgets could load a user database, and then register it with useq

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 82.66667% with 39 lines in your changes missing coverage. Please review.

Project coverage is 95.70%. Comparing base (1657db7) to head (7366f82). Report is 10 commits behind head on main.

Files Patch % Lines
src/useq/_plate.py 81.73% 38 Missing :warning:
src/useq/_position.py 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #166 +/- ## ========================================== - Coverage 98.28% 95.70% -2.58% ========================================== Files 14 15 +1 Lines 874 1048 +174 ========================================== + Hits 859 1003 +144 - Misses 15 45 +30 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tlambert03 commented 3 months ago

shall we merge it and improve in later PRs @fdrgsp?

fdrgsp commented 3 months ago

shall we merge it and improve in later PRs @fdrgsp?

Yes, I think so. We can add the better position naming after (https://github.com/pymmcore-plus/useq-schema/pull/166#discussion_r1660311170).

I'm working on using this WellPlatePlan in the HCS Wizard and I'll open a new PR soon.

tlambert03 commented 3 months ago

We can add the better position naming after (https://github.com/pymmcore-plus/useq-schema/pull/166#discussion_r1660311170).

yeah, and #169 was also partially with naming in mind (though it's probably not immediately obvious)