Skip to content

Commit 364496f

Browse files
committed
removed some MATLAB syntax (thanks Jonas Mucke)
1 parent ae9f510 commit 364496f

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

functions/I2MC_funcs.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ def windowedInterpolate(xpos, ypos, missing, missStart, missEnd, edgesamples, de
548548
validsamps = np.concatenate((outWin[0]+np.arange(-edgesamples,0), outWin[outWinNotMissing], outWin[-1]+np.arange(1,edgesamples+1)))
549549

550550
# get valid values: where no missing data was observed
551-
validx = xpos[validsamps];
552-
validy = ypos[validsamps];
551+
validx = xpos[validsamps]
552+
validy = ypos[validsamps]
553553

554554
# do Steffen interpolation, update xpos, ypos
555555
xpos[outWin]= steffenInterp(validsamps,validx,outWin)
@@ -725,8 +725,8 @@ def kmeans2(data):
725725
iter += 1
726726
# Calculate the new cluster centroids and counts, and update the
727727
# distance from every point to those new cluster centroids
728-
Clast = C;
729-
mlast = m;
728+
Clast = C
729+
mlast = m
730730
D = cdist(C, data, metric='sqeuclidean')
731731

732732
# Deal with clusters that have just lost all their members
@@ -744,7 +744,6 @@ def kmeans2(data):
744744
# one member, pick any other non-singleton point.
745745
cFrom = np.argwhere(m>1)[0]
746746
lonely = np.argwhere(mlabel==cFrom)[0]
747-
end
748747
label[lonely] = i
749748

750749
# Update clusters from which points are taken
@@ -766,7 +765,7 @@ def kmeans2(data):
766765
break
767766

768767
# Determine closest cluster for each point and reassign points to clusters
769-
prevlabel = label;
768+
prevlabel = label
770769
prevtotsumD = totsumD
771770
newlabel = vq(data, C)[0]
772771

@@ -842,8 +841,8 @@ def kmeans2(data):
842841
label[moved] = nlbl
843842
m[nlbl] += 1
844843
m[olbl] -= 1
845-
C[nlbl,:] = C[nlbl,:] + (data[moved,:] - C[nlbl,:]) / m[nlbl];
846-
C[olbl,:] = C[olbl,:] - (data[moved,:] - C[olbl,:]) / m[olbl];
844+
C[nlbl,:] = C[nlbl,:] + (data[moved,:] - C[nlbl,:]) / m[nlbl]
845+
C[olbl,:] = C[olbl,:] - (data[moved,:] - C[olbl,:]) / m[olbl]
847846

848847
#------------------------------------------------------------------
849848
if not converged:
@@ -1154,7 +1153,7 @@ def getFixations(finalweights, timestamp, xpos, ypos, missing, par):
11541153
i = fixend[p]
11551154
if i<len(xpos): # don't walk when fixation ending at end of data
11561155
while np.hypot(xpos[i]-xmedThis,ypos[i]-ymedThis)>thresh:
1157-
i = i-1;
1156+
i = i-1
11581157
fixend[p] = i
11591158

11601159
### get start time, end time,
@@ -1166,8 +1165,8 @@ def getFixations(finalweights, timestamp, xpos, ypos, missing, par):
11661165
# get median coordinates of fixation
11671166
xmedThis = np.median(xpos[fixstart[p]:fixend[p]+1])
11681167
ymedThis = np.median(ypos[fixstart[p]:fixend[p]+1])
1169-
xmedPrev = np.median(xpos[fixstart[p-1]:fixend[p-1]+1]);
1170-
ymedPrev = np.median(ypos[fixstart[p-1]:fixend[p-1]+1]);
1168+
xmedPrev = np.median(xpos[fixstart[p-1]:fixend[p-1]+1])
1169+
ymedPrev = np.median(ypos[fixstart[p-1]:fixend[p-1]+1])
11711170

11721171
# check if fixations close enough in time and space and thus qualify
11731172
# for merging
@@ -1178,8 +1177,8 @@ def getFixations(finalweights, timestamp, xpos, ypos, missing, par):
11781177
if starttime[p]-endtime[p-1] < maxMergeTime and \
11791178
np.hypot(xmedThis-xmedPrev,ymedThis-ymedPrev) < maxMergeDist:
11801179
# merge
1181-
fixend[p-1] = fixend[p];
1182-
endtime[p-1]= endtime[p];
1180+
fixend[p-1] = fixend[p]
1181+
endtime[p-1]= endtime[p]
11831182
# delete merged fixation
11841183
fixstart = np.delete(fixstart, p)
11851184
fixend = np.delete(fixend, p)
@@ -1361,12 +1360,12 @@ def getFixStats(xpos, ypos, missing, pixperdeg = None, fix = {}):
13611360
# Difference x position
13621361
xdif = xposf.copy()
13631362
xdif[qMiss] = np.nan
1364-
xdif = np.diff(xdif)**2;
1363+
xdif = np.diff(xdif)**2
13651364
xdif = xdif[np.invert(np.isnan(xdif))]
13661365
# Difference y position
13671366
ydif = yposf.copy()
13681367
ydif[qMiss] = np.nan
1369-
ydif = np.diff(ydif)**2;
1368+
ydif = np.diff(ydif)**2
13701369
ydif = ydif[np.invert(np.isnan(ydif))]
13711370
# Distance and RMS measure
13721371
c = xdif + ydif # 2D sample-to-sample displacement value in pixels
@@ -1389,7 +1388,7 @@ def getFixStats(xpos, ypos, missing, pixperdeg = None, fix = {}):
13891388
rho = xx[0,1]
13901389
P = 0.68 # cumulative probability of area under the multivariate normal
13911390
k = np.log(1./(1-P))
1392-
BCEA[a] = 2*k*np.pi*stdx*stdy*np.sqrt(1-rho**2);
1391+
BCEA[a] = 2*k*np.pi*stdx*stdy*np.sqrt(1-rho**2)
13931392

13941393
### calculate max-min of fixation
13951394
if np.sum(qMiss) == len(qMiss):
@@ -1401,8 +1400,8 @@ def getFixStats(xpos, ypos, missing, pixperdeg = None, fix = {}):
14011400

14021401
if pixperdeg is not None:
14031402
# value in degrees visual angle
1404-
rangeX[a] = rangeX[a]/pixperdeg;
1405-
rangeY[a] = rangeY[a]/pixperdeg;
1403+
rangeX[a] = rangeX[a]/pixperdeg
1404+
rangeY[a] = rangeY[a]/pixperdeg
14061405

14071406
# Add results to fixation dictionary
14081407
fix['RMSxy'] = RMSxy
@@ -1585,8 +1584,8 @@ def I2MC(gazeData, options = {}):
15851584
print('\tSearching for valid interpolation windows')
15861585
missStart,missEnd = findInterpWins(xpos, ypos, missing, par['windowtimeInterp'], par['edgeSampInterp'], par['freq'], par['maxdisp'])
15871586
if q2Eyes:
1588-
llmissStart,llmissEnd = findInterpWins(data['L_X'], data['L_Y'], llmiss, par['windowtimeInterp'], par['edgeSampInterp'], par['freq'], par['maxdisp']);
1589-
rrmissStart,rrmissEnd = findInterpWins(data['R_X'], data['R_Y'], rrmiss, par['windowtimeInterp'], par['edgeSampInterp'], par['freq'], par['maxdisp']);
1587+
llmissStart,llmissEnd = findInterpWins(data['L_X'], data['L_Y'], llmiss, par['windowtimeInterp'], par['edgeSampInterp'], par['freq'], par['maxdisp'])
1588+
rrmissStart,rrmissEnd = findInterpWins(data['R_X'], data['R_Y'], rrmiss, par['windowtimeInterp'], par['edgeSampInterp'], par['freq'], par['maxdisp'])
15901589

15911590
# Use Steffen interpolation and replace values
15921591
print('\tReplace interpolation windows with Steffen interpolation')

0 commit comments

Comments
 (0)