Esempio n. 1
0
example_bci.change_channellabels(10, 30) 


# We want to let the EEG run a bit before we are interested in the data.
# This may be the case, for example, if you have to save your recordings first.
time.sleep(2)  


# We have noted that our computer is a bit slow and seems to be overstrained getting data so fast.
# Because of that, we are going to reduce the returning speed.
example_bci.set_returning_speed(0)   


# We trigger a sign with the size 0.5 (range from 0 to 1 is possible) for 300 milliseconds
# before getting the data by means of a square.
example_bci.trigger_sign('quads', 0.5, 300)   

# At the moment we are just interested in the first (current) data block (made up of <example_bci.numof_samples> 
# samples for each of the <numof_channels> channels).
# Unlike the <get_data>-function, <get_datablock> has no impemented security_mode, so if you want to use it (and it is not
# switched on in the config file) you have to do that manually. In that case, make sure to reset the counters, otherwise
# you'll probably get a warning.

example_bci.set_security_mode(True)
example_bci.reset_security_mode()
example_datablock = example_bci.get_datablock()
example_bci.set_security_mode(False)

# Just to show that this is possible (it may save time if you set <saving_mode> to False and write the data after
# collecting it) we call the saving function from 'externally'.
# In the <get_data>-function it is implemented if you set <saving_mode> to True.
Esempio n. 2
0
# Make sure that the following matches with your config file.
numof_channels = 5
sample_rate = 500

condition_means = N.zeros((len(conditions), numof_channels))

for num, condition in zip(range(len(conditions)), conditions):
    condition_data = N.zeros((trials, numof_channels, sample_rate * sec_per_trial))
    for trial in range(trials):  # For each trial in each condition...

        time.sleep(1)  # ...we'll wait a second...

        # ...then give a sign by means of a triangle for the beginning of the trial, that is, the data
        # collection...
        example_bci.trigger_sign("triangle", 0.5, 300)

        # ...and store the data, separated for each trial.
        condition_data[trial] = example_bci.get_data(sec_per_trial)

    print "Condition", condition, "done."

    # At last, we'll take the average of the respective condition, but keep
    # the channel structure.
    condition_data = N.mean(condition_data, axis=2)  # average over the samples
    condition_data = N.mean(condition_data, axis=0)  # average over the trials

    # The result is an array with the structure [condition][channels], with the
    # channel values averaged over all samples and trials of the respect condition.
    condition_means[num] = condition_data