Skip to content

radiens_core.models.dataset

DatasetMetadata — immutable metadata for a linked dataset.

Attributes

FlexDataset module-attribute

FlexDataset = DatasetMetadata | str | Path

DatasetMetadata that also accepts an ID string or file Path.

Resolution from string/path to DatasetMetadata happens inside the client via _resolve_dataset(). The BeforeValidator validates the input type and provides clear errors for invalid arguments.

Use with @validate_call::

@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def get_signals(self, dataset: FlexDataset, ...) -> ...:
    meta = self._resolve_dataset(dataset)
    ...

FlexTimeRange module-attribute

FlexTimeRange = TimeRangeSpec | Sequence[float]

TimeRangeSpec that also accepts list/tuple shorthand.

Use in Pydantic models::

class MyRequest(BaseModel):
    time_range: FlexTimeRange

Type Aliases

TransformParams

TransformParams = (
    HighLowPassParams
    | BandParams
    | NotchParams
    | CARParams
    | VirtualRefParams
    | PairedRefParams
    | SliceTimeParams
    | SliceChannelsParams
    | DownsampleParams
    | SourceParams
    | SinkParams
    | BulkSourceParams
    | BulkSinkParams
    | None
)

Union of all transform parameter types (or None for parameter-free nodes).

Classes

BandParams

Bases: BaseModel

Parameters for band-pass or band-stop filter transform nodes.

Attributes

high_frequency instance-attribute
high_frequency

Upper cutoff frequency in Hz.

low_frequency instance-attribute
low_frequency

Lower cutoff frequency in Hz.

order class-attribute instance-attribute
order = None

Filter order; None uses the server default.

BulkSinkParams

Bases: BaseModel

Parameters for BULK_SINK transform nodes.

Attributes

file_type instance-attribute
file_type

Output recording file format.

path instance-attribute
path

Output directory path.

suffix instance-attribute
suffix

Suffix appended to each output file's base name.

BulkSourceParams

Bases: BaseModel

Parameters for BULK_SOURCE transform nodes.

Attributes

sources instance-attribute
sources

One entry per input dataset.

CARParams

Bases: BaseModel

Parameters for Common Average Reference transform nodes (no fields).

DatasetMetadata

Bases: BaseModel

Metadata for a linked dataset.

Returned by link_data_file() and similar operations. Contains everything needed to query signals from this dataset.

Attributes:

Name Type Description
id str

Unique identifier for the dataset.

base_name str

Base name of the dataset.

path str

Full filesystem path to the dataset.

file_type RadiensFileType

Type of the recording file. References RadiensFileType.

time_range TimeRange

Valid time range for this dataset. References TimeRange.

channel_metadata ChannelMetadata

Channel configuration and metadata. References ChannelMetadata.

parent_dsource_id str

Identifier for the parent data source. Defaults to "".

probe_uid str

Unique identifier for the probe used. Defaults to "".

associated_spikes_ids list[str]

Registered spikes datasource IDs discovered when the recording file was linked (populated by link_data_file()). Empty if no .spikes file was found alongside the recording.

Attributes

base_path property
base_path

Full path to the dataset file (directory + base name).

duration property
duration

Dataset duration in seconds.

sampling_rate property
sampling_rate

Sampling rate in Hz.

DownsampleParams

Bases: BaseModel

Parameters for downsample transform nodes.

Attributes

factor instance-attribute
factor

Downsampling factor (e.g., 2, 4, 10).

FileInfo

Bases: BaseModel

Filesystem entry metadata returned by list_directory.

Attributes:

Name Type Description
path str

Full filesystem path to the file.

base_name str

Base name of the file without directory components.

file_type RadiensFileType

Type of the recording file. References RadiensFileType.

dataset_uid str

Unique identifier for the dataset.

num_channels int

Number of channels in the file.

duration_sec float

Total duration of the recording in seconds.

sample_rate int

Sampling rate in Hertz.

num_bytes int

Size of the file in bytes.

HighLowPassParams

Bases: BaseModel

Parameters for high-pass or low-pass filter transform nodes.

Attributes

