Skip to content

Commit af41340

Browse files
author
MatthewBCooke
committed
Fixed geometry on mac, deleted invalid variable
1 parent 6fa6f66 commit af41340

File tree

2 files changed

+22
-109
lines changed

2 files changed

+22
-109
lines changed

SearchStrategyAnalysis/Pathfinder.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def buildGUI(self, root): # Called in the __init__ to build the GUI window
515515
trunacteFlag = truncate.get()
516516
rowCount = rowCount + 1
517517
self.calculateButton = Button(self.paramFrame, text="Calculate", fg="black",
518-
command=self.mainHelper, state=DISABLED) # add a button that says calculate
518+
command=self.mainHelper, state='disabled') # add a button that says calculate
519519
self.calculateButton.grid(row=rowCount, column=1, columnspan=1)
520520
self.settingsButton = Button(self.paramFrame, text="Settings", command=self.settings, fg="black")
521521
self.settingsButton.grid(row=rowCount, column=0, columnspan=1) # add custom button
@@ -666,20 +666,16 @@ def detectSoftwareType(self):
666666
twoRows = [row for idx, row in enumerate(data) if idx in (0, 1)]
667667
if (set(anymaze).issubset(twoRows[0])):
668668
softwareStringVar.set("anymaze")
669-
self.calculateButton['state'] = 'normal'
670669
if (set(['x', 'y', 't']).issubset(twoRows[1])):
671670
softwareStringVar.set("watermaze")
672-
self.calculateButton['state'] = 'normal'
673671
if (set(eztrack).issubset(twoRows[0])):
674672
softwareStringVar.set("eztrack")
675-
self.calculateButton['state'] = 'normal'
676673
elif (file_extension == '.xlsx'):
677674
workbook = open_workbook(theFile)
678675
sheet = workbook.sheet_by_index(0)
679676
rowNames = sheet.col_values(0)
680677
if (set(ethovision).issubset(rowNames)):
681678
softwareStringVar.set("ethovision")
682-
self.calculateButton['state'] = 'normal'
683679
else:
684680
self.callDefineOwnSoftware()
685681

@@ -692,7 +688,8 @@ def openFile(self): # opens a dialog to get a single file
692688
fileFlag = 1
693689
fileDirectory = ""
694690
theFile = filedialog.askopenfilename() # look for xlsx and xls files
695-
self.detectSoftwareType()
691+
self.calculateButton['state'] = 'normal'
692+
#self.detectSoftwareType()
696693

697694
def openDir(self): # open dialog to get multiple files
698695
logging.debug("Open Dir...")
@@ -701,6 +698,7 @@ def openDir(self): # open dialog to get multiple files
701698
global fileFlag
702699
fileFlag = 0
703700
theFile = ""
701+
self.calculateButton['state'] = 'normal'
704702
fileDirectory = filedialog.askdirectory(mustexist=TRUE)
705703

706704
def generateHeatmap(self, root):
@@ -2040,7 +2038,11 @@ def calculateValues(self, theTrial, goalX, goalY, mazeCentreX, mazeCentreY, corr
20402038

20412039
startToPlatVector = goalPoint - startPoint
20422040

2043-
aArcTangent = math.degrees(math.atan((goalY - startY) / (goalX - startX)))
2041+
if(goalX-startX != 0):
2042+
aArcTangent = math.degrees(math.atan((goalY - startY) / (goalX - startX)))
2043+
else:
2044+
aArcTangent = 0;
2045+
20442046
upperCorridor = aArcTangent + corridorWidth
20452047
lowerCorridor = aArcTangent - corridorWidth
20462048
corridorWidth = 0.0
@@ -2118,7 +2120,6 @@ def calculateValues(self, theTrial, goalX, goalY, mazeCentreX, mazeCentreY, corr
21182120
try:
21192121
sampleRate = (theTrial.datapointList[-1].gettime() - startTime) / (len(theTrial.datapointList) - 1)
21202122
except:
2121-
print("Error with sample rate calculation")
21222123
logging.info("Error with sample rate calculation")
21232124
sampleRate = 1
21242125
while idealDistance > math.ceil(float(goalDiam) / 2):
@@ -2257,21 +2258,23 @@ def mainCalculate(self, goalPosVar=goalPosVar, goalDiamVar=goalDiamVar):
22572258
return
22582259

22592260
headersToWrite = []
2260-
if aExperiment.hasDateInfo:
2261-
headersToWrite.extend(["Date", "Time", "Day"])
2262-
2263-
headersToWrite.append("Trial")
2264-
if aExperiment.hasTrialNames:
2265-
headersToWrite.append("Name")
2266-
if aExperiment.hasAnimalNames:
2267-
headersToWrite.append("Animal")
2261+
try:
2262+
if aExperiment.hasDateInfo:
2263+
headersToWrite.extend(["Date", "Time", "Day"])
22682264

2265+
headersToWrite.append("Trial")
2266+
if aExperiment.hasTrialNames:
2267+
headersToWrite.append("Name")
2268+
if aExperiment.hasAnimalNames:
2269+
headersToWrite.append("Animal")
2270+
except:
2271+
pass
22692272
headersToWrite.extend(
22702273
["Trial Code", "Strategy", "IPE", "Velocity", "Distance covered", "Average distance to goal",
2271-
"Average heading error", "Percent of maze traversed", "Latency", "Sccore", "Initial heading error",
2274+
"Average heading error", "Percent of maze traversed", "Latency", "Score", "Initial heading error",
22722275
"Entropy", "Distance to swim path centroid", "Average distance to centre of maze",
22732276
"Percent in angular corridor", "Percent in annulus zone", "Percent in smaller thigmotaxis zone",
2274-
"Percent in full thigmotaxis zone", "Strategy (manual)", "File"])
2277+
"Percent in full thigmotaxis zone", "Strategy (manual)"])
22752278
writer.writerow(headersToWrite) # write to the csv
22762279

