Fix get_closest_channels logic
@@ -59,32 +59,35 @@ def get_closest_channels(recording, channel_ids=None, num_channels=None):
Parameters
----------
recording: RecordingExtractor
- The recording extractor to be re-referenced
- channel_ids: list or int
- list of channels id to compute there near neighborhood
+ The recording extractor to get closest channels
+ channel_ids: list
+ List of channels ids to compute there near neighborhood
num_channels: int, optional
Maximum number of neighborhood channel to return
Returns
-------
- : array (2d)
- closest channel indices in ascending order for each channel id given in input
- : array (2d)
- distance in ascending order for each channel id given in input
+ closest_channels_inds : array (2d)
+ Closest channel indices in ascending order for each channel id given in input
+ dists: array (2d)
+ Distance in ascending order for each channel id given in input
"""
- closest_channels_id = []
+ if channel_ids is None:
+ channel_ids = recording.get_channel_ids()
+ if num_channels is None:
+ num_channels = len(channel_ids) - 1
locations = recording.get_channel_locations(channel_ids=channel_ids)
closest_channels_inds = []
- dist = []
+ dists = []
for i in range(locations.shape[0]):
distances = np.linalg.norm(locations[i, :] - locations, axis=1)
order = np.argsort(distances)
- closest_channels_inds.append(order[1:num_channels])
- dist.append(distances[order][1:num_channels])
+ closest_channels_inds.append(order[1:num_channels + 1])
+ dists.append(distances[order][1:num_channels + 1])
- return np.array(closest_channels_inds), np.array(dist)
+ return np.array(closest_channels_inds), np.array(dists)
def get_noise_levels(recording, return_scaled=True, **random_chunk_kwargs):
