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

GridPlan problems #149

Closed wl-stepp closed 8 months ago

wl-stepp commented 10 months ago

useq-schema 0.4.7

I think the sequence setup in the documentation does not work anymore:

>>> from useq import MDASequence, Position, Channel, TIntervalDuration
>>> seq = MDASequence(
...     time_plan={"interval": 0.1, "loops": 2},
...     stage_positions=[(1, 1, 1)],
...     grid_plan={"rows": 2, "cols": 2},
...     z_plan={"range": 3, "step": 1},
...     channels=[{"config": "DAPI", "exposure": 1}]
... )

Works for me if I put "columns" instead of "cols".

Another small problem I see is for this sequence:

>>> seq = MDASequence(axis_order="gtc",time_plan={"interval": 1, "loops": 2},channels=[{"config": "DAPI", "exposure": 1}],grid_plan={"rows": 2, "columns": 2})
>>> for event in seq:
...    print(event)
...
index=mappingproxy({'t': 0, 'g': 0, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=-0.5 y_pos=0.5
index=mappingproxy({'t': 1, 'g': 0, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=-0.5 y_pos=0.5
index=mappingproxy({'t': 0, 'g': 1, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=0.5 y_pos=0.5
index=mappingproxy({'t': 1, 'g': 1, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=0.5 y_pos=0.5
index=mappingproxy({'t': 0, 'g': 2, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=0.5 y_pos=-0.5
index=mappingproxy({'t': 1, 'g': 2, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=0.5 y_pos=-0.5
index=mappingproxy({'t': 0, 'g': 3, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=-0.5 y_pos=-0.5
index=mappingproxy({'t': 1, 'g': 3, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=-0.5 y_pos=-0.5

Might no be a very typical setup with axis order "gtc, but note how the min_start_time resets for every g index. This leads to the first time series at position 0 respecting the interval, while all later positions are acquired at max speed.

wl-stepp commented 10 months ago

For overlaps, I don't think those are implemented yet, correct?

>>> seq = MDASequence(grid_plan={"rows": 2, "columns": 2, "overlap": (0.2, 0.2)})
>>> for event in seq:
...     print(event)
... 
index=mappingproxy({'g': 0}) x_pos=-0.499 y_pos=0.499
index=mappingproxy({'g': 1}) x_pos=0.499 y_pos=0.499
index=mappingproxy({'g': 2}) x_pos=0.499 y_pos=-0.499
index=mappingproxy({'g': 3}) x_pos=-0.499 y_pos=-0.499
>>> seq = MDASequence(grid_plan={"rows": 2, "columns": 2, "overlap": (0.1, 0.1)}) 
>>> for event in seq:
...     print(event)
... 
index=mappingproxy({'g': 0}) x_pos=-0.4995 y_pos=0.4995
index=mappingproxy({'g': 1}) x_pos=0.4995 y_pos=0.4995
index=mappingproxy({'g': 2}) x_pos=0.4995 y_pos=-0.4995
index=mappingproxy({'g': 3}) x_pos=-0.4995 y_pos=-0.4995

x_pos and y_pos stay the same for different overlap settings. I see the same for a specific value for the fov size.

fdrgsp commented 10 months ago

I think the sequence setup in the documentation does not work anymore

Thanks Willi, I'll fix the docs!

Another small problem I see is for this sequence

That's definitely not the intended behavior! Thanks, I'll have a look!

For overlaps, I don't think those are implemented yet, correct?

I will update the docs for that as well but the overlap is expressed in percentage so 0.1 or 0.2 won't do much. Does it make sense?

wl-stepp commented 10 months ago

Ok, thanks. But then there is a problem in the GridPlanWidget in the useq_widgets. Because if I set 50% overlap there I get 0.5 overlap in the acquisition. Can you check that?

wl-stepp commented 10 months ago

https://github.com/pymmcore-plus/pymmcore-widgets/blob/8135e080a2bf9cd493abde4dddf33f647abe9bb8/src/pymmcore_widgets/useq_widgets/_grid.py#L229

To be honest, for me having overlap 0 to 1 would be more intuitive. But as long as it's consistent...

tlambert03 commented 10 months ago

Yeah I kinda prefer 0-1 as well

tlambert03 commented 8 months ago

@fdrgsp is this resolved now with https://github.com/pymmcore-plus/pymmcore-widgets/pull/249?

fdrgsp commented 8 months ago

@fdrgsp is this resolved now with pymmcore-plus/pymmcore-widgets#249?

I think everything is fixed but this:

Another small problem I see is for this sequence:

>> seq = MDASequence(axis_order="gtc",time_plan={"interval": 1, "loops": 2},channels=[{"config": "DAPI", "exposure": 1}],grid_plan={"rows": 2, "columns": 2})
>> for event in seq:
...    print(event)
...
index=mappingproxy({'t': 0, 'g': 0, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=-0.5 y_pos=0.5
index=mappingproxy({'t': 1, 'g': 0, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=-0.5 y_pos=0.5
index=mappingproxy({'t': 0, 'g': 1, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=0.5 y_pos=0.5
index=mappingproxy({'t': 1, 'g': 1, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=0.5 y_pos=0.5
index=mappingproxy({'t': 0, 'g': 2, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=0.5 y_pos=-0.5
index=mappingproxy({'t': 1, 'g': 2, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=0.5 y_pos=-0.5
index=mappingproxy({'t': 0, 'g': 3, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=0.0 x_pos=-0.5 y_pos=-0.5
index=mappingproxy({'t': 1, 'g': 3, 'c': 0}) channel=Channel(config='DAPI') exposure=1.0 min_start_time=1.0 x_pos=-0.5 y_pos=-0.5

Might no be a very typical setup with axis order "gtc, but note how the min_start_time resets for every g index. This leads to the first time series at position 0 respecting the interval, while all later positions are acquired at max speed.

I will open an issue just for that and close this.