Experiment running code - basic structure
Save locations
Experiment scripts are normally divided into two main functions, with the name of the experiment in the middle of the function name, like run_vsaPD_expt
and run_vsaPD_audapter
. These functions will be saved in the current-studies repository in a folder for the experiment. On a lab computer, this would be the filepath to the folder containing those functions: C:\Users\Public\Documents\software\current-studies\vsaPD
run_[experiment]_expt
This function sets up the vast majority of experiment settings, like number of trials, stimulus words, conditions, and perturbations. Most settings are saved into expt.mat. This function does not call Audapter or record any audio -- that's all in the other function.
Here is the overall code flow for a run_..._expt function:
- Make expt variable
- Make folders where data will be saved
- (Sometimes) Determine counterbalancing, if experiment has things to counterbalance. For example, for a 2-visit study, whether visit 1 is the null visit or perturbation visit
- Determine LPC Order to use in Audapter. Normally done via
run_checkLPC
- (Sometimes) find mean formant values, either from the run_checkLPC recordings, or by running an independent set of trials
- (Sometimes) Run practice phase of main study task. Used if we think some participants might need further instruction to understand the task properly before beginning.
- Start main experiment by calling
run_..._audapter
run_[experiment]_audapter
This function primarily takes an expt.mat file which was set up by the previous function, runs the trials of the experiment, and saves the data. A more detailed code flow:
- Set up Audapter
- Set up temporary save folder for individual trial data
- Set up windows and screens to display stimuli for participant and display monitoring info for experimenter
- Do a big loop to run the trial:
- Check for experimenter trying to pause
- Set Audapter perturbation settings for this trial
- Display stimulus and begin recording in Audapter
- Pause for specified duration, then stop recording
- Collect trial data from Audapter
- Clear participant's screen; display monitoring info to experimenter
- Check trial for appropriate amplitude and/or duration. Set flag to repeat this trial if it was bad
- Save this trial's data to temporary save folder
- Check for a break or end of experiment after this trial
- Load in all individual trial data from temporary folder, combine it into a variable
data
, savedata.mat
, then delete temporary files and folder - Close stimulus and monitoring screens
Annotated experiment running code
The functions run_modelExpt_expt
and run_modelExpt_audapter
are extensively commented and go into more depth and detail about our experiment running code. The functions are in the free-speech repository in free-speech/templates/modelExpt