Skip to content

Commit

Permalink
path
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeitgeberH committed Jun 1, 2021
1 parent 9758258 commit 02ccaa5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 84 deletions.
82 changes: 1 addition & 81 deletions HEKA_Reader_MAIN.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,36 +735,6 @@ def __getitem__(self, *args):
else:
data = np.fromfile(fh, count=trace.DataPoints, dtype=dtype)
return data * trace.DataScaler + trace.ZeroData

#class StimWave(object):
# ''' generate stim wave according to the .pgf file'''
# ''' For now, this only applies to step wise simple stimuli'''
# def __init__(self, bundle,index):
# stimTree = bundle.stim
# assert len(index) < 3 ## Do this at channel level
# stimID = index[0] ## index for stimulation record
# iC = index[1] ## index for channel record
# iSweep = index[2]
# chanRecord = stimTree[stimID].children[iC]
# sampleInteval = stimTree[stimID].SampleInterval
# stim = []
# cumSamples = 0 ## cumulated stimulation time
# cumTime = 0
# stimInfo = []
# for seg in chanRecord.children: ## go through segment one by one
# segSamples = int(seg.Duration/sampleInteval) ## convert into time
## segV0 = seg.Voltage ## initial voltage
# seg_V = seg.Voltage + iSweep*seg.DeltaVIncrement*seg.DeltaVFactor
#
## seg_dT = seg.DeltaTIncrement*seg.DeltaTFactor ## probably not necessary for stepwise type of stimuli
# stim.append(np.ones((segSamples,))*seg_V)
# stim_ = {'start': cumSamples, 'end': cumSamples + segSamples,
# 'duration': seg.Duration, 'ampitude': seg_V, 'sampleInteval': sampleInteval}
# cumSamples = cumSamples + segSamples
# cumTime = cumTime + seg.Duration
# stimInfo.append(stim_)
# time = np.arange(cumSamples)*sampleInteval
# return time, stim, stimInfo

class StimulationRecord(TreeNode):
'''
Expand Down Expand Up @@ -1135,56 +1105,6 @@ def stim(self, index):
time = np.arange(cumSamples)*sampleInteval
# stimInfo = pd.DataFrame(stimInfo)
return time, stim,stimInfo

# def stim0(self, index):
# '''
# Pgf@stimulation == Pul@series. All stimulation are collapase into the pgf tree,
# so if there are multiple groups in Pulse tree, then the series index
# need to be accumulated from the first group, rather than from that group
# level.
# '''
# stimTree = self.pgf
# assert len(index) >= 3 ## Do this at channel level
## stimID = index[0] ## index for stimulation record. This is the group level!
## iC = index[1] ## index for channel record
## iSweep = index[2]
# stimID = index[0] ## index for stimulation record. This is the accumulated series level!
# iC = 0 ## index for channel record
# iSweep = index[2]
# chanRecord = stimTree.children[stimID].children[iC]
# DacMode = int.from_bytes(chanRecord.DacMode, byteorder = self.endian) ## relative or abolute
# stim2dac = ['StimScale','StimScale, Relative','FileTemplate','FileTemplate, Relative']
# stim2dacType = stim2dac[DacMode]
# Holding = chanRecord.Holding *1000.0 ## pA
# sampleInteval = stimTree.children[stimID].SampleInterval
# stim = []
# cumSamples = 0 ## cumulated stimulation time
# stimInfo = []
# if len(index) ==4:
# traceRecord = self.pul[index[0]][index[1]][index[2]][index[3]]
## print(traceRecord)
# sealResistance = traceRecord.SealResistance
# else:
# sealResistance = np.nan
# for seg in chanRecord.children: ## go through segment one by one
# segSamples = int(seg.Duration/sampleInteval)
## segV0 = seg.Voltage ## initial voltage
# if DacMode == 1: ## relative mode
# seg_V = 1000.0*(seg.Voltage + iSweep*seg.DeltaVIncrement*seg.DeltaVFactor) +Holding
# else:
# seg_V = 1000.0*(seg.Voltage + iSweep*seg.DeltaVIncrement*seg.DeltaVFactor)
#
## seg_dT = seg.DeltaTIncrement*seg.DeltaTFactor ## probably not necessary for stepwise type of stimuli
# stim.extend(np.ones((segSamples,))*seg_V)
# stim_ = {'start': cumSamples, 'end': cumSamples + segSamples,
# 'duration': seg.Duration, 'ampitude': seg_V, 'sampleInteval': sampleInteval,
# 'Vholding': Holding, 'Stim2Dac':stim2dacType,'sealresistance':sealResistance}
# cumSamples = cumSamples + segSamples
# stimInfo.append(stim_)
#
# time = np.arange(cumSamples)*sampleInteval
## stimInfo = pd.DataFrame(stimInfo)
# return time, stim,stimInfo


def __repr__(self):
return "Bundle(%r)" % list(self.catalog.keys())
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
from HekaHelpers import HekaBundleInfo

## read Heka .dat file into a object
bundleTester = HekaBundleInfo(makePath(DataPath, testFile))
# test file is the full path for your Heka .dat file
bundleTester = HekaBundleInfo(testFile))

## Get sample rate
traceIndex = [0,0,0,0] ## [Group, Series, Sweep, Trace]
bundleTester.getSeriesSamplingRate(traceIndex)

## Get stimuli information
traceIndex = [0,0,0,0]
time, stim, stimInfo = bundleTester.getStim(traceIndex)

## Get data from a single sweep and single channel
traceIndex = [0,0,0,0]
data = bundleTester.getSingleTraceData(traceIndex)
```

0 comments on commit 02ccaa5

Please sign in to comment.