예제 #1
0
def test_2_old():
    import time
    start = time.time()

    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == 'WORD']

    # selecting only one session
    base_events = base_events[base_events.eegfile == base_events[0].eegfile]

    from ptsa.data.readers.TalReader import TalReader
    tal_path = '/Users/m/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'
    tal_reader = TalReader(tal_filename=tal_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    print 'bipolar_pairs=', bipolar_pairs

    from ptsa.data.experimental.TimeSeriesEEGReader import TimeSeriesEEGReader

    time_series_reader = TimeSeriesEEGReader(events=base_events, start_time=0.0,
                                             end_time=1.6, buffer_time=1.0, keep_buffer=True)

    base_eegs = time_series_reader.read(channels=monopolar_channels)

    # base_eegs = base_eegs[:, 0:10, :]
    # bipolar_pairs = bipolar_pairs[0:10]


    wf = MorletWaveletFilter(time_series=base_eegs,
                             freqs=np.logspace(np.log10(3), np.log10(180), 2),
                             # freqs=np.array([3.]),
                             output='power',
                             # resamplerate=50.0
                             )

    pow_wavelet, phase_wavelet = wf.filter()

    print 'total time = ', time.time() - start

    res_start = time.time()

    # from ptsa.data.filters.ResampleFilter import ResampleFilter
    # rsf = ResampleFilter (resamplerate=50.0)
    # rsf.set_input(pow_wavelet)
    # pow_wavelet = rsf.filter()



    print 'resample_time=', time.time() - res_start
    return pow_wavelet
예제 #2
0
def test_2():
    import time
    start = time.time()

    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path,
                                    eliminate_events_with_no_eeg=True,
                                    use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == 'WORD']

    # selecting only one session
    base_events = base_events[base_events.eegfile == base_events[0].eegfile]

    from ptsa.data.readers.TalReader import TalReader
    tal_path = '/Users/m/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'
    tal_reader = TalReader(tal_filename=tal_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    print 'bipolar_pairs=', bipolar_pairs

    from ptsa.data.experimental.TimeSeriesEEGReader import TimeSeriesEEGReader

    time_series_reader = TimeSeriesEEGReader(events=base_events,
                                             start_time=0.0,
                                             end_time=1.6,
                                             buffer_time=1.0,
                                             keep_buffer=True)

    base_eegs = time_series_reader.read(channels=monopolar_channels)

    # base_eegs = base_eegs[:, 0:10, :]
    # bipolar_pairs = bipolar_pairs[0:10]

    wf = MorletWaveletFilter(
        time_series=base_eegs,
        # bipolar_pairs=bipolar_pairs,
        freqs=np.logspace(np.log10(3), np.log10(180), 2),
        # freqs=np.array([3.]),
        output='power',
        # resamplerate=50.0
    )

    pow_wavelet, phase_wavelet = wf.filter()

    print 'total time = ', time.time() - start

    return pow_wavelet
예제 #3
0
 def read_base_events(self):
     base_e_reader = BaseEventReader(event_file=self.e_path,
                                     eliminate_events_with_no_eeg=True,
                                     use_ptsa_events_class=False)
     base_e_reader.read()
     base_events = base_e_reader.get_output()
     base_events = base_events[base_events.type == 'WORD']
     base_ev_order = np.argsort(base_events,
                                order=('session', 'list', 'mstime'))
     base_events = base_events[base_ev_order]
     base_events = base_events[self.event_range]
     return base_events
예제 #4
0
    def read_base_events(self):

        base_e_reader = BaseEventReader(event_file=self.e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)


        base_e_reader.read()

        base_events = base_e_reader.get_output()

        base_events = base_events[base_events.type == 'WORD']

        base_ev_order = np.argsort(base_events, order=('session','list','mstime'))
        base_events = base_events[base_ev_order]

        base_events = base_events[self.event_range]

        return base_events
def test_1_old():
    import time
    start = time.time()

    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path,
                                    eliminate_events_with_no_eeg=True,
                                    use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == 'WORD']

    # selecting only one session
    base_events = base_events[base_events.eegfile == base_events[0].eegfile]

    from ptsa.data.readers.TalReader import TalReader
    tal_path = '/Users/m/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'
    tal_reader = TalReader(tal_filename=tal_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    print('bipolar_pairs=', bipolar_pairs)

    from ptsa.data.experimental.TimeSeriesSessionEEGReader import TimeSeriesSessionEEGReader

    # time_series_reader = TimeSeriesSessionEEGReader(events=base_events, channels = ['002', '003', '004', '005'])
    time_series_reader = TimeSeriesSessionEEGReader(
        events=base_events, channels=monopolar_channels)
    ts_dict = time_series_reader.read()

    first_session_data = list(ts_dict.items())[0][1]

    print(first_session_data)

    wavelet_start = time.time()

    wf = MorletWaveletFilterSimple(
        time_series=first_session_data,
        freqs=np.logspace(np.log10(3), np.log10(180), 2),
        # freqs=np.array([3.]),
        output='power',
        # resamplerate=50.0
    )

    pow_wavelet, phase_wavelet = wf.filter()
    print('wavelet total time = ', time.time() - wavelet_start)
    # return pow_wavelet

    from ptsa.data.experimental.EventDataChopper import EventDataChopper
    edcw = EventDataChopper(events=base_events,
                            event_duration=1.6,
                            buffer=1.0,
                            data_dict={base_events[0].eegfile: pow_wavelet})

    chopped_wavelets = edcw.filter()

    chopped_wavelets = list(chopped_wavelets.items())[0][
        1]  # getting first item of return dictionary

    print('total time = ', time.time() - start)
    #
    # from ptsa.data.filters.ResampleFilter import ResampleFilter
    # rsf = ResampleFilter (resamplerate=50.0)
    # rsf.set_input(chopped_wavelets)
    # chopped_wavelets_resampled = rsf.filter()
    #
    # return chopped_wavelets_resampled
    return chopped_wavelets
예제 #6
0
def test_1_old():
    import time
    start = time.time()

    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == 'WORD']

    # selecting only one session
    base_events = base_events[base_events.eegfile == base_events[0].eegfile]

    from ptsa.data.readers.TalReader import TalReader
    tal_path = '/Users/m/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'
    tal_reader = TalReader(tal_filename=tal_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    print 'bipolar_pairs=', bipolar_pairs

    from ptsa.data.experimental.TimeSeriesSessionEEGReader import TimeSeriesSessionEEGReader

    # time_series_reader = TimeSeriesSessionEEGReader(events=base_events, channels = ['002', '003', '004', '005'])
    time_series_reader = TimeSeriesSessionEEGReader(events=base_events, channels=monopolar_channels)
    ts_dict = time_series_reader.read()

    first_session_data = ts_dict.items()[0][1]

    print first_session_data

    wavelet_start = time.time()

    wf = MorletWaveletFilter(time_series=first_session_data,
                             freqs=np.logspace(np.log10(3), np.log10(180), 2),
                             # freqs=np.array([3.]),
                             output='power',
                             # resamplerate=50.0
                             )

    pow_wavelet, phase_wavelet = wf.filter()
    print 'wavelet total time = ', time.time() - wavelet_start
    # return pow_wavelet

    from ptsa.data.experimental.EventDataChopper import EventDataChopper
    edcw = EventDataChopper(events=base_events, event_duration=1.6, buffer=1.0,
                            data_dict={base_events[0].eegfile: pow_wavelet})

    chopped_wavelets = edcw.filter()

    chopped_wavelets = chopped_wavelets.items()[0][1]  # getting first item of return dictionary

    print 'total time = ', time.time() - start
    #
    # from ptsa.data.filters.ResampleFilter import ResampleFilter
    # rsf = ResampleFilter (resamplerate=50.0)
    # rsf.set_input(chopped_wavelets)
    # chopped_wavelets_resampled = rsf.filter()
    #
    # return chopped_wavelets_resampled
    return chopped_wavelets
            session_eegdata_dict[eegfile_name] = eegdata_xray

        return session_eegdata_dict


if __name__ == "__main__":
    event_range = range(0, 30, 1)
    e_path = "/Users/m/data/events/RAM_FR1/R1060M_events.mat"

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == "WORD"]

    from ptsa.data.experimental.TimeSeriesSessionEEGReader import TimeSeriesSessionEEGReader

    time_series_reader = TimeSeriesSessionEEGReader(events=base_events, channels=["002", "003", "004", "005"])

    # time_series_reader = TimeSeriesSessionEEGReader(events=base_events, event_data_only=True, channels=['002', '003', '004', '005']*20)
    ts = time_series_reader.read()

    print ts

    # #
    # # sys.exit()
    # print ts
