EDF Support in FileWriter broken
Closed this issue · 2 comments
Issue
Setting File Writer
node to EDF
format creates a zero bytes file on disk.
The according node stays in a re-initialization loop, because the write fails:
studio/src/Engine/Graph/FileWriterNode.cpp
Lines 269 to 273 in 73f93f1
Problem 1
studio/src/Engine/DSP/ChannelFileWriter.cpp
Line 271 in 73f93f1
edfclose_file()
actually returns 0 on success.
Solution:
So the line should be: success = success && edfclose_file(handle) == 0;
This will create a ~2kb file on disk which seems to get refreshed with exactly one last sample.
Problem 2
Calling edfopen_file_writeonly()
will recreate the file from scratch. It does NOT append to an existing file.
studio/src/Engine/DSP/ChannelFileWriter.cpp
Lines 246 to 273 in 73f93f1
Solution:
Both, edfopen_file_writeonly()
and edfclose_file()
must NOT be called inside WriteSamplesEDF()
which is supposed to append the last buffer to the file. But instead be called once before the writing starts (respectively once after the writing ends). For reference, see how WriteSamplesCSV()
works:
studio/src/Engine/DSP/ChannelFileWriter.cpp
Line 157 in 73f93f1
It takes an existing FILE handle and appends to it.
It also has a dedicated version that writes the header once:
studio/src/Engine/DSP/ChannelFileWriter.cpp
Line 101 in 73f93f1
I'm on 1.6.0, and this is still broken for me. Neuromore just crashes, I don't get anything to the terminal, which is interesting - no mention of a segfault or unhandled exception etc. Just goes blank and exits. I may be able t break out the debugger later. All I have is a basic OpenBCI via BrainFlow to the EDF writer:
As of 13797ce, am getting the "Device not connected" error in lieu of a crash. Interestingly trying to stream data from my Cyton results in this; whilst using the synthetic board and it outputs a file fine (both backed by Brainflow input node). I've also tried just dividing the data through by 1000 in the classifier, given the issues with min/max in #138 (I get values in excess of 10^6 from the Cyton), but problem still persists.
Also finding it hard to debug this, as I keep getting the "realtime functionality lost" message when the debugger locks up the application. Any tips on this?