123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- function [exclusion_training, criteria] = JA_Training_Stage2(r_block, data_subject, PTP_name)
- % The structure of the script is the same as JA_Main_Experiment_Stage2.m
- % with the following difference (check out the main_expeirment function, before this one)
- % 1) no CF is present for in this block. PTP (SBJ in the scripts) provides responses on both
- % turns.
- % 2) No TMS delivered.
- % differently from the Main Experiment blocks
- % PTP (SBJ) provides responses in both turns, first with his/her right hand
- % then, with the left hand in the second turn
- % some features in the Par structure are similar to the main_experiment
- % function, even though no TMS is present and no CF is present
- %% initialise workspace
- addpath('C:\Users\neuro\Desktop\JA_Stage1');
- cd('C:\Users\neuro\Desktop\JA_Stage2');
- sca;
- close all;
- delete(instrfindall)
- tic
- tinker = 0;
- show_RT = 0;
- TMS_delay = {'none'}
- cfg = []
- cfg.relationship = 'training'
- cfg.PTP_name = PTP_name;
- cfg.TMS_delay = TMS_delay;
- [saving_settings, relationship, PTP_name] = JA_saving_settings(cfg);
- [window, screen_dimensions, screenNum, CenterX, CenterY, ifi] = JA_Screen_Settings(tinker);
- screen_dimensions_ratio = screen_dimensions(4)/screen_dimensions(3);
- GD = JA_CFs_quickness_games_distribution(relationship);
- % final design is a table containing all the info of each trial
- [final_design, game, real_trials, catch_trials] = JA_CFs_trial_type_within_games_alt(GD)
- % add delays between ball landing and color appearence
- [final_design] = JA_ball_colors_delays(final_design, ifi)
- %(leftover from the main experiment function)
- [final_design] = JA_CF_response_delays_and_timings(final_design, ifi)
- % (leftover from the main experiment function)
- [final_design] = JA_trigger_values_setting(final_design)
- % what response has SBJ provided on his/her own original turn (the second)
- final_design(:,14) = cell(size(final_design,1),1);
- final_design.Properties.VariableNames{14} = 'SBJ_performance_Type';
- % what response has SBJ provided on his/her own first turn (left hand)
- final_design(:,15) = cell(size(final_design,1),1);
- final_design.Properties.VariableNames{15} = 'CF_performance_Type';
- %%
- % clear other opened ports
- delete(instrfindall);
- clear s
- %Set up the serial port
- global s;
- s = serial('COM5');
- set(s, 'BaudRate', 115200); % set BaudRate to 115200 (as in Arduino!!!!!)
- % open serial
- fopen(s);
- WaitSecs(2);
- for d = 1:2
- scrittura(s);
- end
- % define Parallel Port (see main_experiment function)
- ioObj = io64;
- status = io64(ioObj);
- % specify address where u want to send triggers
- address = hex2dec('DFB8'); %select LTP1 output port address
- io64(ioObj, address, 0); %initialisation
- %%
- Par = [];
- Par.PTP_name = PTP_name;
- Par.window = window;
- Par.screen_dimensions = screen_dimensions;
- Par.ifi = ifi;
- Par.VBL = [];
- Par.tr = 1;
- Par.real_trials_x_game = real_trials;
- Par.catch_trials_x_game = catch_trials;
- Par.trials_x_game = real_trials + catch_trials;
- Par.charge = 0.3; %secs
- Par_baseline{Par.tr} = [];
- Par.relationship = relationship;
- Par.final_design = final_design;
- Par.initial_color = [0.5 0.5 0.5];
- Par.lift_color = [1 1 0];%[0 0.5 1];
- Par.press_color = [1 0.0 0.0];%[1 0.5 0];
- Par.catch_color = [1 0.55 0.0];
- Par.color_change_duration = 4*Par.ifi;
- Par.address = address;
- Par.PP = ioObj;
- Par.threshold_catch_response = 0.05;
- Par.SBJ_RT_tmp = {[]};
- Par.SBJ_RT = {[]};
- Par.SBJ_classification = {[]};
- Par.SBJ_RT_median = {[]};
- Par.CF_RT_tmp = {[]};
- Par.CF_RT = {[]};
- Par.CF_classification = {[]};
- Par.CF_RT_median = {[]};
- Par.VBL_first_frame{1} = [];
- Par.VBL_ball_landed_on_table_CF{1} = [];
- Par.VBL_ball_delay_CF{1} = [];
- Par.VBL_ball_changes_color_CF{1} = [];
- Par.VBL_ball_back_to_gray_CF{1} = [];
- Par.VBL_piston_CF{1} = [];
- Par.VBL_TMS{1} = [];
- Par.VBL_ball_landed_on_table_SBJ{1} = [];
- Par.VBL_ball_changes_color_SBJ{1} = [];
- Par.VBL_ball_back_to_gray_SBJ{1} = [];
- Par.VBL_piston_SBJ{1} = [];
- Par.outcome_feedback_trials = find(diff(cell2mat(Par.final_design.Games)));
- Par.warming_up_correctness.catch = {[]};
- Par.warming_up_correctness.real = {[]};
- % task instructions
- JA_instruction_selection(Par);
- %%
- HideCursor
- switch Par.relationship
-
- case 'warming_up'
-
- EEG_Trigger(Par.PP,Par.address,122);
-
- case 'training'
-
- EEG_Trigger(Par.PP,Par.address,123);
-
- case 'joint'
-
- EEG_Trigger(Par.PP,Par.address,124);
-
- case 'parallel'
-
- EEG_Trigger(Par.PP,Par.address,125);
-
- case 'competitive'
-
- EEG_Trigger(Par.PP,Par.address,126);
-
- case 'imagery'
- EEG_Trigger(Par.PP,Par.address,127);
-
- end
- %%
- for x = 1:size(final_design,1)
- Par.tr = x;
-
- % initialize objects on the screen
- [Ob, Par] = JA_Initialise_Shapes(Par);
-
- %at the onset check if sensors are pressed and saves the baseline
- [bs, Par] = JA_check_hands_Warming_Up(Par, s)
- Par.baseline{Par.tr} = bs;
-
- % load the objects on the 'hidden screen' before flipping it on the front
- [Ob, Par]= JA_Load_Obj_On_Screen(Par, Ob);
- [Par.VBL] = Screen(Par.window, 'Flip');
- Par.VBL_first_frame{Par.tr} = Par.VBL;
- value = Par.final_design.Trial_Type_Trigger(Par.tr);
- EEG_Trigger(Par.PP,Par.address,value);
-
- % trial starts --> ball falls down --> when toiches the table_CF it
- Par.VBL_ball_landed_on_table_CF{Par.tr} = [];
-
- arg = [];
- arg.player = 'CF';
- arg.distanceX = 0; % proportion of the horizontal screen side
- arg.distanceY = 0.4; % proportion of the vertical screen side
- [Ob, Par] = JA_Object_Movement(Par,Ob, arg);
-
-
- % after a delay change color
- Par.VBL_ball_changes_color_CF{Par.tr} = [];
- Par.VBL_ball_back_to_gray_CF{Par.tr} = [];
-
- arg = [];
- arg.player = 'CF';
- [Ob, Par] = JA_Ball_color_change(Par,Ob, arg);
-
-
-
-
-
- Par.VBL_TMS{Par.tr} = [];
- Par.VBL_piston_CF{Par.tr} = [];
-
-
- % get responses from PTP's right hand
- %(as if he/she was the CF, but getting the pressure values from the SBJ_DCG sensor)
-
- arg = [];
- arg.player = 'CF';
- arg.sensor = 'SBJ_DCG';
- [Ob, Par] = JA_SBJ_performance(Par,Ob,arg,s)
-
-
- % second turn --> ball moves leftwards --> the ball touches the table_SBJ
- Par.VBL_ball_landed_on_table_SBJ{Par.tr} = [];
-
- arg = [];
- arg.player = 'SBJ';
- arg.distanceX = -0.4; % proportion of the horizontal screen side
- arg.distanceY = 0.0; % proportion of the vertical screen side
- [Ob, Par] = JA_Object_Movement(Par, Ob, arg)
-
-
- % after a delay change color
- Par.VBL_ball_changes_color_SBJ{Par.tr} = [];
- Par.VBL_ball_back_to_gray_SBJ{Par.tr} = [];
-
- arg = [];
- arg.player = 'SBJ';
- [Ob, Par] = JA_Ball_color_change(Par,Ob, arg);
-
-
- %..as in the main experiment, get response from the left hand (SBJ_RISP sensor)
-
- Par.VBL_piston_SBJ{Par.tr} = [];
-
- arg = [];
- arg.player = 'SBJ';
- arg.sensor = 'SBJ_RISP';
- [Ob,Par] = JA_SBJ_performance(Par, Ob, arg, s);
-
-
- % the ball has been hit by SBJ's piston and traveles towards the top
- % of the screen
- arg = [];
- arg.player = 'no_player';
- arg.distanceX = 0.0; % proportion of the horizontal screen side
- arg.distanceY = -0.4; % proportion of the vertical screen side
-
- [Ob, Par] = JA_Object_Movement(Par, Ob, arg)
-
-
- % feedback screen if something went wrong or catch trial
- [Par] = JA_interim_feedback_warming_up(Par);
-
- % outcome feedback
- [Par] = JA_outcome_feedback_warming_up(Par);
-
- scrittura(s)
- end
- sca
- end_block_time = toc;
- %%
- [abs_number_of_out_of_range_CF,...
- out_time_range_percentage_CF,...
- abs_number_wrong_catch_CF,...
- wrong_catch_percentage_CF,...
- abs_number_wrong_responses_last_three_game_CF,...
- wrong_response_last_three_games_percentage_CF]= JA_exclusion_criteria_CF(Par);
- [abs_number_of_out_of_range_SBJ,...
- out_time_range_percentage_SBJ,...
- abs_number_wrong_catch_SBJ,...
- wrong_catch_percentage_SBj,...
- abs_number_wrong_responses_last_three_game_SBJ,...
- wrong_response_last_three_games_percentage_SBJ]= JA_exclusion_criteria_SBJ(Par)
- %%
- total_out_of_time_range_percentage = 100*(abs_number_of_out_of_range_CF + abs_number_of_out_of_range_SBJ)/ (9*12*2)
- total_within_time_range_percentage = 100 - total_out_of_time_range_percentage;
-
- total_wrong_catch_percentage = 100*(abs_number_wrong_catch_CF + abs_number_wrong_catch_SBJ)/ (2*12*2)
- total_correct_catch_percentage = 100 - total_wrong_catch_percentage;
-
-
- if (total_correct_catch_percentage < 50) && (total_out_of_time_range_percentage > 30); % if correct responses < 70%
-
- exclusion_training = 1;
-
- else
- exclusion_training = 0;
-
- end
-
- criteria.out_of_time = total_out_of_time_range_percentage;
- criteria.correct_catch = total_correct_catch_percentage;
- save(data_subject);
- end
|