Skip to content

Commit

Permalink
Version 0.1.5
Browse files Browse the repository at this point in the history
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
schwanbeck committed Oct 15, 2024
1 parent db7656c commit 6766a2c
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion ysmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ysmr/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
# #### #### #### # ### # # # # ###### # # #### #### # # #####
or YoghurtYetis Software for Motility Recognition
"""
VERSION = (0, 1, 4)
VERSION = (0, 1, 5)

__version__ = '.'.join(map(str, VERSION))
2 changes: 1 addition & 1 deletion ysmr/gsff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions ysmr/helper_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ysmr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ysmr/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 9 additions & 6 deletions ysmr/track_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ysmr/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6766a2c

Please sign in to comment.