@@ -313,6 +313,27 @@ def get_electrodes_mapping(electrodes):
313
313
314
314
315
315
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
+ """
316
337
if all (x == 1 for x in gains ):
317
338
return dict (conversion = 1e-6 , channel_conversion = None )
318
339
if all (x == gains [0 ] for x in gains ):
@@ -323,7 +344,8 @@ def gains_helper(gains):
323
344
def add_ephys_recording_to_nwb (
324
345
session_key : dict , ephys_root_data_dir ,
325
346
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
327
349
applies lossless compression to the data, so the final file might be smaller than the original, without
328
350
data loss. Currently supports Neuropixels data acquired with SpikeGLX or Open Ephys, and relies on SpikeInterface to read the data.
329
351
0 commit comments