1
+ from .. import probe
2
+ from modulefinder import Module
1
3
import numpy as np
2
4
import pandas as pd
3
5
import plotly .graph_objs as go
@@ -65,19 +67,17 @@ def plot_correlogram(
65
67
template = "simple_white" ,
66
68
width = 350 ,
67
69
height = 350 ,
68
- yaxis_range = [0 , None ]
70
+ yaxis_range = [0 , None ],
69
71
)
70
72
return fig
71
73
72
74
73
75
def plot_depth_waveforms (
76
+ ephys : Module ,
74
77
unit_key : dict ,
75
78
y_range : float = 60 ,
76
79
) -> go .Figure :
77
80
78
- from .. import probe
79
- from .. import ephys_no_curation as ephys
80
-
81
81
sampling_rate = (ephys .EphysRecording & unit_key ).fetch1 (
82
82
"sampling_rate"
83
83
) / 1e3 # in kHz
@@ -122,13 +122,13 @@ def plot_depth_waveforms(
122
122
x_min , x_max = np .min (coords [:, 0 ]), np .max (coords [:, 0 ])
123
123
y_min , y_max = np .min (coords [:, 1 ]), np .max (coords [:, 1 ])
124
124
125
- # Spacing between channels (in um)
126
- x_inc = np .abs (np .diff (coords [:, 0 ] )).min ()
127
- y_inc = ( np .abs (np .diff (coords [:, 1 ]))). max ()
125
+ # Spacing between recording sites (in um)
126
+ x_inc = np .abs (np .diff (coords [coords [ :, 1 ] == coords [ 0 , 1 ]][:, 0 ] )).mean () / 2
127
+ y_inc = np .abs (np .diff (coords [coords [ :, 0 ] == coords [ 0 , 0 ]][:, 1 ])). mean () / 2
128
128
129
129
time = np .arange (waveforms .shape [1 ]) / sampling_rate
130
130
131
- x_scale_factor = x_inc / (time [- 1 ] + 1 / sampling_rate )
131
+ x_scale_factor = x_inc / (time [- 1 ] + 1 / sampling_rate ) # correspond to 1 ms
132
132
time_scaled = time * x_scale_factor
133
133
134
134
wf_amps = waveforms .max (axis = 1 ) - waveforms .min (axis = 1 )
@@ -152,7 +152,7 @@ def plot_depth_waveforms(
152
152
x = time_scaled + coord [0 ],
153
153
y = wf_scaled + coord [1 ],
154
154
mode = "lines" ,
155
- line = dict (color = color , width = 1 ),
155
+ line = dict (color = color , width = 1.5 ),
156
156
hovertemplate = f"electrode { electrode } <br>"
157
157
+ f"x ={ coord [0 ]: .0f} μm<br>"
158
158
+ f"y ={ coord [1 ]: .0f} μm<extra></extra>" ,
@@ -164,7 +164,7 @@ def plot_depth_waveforms(
164
164
yaxis_title = "Distance from the probe tip (μm)" ,
165
165
template = "simple_white" ,
166
166
width = 400 ,
167
- height = 700 ,
167
+ height = 600 ,
168
168
xaxis_range = [x_min - x_inc / 2 , x_max + x_inc * 1.2 ],
169
169
yaxis_range = [y_min - y_inc * 2 , y_max + y_inc * 2 ],
170
170
)
@@ -173,12 +173,12 @@ def plot_depth_waveforms(
173
173
fig .update_xaxes (tickvals = xtick_loc , ticktext = xtick_label )
174
174
175
175
# Add a scale bar
176
- x0 = xtick_loc [0 ] / 6
177
- y0 = y_min - y_inc * 1.5
176
+ x0 = xtick_loc [0 ] - ( x_scale_factor * 1.5 )
177
+ y0 = y_min - ( y_inc * 1.5 )
178
178
179
179
fig .add_trace (
180
180
go .Scatter (
181
- x = [x0 , xtick_loc [ 0 ] + x_scale_factor ],
181
+ x = [x0 , x0 + x_scale_factor ],
182
182
y = [y0 , y0 ],
183
183
mode = "lines" ,
184
184
line = dict (color = "black" , width = 2 ),
0 commit comments