Demos
*****

The "demos" directory of the PsyNet repository holds three kinds of
runnable demo: "demos/features" shows one building block per demo,
"demos/pipelines" holds end-to-end pipelines for common paradigms, and
"demos/experiments" holds fuller experiments. Each demo runs with
"psynet debug local", either in place in a PsyNet source checkout or
as a copy, as described in Starting from a demo or an existing
experiment.

To read a demo's code without leaving your editor, run "psynet docs
demos". It prints a folder with the demos' code for the installed
PsyNet version. Release installs leave out the demos' media files and
vendored libraries, so to run a demo that uses them, take it from the
repository instead.


Pipelines
=========

Each pipeline takes a directory of audio files and collects one kind
of judgment on them. To use your own stimuli, copy the pipeline, put
the files in its "static/" directory, and change "STIMULUS_DIR" and
"STIMULUS_PATTERN" at the top of "experiment.py". Paths are relative
to the experiment directory. Changes to the stimuli need a restart of
"psynet debug local". Using stimuli and media describes how the files
reach the participant, and Hosting stimuli on S3 covers stimulus sets
too large to deploy with the experiment.

pipelines/simple_rating
   Participants rate each sound on several 1–5 scales. Writing a
   static trial maker.

pipelines/similarity
   Participants hear pairs of sounds and rate their similarity from 1
   to 5.

pipelines/timed_push_buttons
   While a piece of music plays, participants press a button at
   interesting moments, then describe each moment.

pipelines/step_tag
   Participants write emotion tags for music clips and rate each
   other's tags until the tags for each clip settle.

pipelines/tapping
   Participants tap along to metronomes and to music, with REPP
   volume, recording and tapping calibration. Stimuli are ".wav" files
   in "data/music_stimuli", each with an onset file of the same name
   ending in ".txt".


Timelines
=========

experiments/hello_world
   The smallest experiment: a single info page.

features/timeline
   Page makers, code blocks, "conditional", "switch", "while_loop" and
   "for_loop" on deliberately simple pages. The timeline, Writing a
   timeline.

experiments/timeline
   A longer walk through the same constructs, with consent, forms,
   modules and participant variables.

features/for_loop
   Nested "for_loop" constructs that show one page per item.

features/page_maker
   "PageMaker" building pages, code blocks and loops from earlier
   answers.

features/randomize
   "randomize" shuffling 100 info pages into a different order for
   each participant.

features/randomize_2
   "randomize" shuffling the order of two whole trial makers.

features/accumulate_answers
   "accumulate_answers=True" collecting the answers from several pages
   into one dictionary, in a page maker, a trial and a loop.

features/async_codeblock
   "AsyncCodeBlock" running server-side work in the background, with
   and without waiting for the result.

features/wait
   "wait_while" holding the participant on a waiting indicator until a
   condition becomes false.

features/pre_deploy_constant
   "pre_deploy_constant" recording values from your own computer at
   deploy time, such as a list of local data files, so the deployed
   experiment can read them.

features/website
   A small multi-page website built from "while_loop" and "switch",
   with the reward and progress bar turned off.


Pages and controls
==================

features/pages
   Info pages and modular pages combining text, image and audio
   prompts with buttons, text boxes and audio recording. Pages,
   Writing pages.

features/modular_page
   A gallery of prompt and control combinations, ending with custom
   "Prompt" and "Control" classes. Control gallery.

features/option_controls
   Push buttons, dropdowns, checkboxes and radio buttons, with their
   layout and selection options.

features/slider
   "SliderControl" options: range, steps, snapping, circular sliders,
   "minimal_interactions" and "random_wrap".

features/rhythm_slider
   "AudioSliderControl" playing a different rhythm for each slider
   position.

features/simple_multimedia_slider
   "MediaSliderControl" playing a different audio or video clip for
   each slider position.

features/progress_display
   "ProgressDisplay" and "ProgressStage" labeling the stages of a
   timed page, and events that trigger messages and alerts. Event
   management.

features/validate
   Page-level and control-level validation that keeps the participant
   on the page until the answer is acceptable.

features/music_notation
   "MusicNotationPrompt" showing a chord in staff notation.

experiments/survey_js
   A questionnaire built with "SurveyJSControl". To design one, use
   the SurveyJS Creator, copy the JSON from its JSON Editor tab into
   the control's "design" argument, and change JSON literals such as
   "true" to Python ones such as "True".

experiments/graphics
   Graphic prompts and controls with shapes, paths, images, text and
   animations. Graphics.

features/custom_theme
   Styling an experiment with a CSS file in "css_links" and inline
   rules in "css". Theming.

features/api
   "expose_to_api" letting a page's JavaScript call Python functions
   without leaving the page. Custom front ends.

experiments/jspsych
   A jsPsych reaction-time task embedded with "JsPsychPage".

