{ "cells": [ { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "HD-tDCS parametric simulation\n", "=============================\n", "\n", "As for the EEG leadfield matrix, a parametric solution can be computed with respect to the distributions of values set for the electrical conductivity of the tissues butalso for the injected current value.\n", "\n", "The first steps are the same as for the single problem." ] }, { "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.hd_tdcs import ProbParamHDTDCSSim\n", "\n", "problem = ProbParamHDTDCSSim()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The only differences are the values used to determine the conductivity and the injected current since :py:class:`~shamo.core.distributions.abc.DistABC` are used." ] }, { "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.source.add(\"P3\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.references.adds([\"T5\", \"C3\", \"PZ\", \"O1\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "problem.current.set(DistUniform(0.002, 0.008))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import nibabel as nib\n", "\n", "img = nib.load(model.path / f\"{model.name}.nii\")\n", "problem.grid.set(img.affine, img.shape)" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Similarly to any parametric problem in *shamo*, the number of evaluations and the method used to solve the sub-solutions is up to the user." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solution = problem.solve(\"parametric\", \"../../derivatives/hd_tdcs_simulation\", 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 }