Skip to content

Commit f40d93b

Browse files
authored
Extend unsigned to signed docs (#4448)
1 parent 6a9966e commit f40d93b

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

doc/how_to/unsigned_to_signed.rst

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ For users that receive an error because their :code:`Recording` is unsigned, the
5353
5454
Now with the signed dtype of the :code:`Recording` one can use a SpikeInterface pipeline as usual.
5555

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

5958
.. code:: python
@@ -89,6 +88,39 @@ while converting the data from unsigned to signed.
8988
recording_signed = spre.unsigned_to_signed(recording_unsigned, bit_depth=12)
9089
9190
91+
Reading an unsigned binary file
92+
-------------------------------
93+
94+
If you have a binary file saved in unsigned integers, you can use the ``si.read_binary`` function to read it into
95+
SpikeInterface:
96+
97+
.. code:: python
98+
99+
recording_unsigned = se.read_binary(
100+
file_path,
101+
sampling_frequency=30000.,
102+
dtype=np.uint16,
103+
num_channels=384,
104+
gain_to_uV=3.05176,
105+
offset_to_uV=0,
106+
)
107+
108+
Note that the ``offset_to_uV`` is not meant to be used to correct for the unsigned nature of the data,
109+
but rather to correct for any additional offset that may be present in the data (e.g., due to the recording equipment).
110+
111+
The ``unsigned_to_signed`` function will take care of the conversion from unsigned to signed, so you can simply pass
112+
the ``recording_unsigned`` to it:
113+
114+
.. code:: python
115+
116+
recording_signed = spre.unsigned_to_signed(recording_unsigned, bit_depth=12)
117+
118+
119+
When retrieving traces and scaling them to µV, first the data will be converted from unsigned to signed using the
120+
specified bit depth, and then the gain and offset (in this case 0) will be applied to convert the data to µV.
121+
This ensures that the data is correctly centered around 0 and scaled to the appropriate units for further analysis.
122+
123+
92124
Additional Notes
93125
----------------
94126

0 commit comments

Comments
 (0)