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

Container for FiffAnnotation entries with FIFF, JSON and CSV serializers. 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 FiffAnnotation entries with FIFF, JSON and CSV serializers.

Read and written under FIFFB_MNE_ANNOTATIONS so the annotation list travels with the FIFF file. The JSON and CSV exporters let the same annotations be consumed by BIDS sidecars and by external scoring tools that do not understand FIFF directly.

Definition at line 78 of file fiff_annotations.h.

Member Typedef Documentation

◆ ConstSPtr

Const shared pointer type.

Definition at line 82 of file fiff_annotations.h.

◆ SPtr

Shared pointer type.

Definition at line 81 of file fiff_annotations.h.

Constructor & Destructor Documentation

◆ FiffAnnotations()

FiffAnnotations::FiffAnnotations ( )

Constructs an empty FiffAnnotations object.

Definition at line 45 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 79 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 86 of file fiff_annotations.cpp.

◆ clear()

void FiffAnnotations::clear ( )

Removes all annotations.

Definition at line 107 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 162 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 128 of file fiff_annotations.cpp.

◆ isEmpty()

bool FiffAnnotations::isEmpty ( ) const

Returns true if no annotations are stored.

Returns
True if empty.

Definition at line 58 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 121 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 72 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 65 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 339 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 271 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 190 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 100 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 136 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 149 of file fiff_annotations.cpp.

◆ size()

int FiffAnnotations::size ( ) const

Returns the number of annotations.

Returns
Number of annotations.

Definition at line 51 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 114 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 359 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 318 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 236 of file fiff_annotations.cpp.


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