-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1996 from samuelgarcia/split_merge_clean
implement proof of concept merge_clusters/split_clusters from tridesclous and columbia codes.
- Loading branch information
Showing
11 changed files
with
1,200 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import numpy as np | ||
|
||
from .tools import FeaturesLoader, compute_template_from_sparse | ||
|
||
# This is work in progress ... | ||
|
||
|
||
def clean_clusters( | ||
peaks, | ||
peak_labels, | ||
recording, | ||
features_dict_or_folder, | ||
peak_sign="neg", | ||
): | ||
total_channels = recording.get_num_channels() | ||
|
||
if isinstance(features_dict_or_folder, dict): | ||
features = features_dict_or_folder | ||
else: | ||
features = FeaturesLoader(features_dict_or_folder) | ||
|
||
clean_labels = peak_labels.copy() | ||
|
||
sparse_wfs = features["sparse_wfs"] | ||
sparse_mask = features["sparse_mask"] | ||
|
||
labels_set = np.setdiff1d(peak_labels, [-1]).tolist() | ||
n = len(labels_set) | ||
|
||
count = np.zeros(n, dtype="int64") | ||
for i, label in enumerate(labels_set): | ||
count[i] = np.sum(peak_labels == label) | ||
print(count) | ||
|
||
templates = compute_template_from_sparse(peaks, peak_labels, labels_set, sparse_wfs, sparse_mask, total_channels) | ||
|
||
if peak_sign == "both": | ||
max_values = np.max(np.abs(templates), axis=(1, 2)) | ||
elif peak_sign == "neg": | ||
max_values = -np.min(templates, axis=(1, 2)) | ||
elif peak_sign == "pos": | ||
max_values = np.max(templates, axis=(1, 2)) | ||
print(max_values) | ||
|
||
return clean_labels |
Oops, something went wrong.