Skip to content

Commit

Permalink
Update online_plots.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Dec 12, 2024
1 parent 23eac80 commit 65d2941
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions iblrig/gui/online_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> A
outcome = index.siblingAtColumn(3).data()
timing = index.siblingAtColumn(4).data()
tip = (
f'Trial {trial}: stimulus with {contrast:g}% contrast on {"right" if position == 1 else "left"} '
f'side of screen, {outcome}'
f'Trial {trial}: {contrast:g}% contrast / {abs(position):g}° {"right" if position > 0 else "left"} / {outcome}'
)
return f'{tip}.' if outcome == 'no-go' else f'{tip} after {timing:0.2f} s.'
return tip + ('.' if outcome == 'no-go' else f' after {timing:0.2f} s.')
return super().data(index, role)


Expand Down Expand Up @@ -81,7 +80,7 @@ def readJsonable(self, _: str) -> None:

table = pd.DataFrame()
table['Trial'] = self._trial_data.trial_num
table['Stimulus'] = np.sign(self._trial_data.position)
table['Stimulus'] = self._trial_data.position
table['Contrast'] = self._trial_data.contrast
table['Outcome'] = self._trial_data.apply(
lambda row: 'no-go' if row['response_side'] == 0 else ('correct' if row['trial_correct'] else 'error'), axis=1
Expand Down Expand Up @@ -150,19 +149,16 @@ def paint(self, painter, option, index):

# Draw the progress bar
painter.fillRect(option.rect, option.backgroundBrush)
if outcome == 'no-go':
filled_rect = QRectF(option.rect)
painter.setBrush(self.color_nogo)
else:
if outcome != 'no-go':
norm_value = np.log(value / self.norm_min) / self.norm_div
filled_rect = QRectF(option.rect)
filled_rect.setWidth(filled_rect.width() * norm_value)
gradient = QLinearGradient(filled_rect.topLeft(), filled_rect.topRight())
gradient.setColorAt(0, QColor(255, 255, 255, 0))
gradient.setColorAt(1, self.color_correct if outcome == 'correct' else self.color_error)
painter.setBrush(gradient)
painter.setPen(Qt.NoPen)
painter.drawRect(filled_rect)
painter.setPen(Qt.NoPen)
painter.drawRect(filled_rect)

# Draw the value text
painter.setPen(option.palette.text().color())
Expand Down

0 comments on commit 65d2941

Please sign in to comment.