|
1 | 1 | % (C) Copyright 2020 CPP_PTB developers |
2 | 2 |
|
3 | 3 | function responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) |
4 | | - % responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) |
5 | 4 | % |
6 | | - % Wrapper function to use KbQueue |
| 5 | + % Wrapper function to use KbQueue. The queue will be listening to key presses |
| 6 | + % on a keyboard device: |
| 7 | + % ``cfg.keyboard.responseBox`` or ``cfg.keyboard.keyboard`` are 2 main examples. |
| 8 | + % When no ``deviceNumber`` is set then it will listen to the default device. |
| 9 | + % Check the ``CPP_getResponseDemo`` for a quick script on how to use it. |
7 | 10 | % |
8 | | - % The queue will be listening to key presses on a keyboard device: |
9 | | - % cfg.keyboard.responseBox or cfg.keyboard.keyboard are 2 main examples. |
| 11 | + % USAGE:: |
10 | 12 | % |
11 | | - % When no deviceNumber is set then it will listen to the default device. |
| 13 | + % responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) |
12 | 14 | % |
13 | | - % Check the CPP_getResponseDemo for a quick script on how to use it. |
| 15 | + % :param action: Defines what we want the function to do |
| 16 | + % :param deviceNumber: device number of the keyboard or trigger box in MRI |
| 17 | + % :type deviceNumber: integer |
| 18 | + % :param cfg: |
| 19 | + % :param getOnlyPress: if set to true the function will only return the key presses and will not |
| 20 | + % return when the keys were released (default=true). See the section on |
| 21 | + % `Returns` below for more info |
14 | 22 | % |
| 23 | + % :returns: |
15 | 24 | % |
16 | | - % INPUT |
| 25 | + % - :responseEvents: returns all the keypresses and return them |
| 26 | + % as a structure with field names that make it easier |
| 27 | + % to save the output of in a BIDS format |
17 | 28 | % |
18 | | - % - action: Defines what we want the function to do |
19 | | - % - init: to initialise the queue |
20 | | - % - start: to start listening to keypresses |
21 | | - % - check: checks all the key presses events since 'start', or since last |
22 | | - % 'check' or 'flush' (whichever was the most recent) |
23 | | - % -- can check for demand to abort if the escapeKey is listed in the |
24 | | - % Keys of interest. |
25 | | - % -- can only check for demands to abort when getResponse('check') is called: |
26 | | - % so there will be a delay between the key press and the experiment stopping |
27 | | - % -- abort errors send specific signals that allow the catch to get |
28 | | - % them and allows us to "close" nicely |
29 | | - % - flush: empties the queue of events in case you want to restart from a clean |
30 | | - % queue |
31 | | - % - stop: stops listening to key presses |
| 29 | + % - ``responseEvents.onset`` this is an absolute value and you should substract |
| 30 | + % the "experiment start time" to get a value relative to when the experiment was started. |
32 | 31 | % |
33 | | - % - getOnlyPress: if set to true the function will only return the key presses and |
34 | | - % will not return when the keys were released (default=true) |
35 | | - % See the section on OUTPUT below for more info |
| 32 | + % - ``responseEvents.trial_type = response`` |
36 | 33 | % |
| 34 | + % - ``responseEvents.duration = 0`` |
37 | 35 | % |
| 36 | + % - ``responseEvents.keyName`` the name of the key pressed |
38 | 37 | % |
39 | | - % OUTPUT |
| 38 | + % - ``responseEvents(iEvent,1).pressed`` if |
40 | 39 | % |
41 | | - % responseEvents: returns all the keypresses and return them as a structure |
42 | | - % with field names that make it easier to save the output of in a BIDS |
43 | | - % format |
| 40 | + % - ``pressed == 1`` --> the key was pressed |
| 41 | + % - ``pressed == 0`` --> the key was released |
44 | 42 | % |
45 | | - % responseEvents.onset : this is an absolute value and you should |
46 | | - % substract the "experiment start time" to get a value relative to when the |
47 | | - % experiment was started. |
| 43 | + % --- |
48 | 44 | % |
49 | | - % responseEvents.trial_type = 'response'; |
| 45 | + % ``action`` options: |
50 | 46 | % |
51 | | - % responseEvents.duration = 0; |
| 47 | + % - ``init`` to initialise the queue |
52 | 48 | % |
53 | | - % responseEvents.keyName : the name of the key pressed |
| 49 | + % - ``start`` to start listening to keypresses |
| 50 | + % |
| 51 | + % - ``check`` checks all the key presses events since 'start', or since last 'check' |
| 52 | + % or 'flush' (whichever was the most recent) |
| 53 | + % |
| 54 | + % - can check for demand to abort if the ``escapeKey`` is listed in the Keys of interest |
| 55 | + % |
| 56 | + % - can only check for demands to abort when ``getResponse('check')`` is called |
| 57 | + % so there will be a delay between the key press and the experiment stopping |
| 58 | + % |
| 59 | + % - abort errors send specific signals that allow the catch to get them and allows us |
| 60 | + % to "close" nicely |
| 61 | + % |
| 62 | + % - ``flush`` empties the queue of events in case you want to restart from a clean queue |
| 63 | + % |
| 64 | + % - ``stop`` stops listening to key presses |
54 | 65 | % |
55 | | - % responseEvents(iEvent,1).pressed : if |
56 | | - % pressed == 1 --> the key was pressed |
57 | | - % pressed == 0 --> the key was released |
58 | 66 |
|
59 | 67 | if nargin < 2 || isempty(deviceNumber) |
60 | 68 | deviceNumber = -1; |
|
0 commit comments