コード例 #1
0
ファイル: cerelink.py プロジェクト: DerekYJC/bmi_python
    def get_event_data(self):
        '''A generator that yields spike event data.'''

        sleep_time = 0

        while self.streaming:

            result, trial = cbpy.trial_event(
                reset=True)  # TODO -- check if result = 0?
            arrival_ts = time.time()

            for list_ in trial:
                chan = list_[0]
                for unit, unit_ts in enumerate(list_[1]['timestamps']):
                    for ts in unit_ts:
                        # blackrock unit numbers are 0-based where zero is unsorted unit
                        if unit == 0:
                            # Unsorted units are unit 10 (j)
                            un = 10
                        else:
                            un = unit
                        yield SpikeEventData(chan=chan - self.channel_offset,
                                             unit=un,
                                             ts=ts,
                                             arrival_ts=arrival_ts)

            time.sleep(sleep_time)
コード例 #2
0
 def get_event_data(self):
     # Spike event data. #
     if self.cbsdk_config['get_events']:
         if self.is_connected:
             result, data = cbpy.trial_event(
                 instance=self.cbsdk_config['instance'], reset=True)
             if result == 0:
                 return data
             else:
                 logger.error('failed to get trial event data. Error (%d)' %
                              result)
     return None
コード例 #3
0
    def get_event_data(self):
        '''A generator that yields spike event data.'''

        sleep_time = 0

        while self.streaming:

            result, trial = cbpy.trial_event(reset=True)  # TODO -- check if result = 0?
            arrival_ts = time.time()

            for list_ in trial:
                chan = list_[0]
                for unit, unit_ts in enumerate(list_[1]['timestamps']):
                    for ts in unit_ts:
                        # blackrock unit numbers are 0-based where zero is unsorted unit
                        if unit == 0:
                            # Unsorted units are unit 10 (j)
                            un = 10
                        else:
                            un = unit
                        yield SpikeEventData(chan=chan-self.channel_offset, unit=un, ts=ts, arrival_ts=arrival_ts)

            time.sleep(sleep_time)
コード例 #4
0
n_secs = 20
loop_time = 0.1
n_itrs = int(n_secs / loop_time)

last_nsp_time = 0

for itr in range(n_itrs):
    t_start = time.time()
    print '-' * 79
    print '\nitr %d of %d:' % (itr+1, n_itrs)
    print ''

    # print 'calling cbpy.trial_event(), followed by cbpy.time()'
    # print ''
    trial_event_result, trial = cbpy.trial_event(reset=True)
    time_result, nsp_time = cbpy.time()

    n_ts = 0
    for list_ in trial:
        for unit, unit_ts in enumerate(list_[1]['timestamps']):
            n_ts += len(unit_ts)

    data = np.zeros((n_ts, 3), dtype=np.int32)  # 3 columns: timestamp, chan, unit
    idx = 0
    for list_ in trial:
        chan = list_[0] - nPlay_chan_offset
        for unit, unit_ts in enumerate(np.array(list_[1]['timestamps'])):
            if len(unit_ts) > 0:
                for ts in unit_ts:
                    if ts < last_nsp_time:
コード例 #5
0
n_secs = 20
loop_time = 0.1
n_itrs = int(n_secs / loop_time)

last_nsp_time = 0

for itr in range(n_itrs):
    t_start = time.time()
    print('-' * 79)
    print('\nitr %d of %d:' % (itr + 1, n_itrs))
    print('')

    # print 'calling cbpy.trial_event(), followed by cbpy.time()'
    # print ''
    trial_event_result, trial = cbpy.trial_event(reset=True)
    time_result, nsp_time = cbpy.time()

    n_ts = 0
    for list_ in trial:
        for unit, unit_ts in enumerate(list_[1]['timestamps']):
            n_ts += len(unit_ts)

    data = np.zeros((n_ts, 3),
                    dtype=np.int32)  # 3 columns: timestamp, chan, unit
    idx = 0
    for list_ in trial:
        chan = list_[0] - nPlay_chan_offset
        for unit, unit_ts in enumerate(np.array(list_[1]['timestamps'])):
            if len(unit_ts) > 0:
                for ts in unit_ts:
コード例 #6
0
ファイル: fetch_data_events.py プロジェクト: stinos/CereLink
# Make sure the CereLink project folder is not on the path,
# otherwise it will attempt to import cerebus from there, instead of the installed python package.
from cerebus import cbpy

res, con_info = cbpy.open(parameter=cbpy.defaultConParams())
res, reset = cbpy.trial_config(reset=True,
                               buffer_parameter={},
                               range_parameter={},
                               noevent=0,
                               nocontinuous=1,
                               nocomment=1)

try:
    while True:
        result, data = cbpy.trial_event(reset=True)
        if len(data) > 0:
            print(data)
except KeyboardInterrupt:
    cbpy.close()