/ proof-of-concept / audio-spike-sorting
Sign in
proof-of-concept / audio-spike-sorting
audio-spike-sorting / src / algorithms / index.ts
52 lines · 1.5 KBBlameHistoryRaw
1/**
2 * The built-in baseline algorithms. Their sources ship with the app and
3 * can be reset to these originals after editing; user-added algorithms
4 * live only in the store.
5 */
6import type { AlgorithmDef } from '../bench/types.ts';
7import matchedFilterSrc from './template_matched_filter.m?raw';
8import onsetKnnSrc from './onset_knn.m?raw';
9import silenceGapKnnSrc from './silence_gap_knn.m?raw';
10import naiveSrc from './naive_threshold.m?raw';
12export const BUILTIN_ALGORITHMS: AlgorithmDef[] = [
13 {
14 id: 'builtin:template_matched_filter',
15 name: 'template_matched_filter',
16 source: matchedFilterSrc,
17 enabled: true,
18 builtin: true,
19 },
20 {
21 id: 'builtin:onset_knn',
22 name: 'onset_knn',
23 source: onsetKnnSrc,
24 enabled: true,
25 builtin: true,
26 },
27 {
28 id: 'builtin:silence_gap_knn',
29 name: 'silence_gap_knn',
30 source: silenceGapKnnSrc,
31 enabled: true,
32 builtin: true,
33 },
34 {
35 id: 'builtin:naive_threshold',
36 name: 'naive_threshold',
37 source: naiveSrc,
38 enabled: true,
39 builtin: true,
40 },
41];
43export const NEW_ALGORITHM_TEMPLATE = `function [times, labels] = my_sorter(x, fs, training)
44% x recording, column vector at fs Hz
45% training struct: snips {1 x nTypes} cell of [snipLen x nSnips] matrices
46% (columns are snippets), names {1 x nTypes}, pre (samples
47% before the event onset within each snippet)
48% Return event times in seconds and 1-based type labels.
49times = zeros(0, 1);
50labels = zeros(0, 1);
51end
52`;
↑↓ move↵openescclose