experiments/unity_autoplay
   A Unity WebGL game embedded with "UnityPage", with participants
   randomly assigned to scoring conditions. Unity integration.


Trials
======

experiments/trial
   A "Trial" class shown with "Trial.cue" inside a "for_loop", without
   a trial maker: participants rate how happy some words feel. Static
   trial makers, Writing a static trial maker.

experiments/trial_2
   The same task with a fixed set of nodes, each with a synthesized
   audio stimulus generated at launch.

experiments/trial_3
   The same task with stimulus parameters sampled from a continuous
   range and audio synthesized when the trial needs it.

experiments/static
   "StaticTrialMaker" with blocks, keyboard responses, repeat trials
   and a performance check.

experiments/simple_audio_rating
   Participants rate a fixed list of instrument sounds on several 1–5
   scales, six trials each. For your own stimuli, start from
   "pipelines/simple_rating", which reads a folder of files.

experiments/audio_similarity
   Participants rate the similarity of pairs from a fixed list of
   instrument sounds from 1 to 5. For your own stimuli, start from
   "pipelines/similarity", which reads a folder of files.

experiments/audio_stimulus_set_from_dir
   "compile_nodes_from_directory" turning folders of audio files into
   practice and main trial makers. Using stimuli and media.

experiments/static_audio_3
   Participants rate how much they like existing sound files.

features/dense_color
   "DenseTrialMaker" sampling colors from continuous hue, saturation
   and lightness dimensions for participants to rate.

features/trial_cue_adaptive
   A 1-up/1-down staircase written with "Trial.cue" and "while_loop",
   with the adaptive rule in a separate, testable module.


Chains
======

experiments/chain_trial_maker
   A custom "ChainTrialMaker" in which each participant retells the
   previous participant's story. Chains, Writing a chain experiment.

experiments/imitation_chain
   An imitation chain in which participants remember a number and type
   it back.

experiments/imitation_chain_video
   An imitation chain of gestures recorded with the camera.

experiments/tapping_iterated
   An audio imitation chain of rhythms: participants tap along to a
   rhythm, and the server extracts the tap times to make the next
   rhythm.

experiments/tapping_memory
   The same chain, but participants tap the rhythm from memory after
   it stops.

experiments/gibbs
   Gibbs Sampling with People: participants adjust one dimension of a
   color at a time to match a word, in across-participant chains with
   two participant groups. See Writing a Gibbs Sampling with People
   experiment.

experiments/gibbs_within
   The same task with within-participant chains.

experiments/gibbs_audio
   "AudioGibbsTrialMaker": participants move through a space of
   synthesized voices to make a word sound as dominant or trustworthy
   as possible.

experiments/gibbs_audio_complex
   Audio Gibbs sampling over several prosodic dimensions, with emotion
   targets.

experiments/gibbs_image
   "ImageGibbsTrialMaker" with generated images of colored squares.

experiments/gibbs_svg
   "HtmlGibbsTrialMaker" with animated SVG stimuli, locking the slider
   while the animation plays.

experiments/gibbs_svg_zipped
   The same task, synthesizing all slider positions in one batch and
   delivering them as one zipped file.

experiments/gibbs_video
   "VideoGibbsTrialMaker" with synthesized video clips.

experiments/mcmcp
   Markov Chain Monte Carlo with People: participants choose which of
   two ages better fits an occupation, and the choice becomes the
   chain's next state.

experiments/staircase_pitch_discrimination
   "GeometricStaircaseTrialMaker": a 2-up/1-down pitch discrimination
   staircase.

experiments/graph
   "GraphChainTrialMaker" with chains on a lattice, using necklaces of
   colored beads.

experiments/create_and_rate/basic
   Create and rate: participants describe a dog image, and others rate
   the descriptions or choose the best one. Create and rate.

experiments/create_and_rate/picnic
   Participants guess a hidden rule from examples, and others rate the
   guesses.

experiments/create_and_rate/robot_voice
   Participants create a robot voice with audio Gibbs sampling, and
   others rate or choose the best match.

experiments/create_and_rate/gap
   Participants record a sentence for an imagined situation, and
   separate raters choose the most emotional recording.


Stimuli, media and recording
============================

experiments/audio
   JSSynth chords, audio and video prompts, audio meters, and audio
   and video recording. Writing pages.

features/video
   "VideoPrompt" and "VideoRecordControl": clipped playback, separate
   soundtracks, and recording from the camera and screen.

features/background_recording
   Camera recording alongside ordinary button answers, comparing
   optional clips with required trial recordings.

features/assets
   "asset" declaring remote files, local files, folders and generated
   files, and saving participant input as a new asset. Managing
   assets.

experiments/static_audio
   Participants hear a synthesized word, record themselves repeating
   it, and listen back. Using stimuli and media.

experiments/static_audio_2
   The same task with a stimulus parameter drawn from a continuous
   range.

