{ "cells": [ { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "EEG parametric leadfield computation - On equidistant elements\n", "==============================================================\n", "\n", "It is also possible to compute the parametric solution for a subset of the elements of the region of interest. Compared to the single solution, here, the elements must be precomputed to avoid computing it at each iteration.\n", "\n", "The solution is thus to compute a reference single solution and provide the resulting elements. In this example, we use the subset of elements generated for the single solution of a previous example." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from shamo import FEM\n", "\n", "model = FEM.load(\"../../derivatives/fem_from_labels/fem_from_labels.json\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from shamo.eeg import ProbParamEEGLeadfield\n", "\n", "problem = ProbParamEEGLeadfield()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from shamo import DistUniform\n", "\n", "problem.sigmas.set(\"scalp\", DistUniform(0.137, 2.1))\n", "problem.sigmas.set(\"gm\", DistUniform(0.06, 2.47))\n", "problem.sigmas.set(\"wm\", DistUniform(0.0646, 0.81))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.reference.add(\"IZ\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.markers.adds([\"NZ\", \"LeftEar\", \"RightEar\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.rois.add(\"gm\")" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "First, we load the solution that serves as a reference." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from shamo.eeg import SolEEGLeadfield\n", "\n", "ref_solution = SolEEGLeadfield.load(\"../../derivatives/eeg_leadfield/single_ssp-dist/single_ssp-dist.json\")" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "And pass the path to the elements file to the new parametric problem." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.elems_path.set(ref_solution.source_sp_path)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solution = problem.solve(\"parametric_ssp-dist\", \"../../derivatives/eeg_leadfield\", model, n_evals=4, method=\"multiprocessing\", n_proc=4)" ] } ], "metadata": { "kernelspec": { "display_name": "shamo", "language": "python", "name": "shamo" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }