stimpyp.stimpy_core.Stimlog#

final class stimpyp.stimpy_core.Stimlog#

Bases: AbstractStimlog

class 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) – RiglogData

  • file_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 RiglogData

  • reset_mapping (dict[int, list[str]] | None)

Methods

__init__(riglog, file_path[, reset_mapping, ...])

get_log_dict_dataframe()

Log dict dataframe.

get_photo_indicator_dataframe()

Photo Indicator dataframe.

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

session_trials()

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

config

i.e., name, commit hash, missed_frames, ...

exp_end_time

experimental end time (in sec, synced to riglog time with diode offset)

exp_start_time

experimental start time (in sec, synced to riglog time with diode offset)

log_header

i.e., {10: ['code','presentTime','iStim', ...], 20: ['code', 'elapsed', 'cycle', ...]}

log_info

i.e., {10: 'vstim', 20: 'stateMachine'}

n_cycles

Number of cycle for each trial

profile_dataframe

Dataframe with columns:

stim_end_time

the last stimulation end time (in sec, synced to riglog time with diode offset)

stim_start_time

the first stimulation start time (in sec, synced to riglog time with diode offset)

stimulus_segment

stimulation time segment (on-off) in sec (N, 2)

time_offset

time (in sec) to sync stimlog time to riglog

time_offset_statemachine

time offset approach using statemachine

photo_state

photo diode on-off.

indicator_flag

accumulated and zero foreach stim.

s_on_v

statemachine sync time on v, use for time sync if diode signal not reliable.

state_time

Array[float, M]

state_cycle

Array[float, M]

state_new_state

Array[float, M]

state_old_state

Array[float, M]

state_elapsed

Array[float, M]

state_trial_type

Array[float, M]

time

acquisition time in sec.

stim_index

stimulation index.

trial_index

trial index.

contrast

stimulus contrast.

frame_index

stimulation frame index, recount every N.

ori

direction in deg.

sf

spatial frequency in cyc/deg.

tf

temporal frequency in hz.

phase

stimulus phase for each N.

pos_x

object center position X.

pos_y

object center position Y.

size_x

object size width.

size_y

object size height.

flick

TODO.

interpolate

whether do the interpolate, Array[bool, P]

mask

TODO.

pattern

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

  • file_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 RiglogData

  • reset_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:

AbstractStimulusPattern based on stim type

Return type:

AbstractStimulusPattern

property profile_dataframe: DataFrame#

Dataframe with columns:

  • stim type index: i_stims

  • trial 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:

RigEvent

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]