Create Stimulus
This module provides functionality to create stimulus sequences for sensory perturbations. The stimulus sequences can be exportet in a format that is readable in Anaropia and Anaropia legacy Virtual Reality experimental setups.
- balancepy.make_stimulus.make_prts(type='mseq', ncyc=1, ampl=1, vel=0, samplingrate_Hz=1000, t_state=0.25, base=3, power=4, seq=1, shift=0)
Generate a stimulus based on m-sequence or other types.
- Parameters:
type (str, optional) – Type of stimulus (‘Peterka2002’, ‘prts_20s’, ‘mseq’, etc.).
ncyc (int, optional) – Number of cycles to repeat the stimulus.
ampl (float, optional) – Amplitude of the stimulus.
vel (float, optional) – Velocity scaling factor.
samplingrate_Hz (int, optional) – Sampling rate in Hz.
t_state (float, optional) – Time per state in seconds.
base (int, optional) – Base for m-sequence generation.
power (int, optional) – Power for m-sequence generation.
seq (int, optional) – Sequence instantiation to use.
shift (int, optional) – Cyclical shift of the sequence.
- Returns:
stim – Generated stimulus.
- Return type:
np.ndarray
- balancepy.make_stimulus.make_sine(frequency_Hz=1, ncyc=1, ampl=1, samplingrate_Hz=1000, phase=0)
Generate a sine wave stimulus.
- Parameters:
frequency_Hz (float, optional) – Frequency of the sine wave in Hz.
ncyc (int, optional) – Number of cycles to repeat the sine wave.
ampl (float, optional) – Amplitude of the sine wave.
samplingrate_Hz (int, optional) – Sampling rate in Hz.
phase (float, optional) – Phase shift in radians.
- Returns:
stim – Generated sine wave stimulus.
- Return type:
np.ndarray
- balancepy.make_stimulus.mseq(base_val, power_val, which_seq=1, shift=1)
Generate a maximum length sequence (m-sequence).
- Parameters:
base_val (int) – Number of sequence levels (2, 3, or 5 allowed).
power_val (int) – Power, so that sequence length is base_val**power_val - 1.
which_seq (int, optional) – Sequence instantiation to use (default is 1).
shift (int, optional) – Cyclical shift of the sequence (default is 1).
- Returns:
Generated maximum length sequence.
- Return type:
np.ndarray
Notes
Adapted from the MATLAB code by Giedrius T. Buracas, SNL-B, Salk Institute.
References
Davies, W.D.T. (1970). System Identification for Self-Adaptive Control. Wiley-Interscience. Buracas, G.T. & Boynton, G.M. (2002). Efficient Design of Event-Related fMRI Experiments Using M-sequences. NeuroImage, 16, 801–813.
- balancepy.make_stimulus.saveas_anaropia_legacy_stimulus(stim, stim_name='pitch', stimulus_index=1)
Save a stimulus in the legacy Anaropia format.
Note
Stimulus data must be sampled at 1000 Hz. Strict name conventions apply (see Parameters).
- Parameters:
stim (np.ndarray) – Stimulus data to save. Can be 1D or 2D.
stim_name (str or list of str) –
- Name(s) of the stimulus. Options are:
’pitch’: anterior-posterior rotation in degrees (default for 1D)
’roll’: lateral-medial rotation in degrees
’yaw’: vertical rotation in degrees
’trans_ap’: anterior-posterior translation in meters
’trans_ml’: lateral-medial translation in meters
’trans_ud’: vertical translation in meters
Can also be a list of strings for multi-dimensional stimuli.
stimulus_index (int, optional) – Index for the filename. Output will be ‘vr_stim_[stimulus_index].csv’.