features/volume_calibration
   "VolumeCalibration", a page for setting a comfortable listening
   level.

experiments/tapping_static
   Tapping to a metronome and to music with REPP, with calibration and
   recording checks.

experiments/repp_prescreen
   REPP volume calibration, tapping calibration and recording tests
   for use before a tapping task.

experiments/vertical_processing
   A complete music experiment: participants hear a chord and sing
   back its notes, which the server scores. It includes practice
   trials, notation, synthesized audio and questionnaires.


Participants
============

features/demography
   The built-in demography and questionnaire modules, including the
   Gold-MSI. Pre-screening and questionnaires.

features/attention_test
   "AttentionTest" placed between questionnaire items.

features/headphone_test
   "HugginsHeadphoneTest" and "AntiphaseHeadphoneTest" after volume
   calibration.

features/color_blindness
   "ColorBlindnessTest", an Ishihara-style screening test.

features/color_vocabulary
   "ColorVocabularyTest", which checks that participants know common
   color names.

features/audio_forced_choice_test
   "AudioForcedChoiceTest" screening participants with audio stimuli
   and answers listed in a CSV file.

experiments/language_tests
   "LexTaleTest" for English proficiency and "LanguageVocabularyTest"
   for Spanish.

experiments/vocabulary_test
   "WikiVocab" and "BibleVocab" vocabulary tests in Dutch and English.

features/monitor_information
   "MonitorInformation" recording the participant's screen properties.

experiments/translation
   An experiment translated into German and Dutch with "_" and "_p".
   Internationalization.


Groups
======

features/group_closer
   "SimpleGrouper", "GroupBarrier" and "GroupCloser": groups of three
   with roles, later regrouped into pairs. Groups, Groups and barriers
   in detail.

experiments/sync_quorum
   Participants do filler trials until enough people have joined.

experiments/gibbs_within_sync
   Gibbs sampling in which a group responds to each step together and
   the chain continues from the group's summarized answer.

experiments/create_rate_sync
   A live create-and-rate game for groups of three.

experiments/chatroom_simple
   Pairs of participants chat about a topic with "EnableChatrooms" and
   "ChatRoom". Chatrooms.

experiments/rock_paper_scissors
   A two-player game with scored rounds and a chat after each round.

experiments/crowd_estimate
   A wisdom-of-crowds estimation game in an open lobby: groups of up
   to four may start short and take latecomers until the game starts,
   and anyone left without a group answers alone. Each question is one
   cued trial per player, with the group's median on the node they
   share. Groups and barriers in detail.

experiments/story_chain
   Groups of three write a story one sentence at a time. Each turn is
   a cued round whose definition stores the writer, chosen by seat,
   and whose node stores the sentence as soon as the writer submits
   it. A member who leaves plays no more turns, and the next seat
   writes in their place. Writing a round-based experiment.

experiments/ultimatum_pairing
   An ultimatum game in cohorts, formed by a grouper that starts
   cohorts short and lets latecomers join. Each round re-pairs the
   cohort with a "Regrouper", and an odd player out sits out. Each
   round is one cued trial per player, with role-specific pages and
   the pair's result on the node its trials share. Writing a round-
   based experiment.

experiments/microsociety
   A fishing microsociety of three whose members are replaced one at a
   time: a newcomer is admitted at the start of the next round, where
   they read the society's recent catches and the tips of members who
   have left, and the longest-serving member then retires and leaves a
   tip. Groups and barriers in detail.

experiments/public_goods
   A repeated public goods game in groups of three that carries on
   with two when a member returns the study or stops responding, and
   tells the last player, and anyone without a group, why the game
   ended. Each round is one cued trial per player that pays its bonus,
   with the group's pot on the round they share. Groups and barriers
   in detail.

features/websocket_chatroom
   A multi-room chat written directly on WebSockets rather than
   "psynet.chatroom". Clients exchange messages on one shared channel
   and filter them by room. The experiment's "receive_message" stores
   each message in a custom table, "publish_to_subscribers" sends room
   occupancy to every client, and a custom route returns a room's
   history to late joiners. "config.txt" sets "num_chatrooms",
   "chatroom_max_occupancy" and "chatroom_show_history". Real-time
   interaction. Exchanging data with the server.


Database, bots and data
=======================

features/custom_table_simple
   A custom database table that stores a coin each time the
   participant collects one. Querying and storing database objects.

features/custom_table_complex
   A custom table with subclasses, each defining its own pages.

features/bot
   Three ways to give bots responses: a fixed "bot_response", a
   function, and a custom control. Testing back-end logic.

features/bot_2
   A scheduled task that starts a bot every 10 seconds in a running
   imitation chain.

features/artifact_storage
   "S3ArtifactStorage" with automatic backups of the data defined in
   "get_basic_data". Exporting data.
