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

height

None

Minimum spike height. When fractional=True, interpreted as a fraction of the segment mean.

threshold

None

Minimum vertical distance to neighboring samples.

distance

None

Minimum horizontal distance (in samples) between peaks.

prominence

None

Minimum peak prominence — how much a peak stands out from its surroundings. This is usually the most important parameter.

prominence_snr

None

SNR-based prominence (alternative to prominence).

width

None

Required peak width. Pass a tuple (min, max) to filter by width.

wlen

None

Window length for prominence calculation.

rel_height

0.5

Relative height at which width is measured (0–1).

plateu_size

None

Minimum flat-top length for plateau detection.

fractional

True

When True, height, threshold, prominence, and distance are scaled by the segment mean.

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.

SpikeParser height parameter comparison

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.

SpikeParser prominence parameter comparison

distance

Minimum spacing between detected peaks (in samples). Increase this to prevent detecting multiple hits on a single wide event.

SpikeParser distance parameter comparison

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).

SpikeParser width parameter comparison

Full example

SpikeParser full detection 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 prominence only, then add distance and width to refine.

  • Set fractional=False if 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.