예제 #8
0
        return eventdata_xray


if __name__ == '__main__':
    event_range = range(0, 30, 1)
    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(event_file=e_path,
                                    eliminate_events_with_no_eeg=True,
                                    use_ptsa_events_class=False)

    base_e_reader.read()

    base_events = base_e_reader.get_output()

    base_events = base_events[base_events.type == 'WORD']

    # sorting names in the order in which they appear in the file
    eegfile_names = np.unique(base_events.eegfile)
    eeg_file_names_sorter = np.zeros(len(eegfile_names), dtype=np.int)

    for i, eegfile_name in enumerate(eegfile_names):

        eeg_file_names_sorter[i] = np.where(
            base_events.eegfile == eegfile_name)[0][0]

    eeg_file_names_sorter = np.argsort(eeg_file_names_sorter)

    eegfile_names = eegfile_names[eeg_file_names_sorter]
예제 #9
0
    def run(self):


        # PTSA EVENT  READER

        # e_path = join(self.pipeline.mount_point, 'data/events', self.pipeline.task,self.pipeline.subject+'_events.mat')
        e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'
        # e_path = '/Users/m/data/events/RAM_FR1/R1056M_events.mat'
        e_reader = PTSAEventReader(event_file=e_path, eliminate_events_with_no_eeg=True)

        e_reader.read()

        events = e_reader.get_output()

        events = events[events.type == 'WORD']

        events = events[0:30]

        ev_order = np.argsort(events, order=('session','list','mstime'))
        events = events[ev_order]



        events = Events(events) # necessary workaround for new numpy
        print 'events=',events

        eegs= events.get_data(channels=['002','003'], start_time=0.0, end_time=1.6,
                                        buffer_time=1.0, eoffset='eegoffset', keep_buffer=False, eoffset_in_time=False,verbose=True)

        print eegs

        # BASE READER


        base_e_reader = BaseEventReader(event_file=e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)



        base_e_reader.read()

        base_events = base_e_reader.get_output()

        base_events = base_events[base_events.type == 'WORD']

        base_ev_order = np.argsort(base_events, order=('session','list','mstime'))
        base_events = base_events[base_ev_order]

        base_events = base_events[0:30]


        print 'base_events=',base_events


        from ptsa.data.readers.TimeSeriesEEGReader import TimeSeriesEEGReader

        time_series_reader = TimeSeriesEEGReader(base_events)

        time_series_reader.start_time = 0.0
        time_series_reader.end_time = 1.6
        time_series_reader.buffer_time = 1.0
        time_series_reader.keep_buffer = False

        time_series_reader.read(channels=['002','003'])


        base_eegs = time_series_reader.get_output()
        print
