# EEG parametric leadfield sensitivity analysis¶

As for the surrogate model in the previous example, we have to build a simple model from the parametric solution generated before. Since the goal of this example is to compute the Sobol sensitivity indices, we have to produce a scalar value representing the full matrix and then build the surrogate model.

The first steps are the same as before.

[ ]:

from shamo.eeg import SolParamEEGLeadfield


[ ]:

from shamo.eeg import SolEEGLeadfield



We then define the metric function that takes both a reference matrix and another matrix to compare to. This function must return a single scalar value.

[ ]:

import numpy as np

def metric(ref, mat):
return np.linalg.norm(ref - mat, "fro")


Next, we use the SurrEEGLeadfieldToRef class to build such model and fit it with the metric function as a parameter.

[ ]:

from shamo.eeg import SurrEEGLeadfieldToRef


[ ]:

s_i = surrogate.gen_sobol()