Skip to main content

Fiff Library (FIFFLIB)

The Fiff library implements the FIFF (Functional Image File Format) used throughout the MNE ecosystem for MEG/EEG data. It provides file I/O, in-memory data containers, channel and sensor metadata, digitisation points, coordinate transforms, SSP projections, and CTF compensation — everything required to read, manipulate, and write neurophysiological recordings. All classes reside in the FIFFLIB namespace and depend only on Qt and Eigen.

Architecture

Class Inventory

File I/O

ClassDescriptionMNE-PythonMNE-C
FiffStreamLow-level tag-based FIFF file reader/writer — open, read/write individual tags, navigate directory treemne._fiff.open.fiff_open()fiffFile
FiffIOHigh-level convenience reader/writer for complete measurement filesmne.io.read_raw_fif()mne_read_*() family
FiffTagSingle data tag: kind, type, size, position, and typed payloadmne._fiff.tag.TagfiffTag
FiffDirEntryDirectory entry describing a tag's location within the filemne._fiff.treefiffDirEntry
FiffDirNodeTree node representing a block in the FIFF directory hierarchy (e.g., FIFFB_MEAS, FIFFB_MNE_ENV)mne._fiff.tree.dir_tree_find()fiffDirTree
FiffIdUniversally unique file/block identifier (UUID + timestamp)mne._fiff.tagfiffId

Data Containers

ClassDescriptionMNE-PythonMNE-C
FiffRawDataRaw continuous MEG/EEG data with lazy reading, ring-buffer support, projection, and compensationmne.io.RawmneRawData
FiffEvokedAveraged/evoked response data (channels × time) with stimulus metadatamne.EvokedmneEvoked
FiffEvokedSetCollection of multiple evoked data sets read from a single filemne.read_evokeds()
FiffCovNoise or data covariance matrix (dense or diagonal) with eigendecomposition and channel namesmne.CovariancemneCov
FiffEventsEvent array (sample × 3 matrix: sample, value-before, value-after)mne.read_events()
FiffNamedMatrixMatrix with labelled rows and columns, shared-data semanticsInternalmneNamedMatrix
FiffSparseMatrixSparse matrix in Compressed Column/Row Storagescipy.sparse equivalentmneSparseMatrix

Channel & Sensor Information

ClassDescriptionMNE-PythonMNE-C
FiffInfoComplete measurement metadata: channels, sampling rate, SSP projections, CTF data, coordinate transforms, subject info, datemne.InfomneMeasData
FiffInfoBaseLightweight base class for measurement info (channel list, bads, sampling rate)mne.Info (base interface)
FiffChInfoPer-channel metadata: name, type (MEG/EEG/STIM/…), unit, calibration, locationmne.Info['chs'][i]fiffChInfo
FiffChPosSensor position and orientation: integration-point location + two ex/ey vectorsmne.Info['chs'][i]['loc']fiffChPos

Digitisation & Spatial Data

ClassDescriptionMNE-PythonMNE-C
FiffDigPointSingle digitised point: kind (cardinal/HPI/EEG/extra), ident, 3D positionmne._fiff._digitization.DigPointfiffDigPoint
FiffDigPointSetOrdered collection of digitiser points with coordinate transform supportmne.Info['dig']
FiffDigitizerDataDigitiser point set with associated head-to-device transformationmne.Info['dig'] + transforms
FiffCoordTransRigid-body coordinate transformation (4 × 4 homogeneous matrix) between two framesmne.transforms.TransformfiffCoordTrans
FiffCoordTransSetChain of transforms (e.g., head → MRI → MNI Talairach)mne.transforms collection

Calibration & Correction

ClassDescriptionMNE-PythonMNE-C
FiffProjSignal Space Projection (SSP) operator — one projection vector with kind and descriptionmne.ProjectionmneProj
FiffCtfCompCTF software gradient compensation data: compensation matrix and calibrationmne.Info['comps']mneCtfComp

Key utility methods on FiffInfo:

  • make_compensator() — create a compensation matrix for a given grade
  • get_current_comp() — query active CTF compensation setting
  • make_projector() — build an SSP projector from active projections
  • pick_types() / pick_channels() — channel selection by type or name

Constants & Types

HeaderDescriptionMNE-PythonMNE-C
fiff_constants.hAll FIFF block, tag, and value identifiers (FIFFB_*, FIFF_*, FIFFV_*)mne._fiff.constants.FIFFmne_fiff.h
fiff_types.hPrimitive FIFF types: fiff_int_t, fiff_float_t, fiff_byte_t, DAU pack typesmne_types.h
fiff_explain.hHuman-readable string maps for FIFF constants (block type → name, tag kind → name)

Usage Example

#include <fiff/fiff.h>

using namespace FIFFLIB;

// Open a raw FIFF file
QFile file("sample_audvis_raw.fif");
FiffStream::SPtr stream(new FiffStream(&file));
FiffRawData raw(stream);

// Query measurement info
qDebug() << "Sample rate:" << raw.info.sfreq;
qDebug() << "Channels:" << raw.info.nchan;
qDebug() << "Bad channels:" << raw.info.bads;

// Read a time window [0 s, 10 s]
Eigen::MatrixXd data;
Eigen::RowVectorXd times;
raw.read_raw_segment(data, times, 0, raw.info.sfreq * 10);

// Apply SSP projectors
FiffProj::activate_projs(raw.info.projs);
Eigen::MatrixXd proj;
int nproj;
FiffProj::make_projector(raw.info.projs, raw.info.ch_names, proj, nproj);
data = proj * data;

// Read evoked data
QList<FiffEvoked> evokeds = FiffEvoked::read("sample_audvis-ave.fif");

// Read noise covariance
FiffCov cov = FiffCov::read("sample_audvis-cov.fif");

Doxygen Reference

For method signatures, inheritance diagrams, and source-level documentation see the auto-generated FIFFLIB namespace in the Doxygen API reference.

See Also