예제 #10
0
    def run(self):

        # PTSA EVENT  READER

        # e_path = join(self.pipeline.mount_point, 'data/events', self.pipeline.task,self.pipeline.subject+'_events.mat')
        e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'
        # e_path = '/Users/m/data/events/RAM_FR1/R1056M_events.mat'
        e_reader = PTSAEventReader(event_file=e_path,
                                   eliminate_events_with_no_eeg=True)

        e_reader.read()

        events = e_reader.get_output()

        events = events[events.type == 'WORD']

        events = events[0:30]

        ev_order = np.argsort(events, order=('session', 'list', 'mstime'))
        events = events[ev_order]

        events = Events(events)  # necessary workaround for new numpy
        print 'events=', events

        eegs = events.get_data(channels=['002', '003'],
                               start_time=0.0,
                               end_time=1.6,
                               buffer_time=1.0,
                               eoffset='eegoffset',
                               keep_buffer=False,
                               eoffset_in_time=False,
                               verbose=True)

        print eegs

        # BASE READER

        base_e_reader = BaseEventReader(event_file=e_path,
                                        eliminate_events_with_no_eeg=True,
                                        use_ptsa_events_class=False)

        base_e_reader.read()

        base_events = base_e_reader.get_output()

        base_events = base_events[base_events.type == 'WORD']

        base_ev_order = np.argsort(base_events,
                                   order=('session', 'list', 'mstime'))
        base_events = base_events[base_ev_order]

        base_events = base_events[0:30]

        print 'base_events=', base_events

        from ptsa.data.readers.TimeSeriesEEGReader import TimeSeriesEEGReader

        time_series_reader = TimeSeriesEEGReader(base_events)

        time_series_reader.start_time = 0.0
        time_series_reader.end_time = 1.6
        time_series_reader.buffer_time = 1.0
        time_series_reader.keep_buffer = False

        time_series_reader.read(channels=['002', '003'])

        base_eegs = time_series_reader.get_output()
        print