Пример #1
0
def spike_detect(ar,threshold = .008):
    ''' detect spikes in trace using spike_sort extract function '''
    d = np.array([ar])  # pecularity of spike_sort function requires array of trace arrays ([data_array,])
    dic = {'data' : d,'FS' : sr,'n_contacts' : 1}
    spt = extract.detect_spikes(dic,edge = 'falling', thresh = threshold)
    sp_win = [-1,1]
    if len(spt['data'])>0:  # if spikes detected, then align on peak
        spt = extract.align_spikes(dic,spt, sp_win, type = 'max', resample = 1)
    spike_ar = np.zeros(len(spt['data']))
    for i,spike in enumerate(spt['data']):
        spike_ar[i] = int((spike/1000)*sr)  # convert time from milliseconds to samples
    return(spike_ar)
Пример #2
0
#!/usr/bin/env python
#coding=utf-8

from spike_sort.io.filters import PyTablesFilter
from spike_sort import extract
from spike_sort import features
from spike_sort import cluster
from spike_sort.ui import plotting
import os

dataset = '/SubjectA/session01/el1'
datapath = '../../../data/tutorial.h5'

io_filter = PyTablesFilter(datapath)
raw = io_filter.read_sp(dataset)
spt = extract.detect_spikes(raw, contact=3, thresh='auto')

sp_win = [-0.2, 0.8]
spt = extract.align_spikes(raw, spt, sp_win, type="max", resample=10)
sp_waves = extract.extract_spikes(raw, spt, sp_win)
sp_feats = features.combine(
    (features.fetP2P(sp_waves), features.fetPCs(sp_waves)))

clust_idx = cluster.cluster("gmm", sp_feats, 4)
plotting.plot_features(sp_feats, clust_idx)
plotting.show()
io_filter.close()
Пример #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from spike_sort.io.filters import PyTablesFilter
from spike_sort import extract
from spike_sort import features
from spike_sort import cluster
from spike_sort.ui import plotting
import os

dataset = '/SubjectA/session01/el1'
datapath = '../../../data/tutorial.h5'

io_filter = PyTablesFilter(datapath)
raw = io_filter.read_sp(dataset)
spt = extract.detect_spikes(raw,  contact=3, thresh='auto')

sp_win = [-0.2, 0.8]
spt = extract.align_spikes(raw, spt, sp_win, type="max", resample=10)
sp_waves = extract.extract_spikes(raw, spt, sp_win)
sp_feats = features.combine(
     (
      features.fetP2P(sp_waves),
      features.fetPCA(sp_waves)
     )
)
   
plotting.plot_features(sp_feats)
plotting.show()