• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python readers.BaseEventReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ptsa.data.readers.BaseEventReader的典型用法代码示例。如果您正苦于以下问题:Python BaseEventReader类的具体用法?Python BaseEventReader怎么用?Python BaseEventReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BaseEventReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_as_dataframe

    def test_as_dataframe(self):
        ber = BaseEventReader(filename=self.filename)
        events = ber.as_dataframe()
        assert isinstance(events, pd.DataFrame)

        with open(self.filename) as f:
            assert len(events) == len(json.loads(f.read()))
开发者ID:ctw,项目名称:ptsa_new,代码行数:7,代码来源:test_event_read.py


示例2: test_2_old

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
开发者ID:isaac-ped,项目名称:ptsa_new,代码行数:60,代码来源:MorletWaveletFilter.py


示例3: read_events

    def read_events(self, task, subject):
        e_path = join(self.prefix, 'data/events/%s/%s_events.mat' % (task, subject))

        base_e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)

        base_events = base_e_reader.read()
        return base_events
开发者ID:ctw,项目名称:ptsa_new,代码行数:7,代码来源:pyfr_data_read.py


示例4: test_missing_data_read

 def test_missing_data_read(self):
     self.e_path = '/Volumes/rhino_root/data/events/RAM_PS/R1104D_events.mat'
     if sys.platform.startswith('win'):
         self.e_path = 'D:/data/events/RAM_PS/R1104D_events.mat'
     base_e_reader = BaseEventReader(filename=self.e_path)
     base_events = base_e_reader.read()
     print('base_events=',base_events)
开发者ID:ctw,项目名称:ptsa_new,代码行数:7,代码来源:TestRegressionPTSA.py


示例5: get_ltp_subject_sessions_by_experiment

def get_ltp_subject_sessions_by_experiment(experiment):
    events_dir = os.path.join(paths.data_root, 'scalp', 'ltp', experiment, 'behavioral', 'events')
    events_files = sorted(glob.glob(os.path.join(events_dir, 'events_all_LTP*.mat')),
                          key=lambda f: f.split('_')[:-1])
    seen_experiments = defaultdict(list)
    for events_file in events_files:
        print(events_file)
        subject = os.path.basename(events_file)[11:-4]  # Subject number is the basename with events_all_, .mat removed
        subject_no_year = subject.split('_')[0]
        if '_' in subject:
            continue
        mat_events_reader = BaseEventReader(filename=events_file, common_root=paths.data_root)
        logger.debug('Loading matlab events {exp}: {subj}'.format(exp=experiment, subj=subject))
        try:
            mat_events = mat_events_reader.read()
            sessions = np.unique(mat_events['session']) - 1  # MATLAB events start counting sessions at 1 instead of 0
            version = 0.
            for i, session in enumerate(sessions):
                if 'experiment' in mat_events.dtype.names:
                    experiments = np.unique(mat_events[mat_events['session'] == session]['experiment'])
                else:
                    experiments = [experiment]
                for this_experiment in experiments:
                    n_sessions = seen_experiments[subject_no_year].count(this_experiment)
                    yield subject_no_year, subject, n_sessions, session, this_experiment, version
                    seen_experiments[subject_no_year].append(this_experiment)
        except IndexError or AttributeError:
            traceback.print_exc()
            logger.error('Could not get session from {}'.format(events_file))
开发者ID:isaac-ped,项目名称:event_creation,代码行数:29,代码来源:convenience.py


示例6: setUp

    def setUp(self):
        self.start_time = -0.5
        self.end_time = 1.6
        self.buffer_time = 0.5

        self.event_range = range(0, 30, 1)

        # here = osp.abspath(osp.dirname(__file__))
        here = get_rhino_root()
        self.e_path = osp.join(here, 'data', 'events', 'RAM_FR1', 'R1060M_events.mat')
        tal_path = osp.join(here, 'data', 'eeg', 'R1060M', 'tal', 'R1060M_talLocs_database_bipol.mat')

        tal_reader = TalReader(filename=tal_path)
        self.monopolar_channels = tal_reader.get_monopolar_channels()
        self.bipolar_pairs = tal_reader.get_bipolar_pairs()

        base_e_reader = BaseEventReader(filename=self.e_path, eliminate_events_with_no_eeg=True)
        base_events = base_e_reader.read()
        base_events = base_events[base_events.type == 'WORD']
        base_ev_order = np.argsort(base_events, order=('session', 'list', 'mstime'))
        self.base_events = base_events[base_ev_order]

        # retaining first session
        dataroot = self.base_events[0].eegfile
        self.base_events = self.base_events[self.base_events.eegfile == dataroot]
        self.base_events = self.base_events[self.event_range]

        eeg_reader = EEGReader(events=self.base_events, channels=self.monopolar_channels,
                               start_time=self.start_time, end_time=self.end_time, buffer_time=self.buffer_time)

        self.base_eegs = eeg_reader.read()

        session_reader = EEGReader(session_dataroot=dataroot, channels=self.monopolar_channels)
        self.session_eegs = session_reader.read()
