probeinterface icon indicating copy to clipboard operation
probeinterface copied to clipboard

Issue when rotating 3D probes by specifying the axis as "xy"/"yz"/"zx"

Open DrTaDa opened this issue 9 months ago • 2 comments

It is written in the docstring of the method .rotate of the class Probe that the axis is to be specified as a string:

axis : "xy" | "yz" | "xz" | None, default: None
            Axis of rotation.
            It must be None for 2D probes
            It must be given for 3D probes

Howver, that leads to an error:

File "/home/tanguy.damart/virt_env/mozaik/lib/python3.8/site-packages/probeinterface/probe.py", line 1422, in _rotation_matrix_3d
    axis = axis / np.linalg.norm(axis)
  File "<__array_function__ internals>", line 180, in norm
  File "/home/tanguy.damart/virt_env/mozaik/lib/python3.8/site-packages/numpy/linalg/linalg.py", line 2511, in norm
    x = x.astype(float)
ValueError: could not convert string to float: 'xy'

Which hapens because the function _rotation_matrix_3d expects a list or array instead of a string: https://github.com/SpikeInterface/probeinterface/blob/86e5fa45fca02a82b42c954b088a09d9cd7bb010/src/probeinterface/probe.py#L1409

DrTaDa avatar May 13 '24 12:05 DrTaDa