SpikeParser
SpikeParser detects brief spike-like events in ionic current traces. It
wraps scipy.signal.find_peaks and interprets parameters as fractions of
the signal mean when fractional=True (the default).
from ionique.parsers import SpikeParser
parser = SpikeParser(
prominence=0.15,
distance=100,
width=(5, 200),
fractional=True,
)
trace.parse(parser, newrank="event", at_child_rank="vstep")
Parameters
Parameter |
Default |
Description |
|---|---|---|
|
|
Minimum spike height. When |
|
|
Minimum vertical distance to neighboring samples. |
|
|
Minimum horizontal distance (in samples) between peaks. |
|
|
Minimum peak prominence — how much a peak stands out from its surroundings. This is usually the most important parameter. |
|
|
SNR-based prominence (alternative to |
|
|
Required peak width. Pass a tuple |
|
|
Window length for prominence calculation. |
|
|
Relative height at which width is measured (0–1). |
|
|
Minimum flat-top length for plateau detection. |
|
|
When |
Parameter sensitivity
The figures below show how each parameter affects detection on the same synthetic spike signal.
height
Controls the minimum absolute (or fractional) spike amplitude. Lower values detect smaller events; higher values miss shallow dips.
prominence
Prominence measures how much a peak stands out relative to its surrounding baseline. This is generally the single most useful parameter for nanopore spike detection.
distance
Minimum spacing between detected peaks (in samples). Increase this to prevent detecting multiple hits on a single wide event.
width
Filter by peak width. Pass a tuple (min_width, max_width) to reject
events that are too narrow (noise) or too wide (baseline drift).
Full example
from ionique.parsers import SpikeParser
parser = SpikeParser(
prominence=0.15,
distance=100,
width=(1, 200),
fractional=True,
)
trace.parse(parser, newrank="event", at_child_rank="vstep")
events = trace.traverse_to_rank("event")
print(f"Detected {len(events)} spike events")
for ev in events[:5]:
print(f" samples {ev.start}–{ev.end}, mean={ev.mean:.3f} nA")
Tips
Start with
prominenceonly, then adddistanceandwidthto refine.Set
fractional=Falseif you know the absolute current scale and want to specify parameters in nanoamperes directly.For very noisy data, lowpass-filter first (see Signal Preprocessing), then use a moderate
prominence.