radiens_qc.raw
Fetch raw signal, threshold crossings and spectra for the raw-signal figures.
Nothing here is archived on a :class:~radiens_qc.report.QualityReport. A
report is a measurement -- what the KPI pass produced, what save_report
writes and load_report round-trips. An excerpt is a view into the
recording, which needs the file linked and a server up, so it is requested when
a figure is drawn and thrown away afterwards. That is why the raw-signal figures
take (vc, dataset) while the report figures stay pure over a report: a
figure that needs a server says so in its arguments.
Everything a figure reads is measured on the same signal the rest of the report
was: :func:~radiens_qc.preprocess.apply_detection_settings sets the stage-2 DSP
group and the detection threshold, get_signals(apply_dsp=True) reads back
through that same stage, and the crossings come from a fileset checked to be
detected at that threshold. So the filtered trace, the crossings drawn on it, and
event_rate in the report all describe one signal rather than three
approximations of it.
Classes
Excerpt
dataclass
One slice of the recording, read twice through different filter stages.
wideband and filtered are (n_channels, n_samples) in the channel
order of the owning :class:RawSignal, and cover the same samples: the pair
is what makes "did the DSP chain do what we think" answerable.
RawSignal
dataclass
Excerpts, crossings, geometry and whole-file spectra for raw-signal figures.
Attributes:
| Name | Type | Description |
|---|---|---|
base_name |
str
|
Recording identifier. |
sampling_rate |
float
|
Sampling rate in Hz. |
duration_sec |
float
|
Recording duration in seconds. |
channel_indices |
tuple[int, ...]
|
Amplifier |
geometry |
DataFrame
|
Per-channel probe geometry, indexed by |
excerpts |
tuple[Excerpt, ...]
|
One per entry of :data: |
crossings |
dict[int, NDArray[float64]]
|
|
detection |
ResolvedDetection
|
Stage-2 filters and detection threshold the excerpts were read through and the crossings found at. |
freqs |
NDArray[float64]
|
Frequency axis in Hz for whole-file spectral estimates. |
psd_wideband |
NDArray[float64]
|
Whole-file wideband Welch power spectral density,
|
psd_filtered |
NDArray[float64]
|
Whole-file stage-2 filtered Welch power spectral density,
|
Methods:
depth_order
Row order that puts spatially adjacent sites next to each other.
See :func:~radiens_qc._dataset.depth_order.
window_crossings
Crossing times on ntv_idx inside the drawn window, on the dataset's own time base.
window_slice
Sample slice of the centered window_sec of excerpt.
Functions:
compute_welch_overlap
Compute overlap_frac in [0.01, 0.5] to cap total Welch segments across a recording.
Enforces overlap_frac >= 0.01 because the Radix server (common.go:200) checks
overlapFrac > 0 and falls back to 0.5 if 0.0 is sent.
excerpt_starts
Excerpt start times on the dataset's own time base.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration_sec
|
float
|
Recording duration. |
required |
t0_sec
|
float
|
The dataset's own start time, which is not necessarily zero. |
required |
fractions
|
Sequence[float]
|
Where in the recording to sample. |
EXCERPT_FRACTIONS
|
excerpt_sec
|
float
|
Length of each excerpt. |
EXCERPT_SEC
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the recording is shorter than :data: |
fetch_raw_signal
fetch_raw_signal(
vc,
data,
*,
channels=None,
fractions=EXCERPT_FRACTIONS,
excerpt_sec=EXCERPT_SEC,
detection=DEFAULT_DETECTION,
crossings_spikes_id=None,
with_spectra=True,
)
Read paired wideband/filtered excerpts, crossings, and whole-file Welch spectra.
Configures read-time DSP and the detection threshold first, so the filtered
excerpt is the signal the KPI engine measured. Whole-file Welch spectra are queried via
radiens-core's spectral analysis API for both wideband and stage-2
filtered signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vc
|
VidereClient
|
Client connected to the server holding the recording. |
required |
data
|
DatasetMetadata | Path
|
An already-linked recording, or a path to link. |
required |
channels
|
Sequence[int] | None
|
Amplifier |
None
|
fractions
|
Sequence[float]
|
Where in the recording to place excerpts. |
EXCERPT_FRACTIONS
|
excerpt_sec
|
float
|
Seconds fetched per excerpt. |
EXCERPT_SEC
|
detection
|
DetectionSettings
|
Stage-2 filters and detection threshold to read through. Pass
the same object given to :func: |
DEFAULT_DETECTION
|
crossings_spikes_id
|
str | None
|
Detect-only fileset to mark crossings from, detected at
|
None
|
with_spectra
|
bool
|
Whether to fetch whole-file Welch spectra via |
True
|
Returns:
| Type | Description |
|---|---|
RawSignal
|
The fetched excerpts, crossings, and whole-file spectra. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the recording is shorter than :data: |