Skip to content

Commit

Permalink
change cluster labels for 'noise' only, retain 'good' and 'mua'
Browse files Browse the repository at this point in the history
replicating commit of same name from rig43_catgt1.6 branch of msosa fork
  • Loading branch information
emilyasterjones committed Jan 16, 2022
1 parent f2c012d commit 41b303c
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions ecephys_spike_sorting/modules/noise_templates/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from .id_noise_templates import id_noise_templates, id_noise_templates_rf

from ...common.utils import write_cluster_group_tsv, load_kilosort_data
from ...common.utils import write_cluster_group_tsv, load_kilosort_data, read_cluster_group_tsv


def classify_noise_templates(args):
Expand Down Expand Up @@ -41,10 +41,27 @@ def classify_noise_templates(args):
cluster_ids, is_noise = id_noise_templates(cluster_ids, templates, np.squeeze(channel_map), \
args['noise_waveform_params'])

mapping = {False: 'good', True: 'noise'}
labels = [mapping[value] for value in is_noise]
#mapping = {False: 'good', True: 'noise'}
#labels = [mapping[value] for value in is_noise]
ci_tmp, cluster_group = read_cluster_group_tsv(os.path.join(args['directories']['kilosort_output_directory'], \
'cluster_KSLabel.tsv'))

write_cluster_group_tsv(cluster_ids,
print('KS output ' + args['directories']['kilosort_output_directory'])

labels = [ ]
for i, ci in enumerate(ci_tmp):
if is_noise[cluster_ids==ci]:
labels.append('noise')
else:
labels.append(cluster_group[i])

#write_cluster_group_tsv(cluster_ids,
# labels,
# args['directories']['kilosort_output_directory'],
# args['ephys_params']['cluster_group_file_name'])
print(f"{sum([x=='good' for x in labels])} remaining good units")

write_cluster_group_tsv(ci_tmp,
labels,
args['directories']['kilosort_output_directory'],
args['ephys_params']['cluster_group_file_name'])
Expand Down

0 comments on commit 41b303c

Please sign in to comment.