开发者ID:ctw,项目名称:ptsa_new,代码行数:34,代码来源:test_filters.py


示例7: run

    def run(self):
        events = None
        if self.params.include_fr1:
            try:
                e_path = os.path.join(self.pipeline.mount_point , 'data/events/RAM_FR1', self.pipeline.subject + '_math.mat')
                e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)
                events = e_reader.read()
                print "Got FR1 events"
            except IOError:
                pass

        if self.params.include_catfr1:
            try:
                e_path = os.path.join(self.pipeline.mount_point , 'data/events/RAM_CatFR1', self.pipeline.subject + '_math.mat')
                e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)
                catfr1_events = e_reader.read()
                print "Got CatFR1 events"
                if events is None:
                    events = catfr1_events
                else:
                    print "Joining FR1 and CatFR1"
                    catfr1_events.session = -catfr1_events.session-1
                    fields = list(set(events.dtype.names).intersection(catfr1_events.dtype.names))
                    events = np.hstack((events[fields],catfr1_events[fields])).view(np.recarray)
            except IOError:
                pass

        events = events[events.type == 'PROB']

        print len(events), 'PROB events'

        self.pass_object('control_events', events)
开发者ID:maciekswat,项目名称:ram_utils,代码行数:32,代码来源:ControlEventPreparation.py


示例8: test_read_json

    def test_read_json(self):
        ber = BaseEventReader(filename=self.filename)
        events = ber.read_json()
        assert isinstance(events, np.recarray)

        with open(self.filename) as f:
            assert len(events) == len(json.loads(f.read()))
开发者ID:ctw,项目名称:ptsa_new,代码行数:7,代码来源:test_event_read.py


示例9: setUp

    def setUp(self):
        root = get_rhino_root()
        self.e_path = osp.join(root, 'data', 'events', 'RAM_FR1',
                               'R1060M_events.mat')
        tal_path = osp.join(root, 'data', 'eeg', 'R1060M', 'tal',
                            'R1060M_talLocs_database_bipol.mat')

        base_e_reader = BaseEventReader(filename=self.e_path,
                                        eliminate_events_with_no_eeg=True)

        self.base_events = base_e_reader.read()

        tal_reader = TalReader(filename=tal_path)
        self.monopolar_channels = tal_reader.get_monopolar_channels()
        self.bipolar_pairs = tal_reader.get_bipolar_pairs()

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

        # retaining first session
        dataroot = self.base_events[0].eegfile
        self.base_events = self.base_events[self.base_events.eegfile == dataroot]

        eeg_reader = EEGReader(events=self.base_events, channels=self.monopolar_channels,
                               start_time=0.0, end_time=1.6, buffer_time=1.0)

        self.base_eegs = eeg_reader.read()
开发者ID:ctw,项目名称:ptsa_new,代码行数:26,代码来源:test_classifier.py


示例10: run

    def run(self):
        events = None
        if self.params.include_fr1:
            try:
                e_path = os.path.join(self.pipeline.mount_point , 'data/events/RAM_FR1', self.pipeline.subject + '_events.mat')
                e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)
                events = e_reader.read()
                ev_order = np.argsort(events, order=('session','list','mstime'))
                events = events[ev_order]
            except IOError:
                pass

        if self.params.include_catfr1:
            try:
                e_path = os.path.join(self.pipeline.mount_point , 'data/events/RAM_CatFR1', self.pipeline.subject + '_events.mat')
                e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)
                catfr1_events = e_reader.read()
                ev_order = np.argsort(catfr1_events, order=('session','list','mstime'))
                catfr1_events = catfr1_events[ev_order]
                if events is None:
                    events = catfr1_events
                else:
                    catfr1_events.session += 100
                    fields = list(set(events.dtype.names).intersection(catfr1_events.dtype.names))
                    events = np.hstack((events[fields],catfr1_events[fields])).view(np.recarray)
            except IOError:
                pass

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

        print len(events), 'WORD events'

        self.pass_object('FR_events', events)
开发者ID:maciekswat,项目名称:ram_utils,代码行数:33,代码来源:FREventPreparation.py


