v2.0.0
Loading...
Searching...
No Matches
FIFFLIB::FiffAnnotations Class Reference

Container for FIFF annotations with I/O in JSON and CSV formats. More...

#include <fiff_annotations.h>

Public Types

typedef QSharedPointer< FiffAnnotationsSPtr
typedef QSharedPointer< const FiffAnnotationsConstSPtr

Public Member Functions

 FiffAnnotations ()
int size () const
bool isEmpty () const
const FiffAnnotationoperator[] (int index) const
FiffAnnotationoperator[] (int index)
void append (const FiffAnnotation &annotation)
void append (double onset, double duration, const QString &description, const QStringList &channelNames=QStringList(), const QString &comment=QString())
void remove (int index)
void clear ()
const QVector< FiffAnnotation > & toVector () const
int onsetToSample (int index, double sfreq, int firstSample=0) const
int endToSample (int index, double sfreq, int firstSample=0) const
FiffAnnotations select (const QString &descriptionFilter) const
FiffAnnotations selectByChannel (const QString &channelName) const
FiffAnnotations crop (double tmin, double tmax) const

Static Public Member Functions

static FiffAnnotations readJson (const QString &path)
static bool writeJson (const QString &path, const FiffAnnotations &annot)
static FiffAnnotations readCsv (const QString &path)
static bool writeCsv (const QString &path, const FiffAnnotations &annot)
static FiffAnnotations read (const QString &path)
static bool write (const QString &path, const FiffAnnotations &annot)

Detailed Description

Container for FIFF annotations with I/O in JSON and CSV formats.

Definition at line 79 of file fiff_annotations.h.

Member Typedef Documentation

◆ ConstSPtr

Const shared pointer type.

Definition at line 83 of file fiff_annotations.h.

◆ SPtr

Shared pointer type.

Definition at line 82 of file fiff_annotations.h.

Constructor & Destructor Documentation

◆ FiffAnnotations()

FiffAnnotations::FiffAnnotations ( )

Constructs an empty FiffAnnotations object.

Definition at line 63 of file fiff_annotations.cpp.

Member Function Documentation

◆ append() [1/2]

void FiffAnnotations::append ( const FiffAnnotation & annotation)

Appends an annotation.

Parameters
[in]annotationThe annotation to append.

Definition at line 97 of file fiff_annotations.cpp.

◆ append() [2/2]

void FiffAnnotations::append ( double onset,
double duration,
const QString & description,
const QStringList & channelNames = QStringList(),
const QString & comment = QString() )

Appends an annotation by fields.

Parameters
[in]onsetOnset in seconds.
[in]durationDuration in seconds.
[in]descriptionDescription label.
[in]channelNamesChannel names (empty for global).
[in]commentOptional comment.

Definition at line 104 of file fiff_annotations.cpp.

◆ clear()

void FiffAnnotations::clear ( )

Removes all annotations.

Definition at line 125 of file fiff_annotations.cpp.

◆ crop()

FiffAnnotations FiffAnnotations::crop ( double tmin,
double tmax ) const

Returns annotations overlapping [tmin, tmax], clipping partially overlapping ones.

Parameters
[in]tminStart time in seconds.
[in]tmaxEnd time in seconds.
Returns
Cropped annotations.

Definition at line 180 of file fiff_annotations.cpp.

◆ endToSample()

int FiffAnnotations::endToSample ( int index,
double sfreq,
int firstSample = 0 ) const

Converts end (onset+duration) of annotation at index to a sample number.

Parameters
[in]indexAnnotation index.
[in]sfreqSampling frequency in Hz.
[in]firstSampleFirst sample offset.
Returns
Sample number.

Definition at line 146 of file fiff_annotations.cpp.

◆ isEmpty()

bool FiffAnnotations::isEmpty ( ) const

Returns true if no annotations are stored.

Returns
True if empty.

Definition at line 76 of file fiff_annotations.cpp.

◆ onsetToSample()

