expyriment.design.Trial

class expyriment.design.Trial[source]

A class implementing an experimental trial.

Methods

__init__()[source]

Create a Trial.

add_stimulus(stimulus)[source]

Add a stimulus to the trial.

Parameters:

stimulus : expyriment stimulus

stimulus to add (expyriment.stimuli.* object)

Notes

This will add references to stimuli, not copies!

clear_factors()[source]

Clear all factors.

clear_stimuli()[source]

Clear the stimuli.

compare(trial)[source]

Compares this trial with another trail and returns True if all factors associated with both trials are identical. Added stimuli will be ignored for the comparison.

Returns:identical: boolean :
copy()[source]

Return a copy of the trial.

factor_dict

The dictionary with all factors of the trial.

factor_names

Getter for factors names.

factors_as_text

Return all factor names and values as csv string line

find_stimulus(id)[source]

Find the positions of a stimulus.

Parameters:

id : int

stimulus id to look for

Returns:

pos : int

positions as a list or None if not in stimuli list

get_factor(name)[source]

Get a factor of the trial.

Parameters:

name : str

factor name

Returns:

factor_val : str or numeric

id

Getter for id.

order_stimuli(order)[source]

Order the stimuli.

Parameters:

order : list

list with the new order of positions

preload_stimuli()[source]

Preload all stimuli in trial.

Returns:

time : int

time it took to execute this method in ms

remove_stimulus(position)[source]

Remove stimulus from trial.

Parameters:

position : int

position of the stimulus

set_factor(name, value)[source]

Set a factor for the trial.

Parameters:

name : str

factor name

value : str or numeric

factor value

shuffle_stimuli(max_repetitions=None, n_segments=None)[source]

Shuffle all stimuli.

Parameters:

max_repetitions : int, optional

see documentation of randomize.shuffle_list, default = None

n_segments : int, optional

see documentation of randomize.shuffle_list, default = None

Returns:

success : bool

randomization was successful and fulfilled the specified constrains (see max_repetitions)

See also

randomize.shuffle_list

sort_stimuli()[source]

Sort the stimuli according to their IDs from low to high.

stimuli

Getter for stimuli.

swap_stimuli(position1, position2)[source]

Swap two stimuli.

Parameters:

position1 : int

position of first stimulus

position2 : int

position of second stimulus

unload_stimuli(keep_surface=False)[source]

Unload all stimuli in trial.

Parameters:

keep_surface : bool, optional

keep the surface after unloading (default = False)

Returns:

time : int

time it took to execute this method in ms