stimpyp.stimpy_git.StimlogGit#
- final class stimpyp.stimpy_git.StimlogGit#
Bases:
AbstractStimlogclass for handle the stimlog file for stimpy github version (mainly tested in the commits derived from master branch)
Dimension parameters:
N = number of visual stimulation (on-off pairs) = (T * S)
T = number of trials
S = number of Stim Type
I = number of photo indicator pulse
- __init__(riglog, file_path, reset_mapping=None, csv_output=False, diode_offset=True)#
init based on
RiglogDatainformation- Parameters:
riglog (RiglogData) –
RiglogDatafile_path (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – filepath of stimlog. could be None if shared log (pyvstim case)
reset_mapping (dict[int, list[str]] | None) – Customized mapping for
reset()- key: corresponding tolog_header- value: list of field, should be the same name as class annotationscsv_output (bool) – if stimlog is exported to separated csv file
diode_offset (bool) – do the offset to sync time with
RiglogData
Methods
__init__(riglog, file_path[, reset_mapping, ...])init based on
RiglogDatainformationLog Dict DataFrame.
PhotoDiode dataframe.
State Machine dataframe.
get pattern foreach stimulation
Visual presentation 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
config for non-header information
experimental end time (in sec, synced to riglog time with diode offset)
experimental start time (in sec, synced to riglog time with diode offset)
list of header.
{0: <'Gratings', ...>, 1: 'PhotoIndicator', 2: 'StateMachine', 3: 'LogDict'}.
Number of cycle for each trial
object center position X.
object center position Y.
Dataframe with columns:
object size width.
object size height.
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
only for StateMachine(2) and LogDict(3)
duration in sec.
object center position XY.
object size width and height.
photoindicator time.
photoindicator state.
photoindicator size in given unit.
photoindicator in XY.
photoindicator unit.
photoindicator mode.
photoindicator frames .
photoindicator size in pixel.
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.
TODO.
whether do the interpolate, Array[bool, P]
TODO.
object pattern.
- log_info: dict[int, str] = {}#
{0: <’Gratings’, …>, 1: ‘PhotoIndicator’, 2: ‘StateMachine’, 3: ‘LogDict’}. empty if as csv output
- log_header: dict[int, list[str]] = {}#
list of header. empty if as csv output
- log_data: dict[int, list[tuple[Any, ...]]]#
only for StateMachine(2) and LogDict(3)
- duration: ndarray#
duration in sec. Array[float, P]
- pos_xy: ndarray#
object center position XY. Array[float, [P, 2]]
- size_xy: ndarray#
object size width and height. Array[int, [P, 2]]
- photo_time: ndarray#
photoindicator time. Array[float, I]
- photo_state: ndarray#
photoindicator state. Array[bool, I]
- photo_size: ndarray#
photoindicator size in given unit. Array[float, I]
- photo_pos: ndarray#
photoindicator in XY. Array[int, [I, 2]]
- photo_units: ndarray#
photoindicator unit. Array[str, I]
- photo_mode: ndarray#
photoindicator mode. Array[int, I]
- photo_frames: ndarray#
photoindicator frames . Array[int, I]
- photo_enable: ndarray#
photoindicator size in pixel. Array[bool, I]
- __init__(riglog, file_path, reset_mapping=None, csv_output=False, diode_offset=True)#
init based on
RiglogDatainformation- Parameters:
riglog (RiglogData) –
RiglogDatafile_path (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – filepath of stimlog. could be None if shared log (pyvstim case)
reset_mapping (dict[int, list[str]] | None) – Customized mapping for
reset()- key: corresponding tolog_header- value: list of field, should be the same name as class annotationscsv_output (bool) – if stimlog is exported to separated csv file
diode_offset (bool) – do the offset to sync time with
RiglogData
- get_visual_stim_dataframe()#
Visual presentation dataframe:
┌────────────┬──────────┬──────────┬─────┬───┬──────┬─────┬──────┬─────────┐ │ time ┆ duration ┆ contrast ┆ ori ┆ … ┆ sf ┆ tf ┆ opto ┆ pattern │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ i64 ┆ i64 ┆ i64 ┆ ┆ f64 ┆ i64 ┆ i64 ┆ str │ ╞════════════╪══════════╪══════════╪═════╪═══╪══════╪═════╪══════╪═════════╡ │ 18.990026 ┆ 10 ┆ 1 ┆ 0 ┆ … ┆ 0.04 ┆ 10 ┆ 0 ┆ square │ │ 21.000029 ┆ 10 ┆ 1 ┆ 0 ┆ … ┆ 0.04 ┆ 10 ┆ 0 ┆ square │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 619.054972 ┆ 10 ┆ 1 ┆ 0 ┆ … ┆ 0.04 ┆ 50 ┆ 0 ┆ square │ │ 619.084972 ┆ 10 ┆ 1 ┆ 0 ┆ … ┆ 0.04 ┆ 50 ┆ 0 ┆ square │ └────────────┴──────────┴──────────┴─────┴───┴──────┴─────┴──────┴─────────┘
- Returns:
- Return type:
DataFrame
- get_photo_indicator_dataframe()#
PhotoDiode dataframe:
┌────────────┬───────┬──────┬────────────┬───────┬──────┬────────┬────────┐ │ time ┆ state ┆ size ┆ pos ┆ units ┆ mode ┆ frames ┆ enable │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ bool ┆ i64 ┆ list[i64] ┆ str ┆ i64 ┆ i64 ┆ bool │ ╞════════════╪═══════╪══════╪════════════╪═══════╪══════╪════════╪════════╡ │ 18.990026 ┆ false ┆ 60 ┆ [740, 370] ┆ pix ┆ 0 ┆ 20 ┆ true │ │ 21.000029 ┆ true ┆ 60 ┆ [740, 370] ┆ pix ┆ 0 ┆ 20 ┆ true │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 607.094955 ┆ false ┆ 60 ┆ [740, 370] ┆ pix ┆ 0 ┆ 20 ┆ true │ │ 609.104958 ┆ true ┆ 60 ┆ [740, 370] ┆ pix ┆ 0 ┆ 20 ┆ true │ └────────────┴───────┴──────┴────────────┴───────┴──────┴────────┴────────┘
- Returns:
- Return type:
DataFrame
- get_state_machine_dataframe()#
State Machine dataframe:
┌────────────┬───────────────────────────┬───────────────────────────┐ │ time ┆ state ┆ prev_state │ │ --- ┆ --- ┆ --- │ │ f64 ┆ str ┆ str │ ╞════════════╪═══════════════════════════╪═══════════════════════════╡ │ 18.990026 ┆ ('States.SHOW_BLANK', 1) ┆ ('States.STIM_SELECT', 0) │ │ 20.990029 ┆ ('States.SHOW_STIM', 2) ┆ ('States.SHOW_BLANK', 1) │ │ … ┆ … ┆ … │ │ 609.094958 ┆ ('States.SHOW_STIM', 2) ┆ ('States.SHOW_BLANK', 1) │ │ 619.094972 ┆ ('States.STIM_SELECT', 0) ┆ ('States.SHOW_STIM', 2) │ └────────────┴───────────────────────────┴───────────────────────────┘- Returns:
- Return type:
DataFrame
- get_log_dict_dataframe()#
Log Dict DataFrame:
┌────────────┬──────────┬──────────┬──────────────┬────────────┐ │ time ┆ block_nr ┆ trial_nr ┆ condition_nr ┆ trial_type │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 │ ╞════════════╪══════════╪══════════╪══════════════╪════════════╡ │ 18.990026 ┆ 0 ┆ 0 ┆ 0 ┆ 1 │ │ 30.990043 ┆ 1 ┆ 0 ┆ 0 ┆ 1 │ │ … ┆ … ┆ … ┆ … ┆ … │ │ 595.083939 ┆ 48 ┆ 0 ┆ 0 ┆ 1 │ │ 607.094955 ┆ 49 ┆ 0 ┆ 0 ┆ 1 │ └────────────┴──────────┴──────────┴──────────────┴────────────┘
- Returns:
- Return type:
DataFrame
- property pos_x: ndarray#
object center position X. Array[float, P]
- property pos_y: ndarray#
object center position Y. Array[float, P]
- config = {}#
config for non-header information
- property n_cycles: list[int]#
Number of cycle for each trial
- property size_x: ndarray#
object size width. Array[int, P]
- 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]
- 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]
- property size_y: ndarray#
object size height. Array[int, P]
- 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)
- session_trials()#
get the session:SessionInfo dictionary (experimental and user-specific)
- Return type:
dict[str, SessionInfo]
- property time_offset: float#
time (in sec) to sync stimlog time to riglog
- get_stim_pattern()#
get pattern foreach stimulation
- Return type:
- property profile_dataframe: DataFrame#
Dataframe with columns:
stim type index:
i_stimstrial index:
i_trials