int FiffAnnotations::onsetToSample ( int index,
double sfreq,
int firstSample = 0 ) const

Converts onset of annotation at index to a sample number.

Parameters
[in]indexAnnotation index.
[in]sfreqSampling frequency in Hz.
[in]firstSampleFirst sample offset.
Returns
Sample number.

Definition at line 139 of file fiff_annotations.cpp.

◆ operator[]() [1/2]

FiffAnnotation & FiffAnnotations::operator[] ( int index)

Subscript operator.

Parameters
[in]indexIndex of the annotation.
Returns
Reference to the annotation.

Definition at line 90 of file fiff_annotations.cpp.

◆ operator[]() [2/2]

const FiffAnnotation & FiffAnnotations::operator[] ( int index) const

Const subscript operator.

Parameters
[in]indexIndex of the annotation.
Returns
Const reference to the annotation.

Definition at line 83 of file fiff_annotations.cpp.

◆ read()

FiffAnnotations FiffAnnotations::read ( const QString & path)
static

Auto-detects format and reads annotations.

Parameters
[in]pathFile path (.json or .csv).
Returns
Parsed annotations.

Definition at line 357 of file fiff_annotations.cpp.

◆ readCsv()

FiffAnnotations FiffAnnotations::readCsv ( const QString & path)
static

Reads annotations from a CSV file.

Parameters
[in]pathFile path.
Returns
Parsed annotations.

Definition at line 289 of file fiff_annotations.cpp.

◆ readJson()

FiffAnnotations FiffAnnotations::readJson ( const QString & path)
static

Reads annotations from a JSON file.

Parameters
[in]pathFile path.
Returns
Parsed annotations.

Definition at line 208 of file fiff_annotations.cpp.

◆ remove()

void FiffAnnotations::remove ( int index)

Removes the annotation at the given index.

Parameters
[in]indexIndex to remove.

Definition at line 118 of file fiff_annotations.cpp.

◆ select()

FiffAnnotations FiffAnnotations::select ( const QString & descriptionFilter) const

Selects annotations whose description starts with the filter string.

Parameters
[in]descriptionFilterPrefix to match.
Returns
Filtered annotations.

Definition at line 154 of file fiff_annotations.cpp.

◆ selectByChannel()

FiffAnnotations FiffAnnotations::selectByChannel ( const QString & channelName) const

Selects annotations that reference the given channel name.

Parameters
[in]channelNameChannel name to match.
Returns
Filtered annotations.

Definition at line 167 of file fiff_annotations.cpp.

◆ size()

int FiffAnnotations::size ( ) const

Returns the number of annotations.

Returns
Number of annotations.

Definition at line 69 of file fiff_annotations.cpp.

◆ toVector()

const QVector< FiffAnnotation > & FiffAnnotations::toVector ( ) const

Returns a const reference to the underlying vector.

Returns
Const reference to annotation vector.

Definition at line 132 of file fiff_annotations.cpp.

◆ write()

bool FiffAnnotations::write ( const QString & path,
const FiffAnnotations & annot )
static

Auto-detects format and writes annotations.

Parameters
[in]pathFile path (.json or .csv).
[in]annotAnnotations to write.
Returns
True on success.

Definition at line 377 of file fiff_annotations.cpp.

◆ writeCsv()

bool FiffAnnotations::writeCsv ( const QString & path,
const FiffAnnotations & annot )
static

Writes annotations to a CSV file.

Parameters
[in]pathFile path.
[in]annotAnnotations to write.
Returns
True on success.

Definition at line 336 of file fiff_annotations.cpp.

◆ writeJson()

bool FiffAnnotations::writeJson ( const QString & path,
const FiffAnnotations & annot )
static

Writes annotations to a JSON file.

Parameters
[in]pathFile path.
[in]annotAnnotations to write.
Returns
True on success.

Definition at line 254 of file fiff_annotations.cpp.


The documentation for this class was generated from the following files: