Trials (2)
==========

Source: ``demos/trial_2``

This demo follows on from the previous Trial demo. Its key feature is programmatically
generating audio stimuli. Instead of manually creating a folder of audio stimuli
in advance, the experimenter instead defines a custom function, in this case
``synth_prosody``, which is called to generate stimuli.

The stimulus set is specified in the form of a list of Nodes. The Node is a core concept in
PsyNet that typically corresponds to some kind of 'stimulus generator'. We define a collection
of Nodes using a so-called list comprehension. List comprehensions are a special feature of
Python that are really great for creating exhaustive combinations of experimental parameters.
For example, the following part of the list comprehension makes sure that Nodes are created
in all combinations of five frequency gradients and three start frequencies.

.. code-block:: python

    for frequency_gradient in [-100, -50, 0, 50, 100]
    for start_frequency in [-100, 0, 100]


Each Node is linked to a Cached Function Asset. Assets correspond to files that are managed
by PsyNet. A Function Asset is an Asset that is generated by a function;
a Cached Function Asset is a Function Asset whose results are cached to avoid unnecessary
resource usage. Typically the outputs will be stored on a web server and the caching will serve
to avoid running the functions and uploading the files, both of which can otherwise be time-consuming.
When you run an experiment, PsyNet will automatically check the status of these Assets
and perform any computations or uploads that are necessary.


Source: ``demos/trial_2/experiment.py``

.. literalinclude:: ../../demos/trial_2/experiment.py
   :language: python

Source: ``demos/trial_2/custom_synth.py``

.. literalinclude:: ../../demos/trial_2/custom_synth.py
   :language: python