示例11: get_events

def get_events():
    # ---------------- NEW STYLE PTSA -------------------
    base_e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)

    base_events = base_e_reader.read()

    base_events = base_events[base_events.type == 'WORD']
    return base_events
开发者ID:isaac-ped,项目名称:ptsa_new,代码行数:8,代码来源:classifier_time_series.py


示例12: __init__

    def __init__(self, **kwds):
        BaseEventReader.__init__(self, **kwds)

        if self.eeg_fname_search_pattern != '' and self.eeg_fname_replace_pattern != '':

            self.alter_eeg_path_flag = True

        else:
            self.alter_eeg_path_flag = False
开发者ID:ctw,项目名称:ptsa_new,代码行数:9,代码来源:CMLEventReader.py


示例13: main_fcn

def main_fcn():
    e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'

    from ptsa.data.readers import BaseEventReader

    base_e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)

    base_events = base_e_reader.read()



    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(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.readers.EEGReader import EEGReader

    sessions = np.unique(base_events.session)
    dataroot = base_events[0].eegfile

    session_reader = EEGReader(session_dataroot=dataroot, channels=monopolar_channels)
    session_eegs = session_reader.read()

    m2b = MonopolarToBipolarMapper(time_series=session_eegs, bipolar_pairs=bipolar_pairs)
    session_bp_eegs = m2b.filter()





    time_series_reader = EEGReader(events=base_events, channels=monopolar_channels, start_time=0.0,
                                             end_time=1.6, buffer_time=1.0)


    base_eegs = time_series_reader.read()


    m2b = MonopolarToBipolarMapper(time_series=base_eegs, bipolar_pairs=bipolar_pairs)
    ts_filtered = m2b.filter()

    del base_eegs
    del time_series_reader

    print()

    pass
开发者ID:ctw,项目名称:ptsa_new,代码行数:57,代码来源:MonopolarToBipolarMapper.py


示例14: setUp

    def setUp(self):
        self.event_range = range(0, 30, 1)
        self.e_path = '/Users/m/data/events/RAM_FR1/R1060M_events.mat'
        self.tal_path = '/Users/m/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'

        if sys.platform.startswith('win'):
            self.e_path = 'D:/data/events/RAM_FR1/R1060M_events.mat'
            self.tal_path = 'D:/data/eeg/R1060M/tal/R1060M_talLocs_database_bipol.mat'

        # --------------- TAL STRUCTS READ
        tal_reader = TalReader(filename=self.tal_path)
        self.monopolar_channels = tal_reader.get_monopolar_channels()


        # ---------------- ORIG PTSA -------------------
        e_reader = PTSAEventReader(filename=self.e_path, eliminate_events_with_no_eeg=True)
        events = e_reader.read()

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

        events = events[self.event_range]

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

        # self.events = self.read_ptsa_events()

        # in case fancy indexing looses Eventness of events we need to create Events object explicitely
        if not isinstance(self.events, Events):
            self.events = Events(self.events)

        start_time = 0.0
        end_time = 1.6
        buffer_time = 1.0

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

        # ---------------- NEW STYLE PTSA -------------------
        base_e_reader = BaseEventReader(filename=self.e_path, eliminate_events_with_no_eeg=True)

        base_events = base_e_reader.read()

        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]

        self.base_events = base_events[self.event_range]

        # self.base_events = self.read_base_events()

        eeg_reader = EEGReader(events=self.base_events, channels=np.array(['002', '003']),
                               start_time=start_time, end_time=end_time, buffer_time=buffer_time)

        self.base_eegs = eeg_reader.read()
开发者ID:ctw,项目名称:ptsa_new,代码行数:57,代码来源:TestRegressionPTSA.py


示例15: get_suffixes

def get_suffixes(subject):
    events_file= os.path.join(DATA_ROOT, '..', 'events', 'RAM_PS', '{}_events.mat'.format(subject))
    mat_events_reader = BaseEventReader(filename=events_file, common_root=DATA_ROOT)
    mat_events = mat_events_reader.read()
    sessions = np.unique(mat_events.session)
    suffixes = {}
    for session in sessions:
        sess_events = mat_events[mat_events.session == session]
        eegfile = sess_events[10].eegfile
        suffixes[session] =  '_'.join(eegfile.split('_')[-2:])
    return suffixes
开发者ID:isaac-ped,项目名称:event_creation,代码行数:11,代码来源:prep_ps_files.py


示例16: test_1

