Skip to content

Commit 12974ff

Browse files
committed
add docstring for gain_helper
1 parent 00c3691 commit 12974ff

File tree

1 file changed

+23
-1
lines changed
  • element_array_ephys/export/nwb

1 file changed

+23
-1
lines changed

element_array_ephys/export/nwb/nwb.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,27 @@ def get_electrodes_mapping(electrodes):
313313

314314

315315
def gains_helper(gains):
316+
"""
317+
This handles three different cases for gains:
318+
1. gains are all 1. In this case, return conversion=1e-6, which applies to all
319+
channels and converts from microvolts to volts.
320+
2. Gains are all equal, but not 1. In this case, multiply this by 1e-6 to apply this
321+
gain to all channels and convert units to volts.
322+
3. Gains are different for different channels. In this case use the
323+
`channel_conversion` field in addition to the `conversion` field so that each
324+
channel can be converted to volts using its own individual gain.
325+
326+
Parameters
327+
----------
328+
gains: np.ndarray
329+
330+
Returns
331+
-------
332+
dict
333+
conversion : float
334+
channel_conversion : np.ndarray
335+
336+
"""
316337
if all(x == 1 for x in gains):
317338
return dict(conversion=1e-6, channel_conversion=None)
318339
if all(x == gains[0] for x in gains):
@@ -323,7 +344,8 @@ def gains_helper(gains):
323344
def add_ephys_recording_to_nwb(
324345
session_key: dict, ephys_root_data_dir,
325346
nwbfile: pynwb.NWBFile, end_frame: int = None):
326-
"""Read voltage data directly from source files and iteratively transfer them to the NWB file. Automatically
347+
"""
348+
Read voltage data directly from source files and iteratively transfer them to the NWB file. Automatically
327349
applies lossless compression to the data, so the final file might be smaller than the original, without
328350
data loss. Currently supports Neuropixels data acquired with SpikeGLX or Open Ephys, and relies on SpikeInterface to read the data.
329351

0 commit comments

Comments
 (0)