Python APIs

In addition to the GUI interface, you can also access data in Python via two ways:

Heka APIs

Code snippet shows how to read data from original Heka .dat file.

 1## import HekaHelpers which is a wrapper of main file: HEKA_Reader_MAIN
 2from patchview.HekaIO.HekaHelpers import HekaBundleInfo
 3
 4## read Heka .dat file into a object
 5# test file is the full path for your Heka .dat file
 6bundleTester = HekaBundleInfo(testFile)
 7
 8## Get sample rate
 9traceIndex = [0,0,0,0] ## [Group, Series, Sweep, Trace]
10bundleTester.getSeriesSamplingRate(traceIndex)
11
12## Get stimuli information
13time, stim, stimInfo = bundleTester.getStim(traceIndex)
14
15## Get data from a single sweep and single channel
16data = bundleTester.getSingleTraceData(traceIndex)

NWB (NeurodataWithoutBorders) APIs

Code snippet shows how to convert data from original Heka .dat file into NWB format.

 1from patchview.utilitis.PVdat2NWB import dat2NWB
 2
 3seriesIndex = [0,0] # [Group, Series]
 4data = dat2NWB(testFile, seriesIndex) # read data as NWB format
 5
 6## get number of sweeps
 7print(f'Number of sweeps: {data.getNumberOfSweeps()}')
 8
 9## data is now a NWB object with additional plotting functions
10stim, resp = nwbData.getSweep(0) # get one sweep's stimulus and responses
11
12## directly plot sweep 0, 5, 20
13data.plotSweep([0, 5, 20]) # plot three sweeps

The last command in the block above should give you a figure like this:

Alternative text