e-field_targeting
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.1%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: lainem11
- License: mit
- Language: MATLAB
- Default Branch: main
- Size: 116 KB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 4
Metadata Files
README.md
E-field targeting v1.1.2
This repository is used to solve optimization problems where a set of electric fields (E-fields) are superimposed to focus the E-field at a target location and in target direction. It is specifically designed for multi-coil transcranial magnetic stimulation where the E-fields are induced in the cortex usign a set of coils, but it could be used for other applications as well.
Targeting in a spherical surface
Spherical targeting assumes E-fields are generated on a spherical surface, which may be used as an approximation of a more complex surface. The example_spherical.m script creates an example set of E-fields (akin to https://doi.org/10.1016/j.brs.2018.03.014) and solves the optimization problem for a few example targets.
Figure 1. A set of E-fields that need to be summed up with appropriate weightings to focus the E-field on target.
Figure 2. Results of the example script.
Targeting in a complex geometry
The examplecomplexgeom.m has an example of targeting in a more complicated 3D surface. Targeting in complex geometry treats the E-field directions differently from the spherical case. As the induced E-fields occur primarily on a plane, the target direction is adjusted to set realizable goal. This allows constraints to be satisfied, which then gives room for minimizing the objective. The plane is determined by finding the closest vertex to the target location, and selecting two of the largest principal components of the provided E-field set to form the axis of the 2D subspace, where the E-field directions are calculated.
In addition, as the induced E-field strength is much greater in gyri, the target location may not be realizable. Therefore, when using weighted center of gravity (WCOG, see below) as the stimulation location metric, the mesh coordinates are projected onto a 2D plane, defined by the average mesh face normal.
Figure 3. Example specification of the E-field targets for conditioning stimului and a test stimulus. E-field is resticted near the test stimulus when generating the conditioning stimuli.
Figure 4. Example of a set of E-fields on a complex surface.
Figure 5. Results of the E-field targeting example with the conditioning stimuli (CS).
Figure 6. Results of the E-field targeting example with the test stimulus (TS).
Importing E-fields and stimulation targets
See exampleInVesaliusexports.m for example that assumes you have exported files from InVesalius. You need to fill in the correct filepaths.
Optimization constraints and objectives
Let $E = {E¹,...,E^k}$ be an $k$-sized set of E-fields, such that each $E^i$ is a matrix of shape (N x 3) with E-field values, and N is the number of vertices in a coordinate space $S$ with a matching shape (N x 3). The optimization parameters then consist of $k$ parameters ${w¹,...,w^k}$ which weigh the relative contributions of each E-field in the set to produce a total E-field as:\ $$E{\text{norm}} = |\sum{i=1}^k E^i w^i|$$\ We define $\hat{E}_{\text{norm}}$ as $E_{\text{norm}}$ scaled to a maximum value of 1.
Defining stimulation location
The optimization function has two options for defining the focus point of the E-field, i.e., the stimulation location $O_{loc}$: 'WCOG', which aims to place a weighted center of gravity to the target location, and 'Max', which aims to place the E-field maximum at the target location. The optimizers use WCOG by default.
WCOG\ $$O{loc} = \frac{\sum{n=1}^N Sn \hat{E}^q{\text{norm, n}}}{\sum{n=1}^N \hat{E}^q{\text{norm, n}}}$$, where $q$ is a weighting factor (default: $q = 10$) to control how much pull E-field magnitude has on the center of gravity.
Max\ $$O{loc} = S{\text{argmax } E_{\text{norm}}}$$
Defining constraints
Given a target location $T{loc}$ and direction $T{dir}$ the optimization is constrained such that:\ $$|T{loc} - O{loc}| < \delta_{loc}$$, and\ $$\phi < \delta_{dir}$$, and\ $$|O{loc} - S{\text{argmax } E{\text{norm}}}| < \delta_{\text{max}}$$,\ where $\delta{loc}$ is the maximum acceptable diffence between the target and realized stimulation locations, $\phi$ the vector angle between $T{dir}$ and $O{dir}$, $\delta{dir}$ the maximum acceptable angle difference between the target and realized stimulation directions, and $\delta_{\text{max}}$ the maximum acceptable distance between the stimulation location and the E-field maximum location. $O{dir}$ is the direction of the E-field at the closest vertex from $O{loc}$. The constraint thresholds $\delta_{loc}$ and $\delta_{dir}$ can be adjusted and default to 1 mm and 5°, respectively. $\delta_{\text{max}}$ is 5 mm in the optimizeEfieldsspherical.m and 10 mm in optimizeEfieldscomplexgeom.m.
Minimizing the objective
When the optimization constraints are met, the best solution is chosen by minimizing the objective. The optimization function has two options for the objective: 'minEnergy' or 'Focality'.
minEnergy\ $$\text{minimize } f(w) = \sum_{i=1}^k (\frac{w^i}{\text{max}(|w|)})^2 $$
Focality\ $$\text{minimize } f(w) = \sum{n=1}^N \hat{E}^{2}{\text{norm, n}}$$
Resticting E-field in specific regions
The optimization function has an option limit the E-field magnitude in specified locations $S'$ by including a penalty term to the objective function:
minEnergy\ $$\text{minimize } f(w) = \sum_{i=1}^k (\frac{w^i}{\text{max}(|w|)})^2 + \text{mean}(\hat{E}_{\text{norm, S'}})*10$$
Focality\ $$\text{minimize } f(w) = \text{mean}(\hat{E}^{2}_{\text{norm}}) + \text{mean}(\hat{E}^{2}_{\text{norm, S'}})$$
Owner
- Name: Mikael Laine
- Login: lainem11
- Kind: user
- Repositories: 1
- Profile: https://github.com/lainem11
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: E-field targeting
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Mikael
family-names: Laine
email: mikael.h.laine@gmail.com
affiliation: Aalto University
orcid: 'https://orcid.org/0009-0003-5534-9170'
repository-code: 'https://github.com/lainem11/E-field_targeting'
abstract: Focusing a superimposed E-field on a target.
license: MIT
version: '1.1.2'
date-released: '2025-08-04'
GitHub Events
Total
- Release event: 3
- Member event: 1
- Push event: 15
- Pull request event: 1
- Fork event: 1
- Create event: 7
Last Year
- Release event: 3
- Member event: 1
- Push event: 15
- Pull request event: 1
- Fork event: 1
- Create event: 7