Skip to content

Commit

Permalink
add icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Dec 17, 2024
1 parent 260fa4c commit 5b6cdeb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
39 changes: 34 additions & 5 deletions iblrig/gui/online_plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ctypes
import json
import os
from pathlib import Path
from typing import Any

Expand All @@ -7,9 +9,21 @@
import pyqtgraph as pg
from pydantic import DirectoryPath, Field, validate_call
from pydantic_settings import BaseSettings, CliPositionalArg
from qtpy.QtCore import QFileSystemWatcher, QItemSelection, QModelIndex, QObject, QRect, QRectF, Qt, Signal, Slot
from qtpy.QtGui import QColor, QFont, QLinearGradient, QPainter, QTransform
from qtpy.QtCore import (
QCoreApplication,
QFileSystemWatcher,
QItemSelection,
QModelIndex,
QObject,
QRect,
QRectF,
Qt,
Signal,
Slot,
)
from qtpy.QtGui import QColor, QFont, QIcon, QLinearGradient, QPainter, QPixmap, QTransform
from qtpy.QtWidgets import (
QAbstractItemView,
QApplication,
QFrame,
QGraphicsRectItem,
Expand All @@ -23,6 +37,8 @@
)

from iblqt.core import DataFrameTableModel
from iblrig import __version__ as iblrig_version
from iblrig.gui import resources_rc # noqa: F401
from iblrig.raw_data_loaders import bpod_session_data_to_dataframe, load_task_jsonable


Expand All @@ -49,6 +65,7 @@ def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> A

class TrialsTableView(QTableView):
"""A table view that shows a logarithmic x-grid in one column"""

norm_min = 0.1
norm_max = 102.0
norm_div = np.log10(norm_max / norm_min)
Expand Down Expand Up @@ -360,6 +377,9 @@ def __init__(self, raw_data_folder: DirectoryPath, parent: QObject | None = None
self.statusBar().clearMessage()
self.setWindowTitle('Online Plots')
self.setMinimumSize(1024, 768)
icon = QIcon()
icon.addPixmap(QPixmap(':/images/iblrig_logo'), QIcon.Normal, QIcon.Off)
self.setWindowIcon(icon)

# the frame that contains all the plots
frame = QFrame(self)
Expand Down Expand Up @@ -391,6 +411,7 @@ def __init__(self, raw_data_folder: DirectoryPath, parent: QObject | None = None
self.trials = TrialsTableView(self)
self.trials.setModel(self.model.table_model)
self.trials.setMouseTracking(True)
self.trials.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
self.trials.verticalHeader().hide()
self.trials.horizontalHeader().setDefaultAlignment(Qt.AlignLeft)
self.trials.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
Expand Down Expand Up @@ -435,9 +456,9 @@ def __init__(self, raw_data_folder: DirectoryPath, parent: QObject | None = None
self.psychometricFunction.plotItem.addItem(pg.InfiniteLine(0, 90, 'black'))
layout.addWidget(self.psychometricFunction, 2, 1, 1, 1)

# response time
# chronometric function
self.responseTimeWidget = pg.PlotWidget(parent=self, background='white')
self.responseTimeWidget.plotItem.setTitle('Response Time', color='k')
self.responseTimeWidget.plotItem.setTitle('Chronometric Function', color='k')
self.responseTimeWidget.plotItem.getAxis('left').setLabel('Response Time (s)')
self.responseTimeWidget.plotItem.getAxis('bottom').setLabel('Signed Contrast')
for axis in ('left', 'bottom'):
Expand All @@ -454,7 +475,7 @@ def __init__(self, raw_data_folder: DirectoryPath, parent: QObject | None = None

# bpod data
self.bpodWidget = BpodWidget(self, title='Bpod States and Input Channels')
self.bpodWidget.setMinimumHeight(160)
self.bpodWidget.setMinimumHeight(130)
self.bpodWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
layout.addWidget(self.bpodWidget, 4, 0, 1, 2)

Expand Down Expand Up @@ -492,6 +513,14 @@ def online_plots_cli():
class Settings(BaseSettings, cli_parse_args=True):
directory: CliPositionalArg[Path] = Field(description='Raw Data Directory')

# set app information
QCoreApplication.setOrganizationName('International Brain Laboratory')
QCoreApplication.setOrganizationDomain('internationalbrainlab.org')
QCoreApplication.setApplicationName('IBLRIG Online Plots')
if os.name == 'nt':
app_id = f'IBL.iblrig.online_plots.{iblrig_version}'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)

app = QApplication([])

window = OnlinePlotsView(Settings().directory)
Expand Down
2 changes: 1 addition & 1 deletion iblrig/raw_data_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def bpod_trial_data_to_dataframe(bpod_trial_data: dict[str, Any], trial: int) ->
# deduce channels and values from event names
df[['Channel', 'Value']] = df['Event'].str.extract(RE_PATTERN_EVENT, expand=True)
df['Channel'] = df['Channel'].astype('category')
df['Value'] = df['Value'].replace({'Low': 0, 'High': 1, 'Out': 0, 'In': 1})
df['Value'] = df['Value'].replace({'Low': '0', 'High': '1', 'Out': '0', 'In': '1'})
df['Value'] = pd.to_numeric(df['Value'], errors='coerce', downcast='unsigned', dtype_backend='numpy_nullable')

return df

0 comments on commit 5b6cdeb

Please sign in to comment.