InvVolumeSourceEstimate
Namespace: INVLIB · Library: Inverse Library
mne.VolumeSourceEstimate in MNE-Python.
#include <inv/inv_volume_source_estimate.h>
class INVLIB::InvVolumeSourceEstimate
Volume source estimate: scalar values at voxel locations.
Extends InvSourceEstimate with grid shape information to allow reshaping the flat data into a 3D volume.
// A volume estimate keeps the grid shape, so a time slice can be written back into the full grid.
InvVolumeSourceEstimate volumeStc(stc.data.topRows(4), VectorXi::LinSpaced(4, 0, 6), stc.tmin, stc.tstep);
volumeStc.setShape({2, 2, 2}); // 8 voxels, 4 of them sources
const VectorXd grid = volumeStc.toVolume(200);
Inheritance
Public Methods
InvVolumeSourceEstimate()
InvVolumeSourceEstimate(p_sol, p_vertices, p_tmin, p_tstep)
Construct from data and vertices.
Parameters:
-
p_sol : const Eigen::MatrixXd & Data (n_voxels x n_times).
-
p_vertices : const Eigen::VectorXi & Voxel indices.
-
p_tmin : float Start time.
-
p_tstep : float Time step.
setShape(shape)
Set the 3D grid shape (nx, ny, nz) for volume reshaping.
Parameters:
- shape : const QVector< int > & Grid dimensions {nx, ny, nz}.
shape()
Get the 3D grid shape.
Returns:
- const QVector< int > & — Grid dimensions {nx, ny, nz}; empty if no shape was set.
hasShape()
Check whether the grid shape has been set.
Returns:
- bool — True if the shape holds exactly three dimensions.
toVolume(timeIdx)
Extract a 3D volume for a given time point, filling the grid with zeros where no source is active.
Parameters:
- timeIdx : int Time sample index.
Returns:
- Eigen::VectorXd — Flattened volume (nxnynz, x fastest like volume source-space vertex numbers) with values at active voxels.
centreOfMass(timeIdx)
Compute the centre of mass of the activity at a given time point.
Parameters:
- timeIdx : int Time sample index.
Returns:
- Eigen::Vector3d — 3D position (x, y, z) in voxel coordinates, or (0,0,0) if no activity.
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.
// A volume estimate keeps the grid shape, so a time slice can be written back into the full grid.
InvVolumeSourceEstimate volumeStc(stc.data.topRows(4), VectorXi::LinSpaced(4, 0, 6), stc.tmin, stc.tstep);
volumeStc.setShape({2, 2, 2}); // 8 voxels, 4 of them sources
const VectorXd grid = volumeStc.toVolume(200);
ok &= expect(grid.size() == 8 && grid(0) == stc.data(0, 200) && grid(6) == stc.data(3, 200) && grid(1) == 0.0,
"InvVolumeSourceEstimate: source values land on their voxels, the rest of the grid is zero");
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>