def __init__(self,ABFfname=None,debugLevel=<NUM_LIT:0>,saveInfo=False):
self.valid=False<EOL>if ABFfname is None:<EOL><INDENT>return <EOL><DEDENT>if not type(ABFfname) is str:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if not ABFfname.lower().endswith("<STR_LIT>"):<EOL><INDENT>raise Exception('<STR_LIT>'%ABFfname)<EOL><DEDENT>ABFfname=os.path.abspath(ABFfname)<EOL>if not os.path.exists(ABFfname):<EOL><INDENT>raise Exception('<STR_LIT>'%ABFfname)<EOL><DEDENT>if saveInfo:<EOL><INDENT>print("<STR_LIT>",os.path.basename(ABFfname))<EOL><DEDENT>self.fname = os.path.abspath(ABFfname)<EOL>self.ID = os.path.basename(self.fname).replace("<STR_LIT>","<STR_LIT>")<EOL>self.outpath = os.path.join(os.path.split(self.fname)[<NUM_LIT:0>],"<STR_LIT>")<EOL>self.outpre = os.path.abspath(self.outpath+"<STR_LIT:/>"+self.ID+"<STR_LIT:_>") <EOL>self.reader = neo.io.AxonIO(ABFfname)<EOL>self.valid=False<EOL>try:<EOL><INDENT>self.header = self.reader.read_header()<EOL>self.block = self.reader.read_block(lazy=False, cascade=True) <EOL><DEDENT>except:<EOL><INDENT>print("<STR_LIT>")<EOL>return<EOL><DEDENT>self.valid=True<EOL>startDay=time.strptime(str(self.header["<STR_LIT>"]), '<STR_LIT>')<EOL>self.timestamp=time.mktime(startDay)+self.header["<STR_LIT>"]/<NUM_LIT> <EOL>self.units = self.header['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>'].decode('<STR_LIT:utf8>') <EOL>self.unitsCommand = self.header['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>'].decode('<STR_LIT:utf8>') <EOL>self.holding = self.header['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>'] <EOL>self.rate = int(<NUM_LIT>/self.header['<STR_LIT>']['<STR_LIT>']) <EOL>self.timebase = self.header['<STR_LIT>']['<STR_LIT>'] <EOL>self.nADC = self.header['<STR_LIT>']['<STR_LIT>']['<STR_LIT>'] <EOL>self.sweeps = self.header['<STR_LIT>']<EOL>self.gapFree=(self.sweeps==<NUM_LIT:0>)<EOL>if self.gapFree:<EOL><INDENT>self.sweeps=<NUM_LIT:1><EOL><DEDENT>self.sweepSize = self.header['<STR_LIT>']['<STR_LIT>']/self.nADC<EOL>self.sweepLength = self.sweepSize/self.rate <EOL>self.sweepInterval = self.header['<STR_LIT>']['<STR_LIT>'] <EOL>if self.sweepInterval==<NUM_LIT:0>:<EOL><INDENT>self.sweepInterval=self.sweepLength<EOL><DEDENT>self.commentTags = self.block.segments[<NUM_LIT:0>].eventarrays[<NUM_LIT:0>].annotations['<STR_LIT>']<EOL>self.commentTags = [x.decode('<STR_LIT:utf8>') for x in self.commentTags]<EOL>self.commentTimes = np.array(self.block.segments[<NUM_LIT:0>].eventarrays[<NUM_LIT:0>].times)/self.nADC<EOL>self.commentTimes = self.commentTimes/<NUM_LIT:4> <EOL>self.commentSweeps = np.array(self.commentTimes/self.sweepInterval,dtype=int)<EOL>self.baseline=[None,None] <EOL>self.decimateMethod=None <EOL>self.decimateBy=<NUM_LIT:100> <EOL>self.offsetX = int(self.sweepSize/<NUM_LIT:64>) <EOL>self.offsetY = <NUM_LIT:0> <EOL>self.dataY = None <EOL>self.dataX = None <EOL>self.dataStart = None <EOL>self.currentSweep = None <EOL>self.channel = <NUM_LIT:0> <EOL>self.generate_colormap()<EOL>self.generate_protocol()<EOL>self.protoComment=cm.determineProtocol(self.fname)<EOL>if saveInfo:<EOL><INDENT>self.saveThing(self.abfinfo(returnDict=True),'<STR_LIT:info>',overwrite=False)<EOL><DEDENT>
SWHLab4 ABF class.
        Basic usage:
            1.) call this with an ABF filename
            2.) select a sweet with setSweep()
            3.) reference data by ABF.dataX and ABF.dataY