Skip to content

Commit db35c9c

Browse files
committed
Handle None wheel data in QC plot
1 parent 0ea8e9f commit db35c9c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ibllib/qc/task_qc_viewer/task_qc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def n_trials(self):
106106
return self.qc.extractor.data['intervals'].shape[0]
107107

108108
def get_wheel_data(self):
109-
return {'re_pos': self.qc.extractor.data.get('wheel_position', np.array([])),
110-
're_ts': self.qc.extractor.data.get('wheel_timestamps', np.array([]))}
109+
return {'re_pos': self.qc.extractor.data.get('wheel_position') or np.array([]),
110+
're_ts': self.qc.extractor.data.get('wheel_timestamps') or np.array([])}
111111

112112
def create_plots(self, axes,
113113
wheel_axes=None, trial_events=None, color_map=None, linestyle=None):
@@ -280,9 +280,11 @@ def show_session_task_qc(qc_or_session=None, bpod_only=False, local=False, one=N
280280
events = map(lambda x: x.replace('stimFreeze', 'stimCenter'), events)
281281

282282
# Run QC and plot
283-
w = ViewEphysQC.viewqc(wheel=qc.get_wheel_data())
283+
wheel_data = qc.get_wheel_data()
284+
w = ViewEphysQC.viewqc(wheel=wheel_data if wheel_data['re_pos'].size else None)
285+
284286
qc.create_plots(w.wplot.canvas.ax,
285-
wheel_axes=w.wplot.canvas.ax2,
287+
wheel_axes=getattr(w.wplot.canvas, 'ax2', None),
286288
trial_events=list(events),
287289
color_map=cm,
288290
linestyle=ls)
@@ -292,7 +294,7 @@ def show_session_task_qc(qc_or_session=None, bpod_only=False, local=False, one=N
292294
if 'task_qc' in locals():
293295
df_trials = pd.DataFrame({
294296
k: v for k, v in task_qc.extractor.data.items()
295-
if v.size == n_trials and not k.startswith('wheel')
297+
if not k.startswith('wheel') and v.size == n_trials
296298
})
297299
df = df_trials.merge(qc.frame, left_index=True, right_index=True)
298300
else:

0 commit comments

Comments
 (0)