sylvainprigent / stracking

python library for particles tracking in 2D+t and 3D+t scientific images
Other
13 stars 2 forks source link

TypeError for feature filter #2

Closed sebgoti closed 1 month ago

sebgoti commented 2 years ago

I am also getting an error when running the feature filter on the minimum example:

# Keep only tracks that moves less than 60 pixels
filter_calc = FeatureFilter(feature_name='distance', min_val='20', max_val='60')
filter_calc.run(tracks)

with the output:


TypeError Traceback (most recent call last) Input In [1], in <cell line: 26>() 24 # Keep only tracks that moves less than 60 pixels 25 filter_calc = FeatureFilter(feature_name='distance', min_val='20', max_val='60') ---> 26 filter_calc.run(tracks)

File ~/Documents/STracking/stracking/stracking/filters/_feature_filter.py:42, in FeatureFilter.run(self, stracks) 40 self.progress(int(100*t/len(tracks_feature_keys))) 41 val = tracks_feature[track_id] ---> 42 if val < self.min_val or val > self.max_val: 43 # remove from data 44 stracks.data = np.delete(stracks.data, 45 stracks.data[:, 0] == track_id, 46 axis=0) 47 # remove from the graph

TypeError: '<' not supported between instances of 'float' and 'str'

sylvainprigent commented 2 years ago

Thanks for pointing out this error. I just push a commit (366fcceb301da1aef13da1f4d0e8cc22acac2fae) in the main branch to fix this issue.

Actually min_val and max_val are numbers (not strings like written by mistake in the documentation)

I updated the documentation and added a control on the min_val and max_val parameters to get a more understandable error when a wrong parameter type is given.