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:

  • smartbox_pro,

  • smartbox_pro_sinaps_256

  • smartbox_pro_sinaps_512

  • smartbox_pro_sinaps_1024

  • smartbox_classic

  • smartbox_sim_gen_sine

  • smartbox_sim_gen_sine_mapped

  • smartbox_sim_gen_sine_high_freq

  • smartbox_sim_gen_sine_multi_band

  • smartbox_sim_gen_spikes

  • open_ephys_usb2

  • open_ephys_usb3

  • intan_usb2

  • intan_recording_controller_1024

  • intan_recording_controller_512

  • xdaq_one_req

  • xdaq_one_stim

  • xdaq_core_req

  • 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.

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()

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

  • 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

summa_list_sessions(hub_name='default')

Lists the current Summa analysis sessions for the Radiens Hub

Returns:

None

summa_clear_sessions(hub_name='default')

Lists the current Summa analysis sessions for the Radiens Hub

Returns:

None

summa_launch_session_analysis(summa_id=None, dataset_ids=None, bin_dur_sec=1.0, hub_name='default')

Launches a new Summa analysis session.

Returns:

status (SummaStatus) – Summa analysis status.

summa_session_status(summa_id=None, hub_name='default')

Launches a dashboard for the Radiens Hub

Returns:

None

summa_get_session_aggregate_statistics(summa_id=None, hub_name='default')

Launches a dashboard for the Radiens Hub

Returns:

None

summa_get_session_datasource_statistics(summa_id=None, dataset_ids=None, 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.

property type

Returns CURATE

signal_metrics()

Signal metrics API

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)
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

See also

dsp_progress_bar() dsp_low_pass_filter()

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

See also

dsp_progress() dsp_progress_bar() dsp_high_pass_filter()

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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() dsp_high_pass_filter()

file_convert(source_path, dest_path, dest_file_type, force=False, hub_name='default')

Converts source file to target file.

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

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

dsp_progress() dsp_progress_bar() 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

dsp_progress() dsp_progress_bar() 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_client.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 levels. 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 milliseconds (default None=not changed)

  • post_thr_ms (float) – post-threshold window duration in milliseconds (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 as a table.

Returns:

pandas.DataFrame

Example

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

Returns the spike sorter state as a table.

Returns:

pandas.DataFrame

Example

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

Returns the spike sorter dashboard as a table.

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=None, 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=None, hub_name='default')

Gets spike timestamps for specified time range of a spikes file

Parameters:
  • dataset_id (str) – dataset ID

  • time_range (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 and saves signal metrics for a linked dataset. If cmd=standard, then signal metrics are calculated using the set of standard parameters: thresholds: 2.0 * Vex_rms (negative and positive)

If cmd=standard, then signal metrics are calculated using the existing signal metrics parameters (thresholds, windows, etc.)

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_meta=None)

