@@ -902,7 +902,7 @@ def _auto_topomap_coords(info, picks, ignore_overlap, to_sphere, sphere):
902
902
# Use channel locations if available
903
903
locs3d = np .array ([ch ["loc" ][:3 ] for ch in chs ])
904
904
905
- # If electrode locations are not available, use digization points
905
+ # If electrode locations are not available, use digitization points
906
906
if not _check_ch_locs (info = info , picks = picks ):
907
907
logging .warning (
908
908
"Did not find any electrode locations (in the info "
@@ -1089,7 +1089,7 @@ def _pair_grad_sensors(
1089
1089
return picks
1090
1090
1091
1091
1092
- def _merge_ch_data (data , ch_type , names , method = "rms" ):
1092
+ def _merge_ch_data (data , ch_type , names , method = "rms" , * , modality = "opm" ):
1093
1093
"""Merge data from channel pairs.
1094
1094
1095
1095
Parameters
@@ -1102,6 +1102,8 @@ def _merge_ch_data(data, ch_type, names, method="rms"):
1102
1102
List of channel names.
1103
1103
method : str
1104
1104
Can be 'rms' or 'mean'.
1105
+ modality : str
1106
+ The modality of the data, either 'grad', 'fnirs', or 'opm'
1105
1107
1106
1108
Returns
1107
1109
-------
@@ -1112,9 +1114,13 @@ def _merge_ch_data(data, ch_type, names, method="rms"):
1112
1114
"""
1113
1115
if ch_type == "grad" :
1114
1116
data = _merge_grad_data (data , method )
1115
- else :
1116
- assert ch_type in _FNIRS_CH_TYPES_SPLIT
1117
+ elif modality == "fnirs" or ch_type in _FNIRS_CH_TYPES_SPLIT :
1117
1118
data , names = _merge_nirs_data (data , names )
1119
+ elif modality == "opm" and ch_type == "mag" :
1120
+ data , names = _merge_opm_data (data , names )
1121
+ else :
1122
+ raise ValueError (f"Unknown modality { modality } for channel type { ch_type } " )
1123
+
1118
1124
return data , names
1119
1125
1120
1126
@@ -1180,6 +1186,37 @@ def _merge_nirs_data(data, merged_names):
1180
1186
return data , merged_names
1181
1187
1182
1188
1189
+ def _merge_opm_data (data , merged_names ):
1190
+ """Merge data from multiple opm channel by just using the radial component.
1191
+
1192
+ Channel names that end in "MERGE_REMOVE" (ie non-radial channels) will be
1193
+ removed. Only the the radial channel is kept.
1194
+
1195
+ Parameters
1196
+ ----------
1197
+ data : array, shape = (n_channels, ..., n_times)
1198
+ Data for channels.
1199
+ merged_names : list
1200
+ List of strings containing the channel names. Channels that are to be
1201
+ removed end in "MERGE_REMOVE".
1202
+
1203
+ Returns
1204
+ -------
1205
+ data : array
1206
+ Data for channels with requested channels merged. Channels used in the
1207
+ merge are removed from the array.
1208
+ """
1209
+ to_remove = np .empty (0 , dtype = np .int32 )
1210
+ for idx , ch in enumerate (merged_names ):
1211
+ if ch .endswith ("MERGE-REMOVE" ):
1212
+ to_remove = np .append (to_remove , idx )
1213
+ to_remove = np .unique (to_remove )
1214
+ for rem in sorted (to_remove , reverse = True ):
1215
+ del merged_names [rem ]
1216
+ data = np .delete (data , to_remove , axis = 0 )
1217
+ return data , merged_names
1218
+
1219
+
1183
1220
def generate_2d_layout (
1184
1221
xy ,
1185
1222
w = 0.07 ,
0 commit comments