Commits

Anonymous committed 1c5decf

add utilites to plottraces, docs, update test

  • Participants
  • Parent commits ada647a

Comments (0)

Files changed (4)

File axonbinaryfile/README.rst

+Remember to rerun hdr_parse.py
+to regenerate the c snippet

File axonbinaryfile/__init__.py

 import _abf
-import exception
-class AbfNotSupported(exception.Exception):
+import exceptions
+class AbfNotSupported(exceptions.Exception):
     pass
 
     

File axonbinaryfile/test_abf.py

 import _abf, pprint
-a,data =  _abf.read_file('c:/src/py/python-axonbinaryfile/tests/pclamp10v2abf-1.abf')
+a,data =  _abf.read_episodic_file('../tests/pclamp10v2abf-1.abf')
 open('test-md.txt.compare', 'wb+').write(pprint.pformat(a))
 # ADCChannelName
+s = _abf.get_cmdwaveform('../tests/pclamp10v2abf-1.abf', 0,0)

File axonbinaryfile/utils/plottraces.py

+import axonbinaryfile as abf
+import pylab
+import numpy as np
+
+def plottraces(abff,time='ms'):
+    m = abff.arr
+    trnum, signum, numsamples = m.shape
+    print "trnum, signum, numsamples:", trnum, signum, numsamples
+    if time=='ms':
+        t_ms = np.arange(numsamples,dtype='float64')*abff.sample_interval_us/1000.0
+    else:
+        t_ms = np.arange(numsamples)
+    pylab.figure()
+    pylab.subplot(signum,1,1)
+    for ss in range(signum):
+        pylab.subplot(signum,1,ss+1)
+        pylab.ylabel(abff.header['ADCUnits'][ss])
+        for tt in range(trnum):
+            pylab.plot(t_ms, m[tt,ss])
+
+    pylab.xlabel('ms')
+
+
+def plottraces_allback_noticks(abff,time='ms', fmts='-k'):
+    m = abff.arr
+    trnum, signum, numsamples = m.shape
+    print "trnum, signum, numsamples:", trnum, signum, numsamples
+    if time=='ms':
+        t_ms = np.arange(numsamples,dtype='float64')*abff.sample_interval_us/1000.0
+    else:
+        t_ms = np.arange(numsamples)
+    pylab.figure()
+    pylab.subplot(signum,1,1)
+    for ss in range(signum):
+        pylab.subplot(signum,1,ss+1, frameon=False)
+        pylab.ylabel(abff.header['ADCUnits'][ss])
+        for tt in range(trnum):
+            pylab.plot(t_ms, m[tt,ss], fmts)
+            pylab.xticks([])
+            pylab.yticks([])
+    pylab.xlabel('ms')
+
+def plottraces_allback(abff,time='ms', fmts='-k'):
+    m = abff.arr
+    trnum, signum, numsamples = m.shape
+    print "trnum, signum, numsamples:", trnum, signum, numsamples
+    if time=='ms':
+        t_ms = np.arange(numsamples,dtype='float64')*abff.sample_interval_us/1000.0
+    else:
+        t_ms = np.arange(numsamples)
+    pylab.figure()
+    pylab.subplot(signum,1,1)
+    for ss in range(signum):
+        pylab.subplot(signum,1,ss+1)
+        pylab.ylabel(abff.header['ADCUnits'][ss])
+        for tt in range(trnum):
+            pylab.plot(t_ms, m[tt,ss], fmts)
+
+    pylab.xlabel('ms')
+
+
+def ivcurve(at_ms,abf):
+    mspersample = abf.sample_interval_us / 1000.0
+    smpl_at = int(at_ms / mspersample)
+
+    # I=g*V
+    m = abf.arr
+    trnum, signum, numsamples = abf.arr.shape
+    # 2 x trnum # (signum assume is 2)
+    iv = np.zeros((trnum, 2), dtype='float')
+    for tr in range(trnum):
+        pa = m[tr, 0, smpl_at]
+        mv = m[tr, 1, smpl_at]
+        g = (mv,pa)
+        iv[tr,0]=mv
+        iv[tr,1]=pa
+    return iv
+
+def plottraces_ap(abff,time='ms', ticks=True, fmts='-k', t0=0,t1=None):
+    ms2sample = 1000.0/abff.sample_interval_us
+    if t1:
+        x0,x1 = int(t0*ms2sample), int(t1*ms2sample)
+    m = abff.arr
+    trnum, signum, numsamples = m.shape
+    if t1:
+        numsamples = x1-x0
+    else:
+        x0 = 0
+        x1 = numsamples
+        
+    print "trnum, signum, numsamples:", trnum, signum, numsamples
+    if time=='ms':
+        t_ms = np.arange(x1-x0,dtype='float64')*abff.sample_interval_us/1000.0
+    else:
+        t_ms = np.arange(numsamples)
+    pylab.figure()
+    pylab.subplot(signum,1,1)
+    for ss in range(signum):
+        pylab.subplot(signum,1,ss+1, frameon=False)
+        pylab.ylabel(abff.header['ADCUnits'][ss])
+        for tt in range(trnum):
+            pylab.plot(t_ms, m[tt,ss,x0:x1], fmts)
+            if not ticks:
+                pylab.xticks([])
+                pylab.yticks([])
+    pylab.xlabel('ms')