%% initialise workspace cd('C:\Users\neuro\Desktop\JA_Stage1') sca; close all; clearvars delete(instrfindall) tic tinker = 0; show_RT = 0; TMS_delay = {'none'} cfg = [] cfg.relationship = 'training' %'parallel', 'joint', 'imagery' cfg.PTP_name = 'S09_pilot'; 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); % % CAMBIARE LE ISTRUZIONI come su manoscritto e agginugere IMAGERY!!!! % [general_intructions] = JA_instruction_selection_Warming_Up(); GD = JA_CFs_quickness_games_distribution(relationship); [final_design, game, real_trials, catch_trials] = JA_CFs_trial_type_within_games_alt(GD) [final_design] = JA_ball_colors_delays(final_design, ifi) [final_design] = JA_CF_response_delays_and_timings(final_design, ifi) [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'; % the fifth colum represents the delays 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 PP 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); %set Trigger to zero where it allready should be!! %% 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 = {[]}; %% HideCursor 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 vertical 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); % after CF response waiting time Cf piston hits the ball Par.VBL_TMS{Par.tr} = []; Par.VBL_piston_CF{Par.tr} = []; arg = []; arg.player = 'CF'; arg.sensor = 'SBJ_DCG'; [Ob, Par] = JA_SBJ_performance(Par,Ob,arg,s) %[Ob,Par] = JA_CF_performance(Par, Ob); % SBJ turn starts --> 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 vertical 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); % after SBJ response SBJ's piston hits the ball 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 vertical 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 save(saving_settings); end_block_time = toc;