def _getStims(ds,prefChans,thresh1,thresh2,pth=None): """ FUNCTION: Find the active stimulus channel and triger each discrete stimulus presentation. INs: ds= data array prefChans= ordered vector of the numbers of the stimulus channels in ds. thresh1= first dectection threshold thresh2= second detection threshold """ _findStims(ds,prefChans,thresh1,thresh2,pth=pth) dataDict = ds.getHierarchy() events=dataDict['/tmpname'].getData()[:,0] hdr = {'SampleType':'events','SamplesPerSecond':ds.header()['SamplesPerSecond']} ds.createSubData('/tmpnametot',events,hdr) gicc.isolateSpikes(ds,'/tmpnametot','/evts',0.0,30.0,absolute=False) dataDict = ds.getHierarchy() dataDict['/tmpname'].sever() dataDict['/tmpnametot'].sever() if not '/evts' in dataDict or dataDict['/evts'].shape()[0] == 0: print('Could not find an active stimulus channel')
def _unique_events_from_stims(ds,twin=120.): #used after _getStims, takes a dataset with a '/tmpname' child holding stimulus events on various channels and gets all the times of all the mulitchannel stimulus presentations twin = float(twin) dataDict = ds.getHierarchy() events=dataDict['/tmpname'].getData()[:,0] #print 'all events', events, dataDict['/tmpname'].getData(), dataDict.keys() hdr = {'SampleType':'events','SamplesPerSecond':ds.header()['SamplesPerSecond']} ds.createSubData('/tmpnametot',events,hdr) gicc.isolateSpikes(ds,'/tmpnametot','/evts',0.,twin,absolute=False) for m in range(4):#isolate spikes on each channel nam='/tmpname'+str(m) localevents=dataDict['/tmpname'].getData() #print 'bfr',localevents localevents=localevents[where(localevents[:,1]==m),0] hdr = {'SampleType':'events','SamplesPerSecond':ds.header()['SamplesPerSecond']} #print 'aftr',localevents ds.createSubData(nam,localevents.squeeze(),hdr) gicc.isolateSpikes(ds,nam,nam,0.,twin,absolute=False)#note that repeats slower than 30Hz cause problems here dataDict = ds.getHierarchy() events = dataDict['/evts'].getData() return events