No slash command · from TI-Toolbox
Provides domain knowledge on temporal interference (TI) neurostimulation for working with TI-Toolbox code. Covers physics, electrode naming, field quantities, and clinical context.
Ships in TI-Toolbox. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This document is the primary domain reference for AI agents working on TI-Toolbox who have no neuroscience background. Every section is relevant to understanding the codebase, the physics it implements, and the clinical context it serves.
Numerical behavior changes need independent real-library regression tests. If published outputs change, document affected workflows and any user action in the relevant release page. For 2.x migration, read the targeted fixes; MCP clients can discover the release link through
read_changelog.
Temporal interference is a non-invasive brain stimulation technique that can reach deep brain structures without overstimulating the superficial cortex — something conventional methods like tDCS (transcranial direct current stimulation) and tACS (transcranial alternating current stimulation) struggle with.
Two channels — two electrode pairs — are placed on the scalp. TI-Toolbox names channel k's electrodes Ek+ and Ek- (channel 1 is E1+ and E1-, channel 2 is E2+ and E2-; never "A"/"B" or "Pair k"). Each channel delivers a sinusoidal (AC) current at a slightly different high frequency. For example, channel 1 operates at 2000 Hz and channel 2 at 2010 Hz.
High-frequency currents pass through superficial tissue without stimulating neurons. Neurons have a biophysical low-pass filtering property — they cannot follow electrical oscillations above roughly 1 kHz. The 2000 Hz and 2010 Hz signals individually do nothing to neural tissue.
At the deep target, the two electric fields superpose. Where both fields overlap in space, they create an amplitude-modulated (AM) waveform. The envelope of this AM signal oscillates at the difference frequency (2010 - 2000 = 10 Hz). This 10 Hz modulation falls within the range that neurons can follow, so it drives neural activity at the target.
Superficial regions see only the high-frequency carriers (each channel's field dominates near its own electrodes), so they are not stimulated. Only where both fields have comparable magnitude — typically at depth — does meaningful interference occur.
Grossman, N., Bono, D., Dedic, N. et al. (2017). "Noninvasive Deep Brain Stimulation via Temporally Interfering Electric Fields." Cell, 169(6), 1029–1041.e16, doi:10.1016/j.cell.2017.05.024. This paper demonstrated TI stimulation in living mice, showing selective deep-brain activation without superficial cortex engagement.
Understanding these field quantities is critical because they are the primary outputs of every simulation in the codebase:
TI_max field: The maximum envelope amplitude at each spatial point, computed across ALL possible neural fiber orientations. This is the orientation-independent maximum stimulation intensity. It answers: "What is the strongest possible TI effect at this location, regardless of which direction neurons are pointing?"
TI_normal field: The envelope component projected along a specific direction vector — typically the cortical surface normal. It answers: "How strongly would TI stimulate neurons oriented perpendicular to the cortical surface at this point?" This is more physiologically relevant for cortical targets because pyramidal neurons are approximately normal to the cortical sheet. It is always ≤ TI_max.
TI_normal is mesh-only, by design — it only exists on the cortical surface, so a voxel-space analysis of it is an error, not a bug. It is written for both TI and mTI runs onto the run's central surface <TI|mTI>/mesh/surfaces/<montage>_<TI|mTI>_central.msh (tit.volume_fields.central_surface: every volume field and each channel's E interpolated onto the m2m central surfaces, then tit.calc.envelope(e_fields, normals) over every channel); a carrier-only run has none. A run made before the surface carried it gets it on demand (from its old normal-component mesh, else the channel meshes) when an analysis or the fsaverage projection needs it.
fsaverage projection: tit/source/fsaverage.py projects finished simulations onto the fsaverage surface post hoc (spacings 5/6/7 = 10242/40962/163842 nodes per hemisphere), covering TI_max, TI_normal, hf_peak and hf_rms (not TI_avg or hf_power_density), and writing sub-<id>_sim-<sim>_space-fsaverage<spacing>_fields.msh (fsaverage central surfaces, lh then rh, one node field per quantity; opens in the Viewer and Gmsh). This is what makes surface-space group statistics possible. Unlike SimNIBS's native map_to_fsavg (simulation time, TI_max only) it can be run after the fact, for TI and mTI runs alike.
Modulation depth: A dimensionless ratio between 0 and 1 that indicates how effectively the two fields interfere at a given point:
M(x) = 2 · min(|E1(x)|, |E2(x)|) / (|E1(x)| + |E2(x)|)
A common misconception is that the TI effect is just the difference of the two field magnitudes. The actual calculation involves vector fields and must consider orientation. At each spatial point, E1 and E2 are 3D vectors. The envelope magnitude depends on the relative orientation of these vectors and the neural fiber direction being considered. The full TI_max calculation searches over orientations using two quadratic forms built from the fields; the implementation is in tit/calc.py.
For intuition (the scalar case where fields are co-aligned):
E_TI(x) = |E1(x) + E2(x)| - |E1(x) - E2(x)|
This equals 2 · min(|E1|, |E2|) when the fields point in the same direction. The full vector calculation generalizes this to arbitrary 3D field orientations.
| Method | Depth Capability | Mechanism |
|---|---|---|
| tDCS | Superficial only | Static current flow |
| tACS | Superficial only | Low-frequency AC, strongest near electrodes |
| TI | Deep targets | High-freq carriers pass through; interference envelope at depth |
| mTI | Deep + more focal | Multiple interference patterns, more steering control |
Standard TI is one beating pair: two channels at slightly different carrier
frequencies that beat at Δf. Multi-polar TI (mTI) uses 2K channels in K beating
pairs — 4 or more channels, beating in pairs at a common Δf. TI-Toolbox accepts any
even number of channels from 4 (E1± to E4±, K = 2) up to 12 (tit.constants.MAX_MTI_CHANNELS); the optimizers'
mEx-search uses exactly 4.
2k-1 and 2k form beating pair k (carriers f_k and
f_k + Δf) — for K = 2, e.g. 2.000/2.010 kHz and 4.000/4.010 kHz. Every pair
beats at the same Δf, and the beats are phase-aligned.n, with a_k = E_{2k-1} . n and
b_k = E_{2k} . n the two channels of pair k, the squared, low-passed signal is
the power envelope p(t) = P + Q cos(2π Δf t) with P = (1/2) sum_k (a_k^2 + b_k^2)
and Q = sum_k a_k b_k: each pair contributes its own terms to P and Q, so the
pairs add in power. The modulation depth of the amplitude envelope sqrt(2 p(t)) is
E_AM(n) = | sqrt(sum_k (a_k + b_k)^2) - sqrt(sum_k (a_k - b_k)^2) | = | |S n| - |D n| |
(section 8), and mTI_max is its maximum over n (tit.calc.envelope_max over all
2K channel fields at once).The physics and the accuracy of each quantity are on the wiki's Analyzer page
(read_wiki_page("analyzer"), "More beating pairs: multipolar TI").
Check attributions against read_wiki_page("simulator") before repeating them —
several were corrected after a full-text audit, and Botzanowski 2025 in particular
contains no equations to cite: it describes the mTI envelope (square, low-pass,
square root) in prose, pp. 4–5, which is what tit.calc cites it for.
mTI vs standard TI is auto-detected from the montage's channel count. The rule is
stated once, in tit.constants.is_valid_pair_count, and enforced in
Montage.simulation_mode and tit.calc (every envelope function):
an even number of channels (electrode pairs), at least two — 2 = TI, 4 or more = mTI.
So 2, 4, 6, 8, 12, 16 … are legal and 1, 3, 5 are not: an odd count leaves a channel with nothing to beat against, and a single channel is tACS, not TI.
tit/sim/TI.py)tit/sim/mTI.py)Note the capitalisation of both filenames — the container's filesystem is case-sensitive.
tit.calc exposes exactly five public functions. The envelope functions take a
list of 2K field arrays, one per channel, paired positionally (channels
2k-1 and 2k form beating pair k); the carrier functions take any number of
channel fields:
envelope(fields, direction) # (N,) envelope along a direction -> TI_normal
envelope_max(fields) # (N,) max over directions -> TI_max / mTI_max
envelope_max(fields, perpendicular_to=normals) # (N,) max within the surface plane -> tangential TI
envelope_max(fields, return_direction=True) # (amp, unit direction)
envelope_mean(fields) # (N,) mean over directions -> TI_avg
hf_peak(fields, coherent=False) # (N,) peak carrier field
hf_power(fields, coherent=False) # (N,) (1/2) sum |E_c|^2 = hf_rms^2
Methods: envelope is exact for every K. envelope_max is an exact closed form at
K = 1 (also in a plane); at K >= 2 the sphere maximum is an eigen-branch
root-find with a Newton polish (none of 1e4 random elements per K = 2, 3, 4 and
4e5 real grey-matter elements more than 1e-6 below a dense reference), and the
in-plane maximum is exact (degree-6 polynomial roots). envelope_mean is exact at
K = 1 (|E1| + |E2| - (|E1+E2| + |E1-E2|)/2) and a 4096-direction sphere quadrature (2048 hemisphere directions)
(~7e-4) at K >= 2. hf_peak is exact for any number of fields.
Removed — never emit or describe these: any tit.calc name other than the
five above (the older vector/average/direction functions and their psi phase
argument are gone, as is the separate carrier-fields module with its sum-of-squares
function — hf_rms is an on-disk field, sqrt(hf_power), not a function), get_nTI_vectors (the old
recursive TI(TI(E1,E2), TI(E3,E4)) algorithm, which is simply wrong for
N >= 4), get_mTI_vectors / get_mTI_dir, get_magnitude_am, and the
channels= carrier-regrouping parameter. There is no montage.channels and no
separate "carrier wiring" control: wiring is positional — one field per channel,
two channels per beating pair.
A montage is the assignment of electrodes to channels, specifying Ek+ (current source) and Ek- (current sink) for each channel k. In the codebase (electrode_pairs, one pair per channel), a montage is represented as:
# Standard TI (2 channels):
[[anode1, cathode1], [anode2, cathode2]]
# mTI (4 channels):
[[anode1, cathode1], [anode2, cathode2], [anode3, cathode3], [anode4, cathode4]]
Electrodes are referenced by standardized naming conventions:
10-20 System: The international standard with 21 electrode positions (e.g., Fp1, Fp2, F3, F4, C3, C4, Cz, Pz, O1, O2). Positions are defined as percentages of skull measurements (nasion-inion, pre-auricular distances).
10-10 System: Extension to ~64 positions, filling in between 10-20 locations.
10-5 System: Further extension to ~345 positions, extremely dense coverage.
GSN HydroCel (EGI Geodesic Sensor Nets): Commercial electrode nets with numbered electrodes:
"GSN-HydroCel-185.csv"). The CSV files contain 3D electrode coordinates and the parser skips the first (header) line.Each electrode has physical properties that affect the simulation:
In unipolar montages, each channel has one "active" electrode near the target and one "reference" electrode placed far from the region of interest. This is a common configuration in the TI-Toolbox montage system.
Montages are stored in JSON configuration files:
{
"nets": {
"GSN-HydroCel-185.csv": {
"uni_polar_montages": {
"my_montage": [[10, 50], [20, 60]]
}
}
}
}
The human head is not a uniform conductor. It contains multiple tissue types with very different electrical conductivities, complex geometry (folded cortex, irregular skull), and anisotropic properties (white matter fibers). Analytical solutions are impossible for realistic head geometry. FEM discretizes the continuous head volume into millions of small elements and numerically solves the governing equation.
∇ · (σ ∇φ) = 0
Where:
Boundary conditions are set by the electrode currents on the scalp surface.
The electric field is derived from the potential:
E = -∇φ
SimNIBS (Simulation of Non-invasive Brain Stimulation) is the open-source tool TI-Toolbox uses for FEM computation. It:
The head mesh is a volumetric tetrahedral mesh generated from structural MRI. A typical mesh contains 3–5 million tetrahedral elements. Each element belongs to a tissue compartment.
The head model segments tissue into distinct compartments, each with a characteristic electrical conductivity:
| Tissue | Typical Conductivity (S/m) | Notes |
|---|---|---|
| Scalp | 0.465 | Skin + subcutaneous tissue |
| Skull (compact bone) | 0.007 | Very low — skull is the main barrier |
| Skull (spongy bone) | 0.025 | Diploe layer, somewhat more conductive |
| CSF (cerebrospinal fluid) | 1.654 | Highly conductive — acts as current pathway |
| Gray matter | 0.275 | Neuronal cell bodies, dendrites |
| White matter | 0.126 | Myelinated axon fibers |
| Eyes | ~1.5 | Vitreous humor, similar to CSF |
| Ventricles | ~1.654 | CSF-filled cavities deep in brain |
Key insight: the skull is the dominant barrier (conductivity ~50x lower than scalp or brain). The CSF is the most conductive tissue and acts as a preferential current pathway, which is why current tends to shunt through CSF rather than penetrating cortex.
White matter conductivity is anisotropic — it varies with direction relative to axon fiber bundles:
Anisotropic conductivity tensors are derived from diffusion tensor imaging (DTI) data. When DTI is available, the conductivity σ becomes a 3x3 symmetric positive-definite matrix at each mesh element, rather than a scalar.
The leadfield matrix is a precomputed data structure that enables rapid optimization:
Leadfield dimensions: [n_elements × 3 × n_electrodes]
With hundreds of possible electrode positions and continuous current intensities, the space of possible montages is enormous. The goal is to find the montage that best delivers stimulation to a specified target (ROI) while minimizing stimulation elsewhere.
Differential evolution (DE) is a stochastic global optimization algorithm. In the TI-Toolbox, "flex search" is the primary optimization method.
How DE works:
Search variables:
Objective function options:
Multi-start strategy: Run N independent DE optimizations with different random seeds, then take the best result. This mitigates the risk of getting trapped in local optima.
Speed: Each candidate is a full FEM solve (SimNIBS's flex optimizer), so flex-search is slow; only ex-search and mEx-search use the leadfield matrix.
Key parameters:
population_size: number of candidate solutions per generation (~13)max_iterations: maximum generations (~500)tolerance: convergence thresholdmutation_rate: DE mutation scaling factor (typically 0.5–1.0)recombination_rate: crossover probability (typically 0.7–0.9)Brute-force enumeration of all possible montage combinations from a defined electrode pool.
How it works:
Computational cost: O(n^k) where n = number of electrodes in pool, k = number of electrode positions to assign. This grows very quickly, so exhaustive search is only feasible for small electrode pools.
Electrode selection strategies:
Guarantee: finds the global optimum within the search space (unlike DE, which is stochastic).
The optimization target is defined as an ROI:
Spherical ROI: defined by a center point (x, y, z coordinates in mm, either in MNI standard space or subject-native space) and a radius (mm). All mesh elements whose centroids fall within the sphere are included. Simple and commonly used.
Cortical ROI: defined by an atlas region name (e.g., "superiorfrontal" from the DK40 atlas). Includes all mesh elements labeled with that region in the atlas parcellation. More anatomically precise than spherical.
Subcortical ROI: similar to cortical, but targeting deep brain structures (e.g., hippocampus, thalamus, putamen). These are the primary targets where TI's depth advantage matters.
The objective function can be configured as:
| Goal | Formula | When to Use |
|---|---|---|
"mean" | Maximize mean(E_ROI) | General-purpose, robust target coverage |
"max" | Maximize max(E_ROI) | When peak intensity matters (e.g., threshold effects) |
"focality" | Maximize mean(E_ROI) / mean(E_nonROI) | When minimizing off-target stimulation is critical |
Before any simulation can run, the subject's brain anatomy must be imaged, reconstructed, and meshed. This preprocessing pipeline transforms raw scanner data into a simulation-ready head model.
FreeSurfer's recon-all performs automated cortical surface reconstruction from T1-weighted MRI:
Runtime: 6–12 hours per subject. Output goes to derivatives/freesurfer/sub-{id}/.
CHARM (Complete Head Anatomy Reconstruction Model) creates the tetrahedral head mesh needed for FEM:
m2m_{subject} directory containing the head mesh and related filesThe mesh output goes to derivatives/SimNIBS/sub-{id}/m2m_{id}/.
Diffusion-weighted imaging (DWI/DTI) measures water molecule diffusion in brain tissue:
Atlases divide the cortical surface or brain volume into labeled regions. They are essential for defining cortical ROIs:
| Atlas | Regions per Hemisphere | Total Regions | Resolution | Common Use |
|---|---|---|---|---|
| DK40 (Desikan-Killiany) | 34 | 68 | Coarse | Default in most analyses, well-validated |
| Destrieux (a2009s) | 74 | 148 | Medium | When finer parcellation needed |
| HCP-MMP1 (Glasser) | 180 | 360 | Fine | High-resolution analyses |
Example DK40 regions: superiorfrontal, middletemporal, precentral, postcentral, inferiorparietal, lateraloccipital, insula, caudalmiddlefrontal, rostralmiddlefrontal, medialorbitofrontal.
Subcortical structures (not atlas-dependent): hippocampus, amygdala, thalamus, caudate, putamen, pallidum, nucleus accumbens.
For each ROI, the following statistics are computed over all mesh elements within the region:
Focality quantifies how well-targeted the stimulation is:
Focality = mean(E_ROI) / mean(E_nonROI)
Alternative formulation:
Focality = max(E_ROI) / percentile(E_nonROI, 95)
Higher focality means the stimulation is more concentrated at the target and weaker elsewhere. A focality of 1.0 means the target receives no more stimulation than the rest of the brain.
Flex-search also offers focality_tf, a threshold-free variant
mean_ROI^(1+w) / mean_nonROI, which avoids picking an arbitrary cut-off.
The focality above is that of the modulation (TI_max). The analyzer and Ex/mEx also report the focality of the stimulation intensity, the kHz carriers, over the same ROI and GM elements:
hf_peak_focality = mean_ROI(hf_peak) / mean_GM(hf_peak) # Ex/mEx: HFpeak_Focality
hf_rms_focality = mean_ROI(hf_rms) / mean_GM(hf_rms) # hf_rms = sqrt(hf_power)
ti_selectivity = roi_focality / hf_peak_focality # Ex/mEx: TI_Selectivity
ti_selectivity > 1: the envelope is more focal than its carriers, which is the TI
premise. <= 1: a plain kHz field with the carriers' distribution targets as well.
The RMS ratio uses hf_rms, not power, so it is linear like roi_focality. The
analyzer reads hf_peak/hf_rms from the same simulation, which saves them by default
(TI_max, hf_peak, hf_rms); for a run that did not, the analysis computes them from the
channel meshes first and says so (on_demand_note). Ex/mEx never rank on them
(Composite_Index is unchanged).
The analyzer's focality_50_area, focality_75_area, focality_90_area and
focality_95_area measure how much tissue exceeds a fraction of the peak, and
their unit depends on the space:
| Space | Element weight | Reported unit | Conversion |
|---|---|---|---|
| mesh | node area, mm² | cm² | ÷ 100 |
| voxel | voxel volume, mm³ | cm³ | ÷ 1000 |
The _area suffix is deliberately kept for the voxel case too, so existing scripts
and the group aggregator keep working — read the name as "extent", and take the
unit from the space. Voxel-space values produced by v2.3.0–v2.5.0 divided by 100
instead of 1000 and are therefore ten times too large; divide them by 10, no
re-run needed. Mesh values were always correct. total_area_or_volume is raw
mm²/mm³ and never moved.
Voxel volume is |det(A)| of the affine's 3×3 block, and the distance from a
spherical ROI's centre is ‖A(v − c)‖. The older code used
header.get_zooms() — the affine's column norms — which silently assumes the
voxel axes are orthogonal in world space. On an orthogonal grid the two agree
exactly; on a sheared one the zooms overestimated voxel volume by ~11%, which
propagated into total_area_or_volume and every focality_*_area, and made the
"spherical" ROI the wrong ellipsoid. Detection: compare
prod(header.get_zooms()[:3]) with abs(det(affine[:3,:3])) — a difference above
float noise means the data is sheared and the result must be re-run.
Group stacking is guarded the same way: every subject's image must share a grid
(shape, direction block, origin) with the first, or the load raises ValueError
naming the subject. Affines differing by more than 1e-3 mm in origin or 1e-4 in the
direction block mean the analysis compared different anatomy; a sign flip in
det(affine[:3,:3]) (a left–right handedness flip) is the worst case.
Volumetric (3D) field data can be projected onto cortical surfaces for visualization:
Comparing stimulation patterns across multiple subjects:
A non-parametric statistical method for spatial data that controls for the multiple comparisons problem:
Key parameters:
n_permutations: number of random shuffles (~1000; more = more precise p-values)alpha: significance level (typically 0.05)cluster_threshold: initial voxel-level threshold for cluster formationAdvantages: no assumption of normal distribution, controls family-wise error rate across the entire brain, data-driven cluster formation.
(b + 1) / (m + 1)With a sampled Monte-Carlo null, the naive b / m (the fraction of m
permutations at least as extreme) can return exactly 0 and is anti-conservative in
the tail. The correct estimator (Phipson & Smyth 2010) adds the observed statistic
to its own null:
p = (b + 1) / (m + 1)
At the default 1000 permutations the floor is 1/1001 ≈ 9.99e-4, never 0, and the
shift is at most 0.001 absolute. An old report showing p = 0.0000 should be read
as p < 1/(m+1); to convert, p_new = (p_old * m + 1) / (m + 1). The exact b / m
is correct only when the null is an exhaustive enumeration of the permutation
group, not a sample.
A supra-threshold map contains both positive and negative blobs. Labelling it with
a plain connected-components pass fuses touching positive and negative blobs into
one cluster whose signed mass is their difference, and taking max() over signed
masses under a left- or two-sided tail selects the cluster closest to zero
rather than the most extreme. Two rules fix it:
mass for a right tail, −mass for a left tail, |mass| for two-sided. The
observed and permuted values are then on the same scale and the comparison is
always right-tailed.One-sided cluster forming is sign-restricted to match. A right-tailed
(alternative="greater") analysis was never affected, because there the oriented
statistic already is the signed mass. Detection tell: a log line reading
Threshold (p<0.050): <a negative number> mass units — an oriented threshold can
never be negative. Affected analyses must be re-run; there is no rescaling.
Degenerate voxels (zero standard error) are also handled explicitly now: 0/0
(undefined) and ±x/0 (perfect separation) are no longer both flattened to
t = 0, p = 1; degenerate voxels are excluded from the valid mask and counted in a
warning. This can change the valid mask and therefore cluster geometry, so it too
is a re-run, not a rescale.
These equations appear in the codebase (primarily in tit/calc.py) and understanding them is essential for working on simulation and analysis code.
When E1 and E2 are co-aligned scalars:
E_TI(x) = |E1(x) + E2(x)| - |E1(x) - E2(x)| = 2 · min(|E1(x)|, |E2(x)|)
For 3D vector fields E1(x) and E2(x), find the orientation unit vector n that maximizes the envelope:
TI_max(x) = max_n | |n · (E1 + E2)| - |n · (E1 - E2)| |
For K = 1 (one beating pair, two channels) this has an exact closed form. For K >= 2 (mTI), with
a_k = E_ka . n, b_k = E_kb . n (E_ka, E_kb = beating pair k's two channel
fields, i.e. channels 2k-1 and 2k) and S, D the K x 3 matrices with rows
E_ka + E_kb and E_ka - E_kb, the envelope along n is
E_AM(n) = | |S n| - |D n| | = 4 |sum_k a_k b_k| / (|S n| + |D n|)
and TI_max is its maximum over unit n, found by an eigen-branch root-find (the
maximiser is an eigenvector of cos(t) C+ - sin(t) C-, C+ = S^T S / 2,
C- = D^T D / 2) plus a local Newton polish. At K = 1 it reduces to Grossman's
||(E1+E2).n| - |(E1-E2).n|| = 2 min(|a|, |b|).
Numerical conditioning. The envelope is not evaluated as |S n| - |D n|. At
small modulation — every off-target voxel, and therefore the denominator of every
focality ratio — that subtraction of two nearly equal norms loses all leading
digits. The algebraically identical quotient of additions on the right is used
instead (S n = D n = 0 yields 0). If you touch this expression, the conditioning
is the point. The implementation is in tit/calc.py.
M(x) = 2 · min(|E1(x)|, |E2(x)|) / (|E1(x)| + |E2(x)|)
Ranges from 0 (no modulation, one field dominates) to 1 (perfect modulation, equal field strengths).
F = mean(E_ROI) / mean(E_nonROI)
Note the analyzer's focality_*_area outputs are a different thing — an extent
of tissue above a fraction of peak, in cm2 (mesh) or cm3 (voxel). See section 7.
∇ · (σ ∇φ) = 0 (Laplace equation with inhomogeneous conductivity)
E = -∇φ (Electric field from potential)
J = σ E (Current density from Ohm's law)
E(x) = Σ_k I_k · L(x, k)
Where I_k is the current at electrode k and L(x, k) is the precomputed leadfield at point x for electrode k. This is the basis of fast optimization.
hf_peak, hf_rms, hf_power_densityThese are the toolbox's carrier-field outputs, and their definitions are precise. Describe each by what it is (formula, units, peak or RMS); the toolbox designates none of them as the one to compare with exposure limits, so do not recommend one over another on those grounds. Follow Cassarà et al. 2025 (Parts I and II), which the implementation is written to.
The engine is quasi-static. An FEM field E is a phasor amplitude vector
in V/m — a peak, not an RMS — and there is no time axis anywhere in the
toolbox. Every peak quantity is therefore a worst case over the unknown
relative phases of the channels: equal to the time-domain definition when that
worst phase is actually attained (which it is, for incommensurate frequencies), and an
upper bound otherwise.
Peak vs RMS. All E-fields, TI_max and hf_peak are zero-to-peak amplitudes
for zero-to-peak channel currents; hf_rms is the RMS over time.
How channel fields combine (Cassarà Part II, p. 8, verbatim): "coherent field
superposition was used for identical frequencies, and incoherent superposition
(i.e., SAR addition) was used when the frequencies differed." So fields at the
same frequency sum as vectors first, and fields at distinct frequencies then
combine incoherently — in power for hf_rms, and by worst-case sign enumeration
for hf_peak. No two channels of a TI or mTI montage share a frequency, so every
channel field enters on its own; with E_c the field of channel c:
hf_peak = max over signs s_c in {+1,-1} of | sum_c s_c * E_c | (V/m)
hf_power = (1/2) sum_c |E_c|^2 (tit.calc, not saved) ((V/m)^2)
hf_rms = sqrt(hf_power) (saved; shown HF_{rms}) (V/m)
hf_power_density = (1/2) sum_c E_c^T sigma E_c (saved; shown p_{HF}) (W/m^3)
hf_power_density uses the conductivity the simulation solved with (tissue
values with overrides; each element's DTI tensor under vn/dir/mc): the absorbed
(Joule) power density, not SAR (SAR = hf_power_density / rho, IEEE C95.1-2019 p. 35;
rho is not applied). It is a volume field only (not projected to fsaverage).hf_peak is exact for any number of channels (zonotope vertices: the sign
patterns around the directions E_i x E_j).TI_max, TI_avg, TI_normal and everything downstream in the analyzer and
statistics were never affected by the carrier-grouping question.SimulationConfig(carrier_only=True) models
both channels at the same frequency and in phase (each channel's Ek+ at +I
at the same instant): one fixed field, no beat, no envelope. The two channel fields
then add coherently — hf_peak = |E1+E2|, hf_rms = |E1+E2|/sqrt(2), hf_power_density from
E1+E2 (coherent=True) — rather than the TI worst case. Only hf_peak/hf_rms/
hf_power_density may be requested; TI_max,
TI_avg, TI_normal are undefined and not computed; two-channel TI only. Example
|E1| = 1, |E2| = 0.8 at 120°: TI worst case 1.56, carrier-only 0.92.Deliberately not computed (do not claim the toolbox reports them): current
density J = σE, SAR itself (rho is not applied to hf_power_density),
spatially averaged in-situ fields, temperature rise (Pennes bioheat), charge per
phase and the Shannon limit, exposure duration / CEM43, and the activating function.
hf_power_density as SAR.These safety parameters are embedded in the codebase's validation and constraint systems:
TI-Toolbox follows the BIDS (Brain Imaging Data Structure) standard, which enforces a consistent directory hierarchy:
project_root/
├── sourcedata/ # Raw DICOM files from scanner
│ └── sub-{id}/ # Per-subject raw data
│
├── sub-{id}/ # Subject-level BIDS directory
│ └── anat/ # Anatomical images
│ ├── sub-{id}_T1w.nii.gz # T1-weighted MRI (required)
│ └── sub-{id}_T2w.nii.gz # T2-weighted MRI (optional)
│
├── derivatives/ # All derived/computed data
│ ├── SimNIBS/sub-{id}/ # SimNIBS outputs
│ │ ├── m2m_{id}/ # Head mesh (CHARM output)
│ │ │ ├── {id}.msh # Tetrahedral mesh file
│ │ │ ├── T1fs_conform.nii.gz # Conformed T1 image
│ │ │ └── ... # Tissue maps, transforms
│ │ ├── Simulations/ # TI simulation outputs
│ │ │ └── {montage_name}/ # Per-montage results
│ │ │ ├── TI/{mesh,niftis}/ # field mesh (TI_max, hf_peak, hf_rms by default), mesh/surfaces/ central surface (+ TI_normal), NIfTIs (opt-in / on demand)
│ │ │ ├── mTI/{mesh,niftis}/ # mTI only: {montage}_mTI.msh + its NIfTIs
│ │ │ ├── high_Frequency/ # per-channel meshes: what an unsaved field is computed from
│ │ │ └── Analyses/{Mesh,Voxel}/ # ROI analyses of this simulation
│ │ ├── flex-search/{run}/ # optimisation runs (the run name is the dir)
│ │ ├── ex-search/{run}/
│ │ ├── m-ex-search/{run}/
│ │ └── leadfields/ # for ex-search
│ │
│ ├── fastsurfer/sub-{id}/ # FastSurfer reconstruction (the v3 recon)
│ ├── freesurfer/sub-{id}/ # legacy recon-all output (read-only)
│ │ ├── surf/ # Cortical surfaces (lh.pial, rh.pial, etc.)
│ │ ├── label/ # Atlas parcellations
│ │ ├── mri/ # Processed MRI volumes
│ │ └── stats/ # Morphometric statistics
│ │
│ └── ti-toolbox/ # TI-Toolbox-specific outputs
│ ├── reports/ # Generated HTML reports
│ └── stats/{type}/{name}/ # group statistics
│
└── code/ti-toolbox/ # Everything the toolbox itself owns
├── config/ # montage_list.json, EEG nets, settings
├── jobs/{id}/ # v3 job store: spec.json, status.json,
│ # events.jsonl, stdout.log
├── notebooks/ # .ipynb documents (examples/ only subdir)
└── viewer/{kind}.tetravox.json # viewer scenes
The head model also carries m2m_{id}/eeg_positions/, m2m_{id}/segmentation/,
m2m_{id}/surfaces/ and m2m_{id}/stim_configs/ (free-hand electrode placements
in subject-RAS millimetres). The job store lives inside the project so a notebook
and a restarted server see the same jobs; .bidsignore carries the line
code/ti-toolbox/jobs/. Never hand-build any of these paths — go through
tit.paths.get_path_manager.
Subject IDs follow BIDS convention: sub-{id} where {id} is typically a zero-padded number (e.g., sub-001). The sub- prefix is part of the directory name but is stripped in some internal code contexts — the PathManager handles this consistently.
| Term | Definition |
|---|---|
| Anode | Electrode where current enters the tissue (positive terminal) |
| Cathode | Electrode where current exits the tissue (negative terminal) |
| Conductivity (σ) | Material property describing how easily electric current flows (S/m) |
| CSF | Cerebrospinal fluid — highly conductive fluid surrounding the brain |
| DTI | Diffusion Tensor Imaging — MRI technique measuring water diffusion directionality |
| EEG | Electroencephalography — brain electrical activity recording (shares electrode position standards) |
| FEM | Finite Element Method — numerical technique for solving PDEs on complex geometry |
| GM | Gray matter — brain tissue containing neuronal cell bodies |
| Leadfield | Precomputed field-per-electrode matrix enabling fast montage evaluation |
| MNI space | Montreal Neurological Institute standard coordinate system for brain imaging |
| Montage | Configuration of electrode positions and their channel assignments |
| mTI | Multi-polar temporal interference (4 or more channels, beating in pairs at a common Δf) |
| NIfTI | Neuroimaging file format (.nii/.nii.gz) |
| Parcellation | Division of cortical surface into labeled anatomical regions |
| ROI | Region of interest — the stimulation target |
| SAR | Specific Absorption Rate — power absorbed per unit mass of tissue |
| SimNIBS | Simulation of Non-invasive Brain Stimulation — FEM solver |
| TI | Temporal interference — brain stimulation via interfering high-frequency fields |
| WM | White matter — brain tissue containing myelinated axon fibers |
tit.calc implements.tit/constants.py.tit/stats/; non-parametric approach for spatial neuroimaging data.What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/ti-codebaseTI-Toolbox codebase patterns, module graph, conventions and architecture (v3 — Electron desktop app, FastAPI tit.server, shared tit science core). Use when reading or modifying source under tit/ or desktop/ (developers)./ti-run-pipelinesRun TI-Toolbox pipelines for the user through the app they have open — copy raw DICOM/NIfTI into the project's sourcedata, preprocess (charm head model), flex-search or ex-search optimisation, simulate a montage or an optimisation result, and follow the jobs. Use when the user asks you to DO something with their data in TI-Toolbox ("preprocess sub-101", "optimise for the thalamus", "simulate the best montage"), not to explain it. Needs the ti-toolbox-jobs MCP server./npx claudepluginhub idossha/ti-toolbox --plugin ti-toolboxOther plugins' skills for the same job