123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- function [final_design, game, real_trials_number, catch_trials_number] = JA_CFs_trial_type_within_games_Stage2(GD)
- % outputs a structure with the features of the trials for each game
- % number of standard games
- standard_games_number = length(find(~strcmp(GD.games_distribution_names, {'wash_out'})));
- % set number of real trials per game
- real_trials_number = 9;
- % sets the number of catch trials per game
- catch_trials_number = 2;
- % initialise real_trials and catch_trials variables with empty cells
- real_trials = repmat({[]},[1,real_trials_number]);
- catch_trials = repmat({[]},[1,catch_trials_number]);
- total_trial_number = length([real_trials, catch_trials]);
- % initialise game variable
- game = cell(1,total_trial_number);
- % cue colors
- colors = {'press_color', 'lift_color'};
- TMS = {' '};
- % how many possible combinations
- combinations = length(colors)*length(colors)*length(TMS);
- % the two target colors for each participants are balanced and already randomized
- [color_CF_list, color_SBJ_list, TMS_list] = ...
- BalanceFactors((real_trials_number*standard_games_number)/combinations, 1, colors,colors,TMS);
- colors_combinations = [color_CF_list, color_SBJ_list, TMS_list];
- colors_idx = linspace(0, real_trials_number*standard_games_number,standard_games_number+1);
- % similar for the catch trials except that for CF is always orange, while
- % for SBJ can be either red or yellow.
- catch_colors_CF = {'catch_color', 'catch_color'};
- catch_combinations = length(catch_colors_CF)*length(colors)*length(TMS);
- % make combination and randomize couples
- [catch_color_CF_list, catch_color_SBJ_list, catch_TMS_list] = ...
- BalanceFactors((catch_trials_number*standard_games_number)/catch_combinations, 0, catch_colors_CF,colors, TMS);
- catch_colors_combinations = [catch_color_CF_list, catch_color_SBJ_list, catch_TMS_list];
- catch_colors_idx = linspace(0, catch_trials_number*standard_games_number,standard_games_number+1);
- % for each game set trials features
- % randomization of the trials order is performed at the end of the for
- % cycle
- for x = 1:length(GD.games_distribution_names)
-
-
- if strcmp(GD.games_distribution_names(x), 'wash_out')
-
- [wash_out_final_design, washout_game] = JA_internal_fun_washout_game()
- game{x} = washout_game;
- else
-
- col{x} = colors_combinations(colors_idx(x-1)+1:colors_idx(x),:);
- catch_col{x} = catch_colors_combinations(catch_colors_idx(x-1)+1:catch_colors_idx(x),:);
-
- col_tot_tmp{x} = cat(1,col{x},catch_col{x});
-
-
- % which trial is slow and which is fast
- tmp_real = real_trials;
- tmp_real(1:GD.games_distribution(x)) = {'slow_tr'};
- tmp_real(GD.games_distribution(x)+1:end) = {'fast_tr'};
-
-
- % up to this point set catch trials as 'ok_catch'
- tmp_catch = repmat({'ok_catch'},[1,length(catch_trials)]);
-
- % is a game containing catch trial failure?
- if ismember(x, GD. CF_catch_failing_game)
- % set the first element ad failed_catch
- tmp_catch(1,1) = {'failed_catch'};
- end
-
-
- % put real and catch trials in a single vector
- tmp_total = [tmp_real tmp_catch];
-
- % randomizes real and catch trials within each game
- rand_idx = randperm(total_trial_number);
- game{x}.sequence = tmp_total(rand_idx);
- col_tot{x} = col_tot_tmp{x}(rand_idx,:);
-
-
- % add info to the game struct
- if strcmp(GD.games_distribution_names(x), 'slow')
- game{x}.slow_game = 'yes';
- end
-
- game{x}.slow_trials_quantity = GD.games_distribution(x);
- game{x}.slow_trials = find(strcmp(game{x}.sequence, 'slow_tr'));
- game{x}.fast_trials = find(strcmp(game{x}.sequence, 'fast_tr'));
- game{x}.ok_catch_trials = find(strcmp(game{x}.sequence, 'ok_catch'));
- game{x}.out_slow_trials = find(strcmp(game{x}.sequence, 'out_slow'));
- game{x}.out_fast_trials = find(strcmp(game{x}.sequence, 'out_fast'));
- game{x}.failed_catch_trials = find(strcmp(game{x}.sequence, 'failed_catch'));
- game{x}.colors_CF = col_tot{x}(:,1);
- game{x}.colors_SBJ = col_tot{x}(:,2);
- game{x}.TMS = col_tot{x}(:,3);
- game{x}.number = repmat(num2cell(x), [total_trial_number 1]);
-
- table_games{x} = table(game{x}.number, game{x}.sequence',game{x}.colors_CF,game{x}.colors_SBJ,game{x}.TMS);
- game{x}.table = table_games{x};
- game{x}.table.Properties.VariableNames = {'Games', 'Type', 'CF_colors', 'SBJ_colors', 'TMS'};
-
-
-
- end
-
-
- end %for
- final_design_tmp = cat(1,table_games{2:end});
- final_design = cat(1,washout_game.table, final_design_tmp);
- final_design.Properties.VariableNames = {'Games', 'Type', 'CF_colors', 'SBJ_colors', 'TMS'};
- %size(find(sum([strcmp(final_design{:,2},'yellow'), strcmp(final_design{:,3},'yellow'),strcmp(final_design{:,1},'fast_tr')],2) == 3))
- %test_final_design = final_design([find(strcmp(final_design{:,1},'slow_tr')); find(strcmp(final_design{:,1},'fast_tr'))],:);
- function [wash_out_final_design, washout_game] = JA_internal_fun_washout_game()
-
- %% create colors for washout
- % create dummy sequence of colors
- wash_out_sequence_colors_tmp = repmat(colors', [real_trials_number, 1]);
-
- %randomize dummy sequence of colors for SBJ
- wash_out_idx_SBJ = randperm(total_trial_number);
-
- %randomize dummy sequence of colors for SBJ (also catch are either red or yellow for SBJ)
- wash_out_idx_CF = randperm(total_trial_number);%randperm(length(wash_out_sequence_tmp));
-
- %keep only the first 11 which equals --> wash_out_sequence for SBJ is ok
- wash_out_catch_sequence_SBJ = wash_out_sequence_colors_tmp(wash_out_idx_SBJ(1:total_trial_number));
-
- %keep only the first 11 which equals --> wash_out_sequence for CF
- wash_out_catch_sequence_CF = wash_out_sequence_colors_tmp(wash_out_idx_CF(1:total_trial_number));
-
-
- %randomize dummy sequence of colors for catch_colors_CF
- wash_out_catch_idx_CF_tmp = randperm(total_trial_number);
-
- % select the first two (number of catch trials)
- wash_out_catch_idx_CF = wash_out_catch_idx_CF_tmp(1:length(catch_colors_CF));
- %catch trials which are orange
- wash_out_catch_sequence_CF(wash_out_catch_idx_CF) = catch_colors_CF;
-
-
-
- %% create slow/fast
- wash_out_slow_fast_tmp = repmat({'slow_tr'; 'fast_tr'}, [real_trials_number, 1]);
-
- %randomize dummy sequence of slow/fast
- wash_out_slow_fast_idx = randperm(total_trial_number);
- wash_out_slow_fast = wash_out_slow_fast_tmp(wash_out_slow_fast_idx);
- wash_out_slow_fast(wash_out_catch_idx_CF) = {'ok_catch'};
-
- %%
- wash_out_TMS = repmat(TMS, [total_trial_number 1]);
-
- %check
- wash_out_final_design = [wash_out_slow_fast wash_out_catch_sequence_CF wash_out_catch_sequence_SBJ wash_out_TMS];
-
-
-
-
- washout_game.sequence = wash_out_final_design(:,1);
- washout_game.slow_trials_quantity = GD.games_distribution(1);
- washout_game.slow_game = {''} ;
- washout_game.slow_trials = find(strcmp(washout_game.sequence, 'slow_tr'))';
- washout_game.fast_trials = find(strcmp(washout_game.sequence, 'fast_tr'))';
- washout_game.ok_catch_trials = find(strcmp(washout_game.sequence, 'ok_catch'));
- washout_game.out_slow_trials = find(strcmp(washout_game.sequence, 'out_slow'));
- washout_game.out_fast_trials = find(strcmp(washout_game.sequence, 'out_fast'));
- washout_game.failed_catch_trials = find(strcmp(washout_game.sequence, 'failed_catch'));
- washout_game.colors_CF = wash_out_final_design(:,2);
- washout_game.colors_SBJ = wash_out_final_design(:,3);
- washout_game.TMS = wash_out_final_design(:,4);
- washout_game.number = repmat(num2cell(1), [total_trial_number 1]);
-
- table_washout_game = table(washout_game.number, washout_game.sequence,washout_game.colors_CF,washout_game.colors_SBJ,washout_game.TMS);
- washout_game.table = table_washout_game;
-
-
- end
- end
|