1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- function [Par] = JA_Average_previous_trials(Par)
- moving_avg = 5;
- fixed_RT = 0.4;
- % at the very first trial of the block, SBJ_RT is not known
- % so it is set at 0.4 + charge = 0.7
- if Par.tr == 1 % if it is the first trial of the very first game
-
- % set it to a standard velocity
- Par.CF_RT{Par.tr} = fixed_RT + Par.charge; % 0.4 + charge
- Par.SBJ_RT_median{Par.tr} = Par.CF_RT{Par.tr};
- %return soon after assigning the fixed_RT to the CF_RT of the current trial
- % so the reading does not enter the next if cycles
- return
-
- end
- % then, it is possible that the SBJ anticipates/posticipates at the second
- % trial so there would be no info av avilable about SBJ RTs yet
- % if trial is the second one, check if there is already a valid SBJ_RT from
- % the trial before
- if (Par.tr == 2) && isempty(Par.SBJ_RT{Par.tr-1})
-
- % for now assign a value to SBJ_RT even though no response has been
- % provided. In case for example, SBJ does not produce a valid response in
- % the preceding (first) trial, keep CF_RT at fixed_RT value
-
- Par.CF_RT{Par.tr} = fixed_RT + Par.charge; % 0.4 + charge
- Par.SBJ_RT{1} = Par.CF_RT{Par.tr}; % 0.4 + charge
- Par.SBJ_RT_median{Par.tr} = Par.CF_RT{Par.tr};
- return
-
-
-
- end
- % if the script gets here it means that there is at least one number in
- % the SBJ_RT up to trial 2. so, until trials are 'movging_avg' number do
- % median onto the available values
- if (Par.tr >= 2) && (Par.tr <= moving_avg)
-
- % median between trial 1 to eventually trial 4 to put as CF_RT in
- % trials up to 5 (moving_avg)
- Par.CF_RT{Par.tr} = median(cell2mat(Par.SBJ_RT(1:Par.tr-1)));
- Par.SBJ_RT_median{Par.tr} = Par.CF_RT{Par.tr};
- return
-
- end
- % from trials >= 6
- if (Par.tr > moving_avg)
-
- % PAY ATTENTION if too many no-responses it throw errors
- % Par.SBJ_RT
- %
- % ans =
- %
- % [0.7000] [] [] [] [] [] []
-
-
- if ~isnan(median(cell2mat(Par.SBJ_RT(Par.tr-(moving_avg):Par.tr-1))))
-
- % slide the median considering only the last 'moving_avg' number of trials
- Par.CF_RT{Par.tr} = median(cell2mat(Par.SBJ_RT(Par.tr-(moving_avg):Par.tr-1)));
-
- else
-
- Par.CF_RT{Par.tr} = median(cell2mat(Par.SBJ_RT(1:Par.tr-1)));
-
- end
-
- Par.SBJ_RT_median{Par.tr} = Par.CF_RT{Par.tr};
- return
-
- end
- %logging{Par.tr}.RT_SBJ_avg = RT_SBJ_avg{Par.tr};
- end
|