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