Skip to content

Commit 149fa8f

Browse files
authored
Fix handling of EDF containing only annotations (#156)
* Fix handling of EDF containing only annotations * Add changelog entry
1 parent 6f152bb commit 149fa8f

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [UNRELEASED] · YYYY-MM-DD
2+
### 🔧 Fixed
3+
- Show error message when loading EDF files containing only annotations instead of hanging in the loading dialog
4+
15
## [0.7.0] · 2026-04-01
26
### ✨ Added
37
- Use SVG icons with support for light and dark themes

src/gui/commands/open_file_gui_command.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <atomic>
3737
#include <algorithm>
38+
#include <cmath>
3839
#include <fstream>
3940

4041
namespace sigviewer
@@ -314,6 +315,28 @@ void OpenFileGuiCommand::openFileImpl (QString file_path, bool instantly)
314315

315316
ChannelManager* channel_manager (new FileChannelManager (file_signal_reader));
316317

318+
// Guard against files that contain no usable signal data (e.g. EDF files
319+
// that only contain annotations). Such files may still pass BioSig's
320+
// error check but have zero signal channels, zero samples, or an invalid
321+
// (infinite / NaN) sample rate. Without this check SigViewer would hang
322+
// later in the detrend-filter phase.
323+
{
324+
bool no_channels = (channel_manager->getNumberChannels () == 0);
325+
bool no_samples = (channel_manager->getNumberSamples () == 0);
326+
double sr = channel_manager->getSampleRate ();
327+
bool bad_rate = (!std::isfinite (sr) || sr <= 0.0);
328+
if (no_channels || no_samples || bad_rate)
329+
{
330+
delete channel_manager;
331+
QMessageBox::critical (nullptr,
332+
tr ("Cannot Open File"),
333+
tr ("The file \u201c%1\u201d contains only annotations and no signal data "
334+
"and therefore cannot be displayed.")
335+
.arg (file_name));
336+
return;
337+
}
338+
}
339+
317340
std::set<ChannelID> shown_channels;
318341
if (instantly)
319342
shown_channels = channel_manager->getChannels();

0 commit comments

Comments
 (0)