Coverage for ibllib/io/extractors/passive_plotting.py: 22%
51 statements
« prev ^ index » next coverage.py v7.7.0, created at 2025-03-17 09:55 +0000
« prev ^ index » next coverage.py v7.7.0, created at 2025-03-17 09:55 +0000
1#!/usr/bin/env python
2# -*- coding:utf-8 -*-
3# @Author: Niccolò Bonacchi
4# @Date: Friday, October 16th 2020, 5:53:15 pm
5# PLOTTING
6from ibllib.plots import color_cycle, squares, vertical_lines
7from ibllib.io.extractors import ephys_fpga
8import matplotlib.pyplot as plt
9import numpy as np
12def plot_rfmapping(times_interp_RF, ax=None):
13 if ax is None:
14 f, ax = plt.subplots(1, 1)
16 vertical_lines(
17 times_interp_RF, ymin=0, ymax=1, color=color_cycle(9), ax=ax, label="RFframe_times"
18 )
20 ax.legend()
23def plot_sync_channels(sync, sync_map, ax=None):
24 # Plot all sync pulses
25 if ax is None:
26 f, ax = plt.subplots(1, 1)
27 for i, device in enumerate(["frame2ttl", "audio", "bpod"]):
28 sy = ephys_fpga.get_sync_fronts(sync, sync_map[device]) # , tmin=t_start_passive)
29 squares(sy["times"], sy["polarities"], yrange=[0.1 + i, 0.9 + i], color="k", ax=ax)
32def plot_passive_periods(passivePeriods_df, ax=None):
33 if ax is None:
34 f, ax = plt.subplots(1, 1)
35 # Update plot
36 vertical_lines(
37 np.r_[passivePeriods_df.loc['start'], passivePeriods_df.loc['stop']],
38 ymin=-1,
39 ymax=4,
40 color=color_cycle(0),
41 ax=ax,
42 label="spacers",
43 )
44 ax.legend()
47def plot_gabor_times(passiveGabor_df, ax=None):
48 if ax is None:
49 f, ax = plt.subplots(1, 1)
50 # Update plot
51 vertical_lines(
52 passiveGabor_df["start"].values,
53 ymin=0,
54 ymax=1,
55 color=color_cycle(1),
56 ax=ax,
57 label="GaborOn_times",
58 )
59 vertical_lines(
60 passiveGabor_df["stop"].values,
61 ymin=0,
62 ymax=1,
63 color=color_cycle(2),
64 ax=ax,
65 label="GaborOff_times",
66 )
67 ax.legend()
70def plot_valve_times(passiveValve_intervals, ax=None):
71 if ax is None:
72 f, ax = plt.subplots(1, 1)
73 # Update the plot
74 vertical_lines(
75 passiveValve_intervals[:, 0],
76 ymin=2,
77 ymax=3,
78 color=color_cycle(3),
79 ax=ax,
80 label="ValveOn_times",
81 )
82 vertical_lines(
83 passiveValve_intervals[:, 1],
84 ymin=2,
85 ymax=3,
86 color=color_cycle(4),
87 ax=ax,
88 label="ValveOff_times",
89 )
90 ax.legend()
93def plot_audio_times(passiveTone_intervals, passiveNoise_intervals, ax=None):
94 if ax is None:
95 f, ax = plt.subplots(1, 1)
96 # Look at it
97 vertical_lines(
98 passiveTone_intervals[:, 0],
99 ymin=1,
100 ymax=2,
101 color=color_cycle(5),
102 ax=ax,
103 label="toneOn_times",
104 )
105 vertical_lines(
106 passiveTone_intervals[:, 1],
107 ymin=1,
108 ymax=2,
109 color=color_cycle(6),
110 ax=ax,
111 label="toneOff_times",
112 )
113 vertical_lines(
114 passiveNoise_intervals[:, 0],
115 ymin=1,
116 ymax=2,
117 color=color_cycle(7),
118 ax=ax,
119 label="noiseOn_times",
120 )
121 vertical_lines(
122 passiveNoise_intervals[:, 1],
123 ymin=1,
124 ymax=2,
125 color=color_cycle(8),
126 ax=ax,
127 label="noiseOff_times",
128 )
130 ax.legend()
133def plot_stims_times(passiveStims_df, ax=None):
134 if ax is None:
135 f, ax = plt.subplots(1, 1)
136 # Look at it
137 vertical_lines(
138 passiveStims_df["valveOn"].values,
139 ymin=2,
140 ymax=3,
141 color=color_cycle(3),
142 ax=ax,
143 label="ValveOn_times",
144 )
145 vertical_lines(
146 passiveStims_df["valveOff"].values,
147 ymin=2,
148 ymax=3,
149 color=color_cycle(4),
150 ax=ax,
151 label="ValveOff_times",
152 )
153 ax.legend()
154 vertical_lines(
155 passiveStims_df["toneOn"].values,
156 ymin=1,
157 ymax=2,
158 color=color_cycle(5),
159 ax=ax,
160 label="toneOn_times",
161 )
162 vertical_lines(
163 passiveStims_df["toneOff"].values,
164 ymin=1,
165 ymax=2,
166 color=color_cycle(6),
167 ax=ax,
168 label="toneOff_times",
169 )
170 vertical_lines(
171 passiveStims_df["noiseOn"].values,
172 ymin=1,
173 ymax=2,
174 color=color_cycle(7),
175 ax=ax,
176 label="noiseOn_times",
177 )
178 vertical_lines(
179 passiveStims_df["noiseOff"].values,
180 ymin=1,
181 ymax=2,
182 color=color_cycle(8),
183 ax=ax,
184 label="noiseOff_times",
185 )
187 ax.legend()
188 # plt.show()