-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed numpy.float error: error and solution found by Christopher Tinkey. Fixed np.int0 usage, found by Maria Kisch. Fixed argrelextrema_groupby call, might need future improvements. Fixed spelling mistakes Updated copyright info
- Loading branch information
1 parent
db7656c
commit 6766a2c
Showing
9 changed files
with
23 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,10 @@ | |
NAME = 'ysmr' | ||
DESCRIPTION = 'Bacterial video tracking and analysis.' | ||
URL = 'https://github.com/schwanbeck/YSMR' | ||
EMAIL = '[email protected]' | ||
EMAIL = '[email protected]' | ||
AUTHOR = 'Julian Schwanbeck' | ||
REQUIRES_PYTHON = '>=3.6.0' | ||
VERSION = '0.1.4' | ||
VERSION = '0.1.5' | ||
|
||
# What packages are required for this module to be executed? | ||
REQUIRED = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019 Julian Schwanbeck ([email protected]) | ||
Copyright 2019 Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
##Explanation | ||
This file starts YSMR. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Jerôme Dretzke and Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Jerôme Dretzke and Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
Original Idea and Equations from Pak, JM: Gaussian Sum FIR Filtering for 2D Target Tracking | ||
(DOI: 10.1007/s12555-018-0938-4) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
##Explanation | ||
This file contains various functions used by YSMR. | ||
|
@@ -39,7 +39,7 @@ | |
def argrelextrema_groupby(group, comparator=np.greater_equal, order=10, shift_range=4, fill_value=0): | ||
"""Find local minima/maxima in range of order (depending on comparator). | ||
When shift is not 0, will only return one result in range of shift. | ||
Returns array with non-extrema replaced by fil_value | ||
Returns array with non-extrema replaced by fill_value | ||
:param group: array like | ||
:param comparator: numpy comparator or equivalent | ||
|
@@ -63,7 +63,8 @@ def argrelextrema_groupby(group, comparator=np.greater_equal, order=10, shift_ra | |
(query == 1), | ||
0, result)) | ||
result = np.where(result == 1, group_intermediate, fill_value) | ||
result = pd.Series(result, index=group.index) | ||
# @todo: check if we can skip the series conversion while using this with df .transform instead of .apply | ||
result = pd.Series(result, index=group.index) # .reindex_like(group) | ||
return result | ||
|
||
|
||
|
@@ -1200,7 +1201,8 @@ def logging_listener(settings): | |
print('Problem:', file=sys.stderr) | ||
traceback.print_exc(file=sys.stderr) | ||
try: | ||
traceback.print_exc(file=settings['log file path']) | ||
with open(file=settings['log file path'], mode='w+') as file: | ||
traceback.print_exc(file=file) | ||
except (FileNotFoundError, PermissionError): | ||
pass | ||
break | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
##Explanation | ||
This file starts YSMR. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
##Explanation | ||
This file contains functions which create plots for YSMR. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
https://github.com/schwanbeck/YSMR | ||
##Explanation | ||
This file contains the main functions used by YSMR. | ||
|
@@ -288,7 +288,7 @@ def track_bacteria(video_path, settings=None, result_folder=None): | |
# cv2.minAreaRect returns ((x, y), (w, h), degrees) | ||
|
||
if settings['include luminosity in tracking calculation']: | ||
box = np.int0(cv2.boxPoints(reichtangle)) | ||
box = np.intp(cv2.boxPoints(reichtangle)) | ||
# must be generated for each object as cv2.fillpoly() changes it's input | ||
mask = np.zeros((frame_height, frame_width), dtype=np.uint8) | ||
cv2.fillPoly(mask, [box], 255) | ||
|
@@ -304,7 +304,7 @@ def track_bacteria(video_path, settings=None, result_folder=None): | |
# reshape_result(tuple_of_tuples) returns ((x, y[, *args]), (w, h, degrees_orientation)) | ||
|
||
if settings['display video analysis']: # or settings['save video']: # Display bounding boxes | ||
box = np.int0(cv2.boxPoints(reichtangle)) | ||
box = np.intp(cv2.boxPoints(reichtangle)) | ||
# Box: 4 x/y coordinates | ||
cv2.drawContours(frame, [box], -1, (255, 0, 0), 0) | ||
|
||
|
@@ -973,7 +973,9 @@ def evaluate_tracks(path_to_file, results_directory, df=None, settings=None, fps | |
df['y_norm'] = (df['POSITION_Y'].sub(df.groupby('TRACK_ID')['POSITION_Y'].transform('first'))) / px_to_micrometre | ||
|
||
# get local maxima | ||
df['turn_points'] = df.groupby('TRACK_ID')['turn_points'].apply(argrelextrema_groupby) | ||
df['turn_points'] = df.groupby('TRACK_ID')['turn_points'].transform( | ||
argrelextrema_groupby | ||
) | ||
# Convert to binary | ||
df['turn_points'] = np.where(df['turn_points'] == 0, 0, 1).astype(np.int8) | ||
# start counts as TP so we can later group by TPs | ||
|
@@ -1198,9 +1200,10 @@ def evaluate_tracks(path_to_file, results_directory, df=None, settings=None, fps | |
df_stats_seaborne.dropna(subset=[cut_off_category], inplace=True) | ||
|
||
# Exchange int values in 'Categories' for correct labels | ||
df_stats_seaborne[cut_off_category].replace( # name_all_categories is not present and can be skipped | ||
df_stats_seaborne[cut_off_category] = df_stats_seaborne[cut_off_category].replace( | ||
# name_all_categories is not present and can be skipped | ||
{value: key for key, value in zip([i for (_, _, i) in cut_off_list[1:]], range(1, len(cut_off_list)))}, | ||
inplace=True) | ||
) | ||
|
||
# Put name_all_categories and assigned categories in one df | ||
df_stats_seaborne = pd.concat([df_stats, df_stats_seaborne], ignore_index=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Copyright 2019, 2020 Julian Schwanbeck ([email protected]) | ||
Original Idea by Adrian Rosebrock ([email protected]) | ||
https://www.pyimagesearch.com/2018/07/23/simple-object-tracking-with-opencv/ | ||
##Explanation | ||
|