frequency instance-attribute
frequency

Cutoff frequency in Hz.

order class-attribute instance-attribute
order = None

Filter order; None uses the server default.

NotchParams

Bases: BaseModel

Parameters for notch filter transform nodes.

Note

The notch filter is always second-order (scipy.signal.iirnotch). Unlike other IIR filters, it does not accept a custom order.

Attributes

bandwidth instance-attribute
bandwidth

Width of the rejection band in Hz.

notch_frequency instance-attribute
notch_frequency

Center frequency to reject in Hz.

PairedRefParams

Bases: BaseModel

Parameters for paired reference transform nodes.

Attributes

ref_channel instance-attribute
ref_channel

Native channel index of the reference electrode.

target_channel instance-attribute
target_channel

Native channel index of the channel to re-reference.

ProtocolSpec

Bases: BaseModel

Minimal summary of a saved protocol.

Returned by get_protocol and get_all_protocols.

Attributes:

Name Type Description
id str

Unique identifier for the protocol.

node_count int

Number of nodes defined in the protocol.

RadiensFileType

Bases: IntEnum

Recording file type. Values match proto common.RadixFileTypes.

SinkParams

Bases: BaseModel

Parameters for SINK transform nodes.

Attributes

base_name instance-attribute
base_name

Output base filename (without extension or directory).

file_type instance-attribute
file_type

Output recording file format.

path instance-attribute
path

Output directory path.

SliceChannelsParams

Bases: BaseModel

Parameters for channel-slice transform nodes.

Attributes

channels instance-attribute
channels

System-wide channel indices to keep.

SliceTimeParams

Bases: BaseModel

Parameters for time-slice transform nodes.

Attributes

end_sec instance-attribute
end_sec

End of the time window in seconds.

start_sec instance-attribute
start_sec

Start of the time window in seconds.

SourceParams

Bases: BaseModel

Parameters for SOURCE transform nodes.

Attributes

base_name instance-attribute
base_name

Base filename (without extension or directory).

dataset_id class-attribute instance-attribute
dataset_id = ''

ID of the linked dataset (empty for new sources).

file_type instance-attribute
file_type

Recording file format.

path instance-attribute
path

Directory path containing the dataset.

TimeRangeSpec

Bases: BaseModel

Semantic time range specification with embedded mode.

Use factory methods to create specs with clear semantics:

spec = TimeRangeSpec.subset(0, 10) # [0, 10) seconds spec = TimeRangeSpec.lookback(5.0) # Last 5 seconds spec = TimeRangeSpec.full() # Entire recording

Attributes:

Name Type Description
mode TrsMode

Time range selection mode. References TrsMode.

start float

Start time or duration depending on the mode.

end float | None

End time for subset mode. Defaults to None.

Attributes

duration property
duration

Duration in seconds, if known.

Functions

from_list classmethod
from_list(time_range, mode=None)

Create from [start, end] or [duration, nan] list.

full classmethod
full()

Full dataset/cache range.

is_full
is_full()

Check if this is a full-range specification.

lookback classmethod
lookback(duration)

Last duration seconds from head of cache.

resolve
resolve(dataset_metadata=None, fs=None)

Resolve to a concrete TimeRange.

dataset_metadata Dataset metadata used to obtain fs and dataset bounds. fs Sampling rate override (used when dataset_metadata is not provided).

TimeRange or None None for FROM_HEAD mode — caller must use to_array() instead.

subset classmethod
subset(start, end)

Absolute time range [start, end) seconds.

to_array
to_array()

Convert to [start, end] or [duration, nan] array.

to_head classmethod
to_head(start)

From start seconds to current head.

TransformEdge

Bases: BaseModel

A directed edge connecting two nodes in a protocol graph.

Use the source and target fields to specify connectivity by node ID.

Attributes

id class-attribute instance-attribute
id = Field(default_factory=lambda: str(uuid4()))

Edge ID (auto-generated UUID if not provided).

source instance-attribute
source

ID of the source transform node.

target instance-attribute
target

ID of the target transform node.

TransformNode

Bases: BaseModel

A node in a curation protocol transform graph.

