ANP-Granular / ParticleTracking

Library and GUI for tracking (rod-like) particles on camera images in 2D and 3D
https://particletracking.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 2 forks source link

Crash after attempting to save new rods #60

Closed a-niem closed 2 years ago

a-niem commented 2 years ago

The RodTracker crashes while attempting to save with data that has newly created rods. The same problem occurs when attempting to switch the displayed color with a newly created rod in the dataset.

a-niem commented 2 years ago

The crashes occur when:

  1. the currently not displayed camera view has a new rod
  2. the currently displayed camera view has one or more changes
  3. one of the following display actions is performed:
    • switch frame
    • switch color
    • save changes

It does not matter whether the new rod has been loaded from disc or whether it was created in the same session with/without prior saving. The following error is logged after/during the crash:

[10/12 10:42:20] RodTracker.backend.logger ERROR: Uncaught exception:
Traceback (most recent call last):
  File "/.../TrackGUI/Python/src/RodTracker/backend/parallelism.py", line 15, in run
    results = self.f()
  File "/.../TrackGUI/Python/src/RodTracker/backend/data_operations.py", line 194, in change_data
    rod_data = rod_data.astype({"frame": 'int', f"seen_{cam_id}": 'int',
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/generic.py", line 6231, in astype
    res_col = col.astype(dtype=cdt, copy=copy, errors=errors)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/generic.py", line 6245, in astype
    new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 446, in astype
    return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 348, in apply
    applied = getattr(b, f)(**kwargs)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 527, in astype
    new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/dtypes/astype.py", line 299, in astype_array_safe
    new_values = astype_array(values, dtype, copy=copy)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/dtypes/astype.py", line 230, in astype_array
    values = astype_nansafe(values, dtype, copy=copy)
  File "/.../TrackGUI/venv/lib/python3.8/site-packages/pandas/core/dtypes/astype.py", line 170, in astype_nansafe
    return arr.astype(dtype, copy=True)
ValueError: cannot convert float NaN to integer

The problem thereby appears to be the handling of empty fields in the data, that are currently represented using NaN.