Keisuke Sehara
/
STM32_Whisking
fast-feedback virtual target task code on STM Nucleo
task.h@16:33c17c62840e, 2018-06-30 (annotated)
- Committer:
- gwappa
- Date:
- Sat Jun 30 12:28:18 2018 +0000
- Revision:
- 16:33c17c62840e
- Parent:
- 15:20f7f737c256
- Child:
- 17:0b241aa1f5b6
add delay for reward in the Pair paradigm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gwappa | 1:871d3066c2ab | 1 | #ifndef TASK_H_ |
gwappa | 1:871d3066c2ab | 2 | #define TASK_H_ |
gwappa | 1:871d3066c2ab | 3 | |
gwappa | 1:871d3066c2ab | 4 | #include "mbed.h" |
gwappa | 5:849446d19406 | 5 | #include "config.h" |
gwappa | 1:871d3066c2ab | 6 | |
gwappa | 1:871d3066c2ab | 7 | /* |
gwappa | 1:871d3066c2ab | 8 | * command characters |
gwappa | 1:871d3066c2ab | 9 | */ |
gwappa | 9:e136394bdb39 | 10 | |
gwappa | 11:897ecd5413e0 | 11 | #define CMD_TEST_REWARD 'T' |
gwappa | 11:897ecd5413e0 | 12 | #define CMD_EXECUTE 'X' |
gwappa | 1:871d3066c2ab | 13 | |
gwappa | 11:897ecd5413e0 | 14 | #define CHR_DELAY_MIN 'm' |
gwappa | 11:897ecd5413e0 | 15 | #define CHR_DELAY_VAR 'd' |
gwappa | 11:897ecd5413e0 | 16 | #define CHR_PREP_DUR 'p' |
gwappa | 11:897ecd5413e0 | 17 | #define CHR_AUD_DUR 'a' |
gwappa | 11:897ecd5413e0 | 18 | #define CHR_AUD_FREQ 'f' |
gwappa | 13:8ea85a33e37a | 19 | #define CHR_RESP_DUR 'y' |
gwappa | 11:897ecd5413e0 | 20 | #define CHR_POST_DUR 'n' |
gwappa | 16:33c17c62840e | 21 | #define CHR_REWARD_ONSET 'u' |
gwappa | 11:897ecd5413e0 | 22 | #define CHR_REWARD_DUR 'r' |
gwappa | 15:20f7f737c256 | 23 | #define CHR_PRE_MIN 'o' |
gwappa | 14:af3adf5d5ddf | 24 | #define CHR_VIS_MIN 'j' |
gwappa | 14:af3adf5d5ddf | 25 | #define CHR_VIS_AVG 'v' |
gwappa | 13:8ea85a33e37a | 26 | #define CHR_VIS_FAIL 'q' |
gwappa | 1:871d3066c2ab | 27 | |
gwappa | 1:871d3066c2ab | 28 | enum Mode { |
gwappa | 1:871d3066c2ab | 29 | Pair, |
gwappa | 4:fcf597f82632 | 30 | Report, |
gwappa | 11:897ecd5413e0 | 31 | Associate, |
gwappa | 16:33c17c62840e | 32 | Motion, |
gwappa | 16:33c17c62840e | 33 | MotionAlt |
gwappa | 1:871d3066c2ab | 34 | }; |
gwappa | 1:871d3066c2ab | 35 | |
gwappa | 5:849446d19406 | 36 | struct ModeSelection: public config::CommandResponder |
gwappa | 5:849446d19406 | 37 | { |
gwappa | 9:e136394bdb39 | 38 | static const char CMD_ID_MODE; |
gwappa | 9:e136394bdb39 | 39 | static const char CMD_MODE_PAIR; |
gwappa | 9:e136394bdb39 | 40 | static const char CMD_MODE_REPORT; |
gwappa | 11:897ecd5413e0 | 41 | static const char CMD_MODE_ASSOCIATE; |
gwappa | 11:897ecd5413e0 | 42 | static const char CMD_MODE_MOTION; |
gwappa | 16:33c17c62840e | 43 | static const char CMD_MODE_MOTION_ALT; |
gwappa | 9:e136394bdb39 | 44 | |
gwappa | 5:849446d19406 | 45 | ModeSelection(); // not allowed |
gwappa | 5:849446d19406 | 46 | |
gwappa | 5:849446d19406 | 47 | explicit ModeSelection(const Mode& defaultValue); |
gwappa | 1:871d3066c2ab | 48 | |
gwappa | 5:849446d19406 | 49 | virtual ~ModeSelection(); |
gwappa | 5:849446d19406 | 50 | |
gwappa | 5:849446d19406 | 51 | virtual bool parse(const char& c); |
gwappa | 5:849446d19406 | 52 | |
gwappa | 5:849446d19406 | 53 | virtual bool writeSettings(); |
gwappa | 1:871d3066c2ab | 54 | |
gwappa | 5:849446d19406 | 55 | virtual void echoback(); |
gwappa | 5:849446d19406 | 56 | |
gwappa | 5:849446d19406 | 57 | Mode value; |
gwappa | 5:849446d19406 | 58 | }; |
gwappa | 5:849446d19406 | 59 | |
gwappa | 5:849446d19406 | 60 | struct Task { |
gwappa | 5:849446d19406 | 61 | ModeSelection mode; // the trial mode. |
gwappa | 5:849446d19406 | 62 | |
gwappa | 5:849446d19406 | 63 | Property<uint16_t> delay_min_ms; // the minimum duration for the delay. |
gwappa | 5:849446d19406 | 64 | |
gwappa | 5:849446d19406 | 65 | Property<uint16_t> delay_var_ms; // the average for the (exponential) variable |
gwappa | 5:849446d19406 | 66 | // duration of the delay. |
gwappa | 1:871d3066c2ab | 67 | |
gwappa | 5:849446d19406 | 68 | Property<uint16_t> prep_dur_ms; // the duration of the "preparatory period", |
gwappa | 1:871d3066c2ab | 69 | // during which licking is not allowed. |
gwappa | 1:871d3066c2ab | 70 | |
gwappa | 11:897ecd5413e0 | 71 | Property<uint16_t> aud_dur_ms; // the auditory cue duration. |
gwappa | 11:897ecd5413e0 | 72 | |
gwappa | 11:897ecd5413e0 | 73 | Property<uint16_t> aud_tick_hz; // the frequency of auditory cue flickering. |
gwappa | 5:849446d19406 | 74 | |
gwappa | 13:8ea85a33e37a | 75 | Property<uint16_t> resp_dur_ms; // the size of the minimal 'response window' for the passive paradigms. |
gwappa | 13:8ea85a33e37a | 76 | |
gwappa | 5:849446d19406 | 77 | Property<uint16_t> post_dur_ms; // the post-reward recording duration. |
gwappa | 1:871d3066c2ab | 78 | |
gwappa | 16:33c17c62840e | 79 | Property<uint16_t> reward_on_ms; // the onset of reward relative to visual cue during Pair. |
gwappa | 16:33c17c62840e | 80 | |
gwappa | 16:33c17c62840e | 81 | Property<uint16_t> reward_dur_ms; // the duration of reward. |
gwappa | 1:871d3066c2ab | 82 | |
gwappa | 15:20f7f737c256 | 83 | Property<uint16_t> pre_min_ms; // the minimum onset for the (passive) visual cue. |
gwappa | 15:20f7f737c256 | 84 | |
gwappa | 11:897ecd5413e0 | 85 | Property<uint16_t> vis_min_ms; // the minimum duration for the (passive) visual cue. |
gwappa | 11:897ecd5413e0 | 86 | |
gwappa | 14:af3adf5d5ddf | 87 | Property<uint16_t> vis_avg_ms; // the average duration for the (passive) visual cue. |
gwappa | 14:af3adf5d5ddf | 88 | |
gwappa | 13:8ea85a33e37a | 89 | Property<uint16_t> vis_fail_perc; // the 'failure rate' of the (passive) visual cue. |
gwappa | 11:897ecd5413e0 | 90 | |
gwappa | 5:849446d19406 | 91 | Action test_reward; |
gwappa | 5:849446d19406 | 92 | |
gwappa | 5:849446d19406 | 93 | Action run; |
gwappa | 1:871d3066c2ab | 94 | |
gwappa | 1:871d3066c2ab | 95 | explicit Task(const Mode& mode=Pair); |
gwappa | 1:871d3066c2ab | 96 | |
gwappa | 1:871d3066c2ab | 97 | void parseFromSerial(); |
gwappa | 1:871d3066c2ab | 98 | |
gwappa | 1:871d3066c2ab | 99 | private: |
gwappa | 5:849446d19406 | 100 | void testReward(); |
gwappa | 5:849446d19406 | 101 | void runTrial(); |
gwappa | 1:871d3066c2ab | 102 | void writeSettingsToSerial(); |
gwappa | 1:871d3066c2ab | 103 | }; |
gwappa | 1:871d3066c2ab | 104 | #endif |