Downstream Processing#
Having extracted the required anatomical components, and computed the sensor covariance and M/EEG to anatomy co-registration, the inverse model may be calculated as follows. Of note, as the inverse transformation and the following intermediate byproducts depend on the sensor-position, these have to be recomputed in case the sensor covariance or M/EEG co-registration was recomputed (cf. section Sensor Position Dependent Factors).
The following code segment computes the inverse model, employing the previously calculated intermediate results.
import finnpy.src_rec.bem_mdl
import finnpy.src_rec.cort_mdl
import finnpy.src_rec.fwd_mdl
import finnpy.src_rec.inv_mdl
import finnpy.src_rec.subj_to_fsavg
bem_mdl = finnpy.src_rec.bem_mdl.run(fs_path, anatomy_path, subj_name, signal_type, coreg, conductivity = None, tgt_icosahedron_level = 4):
cort_mdl = finnpy.src_rec.cort_mdl.get(anatomy_path, subj_name, signal_type, coreg, bem_mdl)
fwd_mdl = finnpy.src_rec.fwd_mdl.compute(bem_mdl, cort_mdl, coreg, signal_type, rec_info, _mag_factor=1e-7, conductivity = None):
fwd_mdl = finnpy.src_rec.fwd_mdl.restrict(cort_mdl, fwd_sol, coreg)
inv_mdl = finnpy.src_rec.inv_mdl.compute(sen_cov, fwd_sol, signal_type, rec_info, method = "dSPM")
subj_to_fsavg_mdl = compute(cort_mdl, anatomy_path, subj_name, fs_path, overwrite)
Let’s take a closer look at this code example.
bem_mdl = finnpy.src_rec.bem_mdl.run(fs_path, anatomy_path, subj_name, signal_type, coreg, conductivity = None, tgt_icosahedron_level = 4):
Calculates position and current sharing of the individual virtual cortical dipoles.
cort_mdl = finnpy.src_rec.cort_mdl.get(anatomy_path, subj_name, signal_type, coreg, bem_mdl)
Loads cortical data and removes any data points that are outside the inner skull BEM model component.
fwd_mdl = finnpy.src_rec.fwd_mdl.compute(bem_mdl, cort_mdl, coreg, signal_type, rec_info, _mag_factor=1e-7, conductivity = None):
fwd_mdl = finnpy.src_rec.fwd_mdl.restrict(cort_mdl, fwd_sol, coreg)
inv_mdl = finnpy.src_rec.inv_mdl.compute(sen_cov, fwd_sol, signal_type, rec_info, method = "dSPM")
Computation of the forward model proper, restriction to surface orthogonal dipoles only, and subsequent inversion.
Next steps#
This concludes the computation of the inverse matrix. It’s application is demonstrated in section Model Application.