Other data structures, functions, and types

class radiens.lib.channel_metadata.ChannelMetadata(raw=None)

Container for channel metadata.

property table

Metadata table providing metadata on each channel (aka signal) in the dataset.

property attributes

Dictionary of attributes


Signal indices by signal type and index type. All indices are zero-indexed.


stype (SignalType) – Signal type


KeyIdxs (KeyIdxs) – Key index object with keys ntv, dset, sys

See also



>>> meta.index(SignalType.AMP)
>>> KeyIdxs(ntv=[5,1,23,46], dset=[0,1,2,3], sys=[5,1,23,46])
>>> meta.index(SignalType.AIN)
>>> KeyIdxs(ntv=[3,2,0,1], dset=[0,1,2,3], sys=[35,34,32,33])  # signal has 32 AMP channels

See also

KeyIndex SignalType


Selected signal indices by signal type and index type.


stype (~radiens.utils.enums.SignalType): Signal type

See also



Number of signals for the requested signal type.


Number of selected signals for the requested signal type.


Total number of signals

property num_selected_sigs_total

Total number of signals

property sig_units

Dictionary of signal units

property sensor_spec

Dict with ports (str) as keys mapping to dicts describing headstage, site, and probe wireframe metadata

class radiens.lib.dataset_metadata.DatasetMetadata(raw_msg=None)
property id

Dataset ID of this DataSource the Radiens hub. None indicates that it is not on a hub.

property time_range

Dataset time range (TimeRange)

property TR

Alias for time_range.

property channel_metadata

Dataset’s ChannelMetadata, which describes the dataset’s signals (aka channels), probes, positions, etc.

property attributes

Dataset attributes.

property path

File system path of the Radiens data file set that backs this DataSource.

property base_name

File system base name of the Radiens data file set that backs this DataSource.

property file_type

File type of the Radiens data file set that backs this DataSource.

property table

Dataset attributes as a table.


Clears this DataSource’s dataset ID by setting it to None. This is a power user function. Best practice is to call it when the dataset has been cleared from the Radiens hub.

class radiens.lib.allego_lib.AllegoState(raw=<class 'allegoserver_pb2.ConfigAndStatus'>)

Container for Allego state.

property sample_freq

Current system sample frequency in samples/sec [Hz]

property system_mode

Current Allego mode, e.g. ‘sim-spikes’, etc.

property port_num_channels

Number of channels on each connected port.

property cable_length_ft

Headstage cable length in feet for each system port

property recording

Recording status

property stream

Streaming status

property connected

Returns true if there is a headstage connected on any channel.

property base_name

Returns true if there is a headstage connected on any channel.

class radiens.lib.signals_snapshot.Signals(raw)

Container for a multi-channel (multi-trace) dataset for amplifier, GPIO analog in, GPIO digital in, and GPIO digital out signals.

All traces for all signal types have the same sampling frequency and start and end times. Thus, the set of traces of each signal type is a 2-D matrix.

property time_range

dataset time range in seconds

property TR

Aliases dataset time range.

property signals

Time-series signals as a named tuple by signal type.

For each signal type, the multi-channel dataset is a 2-D numpy array, with dim 0=trace position and dim 1 is the sample values over the time range.

property attributes

Dataset attributes

property channel_metadata

Dataset channel metadata


Concatenate two Signals objects into a single Signals object.


other – Signals object to concatenate with self.


Signals – concatenated Signals object.

class radiens.lib.sig_metrics.SignalMetrics(dsource_id, resp=<class 'common_pb2.KpiBundlePacketMetrics'>)

Container for signal metrics

property time_range

Signal metrics time range

property TR

Aliases signal metrics time range

property ntv_idxs

Signal metrics native channel indices

property settings

Signal metrics settings (dict)

property metric_ids

Ordered list of signal metric IDs.

property packet_idxs

Signal metrics packet indices

property num_packets

Signal metrics number of packets

property num_sigs

Signal metrics number of signals

property packet_dur_sec

Signal metrics packet duration in seconds

property val

Signal metrics settings as multi-dimensional np.ndarray, with dim 0=packet idx, dim 1=channel index, dim 2=metric index. The ordered metric IDs are available in obj.metric_ids.


  1. access packet 20, channel 23, and metric 1


  2. access channel 23, metric 1 over all packets:


  3. access metric 1 over all packets and channels:

    z = y[:,:,1] # returns 2-D array, where dim 0=packet index and dim 1=channels np.ravel(z) # returns 1-D array with packets flattened

property packet_stats

Prints a summary of the metrics.

radiens.utils.util.make_time_range(time_range=None, timestamp=None, fs=None, walltime=None, pbTR=None)

Utility function to compose the TimeRange named tuple composed from either a time range or timestamp list.

  • time_range (list | numpy.ndarray) – time range in seconds as [time start, time end] (optional, default=None).

  • timestamp (list | numpy.ndarray) – timestamp in seconds as [timestamp start, timestamp end] (optional, default=None).

  • fs (float) – sampling frequency in samples/sec (required, default=None)

  • walltime (datetime.datetime) – wall time of the time range start.

  • pbTR – low-level system parameter not available to user.


TimeRange named tuple fields:

sec (numpy.ndarray): [time start, time end] timestamp (numpy.ndarray): [timestamp start, timestamp end] fs (float): sampling frequency walltime: wall time of the time range start dur_sec (float): imputed time range duration equal to TR.time_range[1]-TR.time_range[0]. N (int): imputednumber of sample points equal to TR.timestamp[1]-TR.timestamp[0].

Either timestamp or time_range must be provided, with timestamp having preference. walltime is optional. dur_sec and N are imputed from the arguments.

System use only (not available to user) Either pbTR or (fs and either time_range or timestamp) must be provided as arguments. pbTR has preference.

class radiens.utils.constants.TimeRange(sec, timestamp, fs, dur_sec, walltime, N)

Alias for field number 5


Alias for field number 3


Alias for field number 2


Alias for field number 0


Alias for field number 1


Alias for field number 4

class radiens.utils.constants.SignalArrays(amp, gpio_ain, gpio_din, gpio_dout)

Alias for field number 0


Alias for field number 1


Alias for field number 2


Alias for field number 3

class radiens.utils.constants.KeyIdxs(ntv, dset, sys)

Python object with keys of type ntv, dset, sys. See KeyIndex for more details