InvSourceEstimateIO
Namespace: INVLIB · Library: Inverse Library
mne.SourceEstimate.save / read in MNE-Python.
#include <inv/inv_source_estimate_io.h>
class INVLIB::InvSourceEstimateIO
Extended I/O methods for InvSourceEstimate.
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:
- InvSourceEstimate — Source estimate (empty if failed).
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
- Full source:
src/examples/ex_inv_api/main.cpp - Build target:
ex_inv_api(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_inv_api
Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.
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
- Christoph Dinh <christoph.dinh@mne-cpp.org>