v2.0.0
Loading...
Searching...
No Matches
fiff_events.h
Go to the documentation of this file.
1//=============================================================================================================
20
21#ifndef FIFF_EVENTS_H
22#define FIFF_EVENTS_H
23
24//=============================================================================================================
25// INCLUDES
26//=============================================================================================================
27
28#include "fiff_global.h"
29
30//=============================================================================================================
31// QT INCLUDES
32//=============================================================================================================
33
34#include <QString>
35
36//=============================================================================================================
37// EIGEN INCLUDES
38//=============================================================================================================
39
40#include <Eigen/Core>
41
42#include <QList>
43#include <QMap>
44
45#include <optional>
46
47//=============================================================================================================
48// FORWARD DECLARATIONS
49//=============================================================================================================
50
51class QIODevice;
52
53//=============================================================================================================
54// DEFINE NAMESPACE FIFFLIB
55//=============================================================================================================
56
57namespace FIFFLIB
58{
59
60// Forward declaration
61class FiffRawData;
62struct AverageCategory;
63
64//=============================================================================================================
76{
77public:
78 //=========================================================================================================
83
84 //=========================================================================================================
92 explicit FiffEvents(QIODevice& p_IODevice);
93
94 //=========================================================================================================
107 static bool read(const QString& t_sEventName,
108 const QString& t_fileRawName,
109 FiffEvents& p_Events);
110
111 //=========================================================================================================
120 static bool read_from_fif(QIODevice& p_IODevice,
121 FiffEvents& p_Events);
122
123 //=========================================================================================================
132 static bool read_from_ascii(QIODevice& p_IODevice,
133 FiffEvents& p_Events);
134
135 //=========================================================================================================
143 bool write_to_fif(QIODevice& p_IODevice) const;
144
145 //=========================================================================================================
154 bool write_to_ascii(QIODevice& p_IODevice,
155 float sfreq = 0.0f) const;
156
157 //=========================================================================================================
170 static bool detect_from_raw(const FiffRawData& raw,
171 FiffEvents& p_Events,
172 const QString& triggerCh = QString("STI 014"),
173 unsigned int triggerMask = 0xFFFFFFFF,
174 bool leadingEdge = true);
175
176 //=========================================================================================================
182 inline int num_events() const;
183
184 //=========================================================================================================
190 inline bool is_empty() const;
191
192 //=========================================================================================================
201 static bool matchEvent(const AverageCategory& cat,
202 const Eigen::MatrixXi& events,
203 int eventIdx);
204
205 //=========================================================================================================
215 FiffEvents pick(const QList<int>& include, const QList<int>& exclude = {}, bool step = false) const;
216
217 //=========================================================================================================
227 FiffEvents merge(const QList<int>& ids, int newId, bool replaceEvents = true) const;
228
229 //=========================================================================================================
237 QMap<int, int> count(const QList<int>& ids = {}) const;
238
239 //=========================================================================================================
249 static FiffEvents concatenate(const QList<FiffEvents>& events, const QList<int>& firstSamps, const QList<int>& lastSamps);
250
251 //=========================================================================================================
263 static FiffEvents find_stim_steps(const Eigen::MatrixXi& stimData,
264 int firstSamp,
265 std::optional<int> padStart = std::nullopt,
266 std::optional<int> padStop = std::nullopt,
267 int merge = 0);
268
269 //=========================================================================================================
283 static FiffEvents make_fixed_length(const FiffRawData& raw,
284 int id = 1,
285 double start = 0.0,
286 double stop = -1.0,
287 double duration = 1.0,
288 bool firstSamp = true,
289 double overlap = 0.0);
290
291 Eigen::MatrixXi events;
292};
293
294} // NAMESPACE
295
296//=============================================================================================================
297// INLINE DEFINITIONS
298//=============================================================================================================
299
301{
302 return static_cast<int>(events.rows());
303}
304
305//=============================================================================================================
306
308{
309 return events.rows() == 0;
310}
311
312#endif // FIFF_EVENTS_H
Export/import macros and build-info accessors for the FIFFLIB shared library.
#define FIFFSHARED_EXPORT
Definition fiff_global.h:44
FIFF file I/O, in-memory data structures and high-level readers/writers.
FIFF event list: (sample, prev, new) integer triples with read / write / detect / filter helpers.
Definition fiff_events.h:76
int num_events() const
Eigen::MatrixXi events
bool write_to_ascii(QIODevice &p_IODevice, float sfreq=0.0f) const
static bool matchEvent(const AverageCategory &cat, const Eigen::MatrixXi &events, int eventIdx)
static bool read(const QString &t_sEventName, const QString &t_fileRawName, FiffEvents &p_Events)
static bool read_from_fif(QIODevice &p_IODevice, FiffEvents &p_Events)
FiffEvents(QIODevice &p_IODevice)
bool write_to_fif(QIODevice &p_IODevice) const
FiffEvents pick(const QList< int > &include, const QList< int > &exclude={}, bool step=false) const
static bool detect_from_raw(const FiffRawData &raw, FiffEvents &p_Events, const QString &triggerCh=QString("STI 014"), unsigned int triggerMask=0xFFFFFFFF, bool leadingEdge=true)
bool is_empty() const
static bool read_from_ascii(QIODevice &p_IODevice, FiffEvents &p_Events)
One averaging category in an MNE-C ave-description file: trigger logic, timing window,...
Continuous FIFF raw recording: FiffInfo plus a random-access directory of FIFF_DATA_BUFFER tags.