{ "cells": [ { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "EEG leadfield computation - On equidistant elements\n", "===================================================\n", "\n", "The leadfield matrix can be computed on different source spaces in *shamo*. In this example, we consider a subset of the elements of the region of interest by setting a minimal distance between two potential dipoles.\n", "\n", "The first steps are the same as in the previous example." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import logging\n", "import sys\n", "\n", "logger = logging.getLogger(\"shamo\")\n", "handler = logging.StreamHandler(sys.stdout)\n", "handler.setFormatter(logging.Formatter(\"[{levelname}] {message}\", style=\"{\"))\n", "logger.addHandler(handler)\n", "logger.setLevel(logging.INFO)" ] }, { "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 ProbEEGLeadfield\n", "\n", "problem = ProbEEGLeadfield()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.sigmas.set(\"scalp\", 0.4137)\n", "problem.sigmas.set(\"gm\", 0.4660)\n", "problem.sigmas.set(\"wm\", 0.2126)" ] }, { "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": [ "Minimal distance definition\n", "---------------------------\n", "\n", "To limit the amount of potential dipoles in the output leadfield matrix and thus reduce its size, the minimal distance between two elements can be set.\n", "\n", "If it is used, the elements are undersampled by removing the one too close to each other recursively." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.min_elems_dist = 0.01" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solution = problem.solve(\"single_ssp-dist\", \"../../derivatives/eeg_leadfield\", model)" ] } ], "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 }