@@ -515,7 +515,7 @@ def buildGUI(self, root): # Called in the __init__ to build the GUI window
515
515
trunacteFlag = truncate .get ()
516
516
rowCount = rowCount + 1
517
517
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
519
519
self .calculateButton .grid (row = rowCount , column = 1 , columnspan = 1 )
520
520
self .settingsButton = Button (self .paramFrame , text = "Settings" , command = self .settings , fg = "black" )
521
521
self .settingsButton .grid (row = rowCount , column = 0 , columnspan = 1 ) # add custom button
@@ -666,20 +666,16 @@ def detectSoftwareType(self):
666
666
twoRows = [row for idx , row in enumerate (data ) if idx in (0 , 1 )]
667
667
if (set (anymaze ).issubset (twoRows [0 ])):
668
668
softwareStringVar .set ("anymaze" )
669
- self .calculateButton ['state' ] = 'normal'
670
669
if (set (['x' , 'y' , 't' ]).issubset (twoRows [1 ])):
671
670
softwareStringVar .set ("watermaze" )
672
- self .calculateButton ['state' ] = 'normal'
673
671
if (set (eztrack ).issubset (twoRows [0 ])):
674
672
softwareStringVar .set ("eztrack" )
675
- self .calculateButton ['state' ] = 'normal'
676
673
elif (file_extension == '.xlsx' ):
677
674
workbook = open_workbook (theFile )
678
675
sheet = workbook .sheet_by_index (0 )
679
676
rowNames = sheet .col_values (0 )
680
677
if (set (ethovision ).issubset (rowNames )):
681
678
softwareStringVar .set ("ethovision" )
682
- self .calculateButton ['state' ] = 'normal'
683
679
else :
684
680
self .callDefineOwnSoftware ()
685
681
@@ -692,7 +688,8 @@ def openFile(self): # opens a dialog to get a single file
692
688
fileFlag = 1
693
689
fileDirectory = ""
694
690
theFile = filedialog .askopenfilename () # look for xlsx and xls files
695
- self .detectSoftwareType ()
691
+ self .calculateButton ['state' ] = 'normal'
692
+ #self.detectSoftwareType()
696
693
697
694
def openDir (self ): # open dialog to get multiple files
698
695
logging .debug ("Open Dir..." )
@@ -701,6 +698,7 @@ def openDir(self): # open dialog to get multiple files
701
698
global fileFlag
702
699
fileFlag = 0
703
700
theFile = ""
701
+ self .calculateButton ['state' ] = 'normal'
704
702
fileDirectory = filedialog .askdirectory (mustexist = TRUE )
705
703
706
704
def generateHeatmap (self , root ):
@@ -2040,7 +2038,11 @@ def calculateValues(self, theTrial, goalX, goalY, mazeCentreX, mazeCentreY, corr
2040
2038
2041
2039
startToPlatVector = goalPoint - startPoint
2042
2040
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
+
2044
2046
upperCorridor = aArcTangent + corridorWidth
2045
2047
lowerCorridor = aArcTangent - corridorWidth
2046
2048
corridorWidth = 0.0
@@ -2118,7 +2120,6 @@ def calculateValues(self, theTrial, goalX, goalY, mazeCentreX, mazeCentreY, corr
2118
2120
try :
2119
2121
sampleRate = (theTrial .datapointList [- 1 ].gettime () - startTime ) / (len (theTrial .datapointList ) - 1 )
2120
2122
except :
2121
- print ("Error with sample rate calculation" )
2122
2123
logging .info ("Error with sample rate calculation" )
2123
2124
sampleRate = 1
2124
2125
while idealDistance > math .ceil (float (goalDiam ) / 2 ):
@@ -2257,21 +2258,23 @@ def mainCalculate(self, goalPosVar=goalPosVar, goalDiamVar=goalDiamVar):
2257
2258
return
2258
2259
2259
2260
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" ])
2268
2264
2265
+ headersToWrite .append ("Trial" )
2266
+ if aExperiment .hasTrialNames :
2267
+ headersToWrite .append ("Name" )
2268
+ if aExperiment .hasAnimalNames :
2269
+ headersToWrite .append ("Animal" )
2270
+ except :
2271
+ pass
2269
2272
headersToWrite .extend (
2270
2273
["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" ,
2272
2275
"Entropy" , "Distance to swim path centroid" , "Average distance to centre of maze" ,
2273
2276
"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)" ])
2275
2278
writer .writerow (headersToWrite ) # write to the csv
2276
2279
2277
2280
dayNum = 0
@@ -2465,8 +2468,7 @@ def mainCalculate(self, goalPosVar=goalPosVar, goalDiamVar=goalDiamVar):
2465
2468
round (averageHeadingError , 2 ), round (percentTraversed , 2 ), round (latency , 2 ), score ,
2466
2469
initialHeadingError , round (entropyResult , 2 ), round (averageDistanceToSwimPathCentroid , 2 ),
2467
2470
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 )])
2470
2472
writer .writerow (dataToWrite ) # writing to csv file
2471
2473
2472
2474
f .flush ()
0 commit comments