def test_1():
    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(filename=e_path, eliminate_events_with_no_eeg=True, use_ptsa_events_class=False)

    base_events = base_e_reader.read()

    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(filename=tal_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    dataroot = base_events[0].eegfile
    from ptsa.data.readers import EEGReader

    session_reader = EEGReader(session_dataroot=dataroot, channels=monopolar_channels)
    session_eegs = session_reader.read()

    wavelet_start = time.time()

    wf = MorletWaveletFilterSimple(
        time_series=session_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 "wavelet total time = ", time.time() - wavelet_start
    # return pow_wavelet

    from ptsa.data.filters import EventDataChopper

    sedc = EventDataChopper(events=base_events, session_data=pow_wavelet, start_time=0.0, end_time=1.6, buffer_time=1.0)
    chopped_wavelets = sedc.filter()

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

    return chopped_wavelets
开发者ID:maciekswat,项目名称:ptsa_new,代码行数:53,代码来源:MorletWaveletFilterSimpleExact.py


示例17: test_R1070T_read

    def test_R1070T_read(self):
        e_path = '/Volumes/rhino_root/data/events/RAM_FR1/R1070T_events.mat'
        base_event_reader = BaseEventReader(filename=e_path)

        start_time = 0.0
        end_time = 1.366
        buffer_time = 1.365

        base_events = base_event_reader.read()
        eeg_reader = EEGReader(events=base_events, channels=np.array(['042', '043']),
                               start_time=start_time, end_time=end_time, buffer_time=buffer_time)
        base_eegs = eeg_reader.read()
开发者ID:isaac-ped,项目名称:ptsa_new,代码行数:12,代码来源:TestReaders.py


示例18: run

    def run(self):
        subject = self.pipeline.subject
        experiment = self.pipeline.experiment

        from ptsa.data.readers import BaseEventReader
        e_path = os.path.join(self.pipeline.mount_point , 'data', 'events', 'RAM_PS', self.pipeline.subject + '_events.mat')
        e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)

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

        # try:
        #     events = Events(get_events(subject=subject, task='RAM_PS', path_prefix=self.pipeline.mount_point))
        # except IOError:
        #     raise Exception('No parameter search for subject %s' % subject)
        #

        events = events[events.experiment == experiment]
        
        if len(events) == 0:
            raise Exception('No %s events for subject %s' % (experiment,subject))

        sessions = np.unique(events.session)
        print experiment, 'sessions:', sessions

        events = pd.DataFrame.from_records(events)

        events = compute_isi(events)

        is_stim_event_type_vec = np.vectorize(is_stim_event_type)
        stim_mask = is_stim_event_type_vec(events.type)
        if experiment == 'PS3':
            stim_inds = np.where(stim_mask)[0]
            stim_events = pd.DataFrame(events[stim_mask])
            last_burst_inds = stim_inds + stim_events['nBursts'].values
            last_bursts = events.ix[last_burst_inds]
            events = stim_events
            events['train_duration'] = last_bursts['mstime'].values - events['mstime'].values + last_bursts['pulse_duration'].values
        else:
            events = events[stim_mask]

        events = events.to_records(index=False)

        print len(events), 'stim', experiment, 'events'

        # events = Events(events.to_records(index=False))
        #
        # joblib.dump(events, self.get_path_to_resource_in_workspace(subject+'-'+experiment+'-ps_events.pkl'))
        self.pass_object(experiment+'_events', events)
开发者ID:maciekswat,项目名称:ram_utils,代码行数:50,代码来源:PSEventPreparation.py


示例19: run

    def run(self):
        task = self.pipeline.task

        from ptsa.data.readers import BaseEventReader
        e_path = os.path.join(self.pipeline.mount_point , 'data', 'events', task, self.pipeline.subject + '_events.mat')
        e_reader = BaseEventReader(filename=e_path, eliminate_events_with_no_eeg=True)

        events = e_reader.read()

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

        print len(events), task, 'WORD events'

        self.pass_object(task+'_events', events)
开发者ID:maciekswat,项目名称:ram_utils,代码行数:14,代码来源:FR1EventPreparation.py


示例20: read_base_events

    def read_base_events(self):

        base_e_reader = BaseEventReader(filename=self.e_path, eliminate_events_with_no_eeg=True)

        base_events = base_e_reader.read()

        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
开发者ID:isaac-ped,项目名称:ptsa_new,代码行数:14,代码来源:EventReadersTestBase.py



注:本文中的ptsa.data.readers.BaseEventReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ptvsd.enable_attach函数代码示例发布时间:2022-05-25
下一篇:
Python filesystem.join函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap