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
- index(stype)
Signal indices by signal type and index type. All indices are zero-indexed.
- Parameters:
stype (
SignalType
) – requested signal type
Examples
>>> meta.index[SignalType.AMP] >>> KEY_IDXS(ntv=[5,1,23,46], dset=[0,1,2,3], sys=[5,1,23,46]) >>> meta.index[SignalType.AIN] >>> KEY_IDXS(ntv=[3,2,0,1], dset=[0,1,2,3], sys=[35,34,32,33]) # signal has 32 AMP channels
Notes:
- Index definitions:
ntv
is the position of the signal (channel) trace when the backing dataset was created for each signal type. For recording files, it is the position of the channels in the DAQ data stream or primary data file. Thentv
index starts at zero for each signal type.dset
is the position of a signal trace in the backing dataset for each signal type. Unless the signal traces in the dataset were re-ordered,dset
will equalntv
. Thedset
index starts at zero for each signal type.sys
is the position of the signal (channel) trace when the backing dataset was created. Thesys
index starts at zero and increases in natural order over all signal types alway in the following order: ‘amp’, ‘gpio_ain’, ‘gpio_din’, ‘gpio_dout’.
- sel_index(stype)
Selected signal indices by signal type and index type.
See
index()
for more information on signal indices.
- num_sigs(stype)
Number of signals for the requested signal type.
- sel_num_sigs(stype)
Number of selected signals for the requested signal type.
- num_sigs_total()
Total number of signals
- property num_selected_sigs_total
Total number of signals
- 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 time_range
Dataset time range
- property TR
Aliases
obj.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 table
Dataset attributes as a table.
- clear_dataset_id()
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 configuration
- 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
- 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.
Examples:
- access packet 20, channel 23, and metric 1
val[20][23][1]
- access channel 23, metric 1 over all packets:
val[:,23,1]
- access metric 1 over all packets and channels:
z = y[:,:,1]
# returns 2-D array, where dim 0=packet index and dim 1=channelsnp.ravel(z)
# returns 1-D array with packets flattened
- property packet_stats
- print()
Prints a summary of the metrics.
- class radiens.lib.sig_metrics.METRIC_ID(mode, name)
Example
>>> metric_id = METRIC_ID(mode=METRIC_MODE.BASE, name=METRIC.MEAN)
- mode
Alias for field number 0
- name
Alias for field number 1
- class radiens.lib.sig_metrics.METRIC_MODE(value)
An enumeration.
- BASE = 0
base packet
- AVG = 1
running average of all base packets in the stream
- STREAM = 2
cumulative over all base packets in the stream
- class radiens.lib.sig_metrics.METRIC(value)
An enumeration.
- NUM_PTS = 0
Number of points in packet
- NUM_PTS_ISI = 1
Number of interspike intervals in packet
- DUR_SEC = 2
Packet duration in seconds
- MEAN = 3
Mean signal level in packet
- MIN = 4
Minimum signal level in packet
- MIN_ISI = 5
Minimum interspike signal level in packet
- MAX = 6
Maximum signal level in packet
- MAX_ISI = 7
Maximum interspike signal level in packet
- MAX_ABS = 8
Absolute maximum signal level in packet
- MAX_ABS_ISI = 9
Absolute maximum interspike signal level in packet
- TIMESTAMP_MIN = 10
Timestamp of minimum signal level in packet
- TIMESTAMP_MAX = 11
Timestamp of maximum signal level in packet
- MAX_MIN_DIFF_ABS = 12
Absolute difference between maximum and minimum signal levels in packet
- MAX_MIN_DIFF_ABS_ISI = 13
Absolute difference between maximum and minimum interspike signal levels in packet
- SD = 14
Signal standard deviation in packet
- SD_ISI = 15
Signal standard deviation calculated over interspike intervals
- VAR = 16
Signal variance in packet
- VAR_ISI = 17
Signal variance calculated over interspike intervals
- RMS = 18
Root mean square (RMS) signal value in packet
- RMS_ISI = 19
RMS signal value calculated over interspike intervals
- NOISE_UV = 20
Noise level in microvolts
- SNR = 21
Signal-to-noise ratio (SNR) of events in packet
- NUM_EVENTS = 22
Number of events in packet
- EVENT_RATE = 23
Event rate in packet
- EVENT_MAX = 24
Maximum amplitude of events in packet
- EVENT_MIN = 25
Minimum amplitude of events in packet
- EVENT_MAX_ABS = 26
Absolute maximum amplitude of events in packet
- EVENT_MAX_MIN_DIFF_ABS = 27
Absolute difference between maximum and minimum amplitudes of events in packet
- EVENT_TIMESTAMP_MIN = 28
Timestamp of minimum amplitude of events in packet
- EVENT_TIMESTAMP_MAX = 29
Timestamp of maximum amplitude of events in packet
- EVENT_TIMESTAMP_MAX_ABS = 30
Timestamp of maximum absolute amplitude of events in packet
- EVENT_TIMESTAMP_MAX_MIN_DIFF_ABS = 31
Timestamp of absolute difference between maximum and minimum amplitudes of events in packet
- MEAN_MAX = 32
Mean peak maximum amplitude of events in packet (max over all base packets)
- MEAN_MIN = 33
Mean peak minimum amplitude of events in packet (min over all base packets)
- MEAN_MAX_ABS = 34
Mean peak absolute maximum amplitude of events in packet (max over all base packets)
- EVENT_MEAN_MAX_MIN_DIFF_ABS = 35
Mean peak absolute amplitude of events in packet (max over all base packets)
- radiens.utils.util.make_time_range(time_range=None, timestamp=None, fs=None, walltime=None, pbTR=None)
Utility function to compose the TIME_RANGE named tuple composed from either a time range or timestamp list.
- Parameters:
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.
Notes:
- TIME_RANGE named tuple fields:
sec
(numpy.ndarray): [time start, time end]timestamp
(numpy.ndarray): [timestamp start, timestamp end]fs
(float): sampling frequencywalltime
: wall time of the time range startdur_sec
(float): imputed time range duration equal toTR.time_range[1]
-TR.time_range[0]
.N
(int): imputednumber of sample points equal toTR.timestamp[1]
-TR.timestamp[0]
.
Either
timestamp
ortime_range
must be provided, withtimestamp
having preference.walltime
is optional.dur_sec
andN
are imputed from the arguments.System use only (not available to user) Either
pbTR
or (fs
and eithertime_range
ortimestamp
) must be provided as arguments.pbTR
has preference.
- class radiens.utils.constants.KeyIndex(value)
An enumeration of key index types
Example
>>> key_ind = KeyIndex.NTV
Valid values are as follows:
- NTV = 0
native
- DATA = 1
data
- SYS = 2
system
- class radiens.utils.constants.SignalType(value)
An enumeration of signal types
Example
>>> sig_type = SignalType.AMP
Valid values are as follows:
- AMP = 0
primary signals
- AIN = 1
analog in
- DIN = 2
digital in
- DOUT = 3
digital out
- class radiens.utils.constants.TRS_MODE(value)
TRS_MODE is the time range selector (TRS) enum used to control time range selection in calls to get signals, spikes, power spectral density, or similar data sets.
Example
>>> sel_mode = TRS_MODE.SUBSET
Given a time range [start, end) in seconds (dataset time), the selector modes are:
- FROM_HEAD = 2
selects [(head of stream/cache/file - start)
- SUBSET = 0
selects [start, end)
- TO_HEAD = 1
selects [start, head of stream/cache/file]
- class radiens.utils.constants.PSD_SCALING(value)
PSD_SCALING is used to set the power spectral density (PSD) scale.
- class radiens.utils.constants.FFT_WINDOW(value)
FFT_WINDOW is used to set the time-domain window function for power spectral density (PSD) analysis.