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
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
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
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 723 724 725 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 | |
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
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 902 903 904 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 | |
summarize_onset_events(events)
Summarize onset-detection events by subject/decoder/emission group.
Source code in src/neureptrace/onset_detection.py
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 824 825 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 | |
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
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |