Skip to content

Commit

Permalink
channel: fix a bug when sampling within the last element
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Nov 17, 2023
1 parent 38cf4e1 commit df71192
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* Shortcuts `"r"`, `"g"`, and `"b"` can now be used for plotting single color channels in addition to `"red"`, `"green"`, and `"blue"`.
* Two-channel visualizations can be plotted using `"rg"`, `"gb"`, or `"rb"`.

#### Bug fixes

* Fixed a bug in `downsampled_like` that would fail to indicate a lack of overlap between the low frequency and high frequency channel when sampling within the last sample of the low frequency channel.

#### Improvements

* Kymographs consisting of a single scan line now return a valid `line_time_seconds`. This allows certain downstream functionality, such as `Kymo.plot()`.
Expand Down
2 changes: 1 addition & 1 deletion lumicks/pylake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def downsampled_like(self, other_slice, reduce=np.mean):
timestamps = other_slice.timestamps
delta_time = np.diff(timestamps)

if self._src.start >= timestamps[-1] or self._src.stop <= timestamps[0]:
if self._src.start > (timestamps[-1] - delta_time[-1]) or self._src.stop <= timestamps[0]:
raise RuntimeError("No overlap between slices.")

# When the frame rate changes, one frame is very long due to the delay of the camera. It
Expand Down
10 changes: 8 additions & 2 deletions lumicks/pylake/tests/test_channels/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,17 @@ def test_downsampling_like():
):
s.downsampled_like(s)

for offset in (-4 * 4, t_downsampled[-1] + 1):
timestep = 4
for offset in (with_offset(-4 * timestep), t_downsampled[-1] - timestep + 1):
with pytest.raises(RuntimeError, match="No overlap between slices"):
s = channel.Slice(channel.Continuous(np.array([1, 2, 3, 4]), with_offset(offset), 4))
s = channel.Slice(channel.Continuous(np.array([1, 2, 3, 4]), offset, timestep))
s.downsampled_like(reference)

for offset in (with_offset(-4 * timestep + 1), t_downsampled[-1] - timestep):
print(offset - 1592916040906356300)
s = channel.Slice(channel.Continuous(np.array([1, 2, 3, 4]), offset, timestep))
s.downsampled_like(reference)


def test_channel_plot():
def testLine(x, y):
Expand Down

0 comments on commit df71192

Please sign in to comment.