-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Describe the bug
I am attempting to use estimate_csd without generate fake LFP data. I extract genuine lfp data from our files, but it looks like it requires a very specific format of input LFP data in the form of a neo.AnalogSignal with specific annotations and units. I have had a little bit of difficulty with manually converting my LFP data (as a np array) into a neo AnalogSignal, as I am new to neo and I'm unsure exactly what information is required as input. I've done my best to try and mimic the output of generate_lfp but at this point, I've encountered an error which I am unsure if it's a bug or not. 'TypeError: len() of unsized object`.
To Reproduce
- Run the following code after importing the relevant neo and elephant namespaces.
import quantities as pq
coords = np.array(nwb.electrodes.x)
hz = len(lfp.data) / lfp.timestamps[-1]
neo_lfp = AnalogSignal(lfp.data, units="V", sampling_rate = hz*pq.Hz, coordinates = coords * pq.mm)
csd = estimate_csd(neo_lfp, method="KCSD2D")where coords is an array of scalar values and hz is a scalar.
Traceback
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [161], line 1
----> 1 csd = estimate_csd(neo_lfp, method="KCSD2D")
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\elephant\utils.py:80, in deprecated_alias.<locals>.deco.<locals>.wrapper(*args, **kwargs)
77 @wraps(func)
78 def wrapper(*args, **kwargs):
79 _rename_kwargs(func.__name__, kwargs, aliases)
---> 80 return func(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\elephant\current_source_density.py:139, in estimate_csd(lfp, coordinates, method, process_estimate, **kwargs)
137 raise ValueError('Number of signals and coords is not same')
138 for ii in coordinates: # CHECK for Dimensionality of electrodes
--> 139 if len(ii) > 3:
140 raise ValueError('Invalid number of coordinate positions')
141 dim = len(coordinates[0]) # TODO : Generic co-ordinates!
TypeError: len() of unsized objectI suspect that it is the case that either the input coordinates ought to be provided as a 2D list, or the code which checks the length of the coordinates should cast the coordinate item in the input coordinates into a tuple of length 1.
Expected behavior
I expect either the CSD analysis to produce valid output or to be given an explanatory error.
Environment
Windows 10:
Installed elephant with pip install elephant:
Python version: 3.9.10
neo==0.12.0
numpy==1.21.5
elephant==0.12.0