Skip to content

[Bug] ValueError in generate_lfp for one-dimensional input #98

@Moritz-Alexander-Kern

Description

@Moritz-Alexander-Kern

Describe the bug

Running the function generate_lfp with one-dimensional input results in a ValueError.

To Reproduce

  1. Define an array xs to x coordinate values with a length of 2304
  2. Run generate_lfp(gauss_1d_dipole, xs)
  3. See the resulting error. (Traceback shown below)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In [22], line 1
----> 1 lfp = generate_lfp(gauss_1d_dipole, xs)

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:302, in generate_lfp(csd_profile, x_positions, y_positions, z_positions, x_limits, y_limits, z_limits, resolution)
    300 chrg_x = x
    301 csd = csd_profile(chrg_x)
--> 302 pots = integrate_1D(x_positions, chrg_x, csd, h)
    303 pots /= 2. * sigma  # eq.: 26 from Potworowski et al
    304 ele_pos = x_positions

File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\elephant\current_source_density.py:263, in generate_lfp.<locals>.integrate_1D(x0, csd_x, csd, h)
    262 def integrate_1D(x0, csd_x, csd, h):
--> 263     m = np.sqrt((csd_x - x0) ** 2 + h ** 2) - abs(csd_x - x0)
    264     y = csd * m
    265     I = simps(y, csd_x)

ValueError: operands could not be broadcast together with shapes (50,) (2304,) 

Expected behavior I expected the function to return an array of LFP values.

Environment

  • Windows 10:
  • Installed elephant with pip install elephant:
  • Python version: 3.9.10
  • neo==0.12.0
  • numpy==1.21.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions