123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- %% initialise workspace
- cd('C:\Users\neuro\Desktop\JA_Stage1')
- sca;
- close all;
- clearvars
- delete(instrfindall)
- tinker = 0;
- show_RT = 0;
- % choose betwen 0.0 and -0.05
- TMS_delay = {'0.0'};%{'-0.05'}
- tic;
- cfg = []
- cfg.relationship = 'imagery'
- cfg.PTP_name = 'S09_pliot';
- 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, 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)
- % the fifth colum represents the delays
- final_design(:,14) = cell(size(final_design,1),1);
- final_design.Properties.VariableNames{14} = 'SBJ_performance_Type';
- [final_design] = JA_TMS_random_delays(final_design, TMS_delay, ifi)
- % other triggers
- %% 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 = {[]};
- 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.TMS_delay = TMS_delay
- 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)));
- %%
- HideCursor
- for x = 1:size(final_design,1)
- Par.tr = x;
-
- % calculate the CF_RT for the following trial
- % better here in order not to waste run-time
- % initialise CF and SBJ RTs
- Par.CF_RT{Par.tr} = [];
- Par.SBJ_RT{Par.tr} = [];
- [Par] = JA_Average_previous_trials(Par);
-
- % initialize objects on the screen
- [Ob, Par] = JA_Initialise_Shapes(Par);
-
- %at the onset check if sensors are pressed and saves the baseline
- %(initial pressure conditions whcih will be used to detect lifts and presses)
- % arg = [];
- % arg.sensors = {'CF', 'SBJ_RISP'}
- [bs, Par] = JA_check_hands_Main_Experiment(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} = [];
-
- [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(Par)
-
- % outcome feedback
- [Par] = JA_outcome_feedback(Par, GD)
-
- scrittura(s)
- end
- sca
- save(saving_settings);
- end_block_time = toc;
|