Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel labels cause ValueError under some, but not all conditions #10

Open
nimrodlbr opened this issue Mar 8, 2022 · 2 comments
Open

Comments

@nimrodlbr
Copy link

Hi there!
thanks for writing this package :)

After recording an Open-Ephys format recording, while creating the Session object the attached error pops up, it is possible to work with the recording when all channels with names ending with "...AUXx.continuous" (with x being a number) are moved to a different directory

I think there might be a problem with the naming scheme expectation of the code Vs. the AUX channels implementation in the Open-Ephys recording format

Thank you for the attention, and please let me know if this is a usage issue and I should be doing something differently

here is the error report:
"---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
c:\users\marks3\pycharmprojects\pythonproject3\venv\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py in init(self, files, processor_id, recording_index)
59 try:
---> 60 channel_number = int(os.path.basename(file).split('_')[1].split('.')[0].split('H')[1])
61 except IndexError:

IndexError: list index out of range

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
1 session = oea.Session(block.oe_path)
----> 2 session.recordings[0].continuous
3

c:\users\marks3\pycharmprojects\pythonproject3\venv\lib\site-packages\open_ephys\analysis\recording.py in continuous(self)
62 def continuous(self):
63 if self._continuous is None:
---> 64 self.load_continuous()
65 return self._continuous
66

c:\users\marks3\pycharmprojects\pythonproject3\venv\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py in load_continuous(self)
118 for fname in files]))
119
--> 120 self._continuous = [self.Continuous(files, processor_id, self.recording_index)
121 for processor_id in processor_ids]
122

c:\users\marks3\pycharmprojects\pythonproject3\venv\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py in (.0)
118 for fname in files]))
119
--> 120 self._continuous = [self.Continuous(files, processor_id, self.recording_index)
121 for processor_id in processor_ids]
122

c:\users\marks3\pycharmprojects\pythonproject3\venv\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py in init(self, files, processor_id, recording_index)
60 channel_number = int(os.path.basename(file).split('')[1].split('.')[0].split('H')[1])
61 except IndexError:
---> 62 channel_number = int(os.path.basename(file).split('
')[1].split('.')[0]) - 1
63
64 if start_index is None:

ValueError: invalid literal for int() with base 10: 'AUX1'"

@akesner1
Copy link

akesner1 commented Apr 5, 2022

TL;DR --- For data recorded in OpenEphys format.... I think something is whacky with having the AUX files from the intan headstage accelerometers in the folder with the continuous data. It is messing up either the loading or accessing of the session.recordings[0].continuous.XYZ data.

I believe I am having a similar error. It may not have to do with the naming of the AUX channels, since mine are named similar to the other continuous channels (EG. 107_9.continuous is a regular microwire channel, and 107_129.continuous is an AUX channel from the headstage). When I have the 3 AUX channels (the accelerometer) in the folder I used to make the session, I get the following error:

Traceback (most recent call last):

File \niaaa-fcdat2\labdata5_LIN\LIN\Drew_K\Programs\Python\optoDBS_plasticity\optoDBS_plast_OeP_20200405.py:26 in
data_continuous = session.recordings[0].continuous[0].samples

File ~\Anaconda3\envs\oep\lib\site-packages\open_ephys\analysis\recording.py:64 in continuous
self.load_continuous()

File ~\Anaconda3\envs\oep\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py:120 in load_continuous
self._continuous = [self.Continuous(files, processor_id, self.recording_index)

File ~\Anaconda3\envs\oep\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py:120 in
self._continuous = [self.Continuous(files, processor_id, self.recording_index)

File ~\Anaconda3\envs\oep\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py:69 in init
self.samples[:,channel_number-start_index] = samples

IndexError: index -91 is out of bounds for axis 1 with size 19

If I remove those three AUX channels from the folder, and load up the session, the continuous channels are loaded, at least in a way I can work with.

Here is the simple script to load the session and then assign the the continuous channels (16 of them) to a variable to play with:

#%% Load data

from open_ephys.analysis import Session
import numpy as np

#Below just uses GUI file explore method
from tkinter import filedialog
from tkinter import *

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
print("choose folder with OeP data")
directory = filedialog.askdirectory()
print(" folder: "+directory)

session = Session(directory)

data_events = session.recordings[0].events
data_continuous = session.recordings[0].continuous[0].samples

Note, even with the AUX files in the directory, the data_events variable above is assigned fine... it is just trying to access the continuous data (samples, timestamps, etc) that was giving the index error every time - again, until I removed the AUX files from the directory.

All of this is with a fresh anaconda environment with just the necessary packages to install the open_ephys.analysis suite and Spyder.

@akesner1
Copy link

akesner1 commented Apr 5, 2022

sorry, i have no clue why some of that was bolded, and the whole thing was formatted weird :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants