Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/scroll annotations #159

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.vscode/
.DS_Store
timecode-1.3.1/
timecode-1.3.1.tar
timecode-1.3.1.tar
*.h5
1 change: 1 addition & 0 deletions src/bento.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def load_or_init_annotations(self, fn, sample_rate = 30., start_time = None):
self.annotationsScene.loaded = True
self.annotations.active_annotations_changed.connect(self.noteAnnotationsChanged)
self.set_time(self.time_start)
self.annotationsScene.sceneRectChanged.emit(self.annotationsScene.sceneRect())

@Slot()
def newChannel(self):
Expand Down
1 change: 0 additions & 1 deletion src/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(self, bento):
self.ui.annotationsView.setScene(bento.annotationsScene)
bento.annotationsScene.sceneRectChanged.connect(self.ui.annotationsView.update)
self.ui.annotationsView.scale(10., self.ui.annotationsView.height())
self.ui.annotationsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
bento.annotationsSceneHeightChanged.connect(self.ui.annotationsView.setVScaleAndShow)
self.populateChannelsCombo()
self.ui.channelComboBox.currentTextChanged.connect(bento.setActiveChannel)
Expand Down
55 changes: 35 additions & 20 deletions src/mainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<width>604</width>
<height>328</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -24,8 +24,8 @@
</property>
<property name="maximumSize">
<size>
<width>457</width>
<height>328</height>
<width>10000</width>
<height>10000</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -70,6 +70,9 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorViewCenter</enum>
</property>
Expand Down Expand Up @@ -129,48 +132,60 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="nextPrevLayout">
<layout class="QHBoxLayout" name="playbackSpeedLayout">
<item>
<widget class="QPushButton" name="previousButton">
<widget class="QPushButton" name="halveFrameRateButton">
<property name="text">
<string>Previous</string>
<string>/2</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextButton">
<widget class="QPushButton" name="oneXFrameRateButton">
<property name="text">
<string>Next</string>
<string>1x</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="playbackSpeedLayout">
<item>
<widget class="QPushButton" name="halveFrameRateButton">
<widget class="QPushButton" name="doubleFrameRateButton">
<property name="text">
<string>/2</string>
<string>* 2</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="oneXFrameRateButton">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="previousButton">
<property name="text">
<string>1x</string>
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="doubleFrameRateButton">
<widget class="QPushButton" name="nextButton">
<property name="text">
<string>* 2</string>
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="nextPrevLayout"/>
</item>
<item>
<layout class="QHBoxLayout" name="mainButtonLayout">
<item>
Expand Down Expand Up @@ -219,7 +234,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<width>604</width>
<height>24</height>
</rect>
</property>
Expand Down
64 changes: 38 additions & 26 deletions src/mainWindow_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,37 @@
################################################################################
## Form generated from reading UI file 'mainWindow.ui'
##
## Created by: Qt User Interface Compiler version 6.1.2
## Created by: Qt User Interface Compiler version 6.2.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from qtpy.QtCore import * # type: ignore
from qtpy.QtGui import * # type: ignore
from qtpy.QtWidgets import * # type: ignore
from qtpy.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from qtpy.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from qtpy.QtWidgets import (QApplication, QComboBox, QGraphicsView, QHBoxLayout,
QLabel, QMainWindow, QMenuBar, QPushButton,
QSizePolicy, QSpacerItem, QStatusBar, QVBoxLayout,
QWidget)

from widgets.annotationsWidget import AnnotationsView


class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(460, 328)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
MainWindow.resize(604, 328)
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QSize(460, 328))
MainWindow.setMaximumSize(QSize(457, 328))
MainWindow.setMaximumSize(QSize(10000, 10000))
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
sizePolicy1 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
Expand All @@ -52,6 +59,7 @@ def setupUi(self, MainWindow):
self.annotationsView.setMinimumSize(QSize(0, 50))
self.annotationsView.setAcceptDrops(False)
self.annotationsView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.annotationsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.annotationsView.setResizeAnchor(QGraphicsView.AnchorViewCenter)

self.verticalLayout.addWidget(self.annotationsView)
Expand Down Expand Up @@ -96,21 +104,6 @@ def setupUi(self, MainWindow):

self.verticalLayout.addLayout(self.controlButtonLayout)

self.nextPrevLayout = QHBoxLayout()
self.nextPrevLayout.setObjectName(u"nextPrevLayout")
self.previousButton = QPushButton(self.centralwidget)
self.previousButton.setObjectName(u"previousButton")

self.nextPrevLayout.addWidget(self.previousButton)

self.nextButton = QPushButton(self.centralwidget)
self.nextButton.setObjectName(u"nextButton")

self.nextPrevLayout.addWidget(self.nextButton)


self.verticalLayout.addLayout(self.nextPrevLayout)

self.playbackSpeedLayout = QHBoxLayout()
self.playbackSpeedLayout.setObjectName(u"playbackSpeedLayout")
self.halveFrameRateButton = QPushButton(self.centralwidget)
Expand All @@ -128,9 +121,28 @@ def setupUi(self, MainWindow):

