|
| 1 | +function [cfg] = expDesign(cfg, displayFigs) |
| 2 | + % |
| 3 | + % Creates the sequence of blocks and the events in them |
| 4 | + % |
| 5 | + % The conditions are consecutive static and motion blocks. It gives better results than |
| 6 | + % randomised. |
| 7 | + % |
| 8 | + % It can be run as a stand alone without inputs and display a visual example of the |
| 9 | + % possible design. See `getMockConfig` to set up the mock configuration. |
| 10 | + % |
| 11 | + % It computes the directions to display and the task(s), at the moment: |
| 12 | + % (1) detection of change in the color of the fixation target |
| 13 | + % (2) detection of different speed of the moving dots [ W I P - if selected as a task it will |
| 14 | + % give the same null output as if not selected ie no difference in speed ] |
| 15 | + % |
| 16 | + % EVENTS |
| 17 | + % The ``nbEventsPerBlock`` should be a multiple of the number of motion directions requested in |
| 18 | + % ``motionDirections`` (which should be more than 1) e.g.: |
| 19 | + % MT localizer: ``cfg.design.motionDirections = [ 0 90 180 270 ]; % right down left up`` |
| 20 | + % MT_MST localizer: ``cfg.design.motionDirections = [666 -666]; % outward inward`` |
| 21 | + % |
| 22 | + % Pseudorandomization rules: |
| 23 | + % |
| 24 | + % - Directions: |
| 25 | + % (1) Directions are all presented in random orders in `numEventsPerBlock/nDirections` |
| 26 | + % consecutive chunks. This evenly distribute the directions across the |
| 27 | + % block. |
| 28 | + % (2) No same consecutive direction |
| 29 | + % |
| 30 | + % - Color change detection of the fixation cross: |
| 31 | + % (1) If there are 2 targets per block we make sure that they are at least 2 events apart. |
| 32 | + % (2) Targets cannot be on the first or last event of a block. |
| 33 | + % (3) No less than 1 target per event position in the whole run |
| 34 | + % |
| 35 | + % Input: |
| 36 | + % - cfg: parameters returned by setParameters |
| 37 | + % - displayFigs: a boolean to decide whether to show the basic design |
| 38 | + % matrix of the design |
| 39 | + % |
| 40 | + % Output: |
| 41 | + % - cfg.design.blockNames: cell array (nbBlocks, 1) with the condition name for each block |
| 42 | + % - cfg.design.nbBlocks: integer for th etotal number of blocks in the run |
| 43 | + % - cfg.design.directions: array (nbBlocks, nbEventsPerBlock) with the direction to present in a |
| 44 | + % given event of a block. |
| 45 | + % - 0 90 180 270 indicate the angle for translational motion direction |
| 46 | + % - 666 -666 indicate in/out-ward direction in radial motion |
| 47 | + % - -1 indicates static |
| 48 | + % - cfg.design.speeds: array (nbBlocks, nbEventsPerBlock) indicate the dots speed |
| 49 | + % in each event, the target is represented by a higher/lower value |
| 50 | + % - cfg.design.fixationTargets: array (nbBlocks, numEventsPerBlock) showing for each event if it |
| 51 | + % should be accompanied by a target |
| 52 | + % |
| 53 | + % (C) Copyright 2020 CPP visual motion localizer developpers |
| 54 | + |
| 55 | + %% Check inputs |
| 56 | + if nargin < 1 || isempty(cfg) |
| 57 | + |
| 58 | + % ``true`` for MT+ translational localizer |
| 59 | + % ``false`` for MT/MST localizer |
| 60 | + isMT = true; |
| 61 | + |
| 62 | + % Get mock inputs to run this function as a stand alone and get a flavour of how the design |
| 63 | + % looks like given certain inputs. Open this function to set different inputs. |
| 64 | + getMockConfig(isMT); |
| 65 | + |
| 66 | + % Get the computed design on a visual representation |
| 67 | + displayFigs = 1; |
| 68 | + |
| 69 | + end |
| 70 | + |
| 71 | + % Set to 1 for a visualtion of the trials design order |
| 72 | + if nargin < 2 || isempty(displayFigs) |
| 73 | + displayFigs = 0; |
| 74 | + end |
| 75 | + |
| 76 | + fprintf('\n\nComputing the design...\n\n'); |
| 77 | + |
| 78 | + %% Stimuli design |
| 79 | + |
| 80 | + % Computer a vector [nbBlocks x 1] with the order of the conditions to present |
| 81 | + cfg.design.blockNames = setBlocksConditions(cfg); |
| 82 | + |
| 83 | + % Get the nb of blocks |
| 84 | + [~, ~, ~, cfg.design.nbBlocks] = getDesignInput(cfg); |
| 85 | + |
| 86 | + % Compute a matrix [nbBlocks x nbEventsPerBlock] |
| 87 | + cfg.design.directions = setDirections(cfg); |
| 88 | + |
| 89 | + %% Task(s) design |
| 90 | + |
| 91 | + % Compute a matrix [nbBlocks x nbEventsPerBlock] with |
| 92 | + cfg.design.fixationTargets = setFixationTargets(cfg); |
| 93 | + |
| 94 | + % Compute a matrix [nbBlocks x nbEventsPerBlock] with the dots speeds (target speed will be |
| 95 | + % different form the base one) |
| 96 | + cfg.design.speeds = setSpeedTargets(cfg); |
| 97 | + |
| 98 | + %% Plot a visual representation of the design |
| 99 | + diplayDesign(cfg, displayFigs); |
| 100 | + |
| 101 | + fprintf('\n\n...design computed!\n\n'); |
| 102 | + |
| 103 | +end |
0 commit comments