Skip to content

Commit

Permalink
Fix crop limits (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr authored Mar 24, 2022
1 parent a9f921b commit 91e7537
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Fix exporting to BrainVision with annotations starting with "BAD" or "EDGE" ([#276](https://github.com/cbrnr/mnelab/pull/276) by [Clemens Brunner](https://github.com/cbrnr))
- Exporting to .fif.gz now uses the correct extension on macOS ([#301](https://github.com/cbrnr/mnelab/pull/301) by [Clemens Brunner](https://github.com/cbrnr))
- Round physical minima and maxima to integers in EDF export ([#310](https://github.com/cbrnr/mnelab/pull/310) by [Clemens Brunner](https://github.com/cbrnr))
- Fix crop limit could exceed the signal length ([#336](https://github.com/cbrnr/mnelab/pull/336) by [Clemens Brunner](https://github.com/cbrnr))

## [0.7.0] - 2021-12-29
### Added
Expand Down
4 changes: 2 additions & 2 deletions mnelab/dialogs/crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, parent, start, stop):
self.start_checkbox.stateChanged.connect(self.toggle_start)
grid.addWidget(self.start_checkbox, 0, 0)
self._start = QDoubleSpinBox()
self._start.setMaximum(999999)
self._start.setMaximum(stop)
self._start.setValue(start)
self._start.setDecimals(2)
self._start.setSuffix(" s")
Expand All @@ -35,7 +35,7 @@ def __init__(self, parent, start, stop):
self.stop_checkbox.stateChanged.connect(self.toggle_stop)
grid.addWidget(self.stop_checkbox, 1, 0)
self._stop = QDoubleSpinBox()
self._stop.setMaximum(999999)
self._stop.setMaximum(stop)
self._stop.setValue(stop)
self._stop.setDecimals(2)
self._stop.setSuffix(" s")
Expand Down
7 changes: 3 additions & 4 deletions mnelab/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,11 @@ def edit_events(self):

def crop(self):
"""Crop data."""
fs = self.model.current["data"].info["sfreq"]
length = self.model.current["data"].n_times / fs
dialog = CropDialog(self, 0, length)
stop = self.model.current["data"].times[-1]
dialog = CropDialog(self, 0, stop)
if dialog.exec():
self.auto_duplicate()
self.model.crop(dialog.start or 0, dialog.stop)
self.model.crop(max(dialog.start, 0), min(dialog.stop, stop))

def append_data(self):
"""Concatenate raw data objects to current one."""
Expand Down

0 comments on commit 91e7537

Please sign in to comment.