int-brain-lab / ONE

Open Neurophysiology Environment
MIT License
16 stars 4 forks source link

Can't import spikeglx module for python, nor does it seem available. Can't work with the LFP consequently. #102

Closed AngCamp closed 9 months ago

AngCamp commented 9 months ago

I am trying to use the following tutorials as a guide to work with the LPF data: https://int-brain-lab.github.io/iblenv/notebooks_external/loading_raw_ephys_data.html#Example-2:-Stream-LFP-data-around-task-event

But it seems to require two libraries I'm not familiar with and are not part of the API. I am having particular trouble getting spikeglx which is needed to read the LFP data. I cannot find a python library for it spikeglx and running pip install spikeglx does not load it into my conda environment.

(ONE_ibl_env) [acampbell@itchy ~]$ pip install spikeglx
ERROR: Could not find a version that satisfies the requirement spikeglx (from versions: none)
ERROR: No matching distribution found for spikeglx

I ahve installed ibllib and brainbox in addition to the ONE-api but many of the things needed in your tutorials do not load when called. For instance this code from page 25 of your documentation does not load spikeglx

EXAMPLE CODE:

# the following examples will read and convert to Volts
from ibllib.io import spikeglx
lf_file = "/path/to/my/_spikeglx_ephysData_g0_t0.imec1.lf.cbin"
sr = spikeglx.Reader(lf_file)
sr[0:10000]
# this assumes you have 3 files on disk:
# _spikeglx_ephysData_g0_t0.imec1.lf.cbin
# _spikeglx_ephysData_g0_t0.imec1.lf.meta
# _spikeglx_ephysData_g0_t0.imec1.lf.ch

When I run from ibllib.io import spikeglx I just get an error. Note that running import ibllib or import ibllib both work just fine. ERROR:

import ibllib.io
from ibllib.io import spikeglx
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/home/acampbell/Stienmetz2019Reanalyzed/ExtractingSWRs/ibl_swr_data/ibl_swr_detector_testing.ipynb Cell 11 line 2
      [1](vscode-notebook-cell://ssh-remote%2Bitchy.msl.ubc.ca/home/acampbell/Stienmetz2019Reanalyzed/ExtractingSWRs/ibl_swr_data/ibl_swr_detector_testing.ipynb#X41sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0) import ibllib.io 
----> [2](vscode-notebook-cell://ssh-remote%2Bitchy.msl.ubc.ca/home/acampbell/Stienmetz2019Reanalyzed/ExtractingSWRs/ibl_swr_data/ibl_swr_detector_testing.ipynb#X41sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1) from ibllib.io import spikeglx
ImportError: cannot import name 'spikeglx' from 'ibllib.io' (/home/acampbell/miniconda3/envs/ONE_ibl_env/lib/python3.10/site-packages/ibllib/io/__init__.py)

In summary the LFP tutorials are not very much help and there is not explanation for how to load many of the libraries needed to run those tutorials. I was able to track down ibllib and brainbox myself but it is not clear how to get spikeglx working. Is it possible to use some functionality from the npyx library?

mayofaulkner commented 9 months ago

Hello, you will need to install a package called ibl-neuropixel

You can install it using pip install ibl-neuropixel

Alternatively it is also contained within ibllib which can be installed using pip install ibllib