Static¶
- class psynet.trial.static.StaticNetwork(*args, **kwargs)[source]¶
Bases:
ChainNetwork
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- full¶
Whether the network is currently full
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- max_size¶
How big the network can get, this number is used by the full() method to decide whether the network is full
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- role¶
The role of the network. By default dallinger initializes all networks as either “practice” or “experiment”
- time_of_death¶
the time at which failing occurred
- type¶
A String giving the name of the class. Defaults to “network”. This allows subclassing.
- vars¶
- class psynet.trial.static.StaticNode(*args, **kwargs)[source]¶
Bases:
ChainNode
- create_definition_from_seed(seed, experiment, participant)[source]¶
Creates a node definition from a seed. The seed comes from the previous node in the chain. In many cases (e.g. iterated reproduction) the definition will be trivially equal to the seed, but in some cases we may introduce some kind of stochastic alteration to produce the definition.
- Parameters:
seed (object) – The seed, passed from the previous state in the chain.
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – The participant who initiated the creation of the node.
- Returns:
object – The derived definition. Should be suitable for serialisation to JSON.
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- network¶
the network the node is in
- network_id¶
the id of the network that this node is a part of
- participant¶
the participant the node is associated with
- participant_id¶
the id of the participant whose node this is
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- summarize_trials(trials, experiment, participant)[source]¶
Summarizes the trials at the node to produce a seed that can be passed to the next node in the chain.
- Parameters:
trials (
list
) – Trials to be summarized. By default only trials that are completed (i.e. have received a response) and processed (i.e. aren’t waiting for an asynchronous process) are provided here.experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – The participant who initiated the creation of the node.
- Returns:
object – The derived seed. Should be suitable for serialisation to JSON.
- time_of_death¶
the time at which failing occurred
- type¶
A String giving the name of the class. Defaults to
node
. This allows subclassing.
- vars¶
- class psynet.trial.static.StaticTrial(*args, **kwargs)[source]¶
Bases:
ChainTrial
A Trial class for static experiments.
The user must override the
time_estimate
class attribute, providing the estimated duration of the trial in seconds. This is used for predicting the participant’s reward and for constructing the progress bar.- time_estimate¶
The estimated duration of the trial (including any feedback), in seconds. This should generally correspond to the (sum of the)
time_estimate
parameters in the page(s) generated byshow_trial
, plus thetime_estimate
parameter in the page generated byshow_feedback
(if defined). This is used for predicting the participant’s reward and for constructing the progress bar.- Type:
numeric
- participant_id¶
The ID of the associated participant. The user should not typically change this directly. Stored in
property1
in the database.- Type:
int
- complete¶
Whether the trial has been completed (i.e. received a response from the participant). The user should not typically change this directly. Stored in
property2
in the database.- Type:
bool
- answer¶
The response returned by the participant. This is serialised to JSON, so it shouldn’t be too big. The user should not typically change this directly. Stored in
details
in the database.- Type:
Object
- earliest_async_process_start_time¶
Time at which the earliest pending async process was called.
- Type:
Optional[datetime]
- definition¶
A dictionary of parameters defining the trial, inherited from the respective
Stimulus
object.
- participant_group¶
The associated participant group.
- block¶
The block in which the trial is situated.
- complete¶
whether the info is ‘complete’, i.e. has received its contents
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- make_definition(experiment, participant)[source]¶
Creates and returns a definition for the trial, which will be later stored in the
definition
attribute. This can be an arbitrary object as long as it is serialisable to JSON.- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.
- network¶
the network the info is in
- network_id¶
the id of the network the info is in
- origin¶
the Node that created the info.
- origin_id¶
the id of the Node that created the info
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- show_trial(experiment, participant)[source]¶
Returns a
Page
object, or alternatively a list of such objects, that solicits an answer from the participant.- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.
- time_of_death¶
the time at which failing occurred
- type¶
a String giving the name of the class. Defaults to “info”. This allows subclassing.
- vars¶
- class psynet.trial.static.StaticTrialMaker(*, id_, trial_class, nodes, expected_trials_per_participant, max_trials_per_participant=<class 'psynet.utils.NoArgumentProvided'>, recruit_mode=None, target_n_participants=None, target_trials_per_node=None, max_trials_per_block=None, allow_repeated_nodes=False, balance_across_nodes=True, check_performance_at_end=False, check_performance_every_trial=False, fail_trials_on_premature_exit=True, fail_trials_on_participant_performance_check=True, n_repeat_trials=0, assets=None, choose_participant_group=None, sync_group_type=None)[source]¶
Bases:
ChainTrialMaker
Administers a sequence of trials in a static experiment. The class is intended for use with the
StaticTrial
helper class. which should be customised to show the relevant node for the experimental paradigm.The user may also override the following methods, if desired:
choose_block_order()
; chooses the order of blocks in the experiment. By default the blocks are ordered randomly.choose_participant_group()
;Only relevant if the trial maker uses nodes with non-default participant groups. In this case the experimenter is expected to supply a function that takes participant as an argument and returns the chosen participant group for that trial maker.
on_complete()
, run once the sequence of trials is complete.performance_check()
; checks the performance of the participant with a view to rejecting poor-performing participants.compute_performance_reward()
; computes the final performance reward to assign to the participant.
Further customisable options are available in the constructor’s parameter list, documented below.
- Parameters:
trial_class – The class object for trials administered by this maker (should subclass
StaticTrial
).nodes (
Union
[callable
,List
[StaticNode
],None
]) – The nodes to be administered to the participants. This can be provided as a list ofStaticNode
objects, or as a function (taking no arguments) that can be called to generate such a list. The latter is useful for generating nodes based on local files (e.g. large media assets) that are not available on the deployed server.expected_trials_per_participant (
int
) – Expected number of trials that each participant will complete. This is used for timeline/progress estimation purposes.max_trials_per_participant (
Optional
[int
]) – Maximum number of trials that each participant may complete; once this number is reached, the participant will move on to the next stage in the timeline.recruit_mode (
Optional
[str
]) – Selects a recruitment criterion for determining whether to recruit another participant. The built-in criteria are"n_participants"
and"n_trials"
.target_n_participants (
Optional
[int
]) – Target number of participants to recruit for the experiment. All participants must successfully finish the experiment to count towards this quota. This target is only relevant ifrecruit_mode="n_participants"
.target_trials_per_node (
Optional
[int
]) – Target number of trials to recruit for each node in the experiment. This target is only relevant ifrecruit_mode="n_trials"
.max_trials_per_block (
Optional
[int
]) – Determines the maximum number of trials that a participant will be allowed to experience in each block, including failed trials. Note that this number does not include repeat trials.allow_repeated_nodes (
bool
) – Determines whether the participant can be administered the same node more than once.max_unique_nodes_per_block – Determines the maximum number of unique nodes that a participant will be allowed to experience in each block. Once this quota is reached, the participant will be forced to repeat previously experienced nodes.
balance_across_nodes (
bool
) – IfTrue
(default), active balancing across participants is enabled, meaning that node selection favours nodes that have been presented fewest times to any participant in the experiment, excluding failed trials.check_performance_at_end (
bool
) – IfTrue
, the participant’s performance is evaluated at the end of the series of trials. Defaults toFalse
. Seeperformance_check()
for implementing performance checks.check_performance_every_trial (
bool
) – IfTrue
, the participant’s performance is evaluated after each trial. Defaults toFalse
. Seeperformance_check()
for implementing performance checks.fail_trials_on_premature_exit (
bool
) – IfTrue
, a participant’s trials are marked as failed if they leave the experiment prematurely. Defaults toTrue
.fail_trials_on_participant_performance_check (
bool
) – IfTrue
, a participant’s trials are marked as failed if the participant fails a performance check. Defaults toTrue
.n_repeat_trials (
int
) – Number of repeat trials to present to the participant. These trials are typically used to estimate the reliability of the participant’s responses. Repeat trials are presented at the end of the trial maker, after all blocks have been completed. Defaults to 0.choose_participant_group (
Optional
[callable
]) – Only relevant if the trial maker uses nodes with non-default participant groups. In this case the experimenter is expected to supply a function that takes participant as an argument and returns the chosen participant group for that trial maker.sync_group_type (
Optional
[str
]) – Optional SyncGroup type to use for synchronizing participant allocation to nodes. When this is set, then the ordinary node allocation logic will only apply to the ‘leader’ of each SyncGroup. The other members of this SyncGroup will follow that leader around, so that in every given trial the SyncGroup works on the same node together.
- check_timeout_interval_sec¶
How often to check for trials that have timed out, in seconds (default = 30). Users are invited to override this.
- Type:
float
- response_timeout_sec¶
How long until a trial’s response times out, in seconds (default = 60) (i.e. how long PsyNet will wait for the participant’s response to a trial). This is a lower bound on the actual timeout time, which depends on when the timeout daemon next runs, which in turn depends on
check_timeout_interval_sec
. Users are invited to override this.- Type:
float
- async_timeout_sec¶
How long until an async process times out, in seconds (default = 300). This is a lower bound on the actual timeout time, which depends on when the timeout daemon next runs, which in turn depends on
check_timeout_interval_sec
. Users are invited to override this.- Type:
float
- network_query¶
An SQLAlchemy query for retrieving all networks owned by the current trial maker. Can be used for operations such as the following:
self.network_query.count()
.- Type:
sqlalchemy.orm.Query
- n_networks¶
Returns the number of networks owned by the trial maker.
- Type:
int
- networks¶
Returns the networks owned by the trial maker.
- Type:
list
- performance_threshold¶
Score threshold used by the default performance check method, defaults to 0.0. By default, corresponds to the minimum proportion of non-failed trials that the participant must achieve to pass the performance check.
- Type:
float
- end_performance_check_waits¶
If
True
(default), then the final performance check waits until all trials no longer have any pending asynchronous processes.- Type:
bool