m-beau / NeuroPyxels

NeuroPyxels (npyx) is a python library built for electrophysiologists using Neuropixels electrodes. This package stems from the need of a pythonist who really did not want to transition to MATLAB to work with Neuropixels: it features a suite of core utility functions for loading, processing and plotting Neuropixels data.
GNU General Public License v3.0
111 stars 27 forks source link

Import error npyx 4.0.6, python3.9 NameError: name 'KronDecomposed' is not defined` #398

Open Antorithms opened 5 days ago

Antorithms commented 5 days ago

Dear Maxime, Thanks for developing this nice package! With npyx version 4.0.6 I get the error below after installing in a conda environment with python==3.9 and trying to import from npyx.spk_wvf import get_peak_chan. Can you reproduce the issue? Thanks for your help. Anto

In [2]: from npyx.spk_wvf import get_peak_chan
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 from npyx.spk_wvf import get_peak_chan

File -\lib\site-packages\npyx\__init__.py:7
      1 # -*- coding: utf-8 -*-
      3 from . import utils, inout, gl, spk_t, spk_wvf, corr, stats, plot,\
      4               behav, merger, circuitProphyler, feat, metrics,\
      5               info, model, h5, testing, ml, datasets
----> 7 from .c4 import dataset_init, misc
      9 try:
     10     import torch

File -\lib\site-packages\npyx\c4\__init__.py:5
      2 import torch
      4 from .acg_augmentations import *
----> 5 from .acg_vs_firing_rate import *
      6 from .dl_transforms import *
      7 from .dl_utils import *

File -\lib\site-packages\npyx\c4\acg_vs_firing_rate.py:24
     18 from .dataset_init import (
     19     extract_and_check,
     20     extract_and_merge_datasets,
     21     get_paths_from_dir,
     22 )
     23 from .monkey_dataset_init import MONKEY_CENTRAL_RANGE, get_lisberger_dataset
---> 24 from .predict_cell_types import get_n_cores, redirect_stdout_fd
     26 BIN_SIZE = 1
     27 WIN_SIZE = 200

File -\lib\site-packages\npyx\c4\predict_cell_types.py:42
     36 from .misc import require_advanced_deps
     37 from .plots_functions import (
     38     C4_COLORS,
     39     plot_features_1cell_vertical,
     40     plot_survival_confidence,
     41 )
---> 42 from .run_deep_classifier import (
     43     CustomDataset,
     44     encode_layer_info,
     45     ensemble_predict,
     46     load_ensemble,
     47     prepare_classification_dataset,
     48 )
     50 MODELS_URL_DICT = {
     51     "base": "https://figshare.com/ndownloader/files/42117042?private_link=2530fd0da03e18296d51",
     52     "mli_clustering": "https://figshare.com/ndownloader/files/42129447?private_link=d508ebc51d544ed8cd4c",
     53     "layer_information": "https://figshare.com/ndownloader/files/42853297?private_link=6531855c261b7bad032d",
     54     "layer_information_mli_clustering": "https://figshare.com/ndownloader/files/42853708?private_link=3a81e48aff77d844a402",
     55 }
     57 HESSIANS_URL_DICT = {
     58     "base": "https://figshare.com/ndownloader/files/42117033?private_link=2530fd0da03e18296d51",
     59     "mli_clustering": "https://figshare.com/ndownloader/files/42129435?private_link=d508ebc51d544ed8cd4c",
     60     "layer_information": "https://figshare.com/ndownloader/files/42853141?private_link=6531855c261b7bad032d",
     61     "layer_information_mli_clustering": "https://figshare.com/ndownloader/files/42853567?private_link=3a81e48aff77d844a402",
     62 }

File -\lib\site-packages\npyx\c4\run_deep_classifier.py:354
    348         new_probs = new_probs.numpy()
    350     return new_probs
    353 @require_advanced_deps("torch", "torchvision", "laplace")
--> 354 def get_kronecker_hessian_attributes(*kronecker_hessians: KronDecomposed):
    355     hessians = []
    356     for h in kronecker_hessians:

NameError: name 'KronDecomposed' is not defined
m-beau commented 5 days ago

Hi there!

It seems like you are trying to import a dependency that you shouldn't need when using the boilerplate version of npyx: would you mind uninstalling it fully and reinstalling it from pip with 'pip install npyx', and let me how that goes?

Hope you find it useful :)

Antorithms commented 4 days ago

Tried again but the error persists. Thanks for your help. Anto

m-beau commented 4 days ago

All right - can you tell me what was your exact procedure to install npyx (did you use a fresh conda environment?), and also tell me what is the installed version (you can find this out by running 'pip list' and scrolling to npyx in your terminal)