map_electrodes
tit.tools.map_electrodes ¶
Map optimised electrode positions to the nearest EEG net electrodes.
Uses the Hungarian algorithm (scipy.optimize.linear_sum_assignment)
to find the globally optimal one-to-one assignment between optimised
coordinates produced by the flex-search optimiser and the physical
electrode sites in a SimNIBS EEG net CSV file.
See Also¶
tit.opt.flex : Differential-evolution flex-search optimiser. tit.tools.montage_visualizer : Render montage placement as PNG.
read_csv_positions ¶
Read electrode positions from a CSV file using SimNIBS utilities.
Parameters¶
csv_path : str Path to the file containing electrode positions.
Returns¶
positions : np.ndarray Array of electrode positions (Nx3). labels : list of str List of electrode labels/names.
See Also¶
load_electrode_positions_json : Load positions from optimiser output.
Source code in tit/tools/map_electrodes.py
load_electrode_positions_json ¶
Load optimized electrode positions from electrode_positions.json.
Parameters¶
json_path : str Path to the electrode_positions.json file.
Returns¶
positions : np.ndarray
Array of optimized electrode positions (Nx3).
channel_array_indices : list of list
List of [channel, array] indices for each electrode.
See Also¶
read_csv_positions : Load positions from a SimNIBS EEG net CSV.
Source code in tit/tools/map_electrodes.py
map_electrodes_to_net ¶
Map optimized electrode positions to nearest EEG net positions using the Hungarian algorithm for optimal assignment.
Parameters¶
optimized_positions : np.ndarray Array of optimized electrode positions (Nx3). net_positions : np.ndarray Array of EEG net electrode positions (Mx3). net_labels : list List of EEG net electrode labels. channel_array_indices : list List of [channel, array] indices for each optimized electrode.
Returns¶
mapping_result : dict Dictionary containing: - optimized_positions: Original optimized positions - mapped_positions: Corresponding net positions - mapped_labels: Labels of mapped net electrodes - distances: Distances between optimized and mapped positions - channel_array_indices: Channel and array indices
Source code in tit/tools/map_electrodes.py
save_mapping_result ¶
Save mapping result to a JSON file.
Parameters¶
mapping_result : dict Dictionary containing mapping information. output_path : str Path where to save the JSON file. eeg_net_name : str, optional Name of the EEG net file used.
Source code in tit/tools/map_electrodes.py
log_mapping_summary ¶
Log a summary of the electrode mapping results.
Parameters¶
mapping_result : dict Dictionary containing mapping information.