Esempio n. 1
0
    def __init__(self, normalise_seconds = True):
        self.dir_path = '/Users/Jonathan/Dropbox/EEG/'
        self.annotation_file = 'seizures_Rat8_20-271015.xlsx'

        self.normalise_seconds = True


        annotations = pd.read_excel(self.dir_path+self.annotation_file, index_col=False)

        annotations.columns = ['fname','start','end']
        #self.annotations = annotations.dropna(axis=0, how='all')

        fname = annotations.iloc[1,0]
        start = annotations.iloc[1,1]
        end = annotations.iloc[1,2]
        duration = start - end

        print start,end,duration,file
        fname = 'M1445362612.ndf'
        ndf = NDFLoader(self.dir_path+'ndf/'+fname, print_meta=True)
        ndf.load(8)

        np.set_printoptions(precision=3, suppress = True)
        ictal_time = ndf.time[(ndf.time >= start) & (ndf.time <= end)]
        ictal_data = ndf.data[(ndf.time >= start) & (ndf.time <= end)]

        plt.plot(ictal_time,ictal_data)
        #plt.plot(ndf.time[:5120], ndf.data[:5120])
        plt.show()
Esempio n. 2
0
    def _load_ictal_raw(self):
        self.f = h5py.File('ictal_file.hdf5', 'w')
        # only going to load a ndf with max of two seizures in it  - will fail with three!
        for i in xrange(self.annotations.shape[0]):
            #for i in xrange(1):
            fname = self.annotations.iloc[i, 0]
            start = self.annotations.iloc[i, 1]
            end = self.annotations.iloc[i, 2]
            print fname, end, start

            ndf = NDFLoader(self.dir_path + 'ndf/' + fname, print_meta=True)
            ndf.load(8)
            ndf.glitch_removal(plot_glitches=False, print_output=True)
            ndf.correct_sampling_frequency()

            np.set_printoptions(precision=3, suppress=True)
            ictal_time = ndf.time[(ndf.time >= start) & (ndf.time <= end)]
            ictal_data = ndf.data[(ndf.time >= start) & (ndf.time <= end)]

            #print ictal_data.shape[0]
            #print ictal_time.shape
            try:
                self.fname_dset = self.f.create_dataset(
                    fname, (ictal_data.shape[0], 2), dtype='float')
            except:
                self.fname_dset = self.f.create_dataset(
                    fname + '_' + str(2), (ictal_data.shape[0], 2),
                    dtype='float')

            self.fname_dset[:, 0] = ictal_time
            self.fname_dset[:, 1] = ictal_data