Clients API

class radiens.AllegoClient

AllegoClient implements the radiens API for data acquisition and instrument control. It matches and extends the functionality of the Radiens Allego UI app.

property type

Returns ‘allego’

workspace()

Allego workspace API

spike_sorter()

Allego spike sorter API

spikes()

Allego spikes API

signal_metrics()

Allego signal metrics API

restart(mode)

Restarts Allego in the requested mode.

Valid modes:

  • sbpro,

  • sbpro-sinaps-256

  • sbpro-sinaps-1024

  • sbclassic

  • sim-sine

  • sim-spikes

  • open-ephys_usb2

  • open-ephys_usb3

  • intan1024

  • intan512

  • xdaq-one-rec

  • xdaq-one-stim

  • xdaq-core-rec

  • xdaq-core-stim

Returns:

None

Side Effect:

Resets all settings to their initialization values in the requested mode.

Example

>>> client.restart('sim-spikes')
None
get_available_sensors()

Gets dictionary of dictionaries of available Radiens headstage and probe models, with each model of form key=component ID, value=number of channels.

Returns:

sensors (dict) – has keys ‘headstages’ and ‘probes’ that map to dictionaries of the available headstage models and probe models, respectively.

Example

>>> client.get_available_sensors()
{'sensors': {'headstages': {'hstg__chronic_smartlink_HC16': 16, 'hstg__acute_smartlink_A64': 64, ...},
            'probes': {'a2x16_10mm50_500_177': 32, 'a1x16_5mm150_177': 16, ...}}
get_status()

Gets the status of Allego.

Returns:

status (AllegoState)

Example

>>> client.get_status().print()
ALLEGO status:
stream       : S_ON
    time range : [0.000, 2149.197] sec
    HW memory  : 0.0
recording         : R_OFF
    duration        : 0.000 sec
    file name       : allego_0__uid0906-13-55-32
    base name       : allego
    path            : /Users/akelly/sapiens/core_packages/radix/radiens_etc
    index           : 0
    file timestamp  : 0906-13-55-32
get_stream_loop_dur_ms()

Returns the stream loop duration in milliseconds

Notes

Make sure to convert this to seconds if you’re using it to set the sleep time in a loop.

get_channel_metadata()

Gets the channel metadata for all connected ports

Notes

All ports are scanned to detect the connected ports.

get_signals()

Gets the the most recent signals since last call of itself or set_time_to_cache_head().

Returns:
  • sigarray (ndarray[numpy.float32]) – raw signal data; the mapping contained in signal_group (see get_channel_metadata())

  • time_range (list[float]) – time range (in seconds) of sigarray

Notes

Sets current time to most recent time point in signal cache.

This should be called before the first call of get_signals(). The first call of get_signals() will return the new signals since the last call to set_time_to_cache_head()

get_digital_out_states()

Gets digital out state.

Returns:

dout_state_dict (dict) – has keys ‘digital_outs_mode’ and ‘states’.

Example

>>> client.get_digital_out_states()
{'digital_outs_mode': 'manual',
'states': [{'chan_idx': 0, 'state': True}, {'chan_idx': 1, 'state': False}]}
get_analog_out_settings()

Gets analog out settings

Returns:

settings (dict)

Example

>>> client.get_analog_out_settings()
{'dac': [
    {'amp_ntv_chan_idx': -1,
     'aout_ntv_chan_idx': 0,
     'stream': 0,
     'stream_offset_idx': 0},
    {'amp_ntv_chan_idx': -1,
     'aout_ntv_chan_idx': 1,
     'stream': 0,
     'stream_offset_idx': 0}
     ],
'gain': 0,
'high_pass': {'enable': False, 'cutoff_freq': 0.0}}
get_stim_params()

returns current stimulation params (see set_stim_params())

Returns:

stim_params (dict) – a dictionary where the keys are the system channel indices and the values are dictionaries containing the stimulation parameters. Each dictionary associated with a channel will have the following key-value pairs:

  • ‘enabled’: stimulation enabled on channel (bool)

  • ‘enable_amp_settle’: amp settle enabled on channel (bool)

  • ‘enable_charge_recovery’: charge recovery enabled on channel (bool)

  • ‘first_phase_amplitude_uA’: Level of current in µA for the first phase of the stimulation waveform (type)

  • ‘first_phase_duration_us’: (float)

  • ‘interphase_delay_us’: (float)

  • ‘maintain_amp_settle_us’: (float)

  • ‘number_of_stim_pulses’: (int)

  • ‘post_stim_amp_settle_us’: (float)

  • ‘post_stim_charge_recovery_off_us’: (float)

  • ‘post_stim_charge_recovery_on_us’: (float)

  • ‘post_trigger_delay_us’: (float)

  • ‘pre_stim_amp_settle_us’: (float)

  • ‘pulse_or_train’: (int)

  • ‘pulse_train_period_us’: (float)

  • ‘refactory_period_ms’: (float)

  • ‘second_phase_amplitude_uA’: Level of current in µA for the second phase of the stimulation waveform (type)

  • ‘second_phase_duration_us’: (float)

  • ‘stim_polarity’: (int)

  • ‘stim_shape’: (int)

  • ‘stim_sys_chan_idx’: (int)

  • ‘trigger_edge_or_level’: (int)

  • ‘trigger_high_or_low’: (int)

  • ‘trigger_source_is_keypress’: (bool)

  • ‘trigger_source_idx’: (int)

Example

>>> get_stim_params()
{6: # system idx
    {'stim_shape': 0,
    'stim_polarity': 0,
    'first_phase_duration_us': 100.0,
    'second_phase_duration_us': 100.0,
    'interphase_delay_us': 100.0,
    'first_phase_amplitude_uA': 0.0,
    'second_phase_amplitude_uA': 0.0,
    'baseline_voltage': 0.0,
    'trigger_edge_or_level': 0,
    'trigger_high_or_low': 0,
    'enabled': False,
    'post_trigger_delay_us': 0.0,
    'pulse_or_train': 0,
    'number_of_stim_pulses': 2,
    'pulse_train_period_us': 10000.0,
    'refactory_period_ms': 1.0,
    'pre_stim_amp_settle_us': 0.0,
    'post_stim_amp_settle_us': 0.0,
    'maintain_amp_settle_us': False,
    'enable_amp_settle': False,
    'post_stim_charge_recovery_on_us': 0.0,
    'post_stim_charge_recovery_off_us': 0.0,
    'enable_charge_recovery': False,
    'trigger_source_is_keypress': True,
    'trigger_source_idx': 1,
    'stim_sys_chan_idx': 6 # redundant but expected when setting stim params
    },
{...}
set_sampling_freq(fs)

Sets sampling frequency. Valid sampling frequencies: 625, 1000, 1250, 1500, 2000, 2500, 3000, 3333, 4000, 5000, 6250, 8000, 10000, 12500, 15000, 20000, 25000, 30000

Parameters:

fs (int) – requested sampling frequency (samples/sec)

Returns:

None

Example

>>> client.set_samp_freq(12500)
None
set_analog_out_high_pass(cutoff_freq, enable=True)

Sets the analog out hardware filter

Parameters:

fs (int) – requested sampling frequency (samples/sec)

Returns:

analog_out_settings (dict)

Example

>>> client.set_dac_high_pass(500, True)
{...}
set_sensor(port, headstage_id, probe_id)

Sets a sensor (headstage paired with probe) to the requested port.

The headstage_id and probe_id arguments are:
  1. the labels listed in the Allego and Videre Probe Model UI tab.

  2. aliases in radiens.utils.HEADSTAGE_ALIAS and radiens.utils.PROBE_ALIAS

Parameters:
  • port (str) – requested port (must be a currently connected port)

  • headstage_id (str) – requested headstage alias or headstage ID

  • probe_id (str) – requested probe alias or probe ID

Returns:

None

Example

>>> client.set_sensor('A', 'smart-32', '4x8-32')
None

Notes

radiens.utils.HEADSTAGE_ALIAS and radiens.utils.PROBE_ALIAS are an abridged set of headstage and probe aliases provided for convienence.

See also

get_available_sensors() get_connected_ports()

set_time_to_cache_head()

Sets current time to most recent time point in signal cache.

This should be called before the first call of get_signals(). The first call of get_signals() will return the new signals since the last call to set_time_to_cache_head()

set_manual_stim_trigger(trigger)
set_stim_params(param_dict)

Sets stimulation parameters to a stim channel. Any parameter not specified in the parameter param_dict will be kept as is, or set to default parameter, if not already set (see get_stim_params()).

Parameters:

param_dict

has following key-value pairs; comments are defaults:

  • ’enabled’: # False

  • ’enable_amp_settle’: # False

  • ’enable_charge_recovery’: # False

  • ’first_phase_amplitude_uA’: # 0

  • ’first_phase_duration_us’: # 0

  • ’interphase_delay_us’: # 0

  • ’maintain_amp_settle_us’: # 0

  • ’number_of_stim_pulses’: # 2

  • ’post_stim_amp_settle_us’: # 0

  • ’post_stim_charge_recovery_off_us’: # 0

  • ’post_stim_charge_recovery_on_us’: # 0

  • ’post_trigger_delay_us’: # 0

  • ’pre_stim_amp_settle_us’: # 0

  • ’pulse_or_train’: # 0

  • ’pulse_train_period_us’: # 0

  • ’refactory_period_ms’: # 1

  • ’second_phase_amplitude_uA’: # 0

  • ’second_phase_duration_us’: # 0

  • ’stim_polarity’: # 0

  • ’stim_shape’: # 0

  • ’stim_sys_chan_idx’: # 0

  • ’trigger_edge_or_level’: # 0

  • ’trigger_high_or_low’: # 0

  • ’trigger_source_is_keypress’: # True

  • ’trigger_source_idx’: # 0

set_streaming(mode)

Sets signal streaming to ‘on’ or ‘off’

Parameters:

mode – requested mode, on or off

Example

>>> client.set_streaming('on')
None
set_recording(mode)

Sets signal recording to ‘on’ or ‘off’

Parameters:

mode (str) – requested mode, on or off

Returns:

None

Side Effect:

sets streaming on if mode=``on` and streaming is off

Example

>>> client.set_recording('on')
`AllegoState`
set_recording_config(datasource_path, datasource_name, datasource_idx, is_time_stamp=True)

Sets recording configuration

Parameters:
  • datasource_path (str) – path to output XDAT file set

  • datasource_name (str) – base name of XDAT file set

  • datasource_idx (int) – index number for the composed file name.

  • is_time_stamp (bool) – True to time stamp the composed file name.

Returns:

None

Example

>>> client.set_recording_config('~/radix/data', 'my_base_name', 0, True)
None
set_digital_out_manual(dout1_state, dout2_state)

Sets digital out state.

Parameters:
  • dout1_state (bool) – new dout 1 state

  • dout2_state (bool) – new dout 2 state

Returns:

None

Example

>>> client.set_digital_out_manual(true, false)
None
class radiens.VidereClient(hub_name='default')

VidereClient implements the radiens API for offline analysis and visualization. It matches and extends the functionality of the Radiens Videre UI app.

property hubs

dict of active radiens hubs, with hub ID as key.

property hub

Radiens hub for this instance of VidereClient.

property id

UID of this client session.

property type

Returns ‘videre’

signal_metrics()

Videre signal metrics API

spike_sorter()

Videre spike sorter API

spikes()

Videre spikes API

signals()

Signals API

Links a Radiens data file to the Radiens hub and returns the data set meta data. If force=False (default) and the ‘path’ is already linked then nothing is done and existing data set meta data is returned. Use force=True to always link the source as a new dataset. All instances of a linked data set are backed by the same data files.

This is a power user function.

Parameters:
  • path (str, pathlib.Path) – path to source file

  • calc_metrics (bool) – use True to calculate signal metrics (default=True)

  • force (bool) – use True to force the source to be linked to the hub (default=False)

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

data_source (DatasetMetadata) – data file metadata

See also

rename_file() clear_dataset() get_dataset_ids()

get_data_file_metadata(dataset_idx=None, dataset_id=None, path=None, hub_name='default', fail_hard=False)

Returns meta data for one Radiens dataset or file. The dataset can be requested by index, ID or full path, in that order of preference.

Parameters:
  • dataset_idx (int) – index of dataset in table returned by get_dataset_ids() or get_selector_tables()

  • dataset_id (str) – dataset ID as listed in table returned by get_dataset_ids() or get_selector_tables()

  • path (str, pathlib.Path) – full path to data file set in form of path/base_name.ext.

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

  • fail_hard (bool) – if True, then an exception is raised if the requested dataset is not available.

Returns:

dataset_meta (DatasetMetadata) – data set metadata

Side Effects:

If the requested dataset is specified by path, then it is linked to the hub and remains linked.

See also

rename_file() _clear_dataset() get_dataset_ids()

clear_dataset(dataset_idx=None, dataset_id=None, path=None, hub_name='default', fail_hard=False)

Clears one or more datasets of this Curate session from the Radiens hub. Use dataset_id=’all’ to clear all session datasets. This is a power user function.

Parameters:
  • source (str, list) – data source file or list of data source files.

  • dataset_id (str, list) – dataset ID or list of dataset IDs (default=[], ‘all’ clears all datasets for the Curate session)

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:
  • num_unlinked (int) – number of unlinked datasets

  • dataset_ids (pandas.DataFrame) – linked dataset IDs on the Radiens hub.

get_dataset_ids(hub_name='default')

Returns sorted list of linked dataset IDs on the Radiens hub.

Returns:

dataset_ids (pandas.DataFrame) – linked dataset IDs on the Radiens hub.

dashboard(close=False, hub_name='default')

Launches a dashboard for the Radiens Hub

Returns:

None

class radiens.CurateClient

CurateClient implements the radiens API for data curation. It matches and extends the functionality of the Radiens Curate UI app.

property hubs

dict of active radiens hubs, with hub ID as key.

property id

UID of this client session.

signal_metrics()

Signal metrics

spikes()

Spikes API

property dsp_stream

dict of DSP streams running in the background.

dsp_clean_up()

Cleans up after any DSP operation that has finished.

Returns:

None

Examples

>>> stream_id = client.dsp_low_pass_filter(750, './my_source_file', './my_output_file')
>>> progress_bar(stream_id)
dsp_progress_bar(stream_id)

Displays a progress bar showing the progress of the DSP stream running in the background. This function blocks until the background DSP stream is complete. This is an optional function that does not effect the DSP operation.

Parameters:

stream_id (str) – stream ID of the requested DSP stream.

Returns:

None

Examples

>>> stream_id = client.dsp_low_pass_filter(750, './my_source_file', './my_output_file')
>>> progress_bar(stream_id)
dsp_progress(stream_id)

Returns the progress of the ‘stream_id’ DSP stream running in the background. It returns 1.0 if the DSP operation has completed. It is non-blocking.

Parameters:

stream_id (str) – stream ID of the requested DSP stream.

Returns:

frac_complete (float) – fraction complete of the DSP stream.

Examples

>>> stream_id = client.dsp_low_pass_filter(750, './my_source_file', './my_output_file')
>>> dsp_progress(stream_id)
>>> 0.5
dsp_low_pass_filter(cutoff_freq, source_path, target_path, force=False, hub_name='default')

Applies low-pass filter to source file to result in target file.

The requested cut-off frequency must be < fs/2, where fs is the sample frequency of the source file.

Parameters:
  • cutoff_freq (float) – filter cut-off frequency in samples/sec (Hz)

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking and the requested DSP operation runs in the background.

Example

>>> client.dsp_low_pass_filter(750, './my_source_file', './my_output_file')
my_stream_id_e4c-jnwq
dsp_high_pass_filter(cutoff_freq, source_path, target_path, force=False, hub_name='default')

Applies high-pass filter to source file to result in target file.

The requested cut-off frequency must be < fs/2, where fs is the sample frequency of the source file.

Parameters:
  • cutoff_freq (float) – filter cut-off frequency in samples/sec (Hz)

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking and the requested DSP operation runs in the background.

Example

>>> client.dsp_high_pass_filter(20, './my_source_file', './my_output_file')
None
dsp_band_pass_filter(low_cutoff_freq, high_cutoff_freq, source_path, target_path, force=False, hub_name='default')

Applies band-pass filter to source file to result in target file.

The requested cut-off frequencies must be < fs/2, where fs is the sample frequency of the source file. The low_cutoff_freq must be less than the high_cutoff_freq.

Parameters:
  • low_cutoff_freq (float) – filter low cut-off frequency in samples/sec (Hz)

  • high_cutoff_freq (float) – filter high cut-off frequency in samples/sec (Hz)

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_band_pass_filter(750,  2000, './my_source_file', './my_output_file')
my_stream_id_e4c-jtyn4

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_band_stop_filter(low_cutoff_freq, high_cutoff_freq, source_path, target_path, force=False, hub_name='default')

Applies band-stop (aka band reject) filter to source file to result in target file.

The requested cut-off frequencies must be < fs/2, where fs is the sample frequency of the source file. The low_cutoff_freq must be less than the high_cutoff_freq.

Parameters:
  • low_cutoff_freq (float) – filter low cut-off frequency in samples/sec (Hz)

  • high_cutoff_freq (float) – filter high cut-off frequency in samples/sec (Hz)

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_band_stop_filter(750,  2000, './my_source_file', './my_output_file')
my_stream_id_e4c-jtyn4

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_notch_filter(freq, bandwidth, source_path, target_path, force=False, hub_name='default')

Applies notch filter to source file to result in target file.

The requested frequency must be < fs/2, where fs is the sample frequency of the source file.

Parameters:
  • freq (float) – notch frequency in samples/sec (Hz)

  • bandwidth (float) – filter bandwidth in samples/sec (Hz)

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_notch_filter(50,  2, './my_source_file', './my_output_file')
my_stream_id_e4c-lkqw

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_paired_diff(source_chan, ref_chan, source_path, target_path, force=False, hub_name='default')

Applies paired differential transform to the source file resulting in the target file.

The source channel is set to the new value = (source-reference) for each time sample. The reference signal is zeroed.

Parameters:
  • source_chan (int) – source channel index

  • ref_chan (int) – reference channel index

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_paired_diff(1,  5, './my_source_file', './my_output_file')
my_stream_id_e4c-rt4m

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_virtual_ref(ref_chan, source_path, target_path, force=False, hub_name='default')

Applies virtual reference transform to the source file resulting in the target file.

All channels are set to the new value = (chan-ref_chan) for each time sample. The reference channel is zeroed.

Parameters:
  • ref_chan (int) – reference channel index

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_virtual_ref(5, './my_source_file', './my_output_file')
my_stream_id_e4c-wq5c

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_car(source_path, target_path, force=False, hub_name='default')

Applies common average reference transform to the source file resulting in the target file.

All channels are set to the new value = (chan-v_ref) for each time sample, where v_ref is the sum of all the channels.

Parameters:
  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_car('./my_source_file', './my_output_file')
my_stream_id_e4c-wq5c

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_time_decimate(decimate, source_path, target_path, force=False, hub_name='default')

Applies time decimation transform to the source file resulting in the target file.

All channels are decimated in time by ‘decimate’. The target file sampling frequency is equal to the source file sampling frequency divided by ‘decimate’ For example, if ‘decimate=2’ and ‘source_sampling_freq=10000’, then the target file consists of every two source channel samples and ‘target_sampling_freq=5000’

Parameters:
  • decimate (int) – sample factor

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

The source and target files must be XDAT files. This is non-blocking. The requested DSP operation runs in the background.

Example

>>> client.dsp_time_decimate(3, './my_source_file', './my_output_file')
my_stream_id_e4c-wq5c

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_high_pass_filter

dsp_slice_time(time_start, time_end, source_path, target_path, force=False, hub_name='default')

Slices the source data file in time to result in the target file.

Parameters:
  • time_start (float) – slice start time in seconds

  • time_end (float) – slice end time in seconds

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

“time_start” and “time_end” are the absolute time in the source file. The source and target files must be XDAT files. This is non-blocking and the requested DSP operation runs in the background.

Example

>>> client.dsp_slice_time(0.5, 10, './my_source_file', './my_output_file')
None

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_slice_channels

dsp_slice_channels(target_channels, source_path, target_path, force=False, hub_name='default')

Slices out (removes) the target channels from source data file to result in the target file.

Parameters:
  • target_channels (list) – channel indices of channels to slice from the source

  • source_path (str, pathlib.Path) – path to source file

  • target_path (str, pathlib.Path) – path to target (output) file

  • force (bool) – flag to force replacing target file if it exists

  • hub_name (str) – radiens hub name (default=radiens.utils.constants.DEFAULT_HUB)

Returns:

stream_id (str) – background DSP stream ID

Notes

“target_channels” are the absolute channel indices of the source file, including GPIO signals. The source and target files must be XDAT files. This is non-blocking and the requested DSP operation runs in the background.

Example

>>> client.dsp_slice_channels([0,2,8,5], './my_source_file', './my_output_file')
None

See also

py:meth:dsp_progress py:meth:dsp_progress_bar py:meth:dsp_slice_time

SubClients API

class radiens.workspace_client.WorkspaceClient

Workspace client object for AllegoClient

property hubs

dict of active radiens hubs, with hub ID as key.

property id

UID of this client session.

workspace_save(workspace_id=None, tags='', notes='')

Saves current workspace

Parameters:
  • workspace_id (str) – optional workspace ID

  • tags (str) – optional tags

  • notes (str) – optional notes

Returns:

None

Example

>>> client.workspace_save(workspace_id='my_wspace', tags='my_tags', notes='my_notes)
None
workspace_switch(workspace_id)

Switches to requested workspace

Parameters:

workspace_id (str) – workspace ID

Returns:

None

Example

>>> client.workspace_switch('my_wspace')
None
workspace_delete(workspace_id)

Deletes requested workspace

Parameters:

workspace_id (str) – workspace ID

Returns:

None

Example

>>> client.workspace_delete('my_wspace')
None
workspace_current()

Returns current workspace ID

Returns:

workspaces (pandas.DataFrame)

Example

>>> client.workspace_current()
df
workspace_list()

Returns table of all available workspaces

Returns:

workspaces (pandas.DataFrame)

Example

>>> client.workspace_list()
df
class radiens.spike_sorter.SpikeSorterClient(parent_client)

Spike sorter client object for AllegoClient, VidereClient

initialize()

Stops, clears, and initializes spike sorter to its default parameters.

Returns:

None

Example

>>> client.spike_sorter().initialize()
None
rebase()

Rebases the spike sorter, which clears all spike data and spike templates.

Returns:

None

Example

>>> client.spike_sorter().rebase()
None
clear_spikes()

Clears all spike data from the spike sorter, but does not clear it’s sorting settings or spike templates.

Returns:

None

Example

>>> client.spike_sorter().clear_spikes()
None
set_sorting(mode)

Sets spike sorting on or off

Parameters:

mode (str) – mode [on, off]

Returns:

None

Example

>>> client.spike_sorter().set_sorting('on')
None
set_threshold_level(neg_thr=None, pos_thr=None, scale='uV', ntv_idxs=None, weak_thr=False, channel_meta=None)

Sets spike detection threshold. This function does not effect the threshold state.

Parameters:
  • neg_thr (str) – on | off

  • pos_thr (str) – on | off

  • scale (str) – uV | sd

  • ntv_idxs (list) – channel native indices (default None=all channels)

  • weak_thr (bool) – use True to set the weak threshold (default=False)

  • channel_meta (ChannelMetadata) – Allego connected channels

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.spike_sorter().set_threshold_level(neg_thr=85)
'[32 channels] detect: neg thr=85.00 uV, pos thr=n/a uV'

See also

set_threshold() get_channel_metadata()

set_threshold(neg_thr=None, pos_thr=None, ntv_idxs=None, weak_thr=False, channel_meta=None)

Set threshold ‘on’ or ‘off’

Parameters:
  • neg_thr (str) – on | off

  • pos_thr (str) – on | off

  • ntv_idxs (list) – channel native indices (default None=all channels)

  • weak_thr (bool) – use True to set the weak threshold (default=False)

  • channel_meta (ChannelMetadata) – Allego connected channels

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.spike_sorter().set_threshold(neg_thr='on')
'[32 channels] detect: neg thr='on', pos thr=n/a'

See also

set_threshold_level() get_channel_metadata()

set_spike_window(pre_thr_ms=None, post_thr_ms=None)

Set spike window.

Parameters:
  • pre_thr_ms (float) – pre-threshold window duration in ms (default None=not changed)

  • post_thr_ms (float) – post-threshold window duration in ms (default None=not changed)

Returns:

msg (str) – summary description of spike window

Example

>>> client.spike_sorter().set_threshold(neg_thr='on')
'[32 channels] detect: neg thr='on', pos thr=n/a'

See also

set_threshold_level() get_channel_metadata()

set_spike_shadow(shadow_ms=None)

Sets spike shadow window. The shadow window is the time skipped after each threshold crossing.

Parameters:

shadow_ms (float) – shadow window duration in ms (default None=not changed)

Returns:

msg (str) – summary description of spike shadow window

Example

>>> client.spike_sorter().set_spike_shadow(1.5)
'[32 channels] shadow window: 1.5 ms [40 points]'

See also

set_threshold_level() get_channel_metadata()

get_params()

Returns the spike sorter parameters

Returns:

pandas.DataFrame

Example

>>> client.sorter_get_params()
None
get_state()

Returns the spike sorter state

Returns:

pandas.DataFrame

Example

>>> client.sorter_get_state()
None
get_dashboard()

Returns the spike sorter dashboard

Returns:

pandas.DataFrame

Example

>>> client.sorter_get_dashboard()
None
class radiens.spikes_client.SpikesClient(parent_client)

Spikes object for AllegoClient, VidereClient

get_spikes_metadata()

Returns metadata on the spikes processed by the spike sorter

Returns:

pandas.DataFrame

Example

>>> client.get_spikes()
None
get_spike_rasters(dsource_id=None)

Returns spike rasters from the spike sorter

Returns:

pandas.DataFrame

Example

>>> client.get_spikes()
None
get_recent_spikes(time_wdw_sec=1.0, ntv_chan_idxs=None, max_spikes_per_chan=100, channel_meta=None)

Returns the most recent spikes for the requested ntv_chan_idxs over the requested time window. The returned spike data has spike timestamps, spike waveforms, and spike labels.

Returns:

pandas.DataFrame

Example

>>> client.get_spikes()
None
get_spike_waveforms(dataset_id, time_range, ntv_idxs=[], hub_name='default')

Gets spike waveforms for specified time range of a spikes file

Parameters:
  • dataset_id (str) – dataset ID

  • time_range (list[float]) –

  • ntv_idxs (list[float]) –

Returns:

get_spike_timestamps(dataset_id, time_range, ntv_idxs=[], hub_name='default')

Gets spike timestamps for specified time range of a spikes file

Parameters:
  • dataset_id (str) – dataset ID

  • time_range (list[float]) –

  • ntv_idxs (list[float]) –

Returns:

get_neurons()

Returns neurons from the spike sorter

Returns:

pandas.DataFrame

Example

>>> client.get_spikes()
None
convert_kilosort_output(source_bio_path='', source_bio_basename='', source_vex_path='', source_vex_basename='', sink_bio_path='', sink_bio_basename='', hub_name='default')

Converts the output of kilosort into a .spikes file that can be loaded into radiens

class radiens.metrics_client.MetricsClient(parent_client)

Metrics client object for CurateClient, VidereClient

clear(dataset_metadata=None, hub_name='default')

Clears KPI data. This is only available for CurateClient and VidereClient

Parameters:

dataset_metadata (DatasetMetadata) – dataset metadata object

Returns:

None

Example

>>> client.signal_metrics().clear()
None
calculate(dataset_metadata=None, hub_name='default')

Calculates KPI data. This is only available for CurateClient and VidereClient

Parameters:

dataset_metadata (DatasetMetadata) – dataset metadata object

Returns:

None

Example

>>> client.signal_metrics().calculate()
None
set_event_threshold_level(neg_thr=None, pos_thr=None, scale='uV', ntv_idxs=None, weak_thr=False, dataset_metadata=None, hub_name='default', channel_metadata=None)

Sets spike detection threshold. This function does not effect the threshold state.

Parameters:
  • neg_thr (str) – on | off

  • pos_thr (str) – on | off

  • scale (str) – uV | sd

  • ntv_idxs (list) – channel native indices (default None=all channels)

  • weak_thr (bool) – use True to set the weak threshold (default=False)

  • dataset_metadata (DatasetMetadata) – dataset metadata object

  • channel_metadata (ChannelMetadata) – Allego connected channels

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.signal_metrics().set_threshold_level(neg_thr=85)
'[32 channels] detect: neg thr=85.00 uV, pos thr=n/a uV'

See also

set_threshold() get_channel_metadata()

set_event_threshold(neg_thr=None, pos_thr=None, ntv_idxs=None, weak_thr=False, dataset_metadata=None, hub_name='default', channel_metadata=None)

Sets signal metrics event detect threshold ‘on’ or ‘off’

Parameters:
  • neg_thr (str) – on | off

  • pos_thr (str) – on | off

  • ntv_idxs (list) – channel native indices (default None=all channels)

  • weak_thr (bool) – use True to set the weak threshold (default=False)

  • dataset_metadata (DatasetMetadata) – dataset metadata object

  • channel_metadata (ChannelMetadata) – Allego connected channels

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.signal_metrics().set_event_threshold(neg_thr='on')
'[32 channels] detect: neg thr='on', pos thr=n/a'

See also

set_threshold_level() get_channel_metadata()

set_event_window(pre_ms, post_ms, dataset_metadata=None, hub_name='default', channel_metadata=None)

Sets signal metrics event event window

Parameters:
Returns:

msg (str) – summary description of event window

Example

>>> client.signal_metrics().set_event_window(2, 2)
'[32 channels] event window: pre-threshold=2 ms, post-threshold=2 ms

See also

set_threshold_level() get_channel_metadata()

set_event_shadow(shadow_ms, dataset_metadata=None, channel_metadata=None, hub_name='default')

Sets signal metrics event shadow

Parameters:
  • shadow_ms (float) – duration of shadow in milliseconds

  • dataset_metadata (DatasetMetadata) – dataset metadata object

  • channel_metadata (ChannelMetadata) – Allego connected channels

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.signal_metrics().set_event_shadow(1)
'[32 channels] event shadow 1 ms'

See also

set_threshold_level() get_channel_metadata()

set_packet_duration(packet_dur_sec, dataset_metadata=None, hub_name='default')

Sets signal metrics packet duration in seconds

Parameters:
  • packet_dur_sec (float) – duration in seconds of signals used to calculate signal metrics packet

  • dataset_metadata (DatasetMetadata) – dataset metadata object

Returns:

msg (str) – summary description of threshold levels

Example

>>> client.signal_metrics().set_packet_duration(neg_thr='on')
None

See also

set_threshold_level() get_channel_metadata()

get_params(dataset_metadata=None, hub_name='default')

Returns KPI parameters

Parameters:

dataset_metadata (DatasetMetadata) – dataset metadata object

Returns:

pandas.DataFrame

get_metrics_status(dataset_metadata=None, hub_name='default')

Returns the status of the stream metrics service

Parameters:

dataset_metadata (DatasetMetadata) – dataset metadata object

Returns:

status (dict) – dict of status parameters, with keys=’time_range’,’packet_dur_sec’, ‘beta’, ‘is_tracking_cache’, ‘wall_time_start’, ‘persistence_sec’

get_metrics(time_range=None, metrics=None, ntv_idxs=None, tail=True, plot=True, file=None, data=True, dataset_metadata=None, hub_name='default', channel_metadata=None)

Gets the requested signal metrics from a data source.

Parameters:
Returns:

SignalMetrics (SignalMetrics) – Requested metrics

class radiens.signals_client.SignalsClient(parent_client)

Signals client object for Allego, Curate, and Videre

get_signals(time_range=None, sel_mode=None, sig_sel=None, dataset_metadata=None, hub_name='default')

Gets the signals for specified time range

Parameters:
  • time_range (TIME_RANGE) – see make_time_range()

  • dataset_metadata – see link_data_file() and get_data_file_metadata()

  • sel_mode – optional (default TRS_MODE.SUBSET)

  • sig_sel – optional

  • hub_name – optional

Returns:

signals (Signals)

get_psd(time_range=None, sel_mode=None, sig_sel=None, samp_freq=2000.0, freq_range=[1, 300], collapse_freq=False, scaling=PSD_SCALING.SPECTRUM, window=FFT_WINDOW.HAMMING_p01, freq_resolution=None, file=None, data=True, dataset_metadata=None, hub_name='default')

Gets the power spectral density (PSD) for the specified signals over the specified time range.

Parameters:
  • time_range (TIME_RANGE) – requested time range (required)

  • sel_mode (TRS_MODE) – time range selection mode (optional, default=TRS_MODE.SUBSET)

  • sig_sel (SIG_SELECT) – requested AMP signals (optional, default=all AMP signals)

  • samp_freq (float) – PSD sample frequency in Hz. None=dataset_metadata.TR.fs (optional, default=2000.0)

  • freq_range (list, np.ndarray) – requested frequency range. (optional, default=[1, 300])

  • collapse_freq (bool) – True collapses freq_range into one frequency bin (optional, default=False)

  • scaling (PSD_SCALING) – sets the PSD scale (optional, default=PSD_SCALING.SPECTRUM)

  • window (FFT_WINDOW) – sets the FFT window(optional, default=FFT_WINDOW.HAMMING_p01)

  • freq_resolution (float) – requested frequency resolution in Hz (optional, default=None)

  • file (string) – save psd data to file (optional, default=None)

  • data (bool) – return PSD data if true (optional, default=True)

  • dataset_metadata (DatasetMetadata) – dataset metadata (required for Videre, optional for Allego, default=None)

  • hub_name (str) – Radiens hub name (optional, default=DEFAULT_HUB)

Returns:

psd (PSD) – container object for PSD data.