Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crop limits #336

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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