question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Multisorting - Extraction from pickle

See original GitHub issue

After dumping a multisorting using (multisorting.dump_to_pickle(output_folder / ‘sorting.pkl’)). It can’t be revovered using se.load_extractor_from_pickle(output_folder / ‘sorting.pkl’). The following error occurs:


KeyError Traceback (most recent call last) <ipython-input-53-040ccfef509c> in <module> ----> 1 multisorting = se.load_extractor_from_pickle(‘/data/sarah/MEA/20210504/C25/829/low/1/merged/sorting.pkl’)

~/miniconda3/envs/spikesorting/lib/python3.8/site-packages/spikeextractors-0.9.6-py3.8.egg/spikeextractors/extraction_tools.py in load_extractor_from_pickle(pkl_file) 747 The loaded extractor object 748 “”" –> 749 return BaseExtractor.load_extractor_from_pickle(pkl_file) 750 751

~/miniconda3/envs/spikesorting/lib/python3.8/site-packages/spikeextractors-0.9.6-py3.8.egg/spikeextractors/baseextractor.py in load_extractor_from_pickle(pkl_file) 497 with open(str(pkl_file), ‘rb’) as f: 498 d = pickle.load(f) –> 499 extractor = _load_extractor_from_dict(d[‘serialized_dict’]) 500 if ‘properties’ in d.keys(): 501 extractor._properties = d[‘properties’]

KeyError: ‘serialized_dict’

Looking at the keys of the pickled file it didn’t create the ‘serialized_dict’ necessary for instantiating the extractor:


import pickle
with open(output_folder / 'sorting.pkl', 'rb') as f:
        d=pickle.load(f)
        print(d.keys())

gives:

dict_keys([‘class’, ‘module’, ‘kwargs’, ‘dumpable’, ‘version’, ‘relative_paths’, ‘annotations’, ‘properties’])

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcbuecommented, Aug 2, 2021

Hi @alejoe91

sorry you are right I was mixing packages. I just tried the same approach using the si.load_extractor() function and loading from pickle works! Thanks for the clarification!

0reactions
alejoe91commented, Aug 2, 2021

Closing the issue then 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Known Bug in Python Pickle? - Stack Overflow
when class instances are pickled, their class's code and data are not pickled along with them. Only the instance data are pickled.
Read more >
Mirroring of output data in pickle file [BUG] · Issue #84 · mkocabas ...
I have extracted 3D joint positions and vertices and plotted them in python, and they seem to be mirrored when compared to the...
Read more >
API — spikeinterface documentation - Read the Docs
Dumps recording extractor to a pickle file. ... A class that contains functions for extracting important information from recorded extracellular data.
Read more >
pickle — Python object serialization — Python 3.11.1 ...
Only the instance data are pickled. This is done on purpose, so you can fix bugs in a class or add methods to...
Read more >
Pickle in Python Tutorial: Object Serialization - DataCamp
Discover the Python pickle module: learn about serialization, when (not) to use it, how to compress pickled objects, multiprocessing, and much more!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found