Sets the signal metrics event (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 (spike) detection 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 (spike) 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 (spike) shadow time in milliseconds.

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 event shadow

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 signal metrics parameters as a table.

Parameters:
  • dataset_metadata (DatasetMetadata) – metadata on linked dataset

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

  • dataset_metadata – dataset metadata object

Returns:

pandas.DataFrame

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

Returns the status of the signal metrics service. This is an advanced function and is not typically used.

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 linked dataset.

Parameters:
  • time_range (int, float, list, ndarray) – if parent client is AllegoClient, then this parameter can be float or int; otherwise, it must be list or ndarray

  • metrics (list) – a list of MetricID. It specified a default list is used.

  • dataset_metadata (DatasetMetadata) – dataset metadata object

  • channel_metadata (ChannelMetadata) – Allego connected channels

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 signals over the specified time range from a linked dataset.

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

  • dataset_metadata – see link_data_file() and get_data_file_metadata()

  • sel_mode – optional (default TrsMode.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=PsdScaling.ABSOLUTE, window=FftWindow.HAMMING_p01, freq_resolution=None, file=None, dataset_metadata=None, hub_name='default')

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

Parameters:
  • time_range (TimeRange) – requested time range in seconds (required)

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

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

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

  • 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 (PsdScaling) – sets the PSD scale (optional, default=PsdScaling.ABSOLUTE)

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

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

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

  • 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.

Enums

class radiens.utils.enums.ClientType(value)

TYPE is used to specify the type of client.

ALLEGO = 'AllegoClient'

Allego client

VIDERE = 'VidereClient'

Videre client

CURATE = 'CurateClient'

Curate client

class radiens.utils.enums.KeyIndex(value)

An enumeration of key index types.

See also

index()

Example

>>> key_ind = KeyIndex.NTV

Valid values are as follows:

NTV = 0

The native key index 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. The ntv index starts at zero for each signal type.

DATA = 1

The dataset key index 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 equal ntv. The dset index starts at zero for each signal type.

SYS = 2

The system key index starts at zero and increases in natural order over all signal types, always in the following order: 'amp', 'gpio_ain', 'gpio_din', 'gpio_dout'.

class radiens.utils.enums.PsdScaling(value)

PsdScaling is used to set the power spectral density (PSD) scale.

ABSOLUTE = 0

absolute scale

class radiens.utils.enums.SignalUnits(value)

An enumeration.

UNKNOWN = 0

unknown units

MICROVOLTS = 1

microvolts

VOLTS = 2

volts

BINARY = 3

binary

class radiens.utils.enums.FftWindow(value)

FftWindow is used to set the time-domain window function for power spectral density (PSD) analysis.

HAMMING_p01 = 0

Hamming window with 1% overlap

HAMMING_p05 = 1

Hamming window with 5% overlap

PASS_THROUGH = 2

pass-through (no windowing)

class radiens.utils.enums.RadiensFileType(value)

An enumeration of Radiens file types

RHD = 0

RHD file

XDAT = 1

XDAT file

CSV = 2

CSV file

HDF5 = 3

HDF5 file

NEX5 = 4

NEX5 file

NWB = 5

NWB file

KILOSORT2 = 8

Kilosort2 (bin) file

NSX = 13

NSX file

TDT = 15

TDT file

SPIKES = 16

Spikes file

class radiens.utils.enums.MetricMode(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.utils.enums.MetricName(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)

MAX_MIN_DIFF_ABS_AMPLIFIED = 36

Absolute difference between maximum and minimum amplitudes of events in packet, amplified

class radiens.utils.enums.TrsMode(value)

TrsMode 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 = TrsMode.SUBSET

Given a time range [start, end) in seconds (dataset time), the selector modes are:

SUBSET = 0

selects [start, end)

TO_HEAD = 1

selects [start, head of stream/cache/file]

FROM_HEAD = 2

selects [(head of stream/cache/file - start)

class radiens.utils.enums.Port(value)

An enumeration of port types

Example

>>> port = Port.A

Valid values are as follows:

A = 0

port A

B = 1

port B

C = 2

port C

D = 3

port D

E = 4

port E

F = 5

port F

G = 6

port G

H = 7

port H

class radiens.utils.enums.SystemMode(value)

An enumeration of system modes

Example

>>> sys_mode = SystemMode.SMARTBOX_PRO

Valid values are as follows:

SMARTBOX_PRO = 0

Smartbox Pro

SMARTBOX_PRO_SINAPS_256 = 13

Smartbox Pro Sinaps 256

SMARTBOX_PRO_SINAPS_512 = 19

Smartbox Pro Sinaps 512

SMARTBOX_PRO_SINAPS_1024 = 14

Smartbox Pro Sinaps 1024

SMARTBOX_CLASSIC = 6

Smartbox Classic

SMARTBOX_SIM_GEN_SINE = 1

Smartbox Sim Gen Sine

SMARTBOX_SIM_GEN_SINE_MAPPED = 10

Smartbox Sim Gen Sine Mapped

SMARTBOX_SIM_GEN_SINE_HIGH_FREQ = 11

Smartbox Sim Gen Sine High Freq

SMARTBOX_SIM_GEN_SINE_MULTI_BAND = 12

Smartbox Sim Gen Sine Multi Band

SMARTBOX_SIM_GEN_SPIKES = 2

Smartbox Sim Gen Spikes

OPEN_EPHYS_USB2 = 8

Open Ephys USB2

OPEN_EPHYS_USB3 = 4

Open Ephys USB3

INTAN_USB2 = 9

Intan USB2

INTAN_RECORDING_CONTROLLER_1024 = 5

Intan Recording Controller 1024

INTAN_RECORDING_CONTROLLER_512 = 7

Intan Recording Controller 512

XDAQ_ONE_REC = 15

XDAQ One Rec

XDAQ_ONE_STIM = 16

XDAQ One Stim

XDAQ_CORE_REC = 17

XDAQ Core Rec

XDAQ_CORE_STIM = 18

XDAQ Core Stim

class radiens.utils.enums.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