22772280
dayNum = 0
@@ -2465,8 +2468,7 @@ def mainCalculate(self, goalPosVar=goalPosVar, goalDiamVar=goalDiamVar):
24652468
round(averageHeadingError, 2), round(percentTraversed, 2), round(latency, 2), score,
24662469
initialHeadingError, round(entropyResult, 2), round(averageDistanceToSwimPathCentroid, 2),
24672470
round(averageDistanceToCentre, 2), round(corridorAverage, 2), round(annulusCounter / i, 2),
2468-
round(smallThigmoCounter / i, 2), round(fullThigmoCounter / i, 2), str(strategyManual),
2469-
str(aTrial.getfile())])
2471+
round(smallThigmoCounter / i, 2), round(fullThigmoCounter / i, 2), str(strategyManual)])
24702472
writer.writerow(dataToWrite) # writing to csv file
24712473

24722474
f.flush()

SearchStrategyAnalysis/appTrial.py

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -268,95 +268,6 @@ def getXYT(event):
268268
top.mainloop()
269269

270270

271-
272-
'''
273-
def heatmapSettings(self, top3):
274-
global softwareStringVar
275-
software = softwareStringVar.get()
276-
if software != "ethovision":
277-
return
278-
global canvas
279-
global xscrollbar
280-
global vsb
281-
global frame
282-
global fileDirectory
283-
global heatValues
284-
global flags
285-
global labels
286-
287-
heatValues = []
288-
flags = []
289-
labels = []
290-
291-
extensionType = r"*.xlsx"
292-
try: # we try to delete a canvas (if one exists this will execute)
293-
deleteCanvas()
294-
logging.info("Canvas destroyed")
295-
except:
296-
logging.debug("Didn't kill canvas, could be first call")
297-
298-
logging.debug("heatmapSettings")
299-
300-
try:
301-
302-
canvas = Canvas(top3, borderwidth=0, width=350, height=800, bg="white") # we create the canvas
303-
frame = Frame(canvas) # we place a frame in the canvas
304-
frame.configure(bg="white")
305-
xscrollbar = Scrollbar(top3, orient=HORIZONTAL, command=canvas.xview) # we add a horizontal scroll bar
306-
xscrollbar.pack(side=BOTTOM, fill=X) # we put the horizontal scroll bar on the bottom
307-
vsb = Scrollbar(top3, orient="vertical", command=canvas.yview) # vertical scroll bar
308-
vsb.pack(side="right", fill="y") # put on right
309-
310-
canvas.pack(side="left", fill="both", expand=True) # we pack in the canvas
311-
canvas.create_window((4, 4), window=frame, anchor="nw") # we create the window for the results
312-
313-
canvas.configure(yscrollcommand=vsb.set) # we set the commands for the scroll bars
314-
canvas.configure(xscrollcommand=xscrollbar.set)
315-
frame.bind("<Configure>", lambda event, canvas=canvas: self.onFrameConfigure(canvas)) # we bind on frame configure
316-
except:
317-
logging.critical("Couldn't create the CSV canvas")
318-
319-
try: # we try and fill the canvas
320-
logging.debug("Populating the canvas")
321-
for aFile in self.find_files(fileDirectory, extensionType):
322-
try:
323-
wb = open_workbook(aFile)
324-
logging.debug("Opened" + aFile)
325-
except:
326-
logging.error("Could not open excel file: " + aFile)
327-
continue
328-
329-
for sheet in wb.sheets(): # for all sheets in the workbook
330-
for row in range(38): # GET CONDITION TREATMENT AND DAY VALUES
331-
for col in range(2):
332-
if str(sheet.cell(row, 0).value) != "":
333-
if col == 0:
334-
labels.append(str(sheet.cell(row, 0).value))
335-
heatmapValueFlag = BooleanVar()
336-
heatmapValueFlag.set(False)
337-
button = Checkbutton(frame, width=30, height=1, \
338-
text=str(sheet.cell(row, col).value), relief=RAISED, bg="white", variable=heatmapValueFlag)
339-
button.grid(row=row, column=col)
340-
flags.append(heatmapValueFlag)
341-
else:
342-
value = StringVar()
343-
value.set(str(sheet.cell(row, col).value))
344-
label = Entry(frame, width=30, textvariable=value)
345-
label.grid(row=row, column=col)
346-
heatValues.append(value)
347-
return
348-
349-
except Exception: # if we can't fill
350-
logging.critical("Fatal error in populate")
351-
352-
353-
'''
354-
355-
356-
357-
358-
359-
360271
def saveFileAsExperiment(software, filename, filedirectory):
361272
trialList = []
362273
filenameList = []

0 commit comments

Comments
 (0)