Calculate Burst - JoseGuzman/minibrain GitHub Wiki

Import the open-ephys channel

myparams = dict(date = '2020-02-17_14-11-20', birth = '2019-07-31_00-00-00', nchan=134)
tc012 = EphysLoader('continuous.dat', **myparams)
ch43 = tc012.get_channel(43)

To calculate burst

  1. band-pass to the desired frequency
  2. Down-sample to 2x the high cutoff frequency of the band-pass
  3. Calculate the square root of the mean squared (RMS)
ch43BP = lfp.band_pass(data = ch43, low = 90, high = 250, srate = tc012.srate)`
ch43DS = lfp.decimate(data = ch43BP, q = 60) # `
ch43RMS = lfp.rms(data = ch43DS, segment = int(0.005*srate) )

# update sampling rate
srate = tc012.srate/60
dt = 1/srate

Plot a 2-minute sample

TMAX = 120 # in sec
pstart, pend = 0, int(TMAX*srate)
time = np.arange(ch43DS.size)*dt


fig, ax = plt.subplots(3,1, figsize=(16,6), sharex = True)
fig.suptitle('TSC012 Ch43')

ch43_ds = lfp.decimate(ch43, 60) # original signal: simply downsample

ax[0].plot(time[pstart:pend], ch43_ds[pstart:pend], label = 'wide-band', lw = 1)
ax[0].set_ylabel('Amplitude \n ($\mu$V)');

ax[1].plot(time[pstart:pend], ch43DS[pstart:pend], label = '90-250 Hz', lw = 1, color='k')
ax[1].set_ylabel('Amplitude \n ($\mu$V)');

ax[2].plot(time[pstart:pend], ch43RMS[pstart:pend], label = 'RMS', color = 'brown', lw =1)
ax[2].set_ylabel('RMS \n ($\mu$V)');


ax[2].set_xlabel('Time (sec.)')

for myax in ax:
    myax.legend(frameon = False, loc = 1)