cortex-lab / phylib

Lightweight electrophysiological data analysis library
BSD 3-Clause "New" or "Revised" License
11 stars 23 forks source link

_load_ function problems #3

Closed adehad closed 5 years ago

adehad commented 5 years ago
  1. Need to from glob import glob for _load_metadata https://github.com/cortex-lab/phylib/blob/f72d0a5f58ba1a741bfa88feba7ee0f64ef721c5/phylib/io/model.py#L321-L324
  2. self.dir_path does not seem to be recognised as a Path object in _load_spike_samples https://github.com/cortex-lab/phylib/blob/f72d0a5f58ba1a741bfa88feba7ee0f64ef721c5/phylib/io/model.py#L426-L429 self.dir_path = Path(dir_path) didn't work in the constructor for me, so I used this non-ideal work around.
    path = self.dir_path +'/'+ 'spike_times.npy'
    path = Path(path)

phy GUI opens after this, but then produces an assertion error:

c:\conda\miniconda3\envs\phydev\lib\site-packages\numpy\core\_methods.py:75: RuntimeWarning: invalid value encountered in reduce
  ret = umr_sum(arr, axis, dtype, out, keepdims)
c:\conda\miniconda3\envs\phydev\lib\site-packages\numpy\lib\function_base.py:3405: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
c:\conda\miniconda3\envs\phydev\lib\site-packages\phylib\utils\geometry.py:161: RuntimeWarning: invalid value encountered in less
  assert np.all(data_bounds[:, 1] < data_bounds[:, 3])

...
Traceback (most recent call last):
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\apps\template\gui.py", line 723, in init_cluster_ids
    view.plot()
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\cluster\views\template.py", line 158, in plot
    self._plot_templates(bunchs, data_bounds=data_bounds)
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\cluster\views\template.py", line 103, in _plot_templates
    self.visual.add_batch_data(**data, data_bounds=data_bounds)
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\plot\base.py", line 142, in add_batch_data
    data = self.validate(**kwargs)
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\plot\visuals.py", line 296, in validate
    data_bounds = _get_data_bounds(data_bounds, length=n_signals)
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phylib\utils\geometry.py", line 193, in _get_data_bounds
    _check_data_bounds(data_bounds)
 File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phylib\utils\geometry.py", line 161, in _check_data_bounds
    assert np.all(data_bounds[:, 1] < data_bounds[:, 3])
AssertionError
rossant commented 5 years ago
  1. Need to from glob import glob for _load_metadata

What is your version of Python?

adehad commented 5 years ago

What is your version of Python?

Python 3.7.3

adehad commented 5 years ago

All except Assertion Error addressed by: ec4cf662b6fed28db206e7c7ba41285e010fdd57

rossant commented 5 years ago

for the assertion error could you send me your dataset?

adehad commented 5 years ago

Have attached it here, with the data binary: kilosort_dataset.zip

rossant commented 5 years ago

There are infinite values in amplitudes.npy. I'll push a fix to skip these points but the real question is: why does kilosort find infinite values as amplitudes?

rossant commented 5 years ago

Same problem for template_features.npy.

adehad commented 5 years ago

There are infinite values in amplitudes.npy. I'll push a fix to skip these points but the real question is: why does kilosort find infinite values as amplitudes?

Hmm, that does seem non-ideal. Those sort results had clusters that looked distinctly like noise, were these the problematic units? image

Managed to get the new phy gui running now (!). Seem to have an error related to phycontrib, is this because you are still in the transitioning phase to remove it as a dependency?:

17:51:27.174 [W] model:49             29042/433611 values are inf in C:\Users\Adehad\preAutoMerge\amplitudes.npy, replacing by zero.
17:51:27.231 [W] model:49             25027/1300833 values are inf in C:\Users\Adehad\preAutoMerge\template_features.npy, replacing by zero.
17:51:27.331 [E] plugin:109           No module named 'phycontrib'
Traceback (most recent call last):
  File "c:\conda\miniconda3\envs\phydev\lib\site-packages\phy\utils\plugin.py", line 107, in discover_plugins
    mod = imp.load_module(modname, file, path, descr)  # noqa
  File "c:\conda\miniconda3\envs\phydev\lib\imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "c:\conda\miniconda3\envs\phydev\lib\imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\SPB_Data\.phy\plugins\phycontrib_loader.py", line 3, in <module>
    import phycontrib
ModuleNotFoundError: No module named 'phycontrib'

[Am running on Windows, hence why I get those strange characters, I believe I opened a similar issue about them for the older phy]

rossant commented 5 years ago

try to remove C:\SPB_Data\.phy\plugins\phycontrib_loader.py ?

adehad commented 5 years ago

try to remove C:\SPB_Data\.phy\plugins\phycontrib_loader.py ?

Tactical. Can confirm that fixes the issue.