expyriment.design.extras.StimulationProtocol

class expyriment.design.extras.StimulationProtocol(unit)

A class implementing a stimulation protocol.

__init__(unit)

Create a stimulation protocol.

Parameters:

unit : str

The unit of the stimulation protocol (‘time’ or ‘volume’)

add_condition(name)

Add a condition to the stimulation protocol.

Parameters:

name : str

The name of the condition to add

add_event(condition, begin, end, weight=1)

Add an event to a condition.

Parameters:

condition : str or int

The name or index of the condition to add the event to

begin : int

The beginning time of the event

end : int

The end time of the event

weight : int, optional

A weight for parametric modulation (default = 1)

export2brainvoyager(exp_name, filename)

Convert the stimulation protocol to BrainVoyager ‘.prt’ format.

DEPRECATED: Use export_to_brainvoyager.

Parameters:

exp_name : str

The name of the Experiment

filename : str

The name of the file to write

export_to_brainvoyager(exp_name, filename)

Convert the stimulation protocol to BrainVoyager ‘.prt’ format.

Parameters:

exp_name : str

The name of the Experiment

filename : str

The name of the file to write

get_as_experimental_block(name=None, block=None)

Create an experimental block from a stimulation protocol.

Each stimulation becomes a trial in the block. Trials are ordered according to the stimulation onset time.

If ‘block’ is an experimental block with the same amount of unique trials as the stimulation protocol, and has a factor called “condition” or “Condition”, with the the factor level names corresponding to the condition names of the protocol, then the returned block will be a copy of the experimental block, with the order of trials randomized, but in line with the order of conditions specified in the protocol.

The resulting block will have the following trial factors:

“condition” - the name of the condition “begin” - the stimulation onset in milliseconds “end” - the stimulation offset in milliseconds “weight” - the parametric weight
Parameters:

name : str, optional

the name of the block

block : expyriment.design.Block object, optional

Returns:

block : expyriment.design.Block object

the experimental block

import_from_brainvoyager(prt_file)

Import prt file as stimulation protocol.

ATTENTION: This will overwrite all data in the current protocol!

Parameters:

prt_file : str

the prt file to import

load(filename, encoding=None)

Load a stimulation protocol from a csv file.

Parameters:

filename : str

The filename to read the protocol from

encoding : str, optional

The encoding to be used when reading from the file

save(filename)

Save the stimulation protocol to a csv file.

Parameters:

filename : str

The name of the file to save the protocol to