Onset Detection
neureptrace.onset_detection detects the first threshold-crossing time in held-out probability-observation traces.
The basic detector estimates a score threshold from a baseline window, then reports the first time each trial/sequence crosses that threshold. The module also supports sustained-onset criteria and a sequence-level max-run threshold to reduce false detections from scanning many time bins.
Sustained-onset controls
Use the following options to require a more persistent representation onset:
python -m neureptrace.onset_detection \
results/nod_sub-01_animate_observations.csv \
--threshold-window -0.10 0.00 \
--threshold-quantile 0.95 \
--threshold-method max_run \
--detection-start 0.00 \
--min-consecutive 3 \
--require-stable-prediction \
--out-events results/nod_sub-01_animate_onset_events.csv \
--out-summary results/nod_sub-01_animate_onset_summary.csv
--min-consecutiverequires at least this many adjacent above-threshold windows.--min-durationrequires the above-threshold run to last at least the given duration in seconds.--require-stable-predictionbreaks an onset run when the predicted class changes across adjacent above-threshold bins.--threshold-method max_runestimates the threshold from sequence-level baseline maxima under the same run criteria, rather than from pointwise baseline scores.
The event CSV includes the run length, run duration, run stop time, and peak score within the detection run. The summary CSV reports detection rates, false-alarm rates, post-zero detection rates, correct-at-detection rates, and median post-zero detection latencies.
neureptrace.onset_detection
annotate_threshold_crossings(observations, *, threshold_window=DEFAULT_THRESHOLD_WINDOW, threshold_quantile=DEFAULT_THRESHOLD_QUANTILE, score_column='confidence', threshold_method='point', min_consecutive=1, min_duration=None, require_stable_prediction=False)
Annotate observation rows with baseline-derived threshold crossings.
Source code in src/neureptrace/onset_detection.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |
detect_onsets(observations, *, threshold_window=DEFAULT_THRESHOLD_WINDOW, threshold_quantile=DEFAULT_THRESHOLD_QUANTILE, score_column='confidence', threshold_method='point', detection_start=None, detection_window=None, min_consecutive=1, min_duration=None, require_stable_prediction=False)
Find the first threshold-crossing time for each probability-observation sequence.
min_consecutive and min_duration can be used to suppress single-bin
spikes by requiring the threshold crossing to be sustained. With
require_stable_prediction=True, an onset run is also broken when the
predicted class changes across adjacent above-threshold bins.
Source code in src/neureptrace/onset_detection.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | |
detect_onsets_from_csvs(observation_csvs, *, threshold_window=DEFAULT_THRESHOLD_WINDOW, threshold_quantile=DEFAULT_THRESHOLD_QUANTILE, score_column='confidence', threshold_method='point', detection_start=None, event_window=None, min_consecutive=1, min_duration=None, require_stable_prediction=False, out_events=None, out_summary=None, out_thresholded_observations=None, out_threshold_summary=None, detection_window=DEFAULT_DETECTION_WINDOW)
Read probability observations, detect onsets, and optionally write CSV outputs.
Source code in src/neureptrace/onset_detection.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
summarize_onset_events(events)
Summarize onset-detection events by subject/decoder/emission group.
Source code in src/neureptrace/onset_detection.py
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | |
summarize_threshold_crossings(thresholded_observations, *, baseline_window=DEFAULT_THRESHOLD_WINDOW, detection_window=DEFAULT_DETECTION_WINDOW)
Summarize baseline false positives separately from post-event detections.
Source code in src/neureptrace/onset_detection.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | |