expyriment.design.Trial

class expyriment.design.Trial

A class implementing an experimental trial.

__init__()

Create a Trial.

add_stimulus(stimulus)

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()

Clear all factors.

clear_stimuli()

Clear the stimuli.

compare(trial)

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()

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)

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)

Get a factor of the trial.

Parameters:

name : str

factor name

Returns:

factor_val : str or numeric

id

Getter for id.

order_stimuli(order)

Order the stimuli.

Parameters:

order : list

list with the new order of positions

preload_stimuli()

Preload all stimuli in trial.

Returns:

time : int

time it took to execute this method in ms

remove_stimulus(position)

Remove stimulus from trial.

Parameters:

position : int

position of the stimulus

set_factor(name, value)

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)

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()

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

stimuli

Getter for stimuli.

swap_stimuli(position1, position2)

Swap two stimuli.

Parameters:

position1 : int

position of first stimulus

position2 : int

position of second stimulus

unload_stimuli(keep_surface=False)

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