Inverse model#
This module inverts the forward model.
- src_rec.inv_mdl.Inv_mdl(trans, noise_norm)#
Container class, populated with the following items.
- Parameters:
trans (numpy.ndarray, shape(valid_vtx_cnt, meg_ch_cnt)) – Inverse model.
noise_norm (numpy.ndarray, shape(valid_vtx_cnt,)) – Noise normalization vector.
- src_rec.inv_mdl.compute(sen_cov, fwd_sol, signal_type, rec_meta_info=None, method='dSPM')#
Convert a forward model into an inverse model.
- Parameters:
sen_cov (finnpy.src_rec.sen_cov.Sen_cov class) – Container class.
fwd_sol (numpy.ndarray, shape(meg_ch_cnt, valid_vtx_cnt)) – Forward model.
signal_type (string) – Either ‘EEG’ or ‘MEG’.
rec_meta_info (mne.io.read_info) – MEG scan meta information, obtainable through mne.io.read_info.
method (string) – Method used to calculate the noise normalization vector, defaults to “dSPM”.
- Returns:
inv_mdl – Container class.
- Return type:
finnpy.src_rec.inv_mdl.Inv_mdl
- Raises:
AssertionError – Signal type must be either ‘EEG’ or ‘MEG’. Covariance matrix is not fully invertible (contains 0s). Noise normalization method is not support, currently only dSPM is implemented.
- src_rec.inv_mdl.apply(sensor_data, inv_mdl)#
Apply an inverse model and noise normalization vector to sensor space data.
- Parameters:
sensor_data (numpy.ndarray, shape(sensor_ch_cnt, samp_cnt)) – Sensor space data
inv_mdl (finnpy.src_rec.inv_mdl.Inv_mdl) – Container class.
- Returns:
source_data – Source space data.
- Return type:
numpy.ndarray, shape(source_ch_cnt, samp_cnt)
- src_rec.inv_mdl._calc_whitener(eigen_val, eigen_vec)#
Calculate PCA based whitener from provided eigenvalues and eigenvectors.
- Parameters:
eigen_val (numpy.ndarray, shape(n,)) – Eigenvalues.
eigen_vec (numpy.ndarray, shape(n, n)) – Eigenvectors.
- Returns:
whitener – Whitener.
- Return type:
numpy.ndarray, shape(n, n)
- src_rec.inv_mdl._get_meg_channel_type_idx(rec_meta_info)#
Return the channel names of the MEG channels.
- Parameters:
rec_meta_info (mne.io.read_info) – MEG scan meta information, obtainable through mne.io.read_info.
- Returns:
sensor_cov_names – Names of the channels.
- Return type:
list, len(ch_cnt,), string