TesFlexOptimization¶
Initialization¶
Python
from simnibs import opt_struct opt = opt_struct.TesFlexOptimization()
MATLAB
opt = opt_struct('TesFlexOptimization');
Attributes¶
- class simnibs.opt_struct.TesFlexOptimization(settings_dict=None)¶
Defines a TES optimization problem using node-wise current sources.
Parameters (general)¶
- electrodeElectrode Object
Electrode object containing ElectrodeArray instances (pre-implemented layouts: ElectrodeArrayPair, CircularArray)
- roilist of RegionOfInterest class instances
Region of interest(s) the field is evaluated in.
- goallist of str [n_roi], or FunctionType, optional, default: [“mean”]
Implemented or user provided goal functions:
“mean”: maximize mean e-field in ROI
“max”: maximize 99.9 percentile of electric field in ROI
“focality”: Maximize focality (goal: sensitivity = specificity = 1). NOTE: “focality” needs excatly two ROIs: The first will be treated as ROI, the second as non-ROI.
“focality_inv”: Maximize inverse focality (goal: sensitivity(ROI) = 1, sensitivity(nonROI) = 1). NOTE: “focality” needs excatly two ROIs: The first will be treated as ROI, the second as non-ROI.
user provided function taking e-field as an input which is a list of list of np.ndarrays of float [n_channel_stim][n_roi] containing np.array with e-field
- e_postprocstr, optional, default: “norm”
Specifies how the raw e-field in the ROI (Ex, Ey, Ez) is post-processed:
“norm”: electric field magnitude (default)
“normal”: determine normal component (requires surface ROIS)
“tangential”: determine tangential component (requires surface ROIS)
“max_TI”: maximum envelope for temporal interference fields
“dir_TI”: directional sensitive maximum envelope for temporal interference fields (requires surface ROIS)
- min_electrode_distancefloat, optional, default: 5.0
Minimally ensured distance between electrodes of different arrays (in mm).
- constrain_electrode_locationsbool, optional, default: False
Constrains the possible locations of freely movable electrode arrays. Recommended for TTF optimizations, where two pairs of large electrode arrays are optimized. If True, parameter bounds for the optimization will be specified restricting the array locations to be frontal, parietal and occipital.
- overlap_factorfloat, optional, default: 1
Factor of overlap of allowed lambda regions to place electrodes. (1 corresponds to neatless regions, <1 regions have a gap in between, >1 regions are overlapping)
- weightsnp.array of float [n_roi], optional, default: equal weights for each ROI
Weights for optimizer for ROI specific goal function weighting NOTE: Will be ignored for “focality” and “focality_inv” goals (see below), where ROI and non-ROI are combined into a single goal function value
Parameters (optimizer + FEM)¶
- optimizerstr, optional, default: “differential_evolution”
Gobal optimization algorithm
- polishbool, optional, default: False
If True, then scipy.optimize.minimize with the L-BFGS-B method is used to polish the best population member at the end, which can improve the minimization.
- run_final_electrode_simulationbool, optional, default: True
Runs final simulation with optimized parameters using real electrode model including remeshing. Note: This is required to get final e-fields for visualization
- anisotropy_typestr, optional, default: ‘scalar’
Specify type of anisotropy for simulation (‘scalar’, ‘vn’ or ‘mc’)
- disable_SPR_for_volume_roibool, optional, default: True
Whether to use SPR interpolation for volume rois
Parameters (debugging)¶
- initial_x0: numpy.array, optional, default: None
starting values for optimization (will be automatically determined per default)
- detailed_resultsbool, optional, default: False
write detailed results into subfolder of output folder for visualization and control
- track_focalitybool, optional, default: False
Tracks focality for each goal function value (requires ROI and non-ROI definition)