コード例 #1
0
def getAvgMov(track, **kwargs):

	SPEED_CONVERSION_FACTOR = kwargs["speedConversionFactor"]

	avgMov = []
	diff = []
	frameDistanceBetweenFrames = []
	positionalDistanceBetweenFrames = []
	for index in range(0, len(track.x) - 1):
		#the number of frames by which two adjacent elements in track are separated
		frameDistanceBetweenFrames = track.t[index + 1] - track.t[index] 
		#the absolute positional distance between adjacent tracked frames
		positionalDistanceBetweenFrames = gen.getDistance(track.x[index], track.x[index + 1], track.y[index], track.y[index + 1])
		#the distance traveled per frame between adjacent tracked frames
		diff.append(positionalDistanceBetweenFrames / frameDistanceBetweenFrames)
	return gen.nanMean(diff) * SPEED_CONVERSION_FACTOR
コード例 #2
0
def getDirectionality(track, **kwargs):
	FIELD_VECTOR = kwargs['gradientVector']

	xDiffs = gen.getDifferenceArray(track.x)
	yDiffs = gen.getDifferenceArray(track.y)

	directedness = []
	#calculate instantenous directionality between frames
	for dx, dy in zip(xDiffs, yDiffs):
		vector = [dx, dy]
		normVector = gen.normalizeVector(vector)
		if normVector != 0:
			normFieldVector = gen.normalizeVector(FIELD_VECTOR)
			directionality = gen.dotProduct(vector, FIELD_VECTOR) / normVector * normFieldVector
			directedness.append(directionality)
		else:
			directedness.append(0)
	return gen.nanMean(directedness)