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

Add support for string time series #138

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sigviewer.pro.user
*.o
tmp/
bin/
build/
.qmake.stash
Makefile
src/Makefile
2 changes: 1 addition & 1 deletion sigviewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CONFIG(release, debug|release) {
UI_DIR = $$BUILD_DIR/release
}

CONFIG += warn_on link_prl qt thread c++11
CONFIG += warn_on link_prl qt thread c++17

macx {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
Expand Down
2 changes: 1 addition & 1 deletion src/editing_commands/new_event_undo_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void NewEventUndoCommand::undo ()
XDFdata->userCreatedEvents.pop_back();
if (XDFdata->userCreatedEvents.empty())
{
XDFdata->streams.pop_back();
XDFdata->streams.erase(XDFdata->userAddedStream);
XDFdata->userAddedStream = 0;
}
}
Expand Down
35 changes: 27 additions & 8 deletions src/file_handling_impl/biosig_basic_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,33 @@ BiosigBasicHeader::BiosigBasicHeader (QString file_format, QString const& file_p
: BasicHeader (file_path),
number_samples_ (XDFdata->totalLen)
{
if (XDFdata->dictionary.size())
std::unordered_set<std::string> event_types;
for (const auto& [stream_id, stream] : XDFdata->streams)
{
for (unsigned index = 0; index < XDFdata->dictionary.size(); index++)
if (std::holds_alternative<std::vector<std::vector<std::string>>>(
stream.time_series))
{
//below we use index+1 because in SigViewer, 0 is reserved for a special event type.
//thus we count from 1
user_defined_event_map_[index + 1] = QString::fromStdString(XDFdata->dictionary[index]);
const auto& time_series = std::get<std::vector<std::vector<std::string>>>(
stream.time_series);
for (const std::vector<std::string>& channel : time_series)
{
for (const std::string& event : channel)
{
event_types.insert(event);
}
}
}
}

unsigned index = 0;
for (const std::string& event_type : event_types)
{
//below we use index+1 because in SigViewer, 0 is reserved for a special event type.
//thus we count from 1
user_defined_event_map_[index + 1] = QString::fromStdString(event_type);
index++;
}

QString fileType = "XDF v" + QString::number(XDFdata->version, 'f', 1);
setFileTypeString (fileType);

Expand Down Expand Up @@ -89,11 +106,13 @@ void BiosigBasicHeader::readChannelsInfo (HDRTYPE const* raw_header)
//-------------------------------------------------------------------------
void BiosigBasicHeader::readChannelsInfo (QString file_format)
{
unsigned ch = 0;
for (unsigned channel_index = 0; channel_index < XDFdata->totalCh; channel_index++)
int channel_index = 0;
for (const auto& [stream_id, stream] : XDFdata->streams)
{
if (stream.info.channel_format == "string") continue;
QSharedPointer<SignalChannel> channel(new SignalChannel(channel_index, file_format));
addChannel(ch++, channel);
addChannel(channel_index, channel);
channel_index++;
}
}

Expand Down
Loading