forked from smarsland/AviaNZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AviaNZ_manual.py
6107 lines (5370 loc) · 290 KB
/
AviaNZ_manual.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Version 3.0 14/09/20
# Authors: Stephen Marsland, Nirosha Priyadarshani, Julius Juodakis, Virginia Listanti
# This is the main class for the AviaNZ interface.
# AviaNZ bioacoustic analysis program
# Copyright (C) 2017--2020
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ? click, shutil
import sys, os, json, platform, re, shutil
from shutil import copyfile
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import QIcon, QStandardItemModel, QStandardItem, QKeySequence, QPixmap
from PyQt5.QtWidgets import QApplication, QInputDialog, QFileDialog, QMainWindow, QActionGroup, QToolButton, QLabel, QSlider, QScrollBar, QDoubleSpinBox, QPushButton, QListWidgetItem, QMenu, QFrame, QMessageBox, QWidgetAction, QComboBox, QTreeView, QShortcut, QGraphicsProxyWidget, QWidget, QVBoxLayout, QGroupBox, QSizePolicy, QHBoxLayout, QSpinBox, QAbstractSpinBox, QLineEdit
from PyQt5.QtCore import Qt, QDir, QTimer, QPoint, QPointF, QLocale, QModelIndex, QRectF
from PyQt5.QtMultimedia import QAudio
import wavio
import numpy as np
from scipy.ndimage.filters import median_filter
import pyqtgraph as pg
from pyqtgraph.dockarea import DockArea, Dock
import pyqtgraph.functions as fn
import pyqtgraph.exporters as pge
from pyqtgraph.parametertree import Parameter, ParameterTree
import SupportClasses, SupportClasses_GUI
import Dialogs
import DialogsTraining
import SignalProc
import Segment
import WaveletSegment
import WaveletFunctions
import Clustering
import colourMaps
import Shapes
import librosa
import webbrowser, copy, math
import time
import openpyxl
import xml.etree.ElementTree as ET
pg.setConfigOption('background','w')
pg.setConfigOption('foreground','k')
pg.setConfigOption('antialias',True)
print("Package import complete.")
# import pdb
# from PyQt5.QtCore import pyqtRemoveInputHook
# from pdb import set_trace
#
# def debug_trace():
# pyqtRemoveInputHook()
# set_trace()
class AviaNZ(QMainWindow):
"""Main class for the user interface.
Contains most of the user interface and plotting code"""
def __init__(self,root=None,configdir=None,CLI=False,cheatsheet=False,zooniverse=False,firstFile='', imageFile='', command=''):
"""Initialisation of the class. Load main config and bird lists from configdir.
Also initialises the data structures and loads an initial file (specified explicitly)
and sets up the window.
One interesting configuration point is the DOC setting, which hides the more 'research' functions."""
print("Starting AviaNZ...")
super(AviaNZ, self).__init__()
self.root = root
self.CLI = CLI
self.cheatsheet = cheatsheet
self.zooniverse = zooniverse
# configdir passes the standard user app dir based on OS.
# At this point, the main config file should already be ensured to exist.
self.configdir = configdir
self.configfile = os.path.join(configdir, "AviaNZconfig.txt")
self.ConfigLoader = SupportClasses.ConfigLoader()
self.config = self.ConfigLoader.config(self.configfile)
self.saveConfig = True
# Load filters
self.filtersDir = os.path.join(configdir, self.config['FiltersDir'])
self.FilterDicts = self.ConfigLoader.filters(self.filtersDir)
# Load the birdlists - both are now necessary:
self.shortBirdList = self.ConfigLoader.shortbl(self.config['BirdListShort'], configdir)
if self.shortBirdList is None:
raise OSError("Short bird list missing, cannot continue")
self.longBirdList = self.ConfigLoader.longbl(self.config['BirdListLong'], configdir)
if self.longBirdList is None:
raise OSError("Long bird list missing, cannot continue")
self.batList = self.ConfigLoader.batl(self.config['BatList'], configdir)
if self.batList is None:
raise OSError("Bat list missing, cannot continue")
# avoid comma/point problem in number parsing
QLocale.setDefault(QLocale(QLocale.English, QLocale.NewZealand))
print('Locale is set to ' + QLocale().name())
# The data structures for the segments
self.listLabels = []
self.listRectanglesa1 = []
self.listRectanglesa2 = []
self.SegmentRects = []
self.segmentPlots = []
self.shapePlots = []
self.box1id = -1
self.started = False
self.startedInAmpl = False
self.startTime = 0
self.segmentsToSave = False
self.viewCallType = False
self.batmode = False
# Spectrogram default settings
# TODO: put in config?
self.sgOneSided = True
self.sgMeanNormalise = True
self.sgEqualLoudness = False
self.sgType = 'Standard'
self.sgNormMode = 'Log'
self.sgScale= 'Linear'
self.nfilters = 128
self.windowType = 'Hann'
self.lastSpecies = [{"species": "Don't Know", "certainty": 0, "filter": "M"}]
self.DOC = self.config['DOC']
self.extra = "none"
self.slowSpeed = 2
# Whether or not the context menu allows multiple birds.
self.multipleBirds = self.config['MultipleSpecies']
if len(self.config['RecentFiles']) > 0:
self.SoundFileDir = os.path.dirname(self.config['RecentFiles'][-1])
if not os.path.isdir(self.SoundFileDir):
self.SoundFileDir = self.config['SoundFileDir']
else:
self.SoundFileDir = self.config['SoundFileDir']
self.filename = None
self.focusRegion = None
self.operator = self.config['operator']
self.reviewer = self.config['reviewer']
# For preventing callbacks involving overview panel
self.updateRequestedByOverview = False
# working directory
if not os.path.isdir(self.SoundFileDir):
print("Directory doesn't exist: making it")
os.makedirs(self.SoundFileDir)
#self.backupDatafiles()
# INPUT FILE LOADING
# search order: infile -> firstFile -> dialog
# Make life easier for now: preload a birdsong
if not os.path.isfile(firstFile) and not cheatsheet and not zooniverse:
# For distribution:
firstFile = self.SoundFileDir
# Can also use:
# firstFile = self.SoundFileDir + '/' + 'kiwi_1min.wav'
if not os.path.isfile(firstFile) and not cheatsheet and not zooniverse:
if self.CLI:
print("file %s not found, exiting" % firstFile)
raise OSError("No input file, cannot continue")
else:
# pop up a dialog to select file
firstFile, drop = QFileDialog.getOpenFileName(self, 'Choose File', self.SoundFileDir, "WAV or BMP files (*.wav *.bmp);; Only WAV files (*.wav);; Only BMP files (*.bmp)")
while firstFile == '':
msg = SupportClasses_GUI.MessagePopup("w", "Select Sound File", "Choose a sound file to proceed.\nDo you want to continue?")
msg.setStandardButtons(QMessageBox.No)
msg.addButton("Choose a file", QMessageBox.YesRole)
msg.button(QMessageBox.No).setText("Exit")
reply = msg.exec_()
if reply == 0:
firstFile, drop = QFileDialog.getOpenFileName(self, 'Choose File', self.SoundFileDir, "WAV or BMP files (*.wav *.bmp);; Only WAV files (*.wav);; Only BMP files (*.bmp)")
else:
sys.exit()
# parse firstFile to dir and file parts
if not cheatsheet and not zooniverse:
self.SoundFileDir = os.path.dirname(firstFile)
print("Working dir set to %s" % self.SoundFileDir)
print("Opening file %s" % firstFile)
# to keep code simpler, graphic options are created even in CLI mode
# they're just not shown because QMainWindow.__init__ is skipped
if not self.CLI:
QMainWindow.__init__(self, root)
# parse mouse settings
if self.config['drawingRightBtn']:
self.MouseDrawingButton = Qt.RightButton
else:
self.MouseDrawingButton = Qt.LeftButton
# Boxes with area smaller than this will be ignored -
# to avoid accidentally creating little boxes
self.minboxsize = 0.1
self.createMenu()
self.createFrame()
self.resetStorageArrays()
if self.CLI:
if cheatsheet or zooniverse:
# use infile and imagefile as directories
print(firstFile)
self.SoundFileDir = firstFile
# Read folders and sub-folders
for root, dirs, files in os.walk(firstFile):
for f in files:
if f[-4:].lower() == '.wav':
print(os.path.join(root, f))
self.loadFile(os.path.join(root, f), cs=True)
self.widthWindow.setValue(60) # self.datalengthSec)
print('file path: ', os.path.join(root, f[:-4]))
self.setColourLevels(20, 50)
self.saveImage(os.path.join(root, f[:-4]+'.png'))
else:
self.loadFile(firstFile)
while command!=():
c = command[0]
command = command[1:]
print("Next command to execute is %s" % c)
if c=="denoise":
self.denoise()
elif c=="segment":
self.segment()
else:
print("ERROR: %s is not a valid command" % c)
raise ValueError("CLI command not recognized")
if imageFile!='':
# reset images to show full width if in CLI:
self.widthWindow.setValue(self.datalengthSec)
# looks unnecessary:
# self.p_spec.setXRange(0, self.convertAmpltoSpec(self.datalengthSec), update=True, padding=0)
self.saveImage(imageFile)
else:
# Make the window and associated widgets
self.setWindowTitle('AviaNZ')
self.setWindowIcon(QIcon('img/AviaNZ.ico'))
# Show the window
if self.config['StartMaximized']:
self.showMaximized()
# extra toggle because otherwise Windows starts at a non-maximized size
self.setWindowState(self.windowState() ^ Qt.WindowMaximized)
self.setWindowState(self.windowState() | Qt.WindowMaximized)
else:
self.show()
# Save the segments every minute
self.timer = QTimer()
self.timer.timeout.connect(self.saveSegments)
self.timer.start(self.config['secsSave']*1000)
self.listLoadFile(os.path.basename(firstFile))
if self.DOC and not cheatsheet and not zooniverse:
self.setOperatorReviewerDialog()
def createMenu(self):
""" Create the menu entries at the top of the screen and link them as appropriate.
Some of them are initialised according to the data in the configuration file."""
fileMenu = self.menuBar().addMenu("&File")
openIcon = self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton)
fileMenu.addAction(openIcon, "&Open sound file", self.openFile, "Ctrl+O")
# fileMenu.addAction("&Change Directory", self.chDir)
fileMenu.addAction("Set Operator/Reviewer (Current File)", self.setOperatorReviewerDialog)
fileMenu.addSeparator()
for recentfile in self.config['RecentFiles']:
fileMenu.addAction(recentfile, lambda arg=recentfile: self.openFile(arg))
fileMenu.addSeparator()
fileMenu.addAction("Restart Program",self.restart,"Ctrl+R")
fileMenu.addAction(QIcon(QPixmap('img/exit.png')), "&Quit",QApplication.quit,"Ctrl+Q")
# This is a very bad way to do this, but I haven't worked anything else out (setMenuRole() didn't work)
# Add it a second time, then it appears!
if platform.system() == 'Darwin':
fileMenu.addAction("&Quit",QApplication.quit,"Ctrl+Q")
specMenu = self.menuBar().addMenu("&Appearance")
self.useAmplitudeTick = specMenu.addAction("Show amplitude plot", self.useAmplitudeCheck)
self.useAmplitudeTick.setCheckable(True)
self.useAmplitudeTick.setChecked(self.config['showAmplitudePlot'])
self.useAmplitude = True
self.useFilesTick = specMenu.addAction("Show file list", self.useFilesCheck)
self.useFilesTick.setCheckable(True)
self.useFilesTick.setChecked(self.config['showListofFiles'])
# this can go under "Change interface settings"
self.showOverviewSegsTick = specMenu.addAction("Show annotation overview", self.showOverviewSegsCheck)
self.showOverviewSegsTick.setCheckable(True)
self.showOverviewSegsTick.setChecked(self.config['showAnnotationOverview'])
self.showPointerDetails = specMenu.addAction("Show pointer details in spectrogram", self.showPointerDetailsCheck)
self.showPointerDetails.setCheckable(True)
self.showPointerDetails.setChecked(self.config['showPointerDetails'])
specMenu.addSeparator()
colMenu = specMenu.addMenu("Choose colour map")
colGroup = QActionGroup(self)
for colour in self.config['ColourList']:
cm = colMenu.addAction(colour)
cm.setCheckable(True)
if colour==self.config['cmap']:
cm.setChecked(True)
receiver = lambda checked, cmap=colour: self.setColourMap(cmap)
cm.triggered.connect(receiver)
colGroup.addAction(cm)
self.invertcm = specMenu.addAction("Invert colour map",self.invertColourMap)
self.invertcm.setCheckable(True)
self.invertcm.setChecked(self.config['invertColourMap'])
# specMenu.addSeparator()
specMenu.addAction("&Change spectrogram parameters",self.showSpectrogramDialog, "Ctrl+C")
if not self.DOC:
specMenu.addSeparator()
self.showDiagnosticTick = specMenu.addAction("Show training diagnostics",self.showDiagnosticDialog)
self.showDiagnosticCNN = specMenu.addAction("Show CNN training diagnostics", self.showDiagnosticDialogCNN)
self.extraMenu = specMenu.addMenu("Diagnostic plots")
extraGroup = QActionGroup(self)
for ename in ["none", "Wavelet scalogram", "Wavelet correlations", "Wind energy", "Rain", "Wind adjustment", "Filtered spectrogram, new + AA", "Filtered spectrogram, new", "Filtered spectrogram, old"]:
em = self.extraMenu.addAction(ename)
em.setCheckable(True)
if ename == self.extra:
em.setChecked(True)
receiver = lambda checked, ename=ename: self.setExtraPlot(ename)
em.triggered.connect(receiver)
extraGroup.addAction(em)
specMenu.addSeparator()
markMenu = specMenu.addMenu("Mark on spectrogram")
self.showFundamental = markMenu.addAction("Fundamental frequency", self.showFundamentalFreq,"Ctrl+F")
self.showFundamental.setCheckable(True)
self.showFundamental.setChecked(True)
self.showSpectral = markMenu.addAction("Spectral derivative", self.showSpectralDeriv)
self.showSpectral.setCheckable(True)
self.showSpectral.setChecked(False)
if not self.DOC:
self.showFormant = markMenu.addAction("Formants", self.showFormants)
self.showFormant.setCheckable(True)
self.showFormant.setChecked(False)
self.showEnergies = markMenu.addAction("Maximum energies", self.showMaxEnergy)
self.showEnergies.setCheckable(True)
self.showEnergies.setChecked(False)
# if not self.DOC:
# cqt = specMenu.addAction("Show CQT", self.showCQT)
specMenu.addSeparator()
self.readonly = specMenu.addAction("Make read only",self.makeReadOnly)
self.readonly.setCheckable(True)
self.readonly.setChecked(self.config['readOnly'])
specMenu.addSeparator()
specMenu.addAction("Interface settings", self.changeSettings)
specMenu.addAction("Put docks back",self.dockReplace)
actionMenu = self.menuBar().addMenu("&Actions")
actionMenu.addAction("Delete all segments", self.deleteAll, "Ctrl+D")
self.addRegularAction = actionMenu.addAction("Mark regular segments", self.addRegularSegments, "Ctrl+M")
actionMenu.addSeparator()
self.denoiseAction = actionMenu.addAction("Denoise",self.showDenoiseDialog)
actionMenu.addAction("Add metadata about noise", self.addNoiseData, "Ctrl+N")
#actionMenu.addAction("Find matches",self.findMatches)
if not self.DOC:
actionMenu.addAction("Filter spectrogram",self.medianFilterSpec)
actionMenu.addAction("Denoise spectrogram",self.denoiseImage)
actionMenu.addSeparator()
self.segmentAction = actionMenu.addAction("Segment",self.segmentationDialog,"Ctrl+S")
if not self.DOC:
actionMenu.addAction("Calculate segment statistics", self.calculateStats)
actionMenu.addAction("Analyse shapes", self.showShapesDialog)
actionMenu.addAction("Cluster segments", self.classifySegments)
actionMenu.addSeparator()
self.showInvSpec = actionMenu.addAction("Save sound file", self.invertSpectrogram)
actionMenu.addSeparator()
if not self.DOC:
actionMenu.addAction("Export spectrogram image", self.saveImageRaw)
actionMenu.addAction("&Export current view as image",self.saveImage,"Ctrl+I")
# "Recognisers" menu
recMenu = self.menuBar().addMenu("&Recognisers")
extrarecMenu = recMenu.addMenu("Train an automated recogniser")
extrarecMenu.addAction("Train a changepoint recogniser", self.buildChpRecogniser)
if not self.DOC:
extrarecMenu.addAction("Train a wavelet recogniser", self.buildRecogniser)
extrarecMenu.addAction("Extend a recogniser with CNN", self.buildCNN)
recMenu.addAction("Test a recogniser", self.testRecogniser)
recMenu.addAction("Manage recognisers", self.manageFilters)
recMenu.addAction("Customise a recogniser (use existing ROC)", self.customiseFiltersROC)
# "Utilities" menu
utilMenu = self.menuBar().addMenu("&Utilities")
utilMenu.addAction("Import from Excel", self.excel2Annotation)
utilMenu.addAction("Import from Freebird", self.tag2Annotation)
utilMenu.addAction("Backup annotations", self.backupAnnotations)
utilMenu.addAction("&Split WAV/DATA files", self.launchSplitter)
helpMenu = self.menuBar().addMenu("&Help")
helpMenu.addAction("Help", self.showHelp, "Ctrl+H")
helpMenu.addAction("&Cheat Sheet", self.showCheatSheet)
helpMenu.addSeparator()
helpMenu.addAction("About", self.showAbout, "Ctrl+A")
if platform.system() == 'Darwin':
helpMenu.addAction("About", self.showAbout, "Ctrl+A")
def showAbout(self):
""" Create the About Message Box"""
msg = SupportClasses_GUI.MessagePopup("a", "About", ".")
msg.exec_()
return
def showHelp(self):
""" Show the user manual (a pdf file), make it offline for easy access"""
# webbrowser.open_new(r'file://' + os.path.realpath('./Docs/AviaNZManual.pdf'))
webbrowser.open_new(r'http://avianz.net/docs/AviaNZManual.pdf')
def showCheatSheet(self):
""" Show the cheatsheet of sample spectrograms"""
webbrowser.open_new(r'http://www.avianz.net/index.php/resources/cheat-sheet/about-cheat-sheet')
def launchSplitter(self):
""" Close the main window, start splitter QMainWindow """
print("Switching to AviaNZ Splitter")
QApplication.exit(2)
def createFrame(self):
""" Creates the main window.
This consists of a set of pyqtgraph docks with widgets in.
d_ for docks, w_ for widgets, p_ for plots"""
# Make the window and set its size
self.area = DockArea()
self.setCentralWidget(self.area)
self.resize(1240,600)
self.move(100,50)
# Make the colours that are used in the interface
# The dark ones are to draw lines instead of boxes
self.ColourSelected = QtGui.QColor(self.config['ColourSelected'][0], self.config['ColourSelected'][1], self.config['ColourSelected'][2], self.config['ColourSelected'][3])
self.ColourNamed = QtGui.QColor(self.config['ColourNamed'][0], self.config['ColourNamed'][1], self.config['ColourNamed'][2], self.config['ColourNamed'][3])
self.ColourNone = QtGui.QColor(self.config['ColourNone'][0], self.config['ColourNone'][1], self.config['ColourNone'][2], self.config['ColourNone'][3])
self.ColourPossible = QtGui.QColor(self.config['ColourPossible'][0], self.config['ColourPossible'][1], self.config['ColourPossible'][2], self.config['ColourPossible'][3])
self.ColourSelectedDark = QtGui.QColor(self.config['ColourSelected'][0], self.config['ColourSelected'][1], self.config['ColourSelected'][2], 255)
self.ColourNamedDark = QtGui.QColor(self.config['ColourNamed'][0], self.config['ColourNamed'][1], self.config['ColourNamed'][2], 255)
self.ColourNoneDark = QtGui.QColor(self.config['ColourNone'][0], self.config['ColourNone'][1], self.config['ColourNone'][2], 255)
self.ColourPossibleDark = QtGui.QColor(self.config['ColourPossible'][0], self.config['ColourPossible'][1], self.config['ColourPossible'][2], 255)
# Make the docks and lay them out
self.d_overview = Dock("Overview",size=(1200,150))
self.d_ampl = Dock("Amplitude",size=(1200,150))
self.d_spec = Dock("Spectrogram",size=(1200,300))
self.d_controls = Dock("Controls",size=(40,90))
self.d_files = Dock("Files",size=(40,200))
self.d_plot = Dock("Plots",size=(1200,150))
self.d_controls.setSizePolicy(1,1)
self.area.addDock(self.d_files,'left')
self.area.addDock(self.d_overview,'right',self.d_files)
self.area.addDock(self.d_ampl,'bottom',self.d_overview)
self.area.addDock(self.d_spec,'bottom',self.d_ampl)
self.area.addDock(self.d_controls,'bottom',self.d_files)
self.area.addDock(self.d_plot,'bottom',self.d_spec)
# Store the state of the docks in case the user wants to reset it
self.state = self.area.saveState()
containers, docks = self.area.findAll()
self.state_cont = [cont.sizes() for cont in containers]
# Put content widgets in the docks:
# OVERVIEW dock
self.w_overview = pg.LayoutWidget()
self.w_overview.layout.setColumnStretch(1, 10)
self.w_overview.layout.setColumnStretch(0, 0)
self.w_overview.layout.setColumnStretch(2, 0)
self.d_overview.addWidget(self.w_overview)
# this will hold both overview image and segment boxes
self.w_overview1 = pg.GraphicsLayoutWidget()
self.w_overview1.ci.layout.setContentsMargins(0.5, 1, 0.5, 1)
self.w_overview1.ci.layout.setRowSpacing(0, 0)
#self.w_overview1.ci.layout.setRowSpacing(1, 0)
self.w_overview1.ci.layout.setRowStretchFactor(0, 7)
self.w_overview1.ci.layout.setRowStretchFactor(1, 1)
#self.w_overview1.ci.layout.setRowMaximumHeight(1, 40)
fileInfo = QHBoxLayout()
self.fileInfoSR = QLabel()
self.fileInfoSR.setStyleSheet("QLabel {color: #505050}")
self.fileInfoNCh = QLabel()
self.fileInfoNCh.setStyleSheet("QLabel {color: #505050}")
self.fileInfoSS = QLabel()
self.fileInfoSS.setStyleSheet("QLabel {color: #505050}")
self.fileInfoDur = QLabel()
self.fileInfoDur.setStyleSheet("QLabel {color: #505050}")
fileInfo.addWidget(self.fileInfoSR)
fileInfo.addSpacing(20)
fileInfo.addWidget(self.fileInfoNCh)
fileInfo.addSpacing(20)
fileInfo.addWidget(self.fileInfoSS)
fileInfo.addSpacing(20)
fileInfo.addWidget(self.fileInfoDur)
fileInfo.addStretch(5)
# annotInfo = QLabel("<b>Annotations present</b> (details go here)")
self.p_overview = SupportClasses_GUI.DemousedViewBox()
self.w_overview1.addItem(self.p_overview,row=0,col=0)
self.p_overview2 = SupportClasses_GUI.ChildInfoViewBox(enableMouse=False, enableMenu=False)
self.w_overview1.addItem(self.p_overview2,row=1,col=0)
self.p_overview2.setXLink(self.p_overview)
self.p_overview2.setPreferredHeight(25)
self.p_overview2.setCursor(Qt.PointingHandCursor)
# The buttons to move through the overview
self.leftBtn = QPushButton()
self.leftBtn.setIcon(QIcon("img/overview-back.png"))
self.leftBtn.setIconSize(QtCore.QSize(7, 28))
self.leftBtn.setMinimumWidth(16)
self.leftBtn.clicked.connect(self.moveLeft)
self.leftBtn.setToolTip("Move view back")
self.rightBtn = QPushButton()
self.rightBtn.setIcon(QIcon("img/overview-next.png"))
self.rightBtn.setIconSize(QtCore.QSize(7, 28))
self.rightBtn.setMinimumWidth(16)
self.rightBtn.clicked.connect(self.moveRight)
self.rightBtn.setToolTip("Move view forward")
self.leftBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
self.rightBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
# Buttons to move to next/previous five minutes
self.prev5mins=QToolButton()
self.prev5mins.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaSeekBackward))
self.prev5mins.setMinimumSize(35, 30)
self.prev5mins.setToolTip("Previous page")
self.prev5mins.clicked.connect(self.movePrev5mins)
self.next5mins=QToolButton()
self.next5mins.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaSeekForward))
self.next5mins.setMinimumSize(35, 30)
self.next5mins.setToolTip("Next page")
self.next5mins.clicked.connect(self.moveNext5mins)
self.placeInFileLabel2 = QLabel('Page')
self.placeInFileLabel = QLabel('')
self.placeInFileLabel.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.placeInFileSelector = QSpinBox()
self.placeInFileSelector.setRange(1,1)
self.placeInFileSelector.setButtonSymbols(QAbstractSpinBox.NoButtons)
self.placeInFileSelector.editingFinished.connect(self.moveTo5mins)
self.placeInFileSelector.setMinimumHeight(25)
# "Find next annotation" buttons
self.annotJumpLabel = QLabel("Jump to next mark:")
self.annotJumpG = QToolButton()
self.annotJumpG.setIcon(QIcon('img/findnext-g.png'))
self.annotJumpG.setToolTip("Any label")
# self.annotJumpG.setAutoRaise(True)
self.annotJumpG.setMinimumSize(35,30)
self.annotJumpG.setIconSize(QtCore.QSize(20, 17))
self.annotJumpG.clicked.connect(lambda: self.annotJumper(100))
self.annotJumpY = QToolButton()
self.annotJumpY.setIcon(QIcon('img/findnext-y.png'))
self.annotJumpY.setToolTip("Uncertain label")
# self.annotJumpY.setAutoRaise(True)
self.annotJumpY.setMinimumSize(35,30)
self.annotJumpY.setIconSize(QtCore.QSize(20, 17))
self.annotJumpY.clicked.connect(lambda: self.annotJumper(99))
# position everything in the dock
self.w_overview.layout.addLayout(fileInfo, 0, 0, 1, 3)
#self.w_overview.addWidget(annotInfo, row=1, col=0, colspan=2)
self.w_overview.addWidget(self.w_overview1, row=2, col=1)
self.w_overview.addWidget(self.leftBtn,row=2,col=0)
self.w_overview.addWidget(self.rightBtn,row=2,col=2)
placeInFileBox = QHBoxLayout()
placeInFileBox.addStretch(10)
placeInFileBox.addWidget(self.placeInFileLabel2)
placeInFileBox.addWidget(self.prev5mins)
placeInFileBox.addWidget(self.placeInFileSelector)
placeInFileBox.addWidget(self.next5mins)
placeInFileBox.addWidget(self.placeInFileLabel)
placeInFileBox.addStretch(4)
placeInFileBox.addWidget(self.annotJumpLabel)
placeInFileBox.addWidget(self.annotJumpG)
placeInFileBox.addWidget(self.annotJumpY)
placeInFileBox.addStretch(4)
self.w_overview.layout.addLayout(placeInFileBox, 3, 1)
# Corresponding keyboard shortcuts:
self.moveLeftKey = QShortcut(QKeySequence(Qt.Key_Left), self)
self.moveLeftKey.activated.connect(self.moveLeft)
self.moveRightKey = QShortcut(QKeySequence(Qt.Key_Right), self)
self.moveRightKey.activated.connect(self.moveRight)
self.movePrev5minsKey = QShortcut(QKeySequence("Shift+Left"), self)
self.movePrev5minsKey.activated.connect(self.movePrev5mins)
self.moveNext5minsKey = QShortcut(QKeySequence("Shift+Right"), self)
self.moveNext5minsKey.activated.connect(self.moveNext5mins)
self.toggleLabelType = QShortcut(QKeySequence("Tab"),self)
self.toggleLabelType.activated.connect(self.toggleViewSp)
# AMPLITUDE dock
self.w_ampl = pg.GraphicsLayoutWidget()
self.p_ampl = SupportClasses_GUI.DragViewBox(self, enableMouse=False,enableMenu=False,enableDrag=False, thisIsAmpl=True)
self.p_ampl.setAutoVisible(False, True)
self.w_ampl.addItem(self.p_ampl,row=0,col=1)
self.d_ampl.addWidget(self.w_ampl)
self.w_spec = pg.GraphicsLayoutWidget()
self.p_spec = SupportClasses_GUI.DragViewBox(self, enableMouse=False,enableMenu=False,enableDrag=self.config['specMouseAction']==3, thisIsAmpl=False)
self.w_spec.addItem(self.p_spec,row=0,col=1)
self.d_spec.addWidget(self.w_spec)
self.w_plot = pg.GraphicsLayoutWidget()
self.p_plot = self.w_plot.addViewBox(enableMouse=False,enableMenu=False)
self.w_plot.addItem(self.p_plot,row=0,col=1)
self.d_plot.addWidget(self.w_plot)
# The axes
# Time axis has to go separately in loadFile
self.ampaxis = pg.AxisItem(orientation='left')
self.w_ampl.addItem(self.ampaxis,row=0,col=0)
self.ampaxis.linkToView(self.p_ampl)
self.ampaxis.setWidth(w=65)
self.ampaxis.setLabel('')
self.specaxis = pg.AxisItem(orientation='left')
if not self.zooniverse:
self.w_spec.addItem(self.specaxis,row=0,col=0)
self.specaxis.linkToView(self.p_spec)
self.specaxis.setWidth(w=65)
# Plot window also needs an axis to make them line up
self.plotaxis = pg.AxisItem(orientation='left')
self.w_plot.addItem(self.plotaxis,row=0,col=0)
self.plotaxis.linkToView(self.p_plot)
self.plotaxis.setWidth(w=65)
self.plotaxis.setLabel('')
# Hide diagnostic plot window until requested
self.d_plot.hide()
# The slider to show playback position
# This is hidden, but controls the moving bar
self.bar = pg.InfiniteLine(angle=90, movable=True, pen={'color': 'c', 'width': 3})
self.bar.btn = self.MouseDrawingButton
self.bar.sigPositionChangeFinished.connect(self.barMoved)
# guides that can be used in batmode
self.guidelines = [0]*len(self.config['guidecol'])
for gi in range(len(self.config['guidecol'])):
self.guidelines[gi] = pg.InfiniteLine(angle=0, movable=False, pen={'color': self.config['guidecol'][gi], 'width': 2})
# The print out at the bottom of the spectrogram with data in
# Note: widgets cannot be directly added to GraphicsLayout, so need to convert
# them to proxy GraphicsWidgets using the proxy
self.pointData = QLabel()
self.pointData.setStyleSheet("QLabel { background-color : white; color : #CC0000; }")
self.pointDataProxy = QGraphicsProxyWidget()
self.pointDataProxy.setWidget(self.pointData)
self.segInfo = QLabel()
self.segInfo.setStyleSheet("QLabel { background-color : white; color : #CC0000; }")
self.segInfoProxy = QGraphicsProxyWidget()
self.segInfoProxy.setWidget(self.segInfo)
# The various plots
self.overviewImage = pg.ImageItem(enableMouse=False)
self.p_overview.addItem(self.overviewImage)
self.overviewImageRegion = SupportClasses_GUI.LinearRegionItemO(pen=pg.mkPen(120,80,200, width=2),
hoverPen=pg.mkPen(60, 40, 230, width=3.5))
# this is needed for compatibility with other shaded rectangles:
self.overviewImageRegion.lines[0].btn = Qt.RightButton
self.overviewImageRegion.lines[1].btn = Qt.RightButton
self.p_overview.addItem(self.overviewImageRegion, ignoreBounds=True)
self.amplPlot = pg.PlotDataItem()
self.p_ampl.addItem(self.amplPlot)
self.specPlot = pg.ImageItem()
self.p_spec.addItem(self.specPlot)
if self.MouseDrawingButton==Qt.RightButton:
self.p_ampl.unsetCursor()
self.specPlot.unsetCursor()
self.bar.setCursor(Qt.OpenHandCursor)
else:
self.p_ampl.setCursor(QtGui.QCursor(QPixmap('img/cursor.bmp'), 0, 0))
self.specPlot.setCursor(QtGui.QCursor(QPixmap('img/cursor.bmp'), 0, 0))
self.bar.unsetCursor()
# Connect up the listeners
self.p_ampl.scene().sigMouseClicked.connect(self.mouseClicked_ampl)
self.p_spec.scene().sigMouseClicked.connect(self.mouseClicked_spec)
# Connect up so can disconnect if not selected...
self.p_spec.scene().sigMouseMoved.connect(self.mouseMoved)
self.w_spec.addItem(self.segInfoProxy, row=2, col=1)
self.w_spec.addItem(self.pointDataProxy, row=3, col=1)
# The content of the other two docks
self.w_controls = pg.LayoutWidget()
self.d_controls.addWidget(self.w_controls)
self.w_files = pg.LayoutWidget()
self.d_files.addWidget(self.w_files)
# Button to move to the next file in the list
self.nextFileBtn=QToolButton()
self.nextFileBtn.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaSkipForward))
self.nextFileBtn.clicked.connect(self.openNextFile)
self.nextFileBtn.setToolTip("Open next file")
self.w_files.addWidget(self.nextFileBtn,row=0,col=1)
# The buttons inside the controls dock
self.playButton = QtGui.QToolButton()
self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
self.playButton.setIconSize(QtCore.QSize(20, 20))
self.playButton.setToolTip("Play visible")
self.playButton.clicked.connect(self.playVisible)
self.playKey = QShortcut(QKeySequence("Space"), self)
self.playKey.activated.connect(self.playVisible)
self.stopButton = QtGui.QToolButton()
self.stopButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaStop))
self.stopButton.setIconSize(QtCore.QSize(20, 20))
self.stopButton.setToolTip("Stop playback")
self.stopButton.clicked.connect(self.stopPlayback)
self.playSegButton = QtGui.QToolButton()
self.playSegButton.setIcon(QIcon('img/playsegment.png'))
self.playSegButton.setIconSize(QtCore.QSize(20, 20))
self.playSegButton.setToolTip("Play selected")
self.playSegButton.clicked.connect(self.playSelectedSegment)
self.playSlowButton = QtGui.QToolButton()
self.playSlowButton.setIcon(QIcon('img/playSlow-w.png'))
self.playSlowButton.setIconSize(QtCore.QSize(35, 20))
self.playSlowButton.setToolTip("Play slowly")
self.playSlowButton.clicked.connect(self.playSlowSegment)
#self.speedButton = QtGui.QToolButton()
#self.speedButton.setPopupMode(QtGui.QToolButton.InstantPopup)
#self.speedButton.setText(u'\u00BD')
#self.speedButton.setIconSize(QtCore.QSize(20, 20))
#self.speedButton.setToolTip("Playback speed")
#self.speedButton.clicked.connect(self.playSlowSegment)
speedMenu = QMenu()
extraGroup = QActionGroup(self)
for ename in ["2",u'\u00BD',u'\u00BC']:
em = speedMenu.addAction(ename)
em.setCheckable(True)
if ename == "0.5":
em.setChecked(True)
receiver = lambda checked, ename=ename: self.setSpeed(ename)
em.triggered.connect(receiver)
extraGroup.addAction(em)
#self.speedButton.setMenu(speedMenu)
self.playSlowButton.setMenu(speedMenu)
self.quickDenButton = QtGui.QToolButton()
self.quickDenButton.setIcon(QIcon('img/denoisesegment.png'))
self.quickDenButton.setIconSize(QtCore.QSize(20, 20))
self.quickDenButton.setToolTip("Denoise segment")
self.quickDenButton.clicked.connect(self.denoiseSeg)
self.viewSpButton = QtGui.QToolButton()
self.viewSpButton.setIcon(QIcon('img/splarge-ct.png'))
self.viewSpButton.setIconSize(QtCore.QSize(35, 20))
self.viewSpButton.setToolTip("Toggle between species/calltype views")
self.viewSpButton.clicked.connect(self.toggleViewSp)
self.playBandLimitedSegButton = QtGui.QToolButton()
self.playBandLimitedSegButton.setIcon(QtGui.QIcon('img/playBandLimited.png'))
self.playBandLimitedSegButton.setIconSize(QtCore.QSize(20, 20))
self.playBandLimitedSegButton.setToolTip("Play selected-band limited")
self.playBandLimitedSegButton.clicked.connect(self.playBandLimitedSegment)
# Volume, brightness and contrast sliders.
# Need to pass true (config) values to set up correct initial positions
self.specControls = SupportClasses_GUI.BrightContrVol(self.config['brightness'], self.config['contrast'], self.config['invertColourMap'], horizontal=False)
self.specControls.colChanged.connect(self.setColourLevels)
self.specControls.volChanged.connect(self.volSliderMoved)
# Confirm button - auto ups the certainty to 100
self.confirmButton = QPushButton(" Confirm labels")
self.confirmButton.clicked.connect(self.confirmSegment)
self.confirmButton.setIcon(QIcon(QPixmap('img/check-mark2.png')))
self.confirmButton.setStyleSheet("QPushButton {padding: 3px 3px 3px 3px}")
self.confirmButton.setToolTip("Set all labels in this segment as certain")
# Delete segment button. We have to get rid of the extra event args
self.deleteButton = QPushButton(" Delete segment")
self.deleteButton.clicked.connect(lambda _ : self.deleteSegment())
self.deleteButton.setIcon(QIcon(QPixmap('img/deleteL.png')))
self.deleteButton.setStyleSheet("QPushButton {padding: 3px 3px 3px 3px}")
# export selected sound
self.exportSoundBtn = QPushButton(" Save sound clip")
self.exportSoundBtn.clicked.connect(lambda _ : self.save_selected_sound())
self.exportSoundBtn.setIcon(QIcon(QPixmap('img/storage2.png')))
self.exportSoundBtn.setToolTip("Export the selected segment to a file")
# export selected sound
if not self.DOC:
self.exportSlowSoundBtn = QPushButton(" Save slow sound clip")
self.exportSlowSoundBtn.clicked.connect(lambda _ : self.save_selected_sound(self.slowSpeed))
self.exportSlowSoundBtn.setIcon(QIcon(QPixmap('img/storage2.png')))
self.exportSlowSoundBtn.setToolTip("Export the selected sound to a file at different speed")
# flips buttons to Disabled state
self.refreshSegmentControls()
# The spinbox for changing the width shown in the controls dock
windowLabel = QLabel('Visible window (seconds)')
windowLabel.setAlignment(Qt.AlignBottom)
self.widthWindow = QDoubleSpinBox()
self.widthWindow.setSingleStep(1.0)
self.widthWindow.setDecimals(2)
self.widthWindow.setValue(self.config['windowWidth'])
self.widthWindow.valueChanged[float].connect(self.changeWidth)
# Place all these widgets in the Controls dock
self.w_controls.addWidget(self.playButton,row=0,col=0)
self.w_controls.addWidget(self.playSegButton,row=0,col=1)
self.w_controls.addWidget(self.playBandLimitedSegButton,row=0,col=2)
self.w_controls.addWidget(self.playSlowButton,row=0,col=3)
self.w_controls.addWidget(self.stopButton,row=1,col=0)
#self.w_controls.addWidget(self.speedButton,row=1,col=1)
if not self.DOC:
self.w_controls.addWidget(self.quickDenButton,row=1,col=2)
# self.w_controls.addWidget(self.quickDenNButton,row=1,col=1)
self.w_controls.addWidget(self.viewSpButton,row=1,col=3)
self.w_controls.addWidget(self.specControls, row=2, col=0, rowspan=2, colspan=4)
self.w_controls.addWidget(QLabel('Visible window'),row=8,col=0,colspan=4)
self.w_controls.addWidget(self.widthWindow,row=9,col=0,colspan=2)
self.w_controls.addWidget(QLabel('seconds'), row=9, col=2, colspan=2)
# spacer b/c pyqtgraph can't add spacer items
spacer = QWidget()
self.w_controls.addWidget(spacer, row=10, col=0, colspan=4)
self.w_controls.layout.setRowMinimumHeight(10, 3)
# empty widget to add in the gridlayout
segContrs = QGroupBox("Selected segment")
segContrs.setStyleSheet("QGroupBox:title{color: #505050; font-weight: 50}")
segContrsBox = QVBoxLayout()
segContrs.setLayout(segContrsBox)
segContrsBox.addWidget(self.confirmButton)
segContrsBox.addWidget(self.deleteButton)
segContrsBox.addWidget(self.exportSoundBtn)
if not self.DOC:
segContrsBox.addWidget(self.exportSlowSoundBtn)
self.w_controls.addWidget(segContrs, row=12, col=0, colspan=4)
# # add spacers to control stretch - seems to be ignored though
# self.w_controls.addWidget(QLabel(), row=12, col=0)
# self.w_controls.layout.setRowMinimumHeight(2, 25)
# self.w_controls.layout.setRowMinimumHeight(3, 10)
# self.w_controls.layout.setRowMinimumHeight(8, 10)
# self.w_controls.layout.setRowMinimumHeight(12, 5)
# # self.w_controls.layout.setColumnStretch(4, 3)
# # set all cells to stretch equally
# for r in range(11):
# self.w_controls.layout.setRowStretch(r, 2)
# for c in range(4):
# self.w_controls.layout.setColumnStretch(c, 2)
# A slider to move through the file easily
self.scrollSlider = QScrollBar(Qt.Horizontal)
self.scrollSlider.valueChanged.connect(self.scroll)
self.d_spec.addWidget(self.scrollSlider)
# List to hold the list of files
self.listFiles = SupportClasses_GUI.LightedFileList(self.ColourNone, self.ColourPossibleDark, self.ColourNamed)
self.listFiles.itemDoubleClicked.connect(self.listLoadFile)
self.w_files.addWidget(QLabel('Double click to open'),row=0,col=0)
self.w_files.addWidget(QLabel('Icon marks annotation certainty'),row=1,col=0)
self.w_files.addWidget(self.listFiles,row=2,colspan=2)
# The context menu (drops down on mouse click) to select birds
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.menuBirdList = QMenu()
self.menuBird2 = QMenu('Other')
#self.menuBird2 = self.menuBirdList.addMenu('Other')
# New line to allow multiple selections
self.menuBirdList.installEventFilter(self)
self.menuBird2.installEventFilter(self)
self.fillBirdList()
self.menuBirdList.triggered.connect(self.birdSelectedMenu)
self.menuBird2.triggered.connect(self.birdSelectedMenu)
#self.menuBirdList.aboutToHide.connect(self.processMultipleBirdSelections)
# Hack to get the type of an ROI
p_spec_r = SupportClasses_GUI.ShadedRectROI(0, 0)
self.ROItype = type(p_spec_r)
# Listener for key presses
self.w_ampl.installEventFilter(self)
self.w_spec.installEventFilter(self)
# add statusbar
self.statusLeft = QLabel("Left")
# Not sure what's the difference between Sunken and Panel?
self.statusLeft.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.statusBM = QLabel("")
self.statusBM.setAlignment(Qt.AlignCenter)
self.statusBM.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.statusRO = QLabel("")
self.statusRO.setAlignment(Qt.AlignCenter)
self.statusRO.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.statusRight = QLabel("")
self.statusRight.setAlignment(Qt.AlignRight)
self.statusRight.setFrameStyle(QFrame.Panel | QFrame.Sunken)
# Style
# statusStyle='QLabel {border:transparent}'
# self.statusLeft.setStyleSheet(statusStyle)
# self.statusRO.setStyleSheet(statusStyle)
# self.statusRight.setStyleSheet(statusStyle)
self.statusBar().addPermanentWidget(self.statusLeft,3)
self.statusBar().addPermanentWidget(self.statusBM,1)
self.statusBar().addPermanentWidget(self.statusRO,1)
self.statusBar().addPermanentWidget(self.statusRight,2)
# Set the message in the status bar
self.statusLeft.setText("Ready")
self.statusRO.setText("Read-only mode" if self.config['readOnly'] else "")
# Function calls to check if should show various parts of the interface, whether dragging boxes or not
self.makeReadOnly()
self.useAmplitudeCheck()
self.useFilesCheck()
self.showOverviewSegsCheck()
self.dragRectsTransparent()
self.showPointerDetailsCheck()
self.w_spec.setFocus()
def toggleBatMode(self):
""" Enables/disables GUI elements when bat mode is entered/left.
Called on every load.
"""
if self.batmode:
print("Bat mode is ON")
else:
print("Bat mode is off")
if self.batmode:
self.useAmplitudeTick.setChecked(False)
# otherwise leave as it was
self.useAmplitudeTick.setEnabled(not self.batmode)
self.useAmplitudeCheck()
if not self.DOC:
self.showDiagnosticTick.setEnabled(not self.batmode)
self.extraMenu.setEnabled(not self.batmode)
self.setExtraPlot("none")
self.showFormant.setEnabled(not self.batmode)
self.showInvSpec.setVisible(self.batmode)
self.showFundamental.setEnabled(not self.batmode)
self.showSpectral.setEnabled(not self.batmode)
self.showEnergies.setEnabled(not self.batmode)
self.addRegularAction.setEnabled(not self.batmode)
self.denoiseAction.setEnabled(not self.batmode)