Keisuke Sehara
/
STM32_Whisking
fast-feedback virtual target task code on STM Nucleo
trial.h
- Committer:
- gwappa
- Date:
- 2018-07-02
- Revision:
- 20:4c06d3041337
- Parent:
- 19:50663f8815b8
- Child:
- 22:41163fb3fdc6
File content as of revision 20:4c06d3041337:
#ifndef TRIAL_H_ #define TRIAL_H_ #include "task.h" #include "arraylist.h" #include "random.h" typedef int trialtime_t; struct TrialFlag { bool cued; bool responded; bool reset; TrialFlag(): cued(false), responded(false), reset(false) {} void clear(); void writeToSerial(); }; struct Trial { /** * whether the animal whisked during the cue. * + whether the animal waited for the cue. */ TrialFlag flag; /** * the timestamp when the trial started. */ trialtime_t starting; /** * the timestamp when the cue started */ trialtime_t cuestarting; /** * the total waiting period for the animal during this trial before the cue. */ unsigned long waiting; // used for calculation of waiting period /** * the duration of the delay period for this trial. */ uint16_t delay_dur_ms; // (passive) visual cue-related params uint16_t vis_onset_us; uint16_t vis_dur_us; /** * a buffer for recording licking events during the trial. */ ArrayList<trialtime_t> licking_events; /** * a buffer for recording whisking events during the trial. */ ArrayList<trialtime_t> whisking_events; /** * initialize the trial parameters according to the given Task parameter set. * typically called from one of the automaton states. */ void reset(const Task& task); /** * a helper function to assign onset & duration randomly for the (passive) visual cue. * * the `onset` will distribute exponentially from `0` to `auddur - respdur - mindur`. * the `duration` will distribute uniformly from `mindur` to `phasedur - onset`. */ void assignRandomStim(const Task& task); /** * a callback mechanism for marking (timestamping) the start of the trial. * called from one of the automaton states. */ void markTrialStart(); /** * a callback mechanism for marking (timestamping) the end of the waiting period of the trial. * called from one of the automaton states. */ void markEndOfWait(); /** * a callback mechanism for marking (timestamping) the end of the trial. * called from one of the automaton states. */ void markTrialEnd(); /** * output the result of a trial into a serial port through the IO mechanism. * typically called from one of the automaton states. */ void writeToSerial(); }; #endif