Construct nodes using the factory class methods for convenience::

src = TransformNode.source(dataset_meta)
hp  = TransformNode.highpass(frequency=300.0)
snk = TransformNode.sink("filtered", "/output", RadiensFileType.XDAT)

edges = [
    TransformEdge(source=src.id, target=hp.id),
    TransformEdge(source=hp.id, target=snk.id),
]

Then pass [src, hp, snk] and edges to CurateClient.set_protocol().

Notes

Each factory method sets the correct type and params for its transform. When constructing manually, the params object must match the type (e.g., CAR_REF requires params=CARParams()).

Attributes

id class-attribute instance-attribute
id = Field(default_factory=lambda: str(uuid4()))

Node ID (auto-generated UUID if not provided).

params class-attribute instance-attribute
params = None

Operation parameters; see each factory method for the expected type.

type instance-attribute
type

Transform operation this node performs.

Functions

bandpass classmethod
bandpass(low_frequency, high_frequency, order=None)

Create a BANDPASS_FILTER node.

low_frequency: Lower cutoff frequency in Hz. high_frequency: Upper cutoff frequency in Hz. order: Filter order; None uses the server default.

bandstop classmethod
bandstop(low_frequency, high_frequency, order=None)

Create a BANDSTOP_FILTER node.

low_frequency: Lower cutoff frequency in Hz. high_frequency: Upper cutoff frequency in Hz. order: Filter order; None uses the server default.

bulk_sink classmethod
bulk_sink(suffix, path, file_type)

Create a BULK_SINK node.

suffix: Suffix appended to each output file's base name. path: Output directory path. file_type: Output recording file format.

bulk_source classmethod
bulk_source(datasets)

Create a BULK_SOURCE node from multiple linked datasets.

datasets: Metadata for all input datasets.

car classmethod
car()

Create a CAR_REF (Common Average Reference) node.

downsample classmethod
downsample(factor)

Create a DOWNSAMPLE node.

factor: Downsampling factor (e.g., 2, 4, 10).

highpass classmethod
highpass(frequency, order=None)

Create a HIGHPASS_FILTER node.

frequency: Cutoff frequency in Hz. order: Filter order; None uses the server default.

lowpass classmethod
lowpass(frequency, order=None)

Create a LOWPASS_FILTER node.

frequency: Cutoff frequency in Hz. order: Filter order; None uses the server default.

notch classmethod
notch(notch_frequency, bandwidth)

Create a NOTCH_FILTER node.

The notch filter is always second-order (scipy.signal.iirnotch). Unlike other IIR filters, it does not accept a custom order.

notch_frequency: Center frequency to reject in Hz. bandwidth: Width of the rejection band in Hz.

paired_ref classmethod
paired_ref(ref_channel, target_channel)

Create a PAIRED_REF node.

ref_channel: Native channel index of the reference electrode. target_channel: Native channel index of the channel to re-reference.

sink classmethod
sink(base_name, path, file_type)

Create a SINK node.

base_name: Output base filename (without extension or directory). path: Output directory path. file_type: Output recording file format.

slice_channels classmethod
slice_channels(channels)

Create a SLICE_CHANNELS node.

channels: System-wide channel indices to keep.

slice_time classmethod
slice_time(start_sec, end_sec)

Create a SLICE_TIME node.

start_sec: Start of the time window in seconds. end_sec: End of the time window in seconds.

source classmethod
source(dataset)

Create a SOURCE node from a linked dataset.

dataset: Metadata for the input dataset (returned by link_data_file).

virtual_ref classmethod
virtual_ref(ref_channel)

Create a VIRTUAL_REF node.

ref_channel: Native channel index of the reference electrode.

TransformNodeType

Bases: IntEnum

Transform node type for curation protocol graphs.

Values match proto common.TransformNodeType.

TrsMode

Bases: IntEnum

Time range selection mode. Values match proto common.TimeRangeSelMode.

VirtualRefParams

Bases: BaseModel

Parameters for virtual reference transform nodes.

Attributes

ref_channel instance-attribute
ref_channel

Native channel index of the reference electrode.