self.playbackSpeedLayout.addWidget(self.doubleFrameRateButton)

self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.playbackSpeedLayout.addItem(self.horizontalSpacer_4)

self.previousButton = QPushButton(self.centralwidget)
self.previousButton.setObjectName(u"previousButton")

self.playbackSpeedLayout.addWidget(self.previousButton)

self.nextButton = QPushButton(self.centralwidget)
self.nextButton.setObjectName(u"nextButton")

self.playbackSpeedLayout.addWidget(self.nextButton)


self.verticalLayout.addLayout(self.playbackSpeedLayout)

self.nextPrevLayout = QHBoxLayout()
self.nextPrevLayout.setObjectName(u"nextPrevLayout")

self.verticalLayout.addLayout(self.nextPrevLayout)

self.mainButtonLayout = QHBoxLayout()
self.mainButtonLayout.setObjectName(u"mainButtonLayout")
self.channelComboBox = QComboBox(self.centralwidget)
Expand Down Expand Up @@ -163,7 +175,7 @@ def setupUi(self, MainWindow):
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 460, 24))
self.menubar.setGeometry(QRect(0, 0, 604, 24))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
Expand All @@ -185,11 +197,11 @@ def retranslateUi(self, MainWindow):
self.stepButton.setText(QCoreApplication.translate("MainWindow", u">", None))
self.ffButton.setText(QCoreApplication.translate("MainWindow", u">>", None))
self.toEndButton.setText(QCoreApplication.translate("MainWindow", u">|", None))
self.previousButton.setText(QCoreApplication.translate("MainWindow", u"Previous", None))
self.nextButton.setText(QCoreApplication.translate("MainWindow", u"Next", None))
self.halveFrameRateButton.setText(QCoreApplication.translate("MainWindow", u"/2", None))
self.oneXFrameRateButton.setText(QCoreApplication.translate("MainWindow", u"1x", None))
self.doubleFrameRateButton.setText(QCoreApplication.translate("MainWindow", u"* 2", None))
self.previousButton.setText(QCoreApplication.translate("MainWindow", u"Previous", None))
self.nextButton.setText(QCoreApplication.translate("MainWindow", u"Next", None))
self.newChannelPushButton.setText(QCoreApplication.translate("MainWindow", u"New Channel", None))
self.trialPushButton.setText(QCoreApplication.translate("MainWindow", u"Select Trial...", None))
self.quitButton.setText(QCoreApplication.translate("MainWindow", u"Quit", None))
Expand Down
1 change: 0 additions & 1 deletion src/neural/neuralFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(self, bento):
self.ui.annotationsView.setScene(bento.annotationsScene)
self.ui.annotationsView.scale(10., self.ui.annotationsView.height())
self.ui.annotationsView.setVScaleAndShow(bento.annotationsScene.sceneRect().height())
self.ui.annotationsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.ui.neuralView.hScaleChanged.connect(self.ui.annotationsView.setHScaleAndShow)
bento.annotationsSceneHeightChanged.connect(self.ui.annotationsView.setVScaleAndShow)
self.annotations = self.bento.annotations
Expand Down
2 changes: 1 addition & 1 deletion src/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def fix_path(path):
return abspath(path.replace('\\', sep).replace('/', sep))

SCENE_PADDING = 200.
def padded_rectf(rectf: QRectF):
def padded_rectf(rectf: QRectF) -> QRectF:
return rectf + QMarginsF(SCENE_PADDING, 0., SCENE_PADDING, 0.)

cm_data_parula = [
Expand Down
9 changes: 6 additions & 3 deletions src/video/seqIo.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def __init__(self,filename,info=[],buildTable=True):
info.numFrames=0
if buildTable:
print("buildTable was True, so calling buildSeekTable()")
self.buildSeekTable(False)
self.buildSeekTable(True)


def readHeader(self):
Expand Down Expand Up @@ -526,7 +526,7 @@ def readHeader(self):
self.timestamp_length = int(self.header['trueImageSize'] \
- (self.bit_depth / 8 * (self.header['height'] * self.header['width'])))

def buildSeekTable(self,memoize=False):
def buildSeekTable(self,memoize=True):
"""Build a seek table containing the offset and frame size for every frame in the video."""
print("in seqIo_reader.buildSeekTable()")
pickle_name = self.filename.strip(".seq") + ".seek"
Expand Down Expand Up @@ -588,7 +588,10 @@ def buildSeekTable(self,memoize=False):
else:
self.seek_table=seek_table
if memoize:
pickle.dump(seek_table,open(pickle_name,'wb'))
try:
pickle.dump(seek_table,open(pickle_name,'wb'))
except OSError as e:
print(f"Problem writing seek table file {e.filename}, maybe no write permission?")

#compute frame rate from timestamps as stored fps may be incorrect
# if n==1: return
Expand Down
Loading