Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion doc/how_to/unsigned_to_signed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ For users that receive an error because their :code:`Recording` is unsigned, the

Now with the signed dtype of the :code:`Recording` one can use a SpikeInterface pipeline as usual.


If you are curious if your :code:`Recording` is unsigned you can simply check the repr or use :code:`get_dtype()`

.. code:: python
Expand Down Expand Up @@ -89,6 +88,39 @@ while converting the data from unsigned to signed.
recording_signed = spre.unsigned_to_signed(recording_unsigned, bit_depth=12)


Reading an unsigned binary file
-------------------------------

If you have a binary file saved in unsigned integers, you can use the ``si.read_binary`` function to read it into
SpikeInterface:

.. code:: python

recording_unsigned = se.read_binary(
file_path,
sampling_frequency=30000.,
dtype=np.uint16,
num_channels=384,
gain_to_uV=3.05176,
offset_to_uV=0,
)

Note that the ``offset_to_uV`` is not meant to be used to correct for the unsigned nature of the data,
but rather to correct for any additional offset that may be present in the data (e.g., due to the recording equipment).

The ``unsigned_to_signed`` function will take care of the conversion from unsigned to signed, so you can simply pass
the ``recording_unsigned`` to it:

.. code:: python

recording_signed = spre.unsigned_to_signed(recording_unsigned, bit_depth=12)


When retrieving traces and scaling them to µV, first the data will be converted from unsigned to signed using the
specified bit depth, and then the gain and offset (in this case 0) will be applied to convert the data to µV.
This ensures that the data is correctly centered around 0 and scaled to the appropriate units for further analysis.


Additional Notes
----------------

Expand Down
Loading