Skip to main content

InvSourceEstimateIO

Namespace: INVLIB  ·  Library: Inverse Library

Python equivalent

mne.SourceEstimate.save / read in MNE-Python.

#include <inv/inv_source_estimate_io.h>

class INVLIB::InvSourceEstimateIO

Extended I/O methods for InvSourceEstimate.

src/examples/ex_inv_api/main.cpp
InvSourceEstimateIO::writeCsv(stc, tmp.filePath("v1-dspm.csv"));
const InvSourceEstimate fromCsv = InvSourceEstimateIO::readCsv(tmp.filePath("v1-dspm.csv"));
QFile stcFile(tmp.filePath("v1-dspm-lh.stc"));
InvSourceEstimate(stc).write(stcFile); // MNE .stc format, readable by mne.read_source_estimate
QFile stcBack(stcFile.fileName());
const InvSourceEstimate fromStc(stcBack);

Static Methods​

writeCsv(stc, sPath, cDelim)​

Export source estimate to CSV format.

Writes a header line with vertex indices, then one row per time point. First column is time (seconds).

Parameters:

  • stc : const InvSourceEstimate & Source estimate to export.

  • sPath : const QString & Output file path.

  • cDelim : char Delimiter character (default comma).

Returns:

  • bool — true if successful.

readCsv(sPath, cDelim)​

Read source estimate from CSV format.

Parameters:

  • sPath : const QString & Input file path.

  • cDelim : char Delimiter character (default comma).

Returns:


writeMatrix(stc, sPath)​

Export source estimate as a tab-separated matrix for easy import.

No header; pure numeric matrix (n_vertices × n_times).

Parameters:

  • stc : const InvSourceEstimate & Source estimate to export.

  • sPath : const QString & Output file path.

Returns:

  • bool — true if successful.

Example​

Used in examples​

ex_inv_api​

Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.

src/examples/ex_inv_api/main.cpp, line 314
InvSourceEstimateIO::writeCsv(stc, tmp.filePath("v1-dspm.csv"));
const InvSourceEstimate fromCsv = InvSourceEstimateIO::readCsv(tmp.filePath("v1-dspm.csv"));
QFile stcFile(tmp.filePath("v1-dspm-lh.stc"));
InvSourceEstimate(stc).write(stcFile); // MNE .stc format, readable by mne.read_source_estimate
QFile stcBack(stcFile.fileName());
const InvSourceEstimate fromStc(stcBack);
ok &= expect(fromCsv.data.rows() == 70 && (fromCsv.data - stc.data).norm() <= 1e-6 * stc.data.norm() && fromStc.vertices == stc.vertices && (fromStc.data - stc.data).norm() <= 1e-6 * stc.data.norm(),
"InvSourceEstimateIO/InvSourceEstimate: CSV and .stc round trips");

Authors of this file​