def load_cscdata(csc_name, maxlength=None): data = nlxio.load_ncs(csc_name) sig_data = data['data'] fs = float(data['sampling_rate']) times = data['time'] if maxlength is not None: sig_data = sig_data[:maxlength] times = times[:maxlength] times = times/1e6 times = times - times[0] times = times return sig_data, times, fs
# coding: utf-8 import neuralynxio import os import scipy.io for filename in os.listdir(os.getcwd()): if filename.endswith(".ncs") and filename.startswith("CSC"): channelname = filename.split('.')[0] rawData = [] csc = neuralynxio.load_ncs(filename) rawData.append(csc['data']) header = csc['header'] samplingRate = float(csc['sampling_rate']) scipy.io.savemat('_' + channelname + '_rawData.mat', mdict={ 'rawData': rawData, 'samplingRate': samplingRate })
""" import os, mea import warnings import numpy as np import scipy.signal as spsig import neuralynxio as nlxio import matplotlib.pyplot as plt import matplotlib.patches as patches from detect_peaks import detect_peaks warnings.filterwarnings('ignore') for filename in os.listdir(os.getcwd()): if 'CSC36' in filename and '.ncs' in filename: # load the data lfpdata = nlxio.load_ncs(filename) eeg_sig = lfpdata['data'] time = lfpdata['time'] / 1e6 # convert to seconds time = time - time[0] fs = lfpdata['sampling_rate'] del lfpdata # load the filtered ripple data f_ripple = (140, 250) filt_rip_sig = mea.get_bandpass_filter_signal(eeg_sig, fs, f_ripple) # mea.plot_lfp(eeg_sig[:fs*1000], filt_rip_sig[:fs*1000], time[:fs*1000]) # calculate the envelope of filtered data filt_rip_env = abs(spsig.hilbert(filt_rip_sig)) filt_rip_env_zscore = mea.zscore(filt_rip_env) # Root mean square (RMS) ripple power calculation
# coding: utf-8 import neuralynxio import os import scipy.io for filename in os.listdir(os.getcwd()): if filename.endswith(".ncs")and filename.startswith("CSC"): channelname = filename.split('.')[0] rawData = [] csc = neuralynxio.load_ncs(filename) rawData.append(csc['data']) header = csc['header'] samplingRate = float(csc['sampling_rate']) scipy.io.savemat('_' + channelname + '_rawData.mat', mdict = {'rawData':rawData, 'samplingRate': samplingRate})