123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- function [Ob,Par] = JA_CF_performance(Par, Ob)
- %% Wait the selected seconds before make the piston hit the ball
- %% distinguish between catch and real trials, then calculate waiting time
- if strcmp(Par.final_design.CF_colors{Par.tr}, 'catch_color') % independently of whether is an ok or failed catch
- waiting_time = Par.final_design.CF_response_timings(Par.tr)+Par.charge;
- else
- % in case it is a normal trial, switch on final.design.Type
- switch Par.final_design.Type{Par.tr}
-
- case {'slow_tr','fast_tr'}
- waiting_time = ...
- Par.SBJ_RT_median{Par.tr} +... % SBJ_RT already includes charge
- Par.final_design.CF_response_timings(Par.tr)
- %+Par.charge;
- case {'out_slow','out_fast'}
- waiting_time = Par.final_design.CF_response_timings(Par.tr)+ Par.charge;
- end
-
- end
- %% calculate waiting_time
- [~, wt_as] = JA_frames_function(waiting_time, Par.ifi);
- %% when should I deliver the TMS pulse
- if strcmp(Par.TMS_delay, '-0.05')
-
- % from the piston hitting time subtract an amount of time, the result is the TMS delay from color change
- [~,TMS_delay_as] = JA_frames_function(waiting_time - abs(Par.final_design.TMS(Par.tr)), Par.ifi);
-
- end
- if strcmp(Par.TMS_delay, '0.0')
- % add a +/- 50 ms delay to the median SBJ_RT
- [~,TMS_delay_as] = JA_frames_function(Par.SBJ_RT_median{Par.tr} + Par.final_design.TMS(Par.tr)-Par.charge, Par.ifi);
- end
- %% the ball has to become gray (initial_color) again
- % prepare the piston final position
- target_object = 'piston_CF';
- [new_piston_dimensions] = JA_piston_sliding_final_dimension(Ob, target_object);
- % set the EEG trigger code value for the current trial
- piston_trigger_name = strcat(target_object, '_Trigger');
- value = Par.final_design.(piston_trigger_name)(Par.tr);
- %%
- if TMS_delay_as == wt_as % if fddelay beteen hitting and tms is zero
-
- % prepare new piston position
- target_object = 'piston_CF';
- Ob.(target_object).dimension = new_piston_dimensions;
- [Ob, Par]= JA_Load_Obj_On_Screen(Par, Ob);
- [Par.VBL] = Screen(Par.window, 'Flip', Par.VBL_ball_changes_color_CF{Par.tr}+TMS_delay_as);
- can_i_trigger = 1;
- disp('TMS delivered')
- [can_i_trigger] = PP_Trigger(Par.PP,Par.address,can_i_trigger);
- % get VBL of TMS pulse
- Par.VBL_TMS{Par.tr} = Par.VBL;
- % get VBL of piston hitting the ball
- Par.VBL_piston_CF{Par.tr} = Par.VBL;
- % EEG trigger code for color change
- EEG_Trigger(Par.PP,Par.address,value);
- else % if it is different from zero, do tms and hitting in sequence
-
-
- % prepare delay for TMS pulse
- % print on front screen what is going on and get a VBL timing
- [Ob, Par]= JA_Load_Obj_On_Screen(Par, Ob);
- [Par.VBL] = Screen(Par.window, 'Flip', Par.VBL_ball_changes_color_CF{Par.tr}+TMS_delay_as);
- can_i_trigger = 1;
- disp('TMS delivered')
- [can_i_trigger] = PP_Trigger(Par.PP,Par.address,can_i_trigger);
- % get VBL of TMS pulse
- Par.VBL_TMS{Par.tr} = Par.VBL;
- % prepare new piston position
- target_object = 'piston_CF';
- Ob.(target_object).dimension = new_piston_dimensions;
- % load and print on screen
- [Ob, Par]= JA_Load_Obj_On_Screen(Par, Ob);
- [Par.VBL] = Screen(Par.window, 'Flip', Par.VBL_ball_changes_color_CF{Par.tr}+wt_as);
- % get VBL of piston hitting the ball
- Par.VBL_piston_CF{Par.tr} = Par.VBL;
- % EEG trigger code for color change
- EEG_Trigger(Par.PP,Par.address,value);
- end
- end
- % end
|