calc
tit.calc ¶
Shared TI Field Calculation Utilities Used by optimization tools
get_TI_vectors ¶
Calculate the temporal interference (TI) modulation amplitude vectors.
This function implements the Grossman et al. 2017 algorithm for computing TI vectors that represent both the direction and magnitude of maximum modulation amplitude when two sinusoidal electric fields interfere.
PHYSICAL INTERPRETATION: When two electric fields E1(t) = E1cos(2πf1t) and E2(t) = E2cos(2πf2t) with slightly different frequencies are applied simultaneously, they create a beating pattern. The TI vector indicates: - DIRECTION: Spatial direction of maximum envelope modulation - MAGNITUDE: Maximum envelope amplitude = 2 * effective_amplitude
ALGORITHM (Grossman et al. 2017): 1. Preprocessing: Ensure |E1| ≥ |E2| and acute angle α < π/2 2. Regime selection based on geometric relationship: - Regime 1 (parallel): |E2| ≤ |E1|cos(α) → TI = 2E2 - Regime 2 (oblique): |E2| > |E1|cos(α) → TI = 2E2_perpendicular_to_h where h = E1 - E2
Parameters¶
E1_org : np.ndarray, shape (N, 3) Electric field vectors from electrode pair 1 [V/m] E2_org : np.ndarray, shape (N, 3) Electric field vectors from electrode pair 2 [V/m]
Returns¶
TI_vectors : np.ndarray, shape (N, 3) TI modulation amplitude vectors [V/m] Direction: Maximum modulation direction Magnitude: Maximum envelope amplitude
References¶
Grossman, N. et al. (2017). Noninvasive Deep Brain Stimulation via Temporally Interfering Electric Fields. Cell, 169(6), 1029-1041.
Source code in tit/calc.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
get_nTI_vectors ¶
Compute mTI vectors for N E-fields using recursive binary-tree pairwise TI.
N must be even. Fields are paired sequentially: (E1,E2), (E3,E4), etc. Then intermediate TI results are paired recursively until one result remains.
For 2 fields: TI(E1, E2) For 4 fields: TI(TI(E1,E2), TI(E3,E4)) For 6 fields: TI(TI(TI(E1,E2), TI(E3,E4)), TI(E5,E6)) For 8 fields: TI(TI(TI(E1,E2), TI(E3,E4)), TI(TI(E5,E6), TI(E7,E8)))
Parameters¶
fields : list of np.ndarray, each shape (N, 3) Electric field vectors, one per electrode pair.
Returns¶
result : np.ndarray, shape (N, 3) Combined TI modulation amplitude vectors.
Raises¶
ValueError If number of fields is not even or less than 2.
Source code in tit/calc.py
get_mTI_vectors ¶
Calculate multi-temporal interference (mTI) vectors from four channel E-fields.
This computes TI between channels 1 and 2 to get TI_A, TI between channels 3 and 4 to get TI_B, and finally TI between TI_A and TI_B to produce the mTI vector field.
Parameters¶
E1_org : np.ndarray, shape (N, 3) Electric field vectors for channel 1 E2_org : np.ndarray, shape (N, 3) Electric field vectors for channel 2 E3_org : np.ndarray, shape (N, 3) Electric field vectors for channel 3 E4_org : np.ndarray, shape (N, 3) Electric field vectors for channel 4
Returns¶
mTI_vectors : np.ndarray, shape (N, 3) Multi-TI modulation amplitude vectors