fast-feedback virtual target task code on STM Nucleo

Dependencies:   mbed

Committer:
gwappa
Date:
Thu Jun 21 17:57:22 2018 +0000
Revision:
11:897ecd5413e0
Parent:
7:6744ec9ccc25
Child:
13:8ea85a33e37a
add auditory cue tickering

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gwappa 2:0c241937eabd 1 #ifndef TRIAL_H_
gwappa 2:0c241937eabd 2 #define TRIAL_H_
gwappa 2:0c241937eabd 3
gwappa 2:0c241937eabd 4 #include "task.h"
gwappa 3:991c6d5ce19d 5 #include "arraylist.h"
gwappa 3:991c6d5ce19d 6
gwappa 3:991c6d5ce19d 7 typedef int trialtime_t;
gwappa 2:0c241937eabd 8
gwappa 2:0c241937eabd 9 namespace TrialFlags {
gwappa 2:0c241937eabd 10 // nothing
gwappa 2:0c241937eabd 11 const char Clear = 0x00;
gwappa 2:0c241937eabd 12 // flags if the auditory cue is there during the trial
gwappa 2:0c241937eabd 13 const char Cues = 0x01;
gwappa 7:6744ec9ccc25 14 // flags if any "response" is detected during the response window
gwappa 2:0c241937eabd 15 const char Responded = 0x02;
gwappa 2:0c241937eabd 16 // flags if licking event is detected during the preparatory/pre-response window
gwappa 2:0c241937eabd 17 const char Licked = 0x04;
gwappa 2:0c241937eabd 18 }
gwappa 2:0c241937eabd 19
gwappa 2:0c241937eabd 20 namespace Responses {
gwappa 2:0c241937eabd 21 const char Hit = 0x03; // cues && responded
gwappa 2:0c241937eabd 22 const char Miss = 0x01; // cues && ~responded
gwappa 2:0c241937eabd 23 const char Catch = 0x02; // ~cues && responded
gwappa 2:0c241937eabd 24 const char Reject = 0x00; // ~cues && ~responded
gwappa 2:0c241937eabd 25 const char Reset = 0x04; // invalid lick
gwappa 2:0c241937eabd 26 const char NA = 0x08; // default
gwappa 2:0c241937eabd 27 }
gwappa 2:0c241937eabd 28
gwappa 2:0c241937eabd 29 struct Trial {
gwappa 2:0c241937eabd 30 /**
gwappa 2:0c241937eabd 31 * whether the animal whisked during the cue.
gwappa 2:0c241937eabd 32 * + whether the animal waited for the cue.
gwappa 2:0c241937eabd 33 */
gwappa 2:0c241937eabd 34 char response;
gwappa 2:0c241937eabd 35 /**
gwappa 2:0c241937eabd 36 * the timestamp when the trial started.
gwappa 2:0c241937eabd 37 */
gwappa 3:991c6d5ce19d 38 trialtime_t starting;
gwappa 2:0c241937eabd 39 /**
gwappa 2:0c241937eabd 40 * the timestamp when the cue started
gwappa 2:0c241937eabd 41 */
gwappa 3:991c6d5ce19d 42 trialtime_t cuestarting;
gwappa 2:0c241937eabd 43 /**
gwappa 2:0c241937eabd 44 * the total waiting period for the animal during this trial before the cue.
gwappa 2:0c241937eabd 45 */
gwappa 2:0c241937eabd 46 unsigned long waiting; // used for calculation of waiting period
gwappa 2:0c241937eabd 47 /**
gwappa 2:0c241937eabd 48 * the duration of the delay period for this trial.
gwappa 2:0c241937eabd 49 */
gwappa 2:0c241937eabd 50 uint16_t delay_dur_ms;
gwappa 2:0c241937eabd 51
gwappa 11:897ecd5413e0 52 uint64_t aud_ticker_cycle;
gwappa 11:897ecd5413e0 53
gwappa 3:991c6d5ce19d 54 ArrayList<trialtime_t> licking_events;
gwappa 3:991c6d5ce19d 55 ArrayList<trialtime_t> whisking_events;
gwappa 3:991c6d5ce19d 56
gwappa 2:0c241937eabd 57 void reset(const Task& task);
gwappa 2:0c241937eabd 58
gwappa 11:897ecd5413e0 59 void markTrialStart();
gwappa 11:897ecd5413e0 60 void markEndOfWait();
gwappa 11:897ecd5413e0 61 void markTrialEnd();
gwappa 11:897ecd5413e0 62
gwappa 2:0c241937eabd 63 void writeToSerial();
gwappa 2:0c241937eabd 64 };
gwappa 2:0c241937eabd 65
gwappa 2:0c241937eabd 66 #endif