-
Notifications
You must be signed in to change notification settings - Fork 0
/
blackbox.py
executable file
·1359 lines (1117 loc) · 57.6 KB
/
blackbox.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
#!/usr/bin/env python
"""
Andrew Huynh '20
Nicholas Fu '25
Yashvi Patel '24
Behavior Box Project
This program is to run experiments on the black box. It is designed to be run on a 800x480 screen.
The UI is designed using TKinter.
Basic overview:
Create experiment object that stores experiment parameters
Create class pages
Buttons on page use specific "show_frame<name.()" commands to raise the next page as well as start
fuctions such as imaging
"""
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
import ttk
import tkMessageBox
import os
import shutil
import pickle
import datetime
from time import *
from picamera import PiCamera
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from matplotlib.patches import Circle
from matplotlib.patches import Arc
from matplotlib.patches import Rectangle
from PIL import ImageTk, Image
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import numpy as np
camera = PiCamera(resolution=(640,480))
camera.awb_mode='off'
camera.awb_gains=(0.7,1.8)
# Font Sizes
LARGE_FONT = ("Lato", 36)
MEDIUM_FONT = ("Lato", 28)
SMALL_FONT = ("Lato", 24)
TINY_FONT = ("Lato", 20)
VERYTINY_FONT = ("Lato", 15)
appheight=400
appwidth=800
xspacer=appheight/80
yspacer=appheight/80
#(Don't need this anymore; adjust fps line 188) imagecapturerate = 0.0625
if not os.path.exists( "/home/pi/Desktop/ExperimentFolder/"): #Makes folder for data if doesn't exist
os.makedirs( "/home/pi/Desktop/ExperimentFolder/")
class Experiment():
"""Saves parameters for each experiment. """
def __init__(self):
self.expnumber = str()
self.exptype = str()
self.exptime = int()
self.savefile = str()
self.isScrunching = bool()
self.isChemo = bool()
#self.capturerate = imagecapturerate
self.iscontrol = False
self.expy = []
def set_number(self, number):
self.expnumber = str(number)
def set_type(self, exptype):
self.exptype = str(exptype)
def set_exptime(self, totaltime):
self.exptime = int(totaltime)
def set_savefile(self, savetofile):
self.savefile = str(savetofile)
Appa = Experiment()
class BehaviorBox(tk.Tk, Experiment):
"""Base line code to initialize everything.
Attributes:
tk.Tk: Tkinter window.
Experiment: Class containing experiment parameters.
"""
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.wm_title(self, "Behavior Box") # Set window title
self.container = tk.Frame(self) # Define frame/edge of window
self.container.pack(side="top", fill="both", expand=True) # Fill will fill space you have allotted pack. Expand will take up all white space.
self.container.grid_rowconfigure(0, weight=1) # Configure rows/grids. 0 sets minimum size weight sets priority
self.container.grid_columnconfigure(0, weight=1)
# Initalize/render all pages
self.frames = {}
for F in (SplashScreen, StartPage, ExpSelPg, TimeSelPg, ConfirmPg, InsertPg, StimPrepPg, ExpFinishPg, ReviewData, DataDelPg, DataAnalysisImagePg, ScrunchingPg, DataAnalysisPg, GraphPage, DataMenu, DataGraphChoice, AnalysisTypeForNone, CameraPreviewPg):
frame = F(self.container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
if(F == "SplashScreen"):
self.show_frame(SplashScreen)
sleep(2)
self.show_frame(StartPage) # Raise Start Page
# Create button styles/fontsizes
s = ttk.Style()
s.configure("VERYTINYFONT.TButton", font=(VERYTINY_FONT))
s.configure("TINYFONT.TButton", font=(TINY_FONT))
s.configure("my.TButton", font=(SMALL_FONT))
s.configure("checkbuttonstyle.TCheckbutton", font=(TINY_FONT), background="white")
s.configure("radio.TRadiobutton", font=(SMALL_FONT))
def startfresh(self): #Reinitialize page & update values
for F in (StartPage, ExpSelPg, TimeSelPg, ConfirmPg, InsertPg, StimPrepPg, DataDelPg):
frame = F(self.container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew") #other choice than pack. Sticky alignment + stretch
def show_frame(self, cont): #Raise frame to front
frame = self.frames[cont]
frame.tkraise() #raise to front
def show_frameAlpha(self, cont): #Main -> NewExp & reset Appa values
#Reset all of experiment-class variables
Appa.expnumber = str()
Appa.exptype = str()
Appa.exptime = int()
Appa.savefile = str()
Appa.expy = []
app.startfresh() #Reinitalize all necessary pages to starting state
frame = self.frames[cont]
frame.tkraise() #raise to front
def show_frameZebra(self, cont): #InsertPg -> ConfirmPg & stop camera preview
"""Confirm Page <- Insert Page; ends camera preview"""
frame = self.frames[cont]
camera.stop_preview()#Stops the preview window
frame.tkraise() #raise to front
def show_frameFish(self, cont): #ConfirmPg -> InsertPg & start camera preview
"""Confirm Page -> Insert Page; starts camera preview"""
frame = self.frames[cont]
camera.start_preview(fullscreen=False, window=(0,appheight/4,appwidth,appheight/2)) #this line starts the preview.
frame.tkraise()
def show_frameCharlie(self, cont): #TimeSelPg -> ConfirmPg
"""TimeSelPg -> Confirm Pg;
save time choice -> confirmation and updates label values in confirmation based on previous user
input
"""
frame = self.frames[cont]
frame.confirmlabels()
frame.tkraise()
def show_frameDelta(self, cont): #Insert -> StimPrepPg & display exp type
"""InsertPg -> StimPrepPg and displays either "Ready" or "Insert stimuli" based on experiment type"""
frame = self.frames[cont]
frame.gettext() #Displays either "Ready" or "Insert stimuli" based on experiment type
frame.tkraise()
def show_frameEcho(self, cont): #StimPrepPg -> Imaging & countdown
"""StimPrepPg -> start imaging and count down"""
self.frames[StimPrepPg].button1.grid_remove()
self.frames[StimPrepPg].button2.grid_remove()
self.frames[StimPrepPg].label1.configure(text="Experiment in progress")
frame = self.frames[cont]
os.makedirs(Appa.savefile) # Create general folder for experiment
os.makedirs(Appa.savefile + "/ExpDataPictures") # Create folder for images from exp
#Image capturing
imgnum=0
fps=1
wait=0.88
seconds=0
frametime=1
#Check Scrunching
if Appa.isScrunching:
fps=4
wait=0.15
frametime=0.25
#Check Chemotaxis
if Appa.isChemo:
fps=0.1
wait=9.88
frametime=10
if Appa.exptype == "3": #Phototaxis
fps=0.25
wait=3.88
frametime=4
if Appa.exptype == "1":
fps=0.2
wait=4.88
frametime=5
numFrames=Appa.exptime*fps
for i in range(int(numFrames)):
startTime = clock()
if i%fps==0: #updates countdown clock every second
remaining = Appa.exptime-seconds # Calculate countdown
self.frames[StimPrepPg].label2.configure(text="Time remaining: %d" % remaining) # Set countdown
self.frames[StimPrepPg].update_idletasks() # Refresh page
seconds+=frametime
camera.capture(Appa.savefile + "/ExpDataPictures/image" + str(imgnum) + ".jpg", use_video_port=True)
Appa.expy.append("") # Append empty place holder for future analysis
imgnum+=1
elapsed = clock() - startTime
if elapsed < wait:
sleep(wait - (elapsed))
#clock() 1 fps (1.00 frameTime) is actually: ~1.13
#clock() 2 fps (0.50 frameTime) is actually: ~0.6
#clock() 3 fps (0.33 frameTime) is actually: ~0.42
#clock() 4 fps (0.25 frameTime) is actually: ~0.33
#clock() 4 fps (0.20 frameTime) is actually: ~0.33
#clock() 4 fps (0.20 frameTime) is actually: ~0.27 (removed resize(640,480) from camera.capture())
#clock() 5 fps (0.15 frameTime) is actually: ~0.26 (removed resize)
#time() 1.0 is actually: 0.9 to 1.1
camera.stop_preview()
frame.tkraise()
def show_frameFoxtrot(self, cont): #Reinitialize without confirmation prompt
"""Reinitalize a page without prompting for confirmation"""
frame = cont(self.container, self)
self.frames[cont] = frame
frame.grid(row=0, column=0, sticky="nsew")
frame.tkraise()
def show_frameFoxtrot2(self, cont): #Reinitialize with confirmation prompt
"""Confirm if want to reinitalize page and the reinitalize"""
result = tkMessageBox.askquestion("Warning", "All progess will be lost.\nProceed anyways?")
if result == "yes":
frame = cont(self.container, self)
self.frames[cont] = frame
frame.grid(row=0, column=0, sticky="nsew")
frame.tkraise()
def show_frameLima(self, cont, chosenexp): #DataAnalPg -> DataAnalImaPg or ScrunchingPg & load Appa obj
"""DataAnalysisPg -> DataAnalysisImagePg; load Appa object for exp and pull up first image from chosen experiment"""
result = True
result2 = True
global Momo # Create variable to store experiment object
Momo = getobject(chosenexp)
# Case of analyzing control
if Momo.iscontrol:
if Momo.exptype != "0": # Not first time analyzing
result2 = tkMessageBox.askquestion("Warning", "This control experiment has already\nbeen analyzed as %s.\nChanges may overwrite exisiting data.\nProceed anyways?" % getpreviouslyanalyzed(Momo))
if result2 != "no": # First time analyzing or want to override
frame = self.frames[AnalysisTypeForNone] # Go to AnalysisTypeForNone to get type to analyze as
for button in [frame.thermobutton, frame.chemobutton, frame.photobutton]:
if getpreviouslyanalyzed(Momo) == button['text']: # Turn on button if that was the previous analysis
button.state(["focus","selected"])
else:
button.state(["!focus",'!selected'])
frame.tkraise()
# Case of not control
else:
if Momo.expy[0] != "": # Already analyzed
result = tkMessageBox.askquestion("Warning", "The selected experiment has already been analyzed.\nChanges may overwrite exisiting data.\nProceed anyways?")
if result != "no": # First time analyzing or want to override
if Momo.exptype != "4": # Not scrunching
frame = cont(self.container, self)
self.frames[cont] = frame
frame.grid(row=0, column=0, sticky="nsew")
frame.ChangePic(1) # Go to first picture
frame.tkraise()
else: #If scrunching, pull up ScrunchingPg
tkMessageBox.askquestion("Warning", "Scrunching analysis under construction, continue?") #show warning
frame = ScrunchingPg(self.container, self) # Create fresh page in case of old data
self.frames[ScrunchingPg] = frame
frame.grid(row=0, column=0, sticky="nsew")
#frame.ChangePic(1)?
frame.tkraise()
def show_frameBean(self, cont): #AnalTypeForNone -> DataAnalImgPg
"""AnalysisTypeForNone -> DataAnalysisImagePg"""
frame = cont(self.container, self)
self.frames[cont] = frame
frame.grid(row=0, column=0, sticky="nsew")
frame.ChangePic(1) # Go to first picture
frame.tkraise()
def show_frameMarlin(self, cont): #ExpFinishPg -> ReviewData & configure/display imgs
"""ExpFinishPg -> ReviewData. Configures ReviewData to display all images taken during experiment"""
frame = cont(self.container, self)
self.frames[cont] = frame
frame.grid(row=0, column=0, sticky="nsew")
i=0
frame.imagelist=[]
numpics = len(os.listdir(Appa.savefile + "ExpDataPictures"))
for picture in os.listdir(Appa.savefile + "ExpDataPictures"):
img = Image.open(Appa.savefile+ "ExpDataPictures/image" + str(i) + ".jpg", mode="r") #read in image
#img = img.resize((frame.canvaswidth, frame.canvasheight))
imwidth, imheight = img.size
frame.tempimage = ImageTk.PhotoImage(img)
frame.imagelist.append(frame.tempimage)
frame.canvas.create_image(0,(imheight+10)*i,image=frame.imagelist[i],anchor="nw")
i+=1
frame.canvas.config(scrollregion=(frame.canvas.bbox("all")))
scrollbar = tk.Scrollbar(frame)
scrollbar.config(command=frame.canvas.yview)
scrollbar.grid(row=1, column=1, rowspan = 2, sticky="NSEW")
frame.canvas.config(yscrollcommand=scrollbar.set)
frame.tkraise()
def show_frameStingray(self, cont, obj): #ReviewData -> StartPage & save data
"""ReviewData(keep) -> StartPage; stores data"""
saveobject(obj)
tkMessageBox.showwarning("Done", "Data has been saved for:" + obj.expnumber) #show warning
frame = self.frames[cont]
frame.tkraise() #raise to front
def show_frameRhino(self, cont): #ReviewData -> StartPage & discard data
"""ReviewData(discard) -> StartPage; deletes data"""
frame = self.frames[cont]
result = tkMessageBox.askquestion("Discard", "Are you sure you want \nto discard these data?")
if result == "yes":
shutil.rmtree(Appa.savefile)
frame.tkraise()
def show_frameShark(self, cont, listofbuttons): #DataGraphChoice -> GraphPage
"""DataGraphChoice -> GraphPage; checks to see if experiments were chosen to graph and will graph"""
frame = cont(self.container, self)
self.frames[cont] = frame
ExpsToGraph = []
expnames = []
unanalyzedlist = []
result = True
# Get list of experiments to plot
for button in listofbuttons:
if button.instate(['selected']):
ExpsToGraph.append(getobject(button['text']))
if len(ExpsToGraph) == 0: # Did not choose an experiment to graph
tkMessageBox.showwarning("Error", "No experiments selected")
else:
# Check to see if all selected experiments are the same type
exptype = ""
exptypenum = 1
itr = 0
error = False
for experiment in ExpsToGraph:
if itr == 0:
exptype = experiment.expnumber[0] #Type of experiment
elif experiment.expnumber[0] != exptype:
tkMessageBox.showwarning("Error", "Selected experiments are not the same type")
error = True
# Check to see if all experiments selected have been analyzed
for experiment in ExpsToGraph:
if experiment.expy[0] == "":
unanalyzedlist.append(experiment.expnumber)
elif error == False:
experiment.expy = list(map(int, experiment.expy))
if exptype == "P":
exptypenum = 4
elif exptype == "C":
exptypenum = 10
elif exptype == "T":
exptypenum = 5
frame.a.plot([exptypenum * n for n in range(len(experiment.expy))], experiment.expy, 'ro:', label=experiment.expnumber)
frame.a.set_ylim(0,5)
expnames.append(experiment.expnumber)
if len(unanalyzedlist) > 0: # If unanalyzed experiments exist warn user
unanalyzedlist = ", ".join(unanalyzedlist)
result = tkMessageBox.askquestion("Warning", "The following experiments have\nnot been analyzed yet\nand will not be graphed\n\n" +unanalyzedlist+ "\n\nProceed anyways?")
if result != "no" and error == False: # Override or all experiments have been analyzed
frame.grid(row=0, column=0, sticky="nsew")
frame.a.legend(loc='upper right', fontsize=8)
if exptype == "P": #phototaxis
frame.a.set_ylabel("Number of worms")
frame.a.set_xlabel("Time (seconds)")
frame.label.config(text = "Graph of Phototaxis")
elif exptype == "C":
frame.a.set_ylabel("Number of worms")
frame.a.set_xlabel("Time (seconds)")
frame.label.config(text = "Graph of Chemotaxis")
elif exptype == "T":
frame.a.set_ylabel("Number of worms")
frame.a.set_xlabel("Time (seconds)")
frame.label.config(text = "Graph of Thermotaxis")
else:
frame.a.set_ylabel("Number of worms")
frame.a.set_xlabel("Frame number")
frame.canvas.draw()
frame.tkraise()
def show_frameSquid(self, cont): #Main -> CamPreviewPg & start preview
"""Main menu -> CameraPreviewPg; starts preview and raises frame"""
frame = self.frames[cont]
frame.tkraise()
camera.start_preview(fullscreen=False, window=(appwidth/800, appheight/4, appwidth-(2*appwidth/800), appheight*9/10)) # This line starts the preview.
class SplashScreen(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
self.grid_rowconfigure(3, weight=1)
self.grid_columnconfigure(3, weight=1)
label = tk.Label(self, text="Loading...", font=LARGE_FONT)
label.grid(row=1, column=1, sticky="nsew")
class StartPage(tk.Frame):
"""Main menu"""
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
for i in range(1,5):
self.grid_rowconfigure(i, weight=1)
self.grid_columnconfigure(0, weight=1)
label = tk.Label(self, text="Main Menu", font=LARGE_FONT)
label.grid(row=0, column=0, sticky="nsew")
button1 = ttk.Button(self, text="New Experiment", style='my.TButton', command=lambda: controller.show_frameAlpha(ExpSelPg))
button1.grid(row=1, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Data Menu", style='my.TButton', command=lambda: controller.show_frame(DataMenu))
button2.grid(row=2, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button3 = ttk.Button(self, text="Preview Camera", style='my.TButton', command=lambda: controller.show_frameSquid(CameraPreviewPg))
button3.grid(row=3, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button4 = ttk.Button(self, text="Quit", style='my.TButton', command=lambda: app.destroy())
button4.grid(row=4, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
class ExpSelPg(tk.Frame, Experiment):
"""Choose experiment type to run"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_columnconfigure(0, minsize=appwidth/2.5*.9) # Back button
self.grid_columnconfigure(1, minsize=appwidth/2.5*.1) # Back button
self.grid_columnconfigure(2, weight=1) # Central column with options
self.grid_columnconfigure(5, minsize=appwidth/2.5) # Next button
self.grid_rowconfigure(8, minsize=appheight/3) # Next/back button rows
self.grid_rowconfigure(1, weight=1) # Spacer
self.grid_rowconfigure(7, weight=1) #Spacer
self.userexpchoice = int()
label = tk.Label(self, text="Select Experiment Type", font=MEDIUM_FONT) #create object
label.grid(row=0, column=0, columnspan=6, sticky="ew") #pack object into window
button1 = ttk.Button(self, text="Back to\nMain Menu", style="TINYFONT.TButton", command=lambda: controller.show_frame(StartPage))
button1.grid(row=8, column= 0, columnspan=2, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Next", style="TINYFONT.TButton", command=lambda: self.checkchosenexp(parent, controller)) # Check experiment then go to time entry
button2.grid(row=8, column=5, sticky="nsew", padx=xspacer, pady=yspacer)
nonebutton = ttk.Radiobutton(self, text="No Stimulus", style="radio.TRadiobutton", variable = "ExpOption", value = 0, command = lambda: self.qfb(0))
thermobutton = ttk.Radiobutton(self, text="Thermotaxis", style="radio.TRadiobutton", variable = "ExpOption", value = 1, command = lambda: self.qfb(1))
chemobutton = ttk.Radiobutton(self, text="Chemotaxis", style="radio.TRadiobutton", variable = "ExpOption", value = 2, command = lambda: self.qfb(2))
photobutton = ttk.Radiobutton(self, text="Phototaxis", style="radio.TRadiobutton", variable = "ExpOption", value = 3, command = lambda: self.qfb(3))
scrunchbutton = ttk.Radiobutton(self, text="Scrunching", style="radio.TRadiobutton", variable = "ExpOption", value = 4, command = lambda: self.qfb(4))
rownum = 2
for button in [nonebutton, thermobutton, chemobutton, photobutton, scrunchbutton]:
button.state(["!focus",'!selected'])
button.grid(row=rownum, column=1, columnspan=5, sticky="w")
rownum += 1
def qfb(self, ExpOptionChosen):
"""Store the selection"""
self.userexpchoice = str(ExpOptionChosen)
if ExpOptionChosen==4:
Appa.isScrunching = True
Appa.isChemo = False
elif ExpOptionChosen==2:
Appa.isScrunching = False
Appa.isChemo = True
else:
Appa.isScrunching = False
Appa.isChemo = False
def checkchosenexp(self, parent, controller):
"""Check if chose an experiment. If yes, store values"""
if self.userexpchoice == int():
tkMessageBox.showwarning("Error", "Must select an experiment type")
else:
if self.userexpchoice == "0":
Appa.iscontrol = True
typeofexp = "N"
elif self.userexpchoice == "1":
typeofexp = "T"
elif self.userexpchoice == "2":
typeofexp = "C"
elif self.userexpchoice == "3":
typeofexp = "P"
elif self.userexpchoice == "4":
typeofexp = "S"
currtime = datetime.datetime.now()
dateandtime = currtime.strftime("%Y%m%d-%H%M")
savetofile = "/home/pi/Desktop/ExperimentFolder/" + typeofexp + dateandtime + "/"
Appa.set_savefile(savetofile) # Save file address
Appa.set_number(typeofexp + dateandtime) # Save exp identifier
Appa.set_type(self.userexpchoice) # Save experiment type
controller.show_frame(TimeSelPg)
class TimeSelPg(tk.Frame):
"""Enter time to run experiment for"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
for row in range (3,7):
self.grid_rowconfigure(row, minsize=50)
for column in range(6):
self.grid_columnconfigure(column, minsize=appwidth/5, weight=1)
self.grid_rowconfigure(8, minsize=appheight/3) # Next/back button row
self.grid_rowconfigure(0, weight=1) # Title row
self.grid_rowconfigure(2, weight=1) # Spacer row
self.grid_rowconfigure(7, weight=1) # Spacer row
self.totaltime = str()
label = tk.Label(self, text="Enter Experiment Duration (seconds)", font=MEDIUM_FONT)
label.grid(row=0, column=0, columnspan=5, sticky="NSEW")
self.totaltimetext = tk.Label(self, text = "", font=SMALL_FONT)
self.totaltimetext.grid(row = 1, column = 1, columnspan=3, sticky="w")
self.totaltimetext.configure(text = "Duration: %.5s" % self.totaltime)
button1 = ttk.Button(self, text="Back to\nExperiment\nSelection", style="TINYFONT.TButton", command=lambda: controller.show_frame(ExpSelPg))
button1.grid(row=8, column= 0, columnspan=2, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Next", style="TINYFONT.TButton", command=lambda: self.checkvalidexptime(parent, controller)) # Make sure entered a valid time then go to confirmation page
button2.grid(row=8, column= 3, columnspan=2, rowspan=1, sticky="nsew", padx=xspacer, pady=yspacer)
"""Number Pad """
btn_numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3', ' ', '0', 'x'] #create list of numbers to be displayed
r = 3
c = 1
for num in btn_numbers:
if num == ' ':
self.num = ttk.Button(self, text=num, width=5)
self.num.grid(row=r, column=c, sticky= "nsew")
c += 1
else:
self.num = ttk.Button(self, text=num, width=5, style='TINYFONT.TButton', command=lambda b = num: self.click(b))
self.num.grid(row=r, column=c, sticky= "nsew")
c += 1
if c > 3:
c = 1
r += 1
def click(self, z):
"""Display user's inputs"""
currentnum = self.totaltime
if currentnum == '0': # Replace value if time = 0
self.totaltime = z
if z == 'x': # Delete last entered value
self.totaltime = currentnum[:-1]
else:
if len(self.totaltime) > 2:
tkMessageBox.showwarning("Error", "Time too long")
else:
self.totaltime = currentnum + z
self.totaltimetext.configure(text = "Duration: %.5s" % self.totaltime)
def checkvalidexptime(self, parent, controller):
"""Check to see if time entered is valid, save the time, then show confirmation page"""
if len(self.totaltime) == 0: # User did not enter a number
tkMessageBox.showwarning("Error", "Must enter an experiment duration")
if self.totaltime == "0": # User entered 0
tkMessageBox.showwarning("Error", "Duration can not be 0")
if len(self.totaltime) != 0 and self.totaltime != "0":
Appa.set_exptime(self.totaltime)
controller.show_frameCharlie(ConfirmPg)
class ConfirmPg(tk.Frame, Experiment):
""" Displays chosen parameters for user to confirm"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_rowconfigure(1, minsize=appheight/8) # Spacer
self.grid_rowconfigure(6, weight=1) # Spacer
self.grid_rowconfigure(7, minsize=appheight/3) # Next/back button rows
self.grid_columnconfigure(0, minsize=appwidth/2.5*.5) # Back button
self.grid_columnconfigure(1, minsize=appwidth/2.5*.5) # Back button
self.grid_columnconfigure(3, minsize=appwidth/2.5) # Next button
self.grid_columnconfigure(2, weight=1) # Central column
self.label1 = tk.Label(self, text="Chosen Parameters", font=LARGE_FONT)
self.label1.grid(row=0, column=0, columnspan=4, sticky="ew")
self.label2 = tk.Label(self, text="", font=SMALL_FONT) # Label for experiment name
self.label2.grid(row=2, column=1, columnspan=3, sticky="w")
self.label3 = tk.Label(self, text="", font=SMALL_FONT) # Label for experiment type
self.label3.grid(row=4, column=1, columnspan=3, sticky="w")
self.label4 = tk.Label(self, text="", font=SMALL_FONT) # Label for experiment duration
self.label4.grid(row=5, column=1, columnspan=3, sticky="w")
button1 = ttk.Button(self, text="Back to\nRun time", style="TINYFONT.TButton", command=lambda: controller.show_frame(TimeSelPg))
button1.grid(row=7, column= 0, columnspan=2, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Next", style="TINYFONT.TButton", command=lambda: controller.show_frameFish(InsertPg)) # Go to insert worms page
button2.grid(row=7, column= 3, sticky="nsew", padx=xspacer, pady=yspacer)
def confirmlabels(self):
"""Configure labels to reflect what user chose"""
words = getpreviouslyanalyzed(Appa)
self.label2.configure(text = "Experiment number: " + str(Appa.expnumber))
self.label3.configure(text = "Experiment type: " + words)
self.label4.configure(text = "Run time (s): " + str(Appa.exptime))
class InsertPg(tk.Frame):
"""Instruct user to insert worms"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_rowconfigure(3, minsize=appheight/3) # Next/back button rows
self.grid_rowconfigure(2, weight=1) # Spacer
self.grid_columnconfigure(0, minsize=appwidth/2.5) # Back button
self.grid_columnconfigure(2, minsize=appwidth/2.5) # Next button
self.grid_columnconfigure(1, weight=1) # Central column
label = tk.Label(self, text="Insert Worms", font=MEDIUM_FONT)
label.grid(row=0, column=0, columnspan=3)
label2 = tk.Label(self, text="Select next once worms have settled down", font=SMALL_FONT)
label2.grid(row=1, column=0, columnspan=3)
button1 = ttk.Button(self, text="Back to\nConfirmation Page", style="TINYFONT.TButton", command=lambda: controller.show_frameZebra(ConfirmPg))
button1.grid(row=3, column= 0, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Next", style="TINYFONT.TButton", command=lambda: controller.show_frameDelta(StimPrepPg))
button2.grid(row=3, column= 2, sticky="nsew", padx=xspacer, pady=yspacer)
class StimPrepPg(tk.Frame):
"""
Instruct students to prepare stimuli
check expchoice to see if need to insert stimuli
Key: 0 = none; 1 = thermo; 2 = chemo; 3 = photo
"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_rowconfigure(3, minsize=appheight/3) #Next/back button rows
self.grid_rowconfigure(2, weight=1) # Spacer
self.grid_columnconfigure(0, minsize=appwidth/2.5) # Back button
self.grid_columnconfigure(2, minsize=appwidth/2.5) # Next button
self.grid_columnconfigure(1, weight=1) # Central column
self.label1 = tk.Label(self, text="", font=MEDIUM_FONT) #create object
self.label1.grid(row=0, column=0, columnspan=3) #grid object into window
self.label2 = tk.Label(self, text="Press 'Start' to begin experiment", font=SMALL_FONT) #create object
self.label2.grid(row=1, column=0, columnspan=3) #grid object into window
self.button1 = ttk.Button(self, text="Back to\nInsert Worms", style="TINYFONT.TButton", command=lambda: controller.show_frame(InsertPg)) #create a button to return to InsertPg
self.button1.grid(row=3, column= 0, sticky="nsew", padx=xspacer, pady=yspacer)
self.button2 = ttk.Button(self, text="Start", style="TINYFONT.TButton", command=lambda: self.beginexp(parent, controller)) #Start Experiment and raise experiment finished page
self.button2.grid(row=3, column= 2, sticky="nsew", padx=xspacer, pady=yspacer)
def beginexp(self, parent, controller):
camera.stop_preview()
result = tkMessageBox.askquestion("Start Experiment", "This experiment will run for \n%s seconds. Once started, you\ncan not quit.\nBegin experiment?" %Appa.exptime)
if result == "yes":
camera.start_preview(fullscreen=False, window=(appwidth/800, appheight/4, appwidth-(2*appwidth/800), appheight*9/10)) # This line starts the preview.
controller.show_frameEcho(ExpFinishPg)
else:
camera.start_preview(fullscreen=False, window=(0, appheight/4, appwidth, appheight/2)) #this line starts the preview.
def gettext(self):
"""Configure text depending on if user needs to insert simulus
Key: 0=none; 1=thermo; 2=chemo; 3=photo; 4=scrunching
"""
if Appa.exptype == "0" or Appa.exptype == "3":
words = "Ready"
elif Appa.exptype == "1" or Appa.exptype == "2":
words = "Prepare/Insert Stimulus"
elif Appa.exptype == "4":
words = "Prepare to cut worm"
self.label1.configure(text = words)
class ExpFinishPg(tk.Frame):
"""Allow user to go directly into data analysis or return to main menu"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_columnconfigure(0, weight=1)
label = tk.Label(self, text="Experiment Finished", font=MEDIUM_FONT)
label.grid(row=0, column=0)
button2 = ttk.Button(self, text="Continue to\nreview this\nexperiment's data", style="TINYFONT.TButton", command=lambda: controller.show_frameMarlin(ReviewData)) # Go to data review
button2.grid(row=2, column=0)
class ReviewData(tk.Frame, BehaviorBox):
"""Data review page. Lets user choose whether or not to keep data"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, minsize=30)
label = tk.Label(self, text = "Keep This Experiment's Data?", font=LARGE_FONT)
label.grid(row = 0, column=0, columnspan = 3, sticky="NSEW")
button2 = ttk.Button(self,text="Keep", style="TINYFONT.TButton", command=lambda: controller.show_frameStingray(StartPage, Appa)) # Save object then show start page
button2.grid(row=1, column = 2, sticky= "NS", padx=xspacer, pady=yspacer)
button3 = ttk.Button(self,text="Discard", style="TINYFONT.TButton", command=lambda: controller.show_frameRhino(StartPage)) # Delete entire date folder then show start page
button3.grid(row=2, column = 2, sticky="NS", padx=xspacer, pady=yspacer)
self.canvaswidth=appwidth*8/10
self.canvasheight=appheight*8/10
self.canvas=tk.Canvas(self, width=self.canvaswidth, height=self.canvasheight)
self.canvas.grid(row=1, column=0, rowspan=2)
class DataMenu(tk.Frame):
"""Choose what to do with data"""
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
for i in range(1,5): # Button rows
self.grid_rowconfigure(i, weight=1)
self.grid_columnconfigure(0, weight=1) # Central column
label = tk.Label(self, text="Choose an Option", font=LARGE_FONT)
label.grid(row=0, column=0, sticky="nsew")
button1 = ttk.Button(self, text="Analyze an Experiment", style='my.TButton', command=lambda: controller.show_frameFoxtrot(DataAnalysisPg)) # Choose specific experiment to analyze
button1.grid(row=1, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button2 = ttk.Button(self, text="Graph Experiments", style='my.TButton', command=lambda: controller.show_frameFoxtrot(DataGraphChoice)) # Graph experiment(s)
button2.grid(row=2, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button3 = ttk.Button(self, text="Delete Data", style='my.TButton', command=lambda: controller.show_frameFoxtrot(DataDelPg))
button3.grid(row=3, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
button4 = ttk.Button(self, text="Back to Main Menu", style='my.TButton', command=lambda: controller.show_frame(StartPage))
button4.grid(row=4, column=0, sticky="nsew", padx=xspacer, pady=yspacer)
class DataAnalysisPg(tk.Frame):
"""Lets user choose experiment to analyze"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.grid_columnconfigure(1, weight=1) # Listbox column
self.grid_columnconfigure(2, minsize=appwidth/30) # Scrollbar column
label = tk.Label(self, text="Data Analysis \n Please choose experiment to analyze", font=MEDIUM_FONT)
label.grid(row = 0, column=0, columnspan = 4, sticky="NSEW")
button1 = ttk.Button(self, text="Back to\nPrevious Page", style='TINYFONT.TButton', command=lambda: controller.show_frame(DataMenu))
button1.grid(row=1, column = 0, sticky="NSEW", padx=xspacer)
scrollbar = tk.Scrollbar(self)
scrollbar.grid(row=1, column=2, rowspan=2, sticky="NSEW")
self.List1=tk.Listbox(self, font=TINY_FONT, yscrollcommand = scrollbar.set)
self.List1.grid(row=1, column=1, rowspan = 2, sticky="NSEW")
self.List1.config(scrollregion=self.List1.bbox("active"))
scrollbar.config(command=self.List1.yview)
button2 = ttk.Button(self, text="Continue", style='TINYFONT.TButton', command=lambda List1=self.List1: self.asdf(parent, controller, List1))
button2.grid(row=1, column = 3, sticky="NSEW", padx=xspacer)
self.explist = []
i=0
for item in os.listdir("/home/pi/Desktop/ExperimentFolder/"):
self.explist.append(item)
self.explist.sort()
for experiment in self.explist:
self.List1.insert(i, experiment)
i+=1
def asdf(self, parent, controller, List1):
if List1.curselection() == ():
tkMessageBox.showwarning("Error", "Must select an experiment to analyze")
else:
itemindex = List1.curselection()[0]
controller.show_frameLima(DataAnalysisImagePg, self.explist[itemindex])
class DataAnalysisImagePg(tk.Frame):
"""Pull up images and get worm counts"""
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
for column in range(3,9):
self.grid_columnconfigure(column, weight=1)
self.grid_columnconfigure(2, minsize=xspacer) # Spacer
self.grid_columnconfigure(9, minsize=xspacer) # Spacer
self.button1 = ttk.Button(self, text="Next\nPicture", style="TINYFONT.TButton", command=lambda: self.ChangePic(1))
self.button1.grid(row=10, column=6, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button2 = ttk.Button(self, text="Previous\nPicture", style="TINYFONT.TButton", command=lambda: self.ChangePic(-1))
self.button2.grid(row=10, column=3, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button3 = ttk.Button(self, text="Save\nand\nFinish", style="TINYFONT.TButton", command=lambda: self.finalpic(controller)) # Save data and provide options
self.button3.grid(row=10, column=6, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button4 = ttk.Button(self, text="Back to\nExperiment\nSelection", style="VERYTINYFONT.TButton", command=lambda: controller.show_frameFoxtrot2(DataAnalysisPg))
self.button4.grid(row=10, column=3, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
# self.button3.lower() # Save and finish
# self.button2.lift() # Previous picture
# Label for number of worms counted
self.wormscounted = ""
self.wormscountedtext = tk.Label(self, text = "", font=VERYTINY_FONT)
self.wormscountedtext.grid(row=2, column=3, rowspan=2, columnspan=7, sticky="EW")
self.wormscountedtext.configure(text = "Number of worms:\n%.5s" % self.wormscounted)
# Label for current image number
self.currentimagenum = -1
self.imagenumtext = tk.Label(self, text = "", font=VERYTINY_FONT)
self.imagenumtext.grid(row=0, column=3, rowspan=2, columnspan=7, sticky="EW")
self.imagenumtext.configure(text = "Image Number:\n%.3i of %.3i" % (self.currentimagenum+1, 5))
self.f = Figure(figsize = (1,1))
self.placesubplot() # Add subplot to figure
self.canvas = FigureCanvasTkAgg(self.f, self) # Render canvas and fill it with figure
self.canvas.draw() #bring canvas to front
self.canvas.get_tk_widget().grid(row=0, column=0, rowspan = 15) #Fill options: BOTH, X, Y Expand options:
self.canvas.get_tk_widget().config(width=450, height=480) # TODO
""" Number Pad """
btn_numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3', ' ', '0', 'x'] #create list of numbers to be displayed
r = 5
c = 3
for num in btn_numbers:
if num == ' ':
self.num = ttk.Button(self, text=num, width=5)
self.num.grid(row=r, column=c, sticky= "nsew", columnspan=2)
c += 2
else:
self.num = ttk.Button(self, text=num, width=5, command=lambda b = num: self.click(b))
self.num.grid(row=r, column=c, sticky= "nsew", columnspan=2)
c += 2
if c > 7:
c = 3
r += 1
def click(self, z):
"""Save user inputs and display them"""
currentnum = self.wormscounted
if currentnum == '0':
self.wormscounted = z
if z == 'x':
self.wormscounted = currentnum[:-1]
else:
if len(self.wormscounted) > 2:
tkMessageBox.showwarning("Error", "There's no way that there are that many worms")
else:
self.wormscounted = currentnum + z
Momo.expy[self.currentimagenum]=self.wormscounted # Store number of counted worms
self.wormscountedtext.configure(text = "Number of worms:\n%.5s" % str(Momo.expy[self.currentimagenum])) # Configure text so user can see what they entered
def ChangePic(self, direction):
"""Go to next or previous screen"""
flag=True
self.button3.lower() # Save and finish
self.button2.lift() # Previous picture
if self.currentimagenum != -1 and self.wormscounted == "" and direction == 1: # Prohibit going forward without enter a number first
tkMessageBox.showwarning("Error", "Must enter a number")
else: # If user did enter a number
# The next 3 if statements make sure the user can not break the program by hitting next/back too quickly
if self.currentimagenum + direction < 0:
self.currentimagenum=0
flag=False
if self.currentimagenum + direction > len(Momo.expy)-1:
self.currentimagenum=len(Momo.expy)-1
flag=False
if flag:
self.currentimagenum = self.currentimagenum + direction # Set current image index to next/previous depending on button clicked
self.wormscountedtext.configure(text = "Number of worms:\n%.5s" % str(Momo.expy[self.currentimagenum])) # Configure text so user can see any previously entered values
self.wormscounted = Momo.expy[self.currentimagenum] # Get any previously entered value for current image index or "" if first time entering
self.f.clf() # Clear plot
self.placesubplot() # Place plot again
img = mpimg.imread(Momo.savefile + "/ExpDataPictures/image" + str(self.currentimagenum) + ".jpg") # Read in image based on current image index
self.a.imshow(img) # Renders image
if Momo.exptype == "1": # Thermotaxis
shape = Rectangle((240,160), width=160, height=160, fill=False, edgecolor="R")
elif Momo.exptype == "2": # Chemotaxis
shape = Circle((320,240),200, fill=False, edgecolor="R")
elif Momo.exptype == "3": # Phototaxis
shape = Rectangle((220,260), width=200, height=200, fill=False, edgecolor="R")
elif Momo.exptype == "4": # Scrunching
shape = Circle((200,400),180, fill=False, edgecolor="R")
self.a.add_patch(shape)
self.canvas.draw()
self.imagenumtext.configure(text = "Image Number:\n%.3i of %.3i" % (self.currentimagenum+1, len(Momo.expy))) # Update text so user knows what image number they are on. +1 accounts for index starting at 0
if self.currentimagenum == len(Momo.expy)-1: # If last image, show "generate graph" button
self.button3.lift()
if self.currentimagenum == 0: # If first image, show "back to experiment selection" button
self.button4.lift()
def placesubplot(self):
"""Add subplot to figure"""
self.a = self.f.add_subplot(1,1,1) #add subplot RCP. Pth pos on grid with R rows and C columns
self.a.xaxis.set_visible(False)
self.a.yaxis.set_visible(False)
self.a.set_position([0,0,1,1])
self.a.set_aspect(1)
def finalpic(self, controller):
if self.wormscounted == "": # Prohibit going forward without enter a number first
tkMessageBox.showwarning("Error", "Must enter a number")
else:
self.wormscounted = Momo.expy[self.currentimagenum] # Store value of just entered number
controller.show_frameStingray(DataMenu, Momo)
class ScrunchingPg(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
for column in range(3,9):
self.grid_columnconfigure(column, weight=1)
self.grid_columnconfigure(2, minsize=xspacer) # Spacer
self.grid_columnconfigure(9, minsize=xspacer) # Spacer
self.button1 = ttk.Button(self, text="Next\nPicture", style="TINYFONT.TButton", command=lambda: self.ChangePic(1))
self.button1.grid(row=10, column=6, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button2 = ttk.Button(self, text="Previous\nPicture", style="TINYFONT.TButton", command=lambda: self.ChangePic(-1))
self.button2.grid(row=10, column=3, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button3 = ttk.Button(self, text="Save\nand\nFinish", style="TINYFONT.TButton", command=lambda: self.finalpic(controller)) # Save data and provide options
self.button3.grid(row=10, column=6, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button4 = ttk.Button(self, text="Back to\nExperiment\nSelection", style="VERYTINYFONT.TButton", command=lambda: controller.show_frameFoxtrot2(DataAnalysisPg))
self.button4.grid(row=10, column=3, sticky="NESW", padx=xspacer, rowspan=4, columnspan=3)
self.button1.lift() # Next picture
self.button2.lift() # Previous picture
# Label for length of worm
self.wormlength = ""
self.wormlengthtext = tk.Label(self, text = "", font=VERYTINY_FONT)
self.wormlengthtext.grid(row=2, column=3, rowspan=2, columnspan=7, sticky="EW")
self.wormlengthtext.configure(text = "Enter length of worm:\n%.5s" % self.wormlength) #edit text
# Label for current image number
self.currentimagenum = -1
#self.imagenumtext = tk.Label(self, text = "", font=VERYTINY_FONT)
#self.imagenumtext.grid(row=0, column=3, rowspan=2, columnspan=7, sticky="EW")
#self.imagenumtext.configure(text = "Image Number:\n%.3i of %.3i" % (self.currentimagenum+1, 5))
# Display images on canvas
self.f = Figure(figsize = (1,1))
self.placesubplot() # Add subplot to figure
self.canvas = FigureCanvasTkAgg(self.f, self) # Render canvas and fill it with figure
self.canvas.draw() #bring canvas to front
self.canvas.get_tk_widget().grid(row=0, column=0, rowspan = 15) #Fill options: BOTH, X, Y Expand options: