stimpyp.stimpy_core.Stimlog#
- final class stimpyp.stimpy_core.Stimlog#
Bases:
AbstractStimlogclass for handle the stimlog file for stimpy bitbucket version (mainly tested in the commits derived from master branch)
Dimension parameters:
N = numbers of visual stimulation (on-off pairs) = (T * S)
T = number of trials
S = number of Stim Type
P = number of acquisition sample pulse (Visual parameters)
M = number of statemachine pulse
- __init__(riglog, file_path, reset_mapping=None, diode_offset=True, sequential_offset=True)#
- Parameters:
riglog (RiglogData) –
RiglogDatafile_path (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – stimlog filepath
diode_offset (bool) – If do the diode offset to sync the time to riglog
sequential_offset (bool) – do the sequential offset to sync time with
RiglogDatareset_mapping (dict[int, list[str]] | None)
Methods
__init__(riglog, file_path[, reset_mapping, ...])Log dict dataframe.
Photo Indicator dataframe.
State Machine dataframe.
get_stim_pattern([with_dur])Get stimulus pattern container
get_visual_stim_dataframe([stim_only])Get the stimlog visual stimulation logging as dataframe.
get the session:SessionInfo dictionary (experimental and user-specific)
stim_square_pulse_event([sampling_rate])Get the stimulation on-off square pulse 0,1 consecutive event
Attributes
i.e., name, commit hash, missed_frames, ...
experimental end time (in sec, synced to riglog time with diode offset)
experimental start time (in sec, synced to riglog time with diode offset)
i.e., {10: ['code','presentTime','iStim', ...], 20: ['code', 'elapsed', 'cycle', ...]}
i.e., {10: 'vstim', 20: 'stateMachine'}
Number of cycle for each trial
Dataframe with columns:
the last stimulation end time (in sec, synced to riglog time with diode offset)
the first stimulation start time (in sec, synced to riglog time with diode offset)
stimulation time segment (on-off) in sec (N, 2)
time (in sec) to sync stimlog time to riglog
time offset approach using statemachine
photo diode on-off.
accumulated and zero foreach stim.
statemachine sync time on v, use for time sync if diode signal not reliable.
Array[float, M]
Array[float, M]
Array[float, M]
Array[float, M]
Array[float, M]
Array[float, M]
acquisition time in sec.
stimulation index.
trial index.
stimulus contrast.
stimulation frame index, recount every N.
direction in deg.
spatial frequency in cyc/deg.
temporal frequency in hz.
stimulus phase for each N.
object center position X.
object center position Y.
object size width.
object size height.
TODO.
whether do the interpolate, Array[bool, P]
TODO.
object pattern.
- config: dict[str, Any] = {}#
i.e., name, commit hash, missed_frames, …
- log_info: dict[int, str] = {}#
i.e., {10: ‘vstim’, 20: ‘stateMachine’}
- log_header: dict[int, list[str]] = {}#
i.e., {10: [‘code’,’presentTime’,’iStim’, …], 20: [‘code’, ‘elapsed’, ‘cycle’, …]}
- photo_state: ndarray#
photo diode on-off. Array[int, P]. value domain in (0,1)
- indicator_flag: ndarray#
accumulated and zero foreach stim. Array[int, P]. value domain in (1, …)
- s_on_v: ndarray#
statemachine sync time on v, use for time sync if diode signal not reliable. Array[float, M]
- state_time: ndarray#
Array[float, M]
- state_cycle: ndarray#
Array[float, M]
- state_new_state: ndarray#
Array[float, M]
- state_old_state: ndarray#
Array[float, M]
- state_elapsed: ndarray#
Array[float, M]
- state_trial_type: ndarray#
Array[float, M]
- __init__(riglog, file_path, reset_mapping=None, diode_offset=True, sequential_offset=True)#
- Parameters:
riglog (RiglogData) –
RiglogDatafile_path (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – stimlog filepath
diode_offset (bool) – If do the diode offset to sync the time to riglog
sequential_offset (bool) – do the sequential offset to sync time with
RiglogDatareset_mapping (dict[int, list[str]] | None)
- get_visual_stim_dataframe(stim_only=True)#
Get the stimlog visual stimulation logging as dataframe:
┌─────────────┬───────┬────────┬───────┬───┬───────┬──────┬───────────┬──────────┐ │ presentTime ┆ iStim ┆ iTrial ┆ photo ┆ … ┆ ori ┆ sf ┆ phase ┆ stim_idx │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞═════════════╪═══════╪════════╪═══════╪═══╪═══════╪══════╪═══════════╪══════════╡ │ 904.048038 ┆ 69.0 ┆ 0.0 ┆ 0.0 ┆ … ┆ 270.0 ┆ 0.16 ┆ 0.066667 ┆ 1.0 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 2710.807378 ┆ 45.0 ┆ 4.0 ┆ 0.0 ┆ … ┆ 270.0 ┆ 0.04 ┆ 11.933333 ┆ 179.0 │ │ 2710.824102 ┆ 45.0 ┆ 4.0 ┆ 0.0 ┆ … ┆ 270.0 ┆ 0.04 ┆ 11.933333 ┆ 179.0 │ └─────────────┴───────┴────────┴───────┴───┴───────┴──────┴───────────┴──────────┘
- Parameters:
stim_only (bool) – only show the stimulation epoch
- Returns:
visual stimuli dataframe
- Return type:
DataFrame
- get_state_machine_dataframe()#
State Machine dataframe:
┌──────────┬───────┬──────────┬──────────┬──────────────┬───────────┐ │ elapsed ┆ cycle ┆ newState ┆ oldState ┆ stateElapsed ┆ trialType │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞══════════╪═══════╪══════════╪══════════╪══════════════╪═══════════╡ │ 902.601 ┆ 0.0 ┆ 1.0 ┆ 0.0 ┆ 902.601 ┆ 0.0 │ │ 904.614 ┆ 0.0 ┆ 2.0 ┆ 1.0 ┆ 2.012 ┆ 0.0 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 2711.425 ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 3.01 ┆ 0.0 │ │ 2711.425 ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 0.0 ┆ 0.0 │ └──────────┴───────┴──────────┴──────────┴──────────────┴───────────┘
- Returns:
- Return type:
DataFrame
- property exp_start_time: float#
experimental start time (in sec, synced to riglog time with diode offset)
- property exp_end_time: float#
experimental end time (in sec, synced to riglog time with diode offset)
- property stim_start_time: float#
the first stimulation start time (in sec, synced to riglog time with diode offset)
- property stim_end_time: float#
the last stimulation end time (in sec, synced to riglog time with diode offset)
- property stimulus_segment: ndarray#
stimulation time segment (on-off) in sec (N, 2)
- property time_offset: float | ndarray#
time (in sec) to sync stimlog time to riglog
- property time_offset_statemachine: ndarray#
time offset approach using statemachine
- session_trials()#
get the session:SessionInfo dictionary (experimental and user-specific)
- Return type:
dict[str, SessionInfo]
- get_stim_pattern(with_dur=False)#
Get stimulus pattern container
- Parameters:
with_dur (bool) – if extract theoretical duration value from protocol file
- Returns:
AbstractStimulusPatternbased on stim type- Return type:
- property profile_dataframe: DataFrame#
Dataframe with columns:
stim type index:
i_stimstrial index:
i_trials
- get_log_dict_dataframe()#
Log dict dataframe. Github version only
- Return type:
DataFrame
- get_photo_indicator_dataframe()#
Photo Indicator dataframe. Github version only
- Return type:
DataFrame
- property n_cycles: list[int]#
Number of cycle for each trial
- stim_square_pulse_event(sampling_rate=30.0)#
Get the stimulation on-off square pulse 0,1 consecutive event
- Parameters:
sampling_rate (float) – sampling rate for the time domain interpolation
- Returns:
Stimulus rig event
- Return type:
- time: ndarray#
acquisition time in sec. Array[float, P]
- stim_index: ndarray#
stimulation index. Array[int, P]
- trial_index: ndarray#
trial index. Array[int, P]
- contrast: ndarray#
stimulus contrast. Array[int, P]. value domain in (0,1)
- frame_index: ndarray#
stimulation frame index, recount every N. Array[int, P]
- ori: ndarray#
direction in deg. Array[float, P]
- sf: ndarray#
spatial frequency in cyc/deg. Array[float, P]
- tf: ndarray#
temporal frequency in hz. Array[float, P]
- phase: ndarray#
stimulus phase for each N. Array[float, P]
- pos_x: ndarray#
object center position X. Array[float, P]
- pos_y: ndarray#
object center position Y. Array[float, P]
- size_x: ndarray#
object size width. Array[int, P]
- size_y: ndarray#
object size height. Array[int, P]
- flick: ndarray#
TODO. Array[int, P]
- interpolate: ndarray#
whether do the interpolate, Array[bool, P]
- mask: ndarray#
TODO. Array[bool|None, P]
- pattern: ndarray#
object pattern. Array[str, P]