Skip to content

Instantly share code, notes, and snippets.

@dapperfu
Created March 17, 2014 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dapperfu/9599672 to your computer and use it in GitHub Desktop.
Save dapperfu/9599672 to your computer and use it in GitHub Desktop.
function EA_loop
% Peruvian_Lumberjack Valence Processing v.01
%
% The script is intended to expedite the valence scoring of the EA_EEG
% experiments for both targets and perceivers. It requires a computer with
% MATLAB 7 installed.
clc; % Clear command window
clear all; % Clear other variables
%% Initial input queries %%
subID = input('Enter Subject ID (e.g. 201): ','s');
intervals = input('Enter the number of intervals: ');
valence = '';
while ~(strcmpi(valence,'positive')||strcmpi(valence,'negative'))
valence = input('Was the video watched positive or negative?: ','s');
end
phase ='';
while ~(strcmpi(phase,'target')||strcmpi(phase,'perceiver'))
phase = input('Is this the target or perceiver phase?: ','s');
end
%% Open file for writing output
outputFilename = sprintf('subject%s_%s_%s.txt',subID,phase,valence);
fid = fopen(outputFilename,'w+');
fprintf(fid,'IntervalNumber\tWeightedAvg\tPhase\tValence\tsubID\n'); % Write headers on text file
%% Record data and loop
% 1 0 - 2
2 2-4
j=0;
jh=2;
for i=1:intervals
if i == 1
fprintf('\nThe current interval is between %s and %s seconds.\n',num2str(j),num2str(jh))
elseif mod(i,2) == 1%odd interval
j=j+2;
jh=jh+2;
fprintf('\nThe current interval is between %s and %s seconds.\n',num2str(j),num2str(jh))
elseif mod(i,2) == 0%even interval
j=j+2;
jh=jh+2;
fprintf('\nThe current interval is between %s and %s seconds.\n',num2str(j),num2str(jh))
end
buttonPresses(i) = input('\nEnter the amount of button presses within the interval: \n');% Initial input queries
% No button presses
if buttonPresses(i) == 0
score = input('Enter the only score in the interval: ');
int_avg = score;
currentInt = num2str(i); % What stage of the loop are we in
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
% Begin if/else logic to process data into weighted means
elseif buttonPresses(i) > 0 && buttonPresses(i) <= 1
score1 = input('Enter the score preceding the button press: '); % Score before the first button press.
time1 = input('Enter the time the button press occured: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score of the first button press.
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = (fix(time1/2)*2 + 2) - time1; % Time that score2 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the score before the first button press.
weightedMean2 = score2*perc_time2; % The weighted mean of the score after the first button press.
%Display interval average
int_avg = weightedMean1 + weightedMean2;
currentInt = num2str(i); % What stage of the loop are we in
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 1 && buttonPresses(i) <=2
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = (fix(time1/2)*2 + 2) - time2; % Time that score3 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3;
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 2 && buttonPresses(i) <=3
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = (fix(time1/2)*2 + 2) - time3; % Time that score4 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4;
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 3 && buttonPresses(i) <=4
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = (fix(time1/2)*2 + 2) - time4; % Time that score5 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3 +weightedMean4 + weightedMean5;
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 4 && buttonPresses(i) <=5
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = (fix(time1/2)*2 + 2) - time5; % Time that score6 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6; %cumulative weighted mean
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 5 && buttonPresses(i) <=6
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = (fix(time1/2)*2 + 2) - time6; % Time that score7 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + weightedMean7;
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 6 && buttonPresses(i) <=7
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = (fix(time1/2)*2 + 2) - time7; % Time that score8 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
%Display interval average
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + weightedMean7 + weightedMean8;
currentInt = num2str(i);
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);
elseif buttonPresses(i) > 7 && buttonPresses(i) <=8
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
time8 = input('Enter the time the eighth button press occurred: '); % Time that the eighth button press occurred.
score9 = input('Enter the ninth score in the interval: '); % Score associated with the eighth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = time8 - time7; % Time that score8 is present in the interval.
score9_int = (fix(time1/2)*2 + 2) - time8; % Time that score9 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
perc_time9 = (score9_int)/2; % Time (in decimal format) that score9 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
weightedMean9 = score9*perc_time9; % The weighted mean of the ninth score.
%Write cumulative weighted mean to output file
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + weightedMean7 + weightedMean8 + weightedMean9;
currentInt = num2str(i);%naming the interval
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);%write to output file
elseif buttonPresses(i) > 8 && buttonPresses(i) <=9
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
time8 = input('Enter the time the eighth button press occurred: '); % Time that the eighth button press occurred.
score9 = input('Enter the ninth score in the interval: '); % Score associated with the eighth button press.
time9 = input('Enter the time the ninth button press occurred: '); % Time that the ninth button press occurred.
score10 = input('Enter the tenth score in the interval: '); % Score associated with the ninth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = time8 - time7; % Time that score8 is present in the interval.
score9_int = time9 - time8; % Time that score9 is present in the interval.
score10_int = (fix(time1/2)*2 + 2) - time9; % Time that score10 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
perc_time9 = (score9_int)/2; % Time (in decimal format) that score9 is present in the interval.
perc_time10 = (score10_int)/2; % Time (in decimal format) that score10 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
weightedMean9 = score9*perc_time9; % The weighted mean of the ninth score.
weightedMean10 = score10*perc_time10; % The weighted mean of the tenth score.
%Write cumulative weighted mean to output file
int_avg = weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + weightedMean7 + weightedMean8 + weightedMean9 + weightedMean10;
currentInt = num2str(i);%naming the interval
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);%write to output file
elseif buttonPresses(i) > 9 && buttonPresses(i) <=10
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
time8 = input('Enter the time the eighth button press occurred: '); % Time that the eighth button press occurred.
score9 = input('Enter the ninth score in the interval: '); % Score associated with the eighth button press.
time9 = input('Enter the time the ninth button press occurred: '); % Time that the ninth button press occurred.
score10 = input('Enter the tenth score in the interval: '); % Score associated with the ninth button press.
time10 = input('Enter the time the tenth button press occurred: '); % Time that the tenth button press occurred.
score11 = input('Enter the eleventh score in the interval: '); % Score associated with the tenth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = time8 - time7; % Time that score8 is present in the interval.
score9_int = time9 - time8; % Time that score9 is present in the interval.
score10_int = time10 - time9; % Time that score10 is present in the interval.
score11_int = (fix(time1/2)*2 + 2) - time10; % Time that score11 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
perc_time9 = (score9_int)/2; % Time (in decimal format) that score9 is present in the interval.
perc_time10 = (score10_int)/2; % Time (in decimal format) that score10 is present in the interval.
perc_time11 = (score11_int)/2; % Time (in decimal format) that score11 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
weightedMean9 = score9*perc_time9; % The weighted mean of the ninth score.
weightedMean10 = score10*perc_time10; % The weighted mean of the tenth score.
weightedMean11 = score11*perc_time11; % The weighted mean of the eleventh score.
%Write cumulative weighted mean to output file
int_avg = (weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + ...
weightedMean7 + weightedMean8 + weightedMean9 + weightedMean10 + weightedMean11);
currentInt = num2str(i);%naming the interval
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);%write to output file
elseif buttonPresses(i) > 10 && buttonPresses(i) <=11
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
time8 = input('Enter the time the eighth button press occurred: '); % Time that the eighth button press occurred.
score9 = input('Enter the ninth score in the interval: '); % Score associated with the eighth button press.
time9 = input('Enter the time the ninth button press occurred: '); % Time that the ninth button press occurred.
score10 = input('Enter the tenth score in the interval: '); % Score associated with the ninth button press.
time10 = input('Enter the time the tenth button press occurred: '); % Time that the tenth button press occurred.
score11 = input('Enter the eleventh score in the interval: '); % Score associated with the tenth button press.
time11 = input('Enter the time the eleventh button press occurred: '); % Time that the eleventh button press occurred.
score12 = input('Enter the twelfth score in the interval: '); % Score associated with the eleventh button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = time8 - time7; % Time that score8 is present in the interval.
score9_int = time9 - time8; % Time that score9 is present in the interval.
score10_int = time10 - time9; % Time that score10 is present in the interval.
score11_int = time11 - time10; % Time that score11 is present in the interval.
score12_int = (fix(time1/2)*2 + 2) - time11; % Time that score12 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
perc_time9 = (score9_int)/2; % Time (in decimal format) that score9 is present in the interval.
perc_time10 = (score10_int)/2; % Time (in decimal format) that score10 is present in the interval.
perc_time11 = (score11_int)/2; % Time (in decimal format) that score11 is present in the interval.
perc_time12 = (score12_int)/2; % Time (in decimal format) that score12 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
weightedMean9 = score9*perc_time9; % The weighted mean of the ninth score.
weightedMean10 = score10*perc_time10; % The weighted mean of the tenth score.
weightedMean11 = score11*perc_time11; % The weighted mean of the eleventh score.
weightedMean12 = score12*perc_time12; % The weighted mean of the twelfth score.
%Write cumulative weighted mean to output file
int_avg = (weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + ...
weightedMean7 + weightedMean8 + weightedMean9 + weightedMean10 + weightedMean11 + weightedMean12);
currentInt = num2str(i);%naming the interval
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);%write to output file
elseif buttonPresses(i) > 11 && buttonPresses(i) <=12
%Initial input queries
score1 = input('Enter the score preceding the first button press: '); % Score before the first button press.
time1 = input('Enter the time the first button press occurred: '); % Time that the first button press occured.
score2 = input('Enter the second score in the interval: '); % Score associated with the first button press.
time2 = input('Enter the time the second button press occured: '); % Time that the second button press occurred.
score3 = input('Enter the third score in the interval: '); % Score associated with the second button press.
time3 = input('Enter the time the third button press occured: '); % Time that the third button press occurred.
score4 = input('Enter the fourth score in the interval: '); % Score associated with the third button press.
time4 = input('Enter the time the fourth button press occurred: '); % Time that the fourth button press occurred.
score5 = input('Enter the fifth score in the interval: '); % Score associated with the fourth button press.
time5 = input('Enter the time the fifth button press occurred: '); % Time that the fifth button press occurred.
score6 = input('Enter the sixth score in the interval: '); % Score associated with the fifth button press.
time6 = input('Enter the time the sixth button press occurred: '); % Time that the sixth button press occurred.
score7 = input('Enter the seventh score in the interval: '); % Score associated with the sixth button press.
time7 = input('Enter the time the seventh button press occurred: '); % Time that the seventh button press occurred.
score8 = input('Enter the eighth score in the interval: '); % Score associated with the seventh button press.
time8 = input('Enter the time the eighth button press occurred: '); % Time that the eighth button press occurred.
score9 = input('Enter the ninth score in the interval: '); % Score associated with the eighth button press.
time9 = input('Enter the time the ninth button press occurred: '); % Time that the ninth button press occurred.
score10 = input('Enter the tenth score in the interval: '); % Score associated with the ninth button press.
time10 = input('Enter the time the tenth button press occurred: '); % Time that the tenth button press occurred.
score11 = input('Enter the eleventh score in the interval: '); % Score associated with the tenth button press.
time11 = input('Enter the time the eleventh button press occurred: '); % Time that the eleventh button press occurred.
score12 = input('Enter the twelfth score in the interval: '); % Score associated with the eleventh button press.
time12 = input('Enter the time the twelfth button press occurred: '); % Time that the twelfth button press occurred.
score13 = input('Enter the thirteenth score in the interval: '); % Score associated with the twelfth button press.
%Time represented in the interval
score1_int = time1 - fix(time1/2)*2; % Time that score1 is present in the interval.
score2_int = time2 - time1; % Time that score2 is present in the interval.
score3_int = time3 - time2; % Time that score3 is present in the interval.
score4_int = time4 - time3; % Time that score4 is present in the interval.
score5_int = time5 - time4; % Time that score5 is present in the interval.
score6_int = time6 - time5; % Time that score6 is present in the interval.
score7_int = time7 - time6; % Time that score7 is present in the interval.
score8_int = time8 - time7; % Time that score8 is present in the interval.
score9_int = time9 - time8; % Time that score9 is present in the interval.
score10_int = time10 - time9; % Time that score10 is present in the interval.
score11_int = time11 - time10; % Time that score11 is present in the interval.
score12_int = time12 - time11; % Time that score12 is present in the interval.
score13_int = (fix(time1/2)*2 + 2) - time12; % Time that score13 is present in the interval.
perc_time1 = (score1_int)/2; % Time (in decimal format) that score1 is present in the interval.
perc_time2 = (score2_int)/2; % Time (in decimal format) that score2 is present in the interval.
perc_time3 = (score3_int)/2; % Time (in decimal format) that score3 is present in the interval.
perc_time4 = (score4_int)/2; % Time (in decimal format) that score4 is present in the interval.
perc_time5 = (score5_int)/2; % Time (in decimal format) that score5 is present in the interval.
perc_time6 = (score6_int)/2; % Time (in decimal format) that score6 is present in the interval.
perc_time7 = (score7_int)/2; % Time (in decimal format) that score7 is present in the interval.
perc_time8 = (score8_int)/2; % Time (in decimal format) that score8 is present in the interval.
perc_time9 = (score9_int)/2; % Time (in decimal format) that score9 is present in the interval.
perc_time10 = (score10_int)/2; % Time (in decimal format) that score10 is present in the interval.
perc_time11 = (score11_int)/2; % Time (in decimal format) that score11 is present in the interval.
perc_time12 = (score12_int)/2; % Time (in decimal format) that score12 is present in the interval.
perc_time13 = (score13_int)/2; % Time (in decimal format) that score13 is present in the interval.
%Weighted means of each score by space in the interval.
weightedMean1 = score1*perc_time1; % The weighted mean of the first score.
weightedMean2 = score2*perc_time2; % The weighted mean of the second score.
weightedMean3 = score3*perc_time3; % The weighted mean of the third score.
weightedMean4 = score4*perc_time4; % The weighted mean of the fourth score.
weightedMean5 = score5*perc_time5; % The weighted mean of the fifth score.
weightedMean6 = score6*perc_time6; % The weighted mean of the sixth score.
weightedMean7 = score7*perc_time7; % The weighted mean of the seventh score.
weightedMean8 = score8*perc_time8; % The weighted mean of the eighth score.
weightedMean9 = score9*perc_time9; % The weighted mean of the ninth score.
weightedMean10 = score10*perc_time10; % The weighted mean of the tenth score.
weightedMean11 = score11*perc_time11; % The weighted mean of the eleventh score.
weightedMean12 = score12*perc_time12; % The weighted mean of the twelfth score.
weightedMean13 = score13*perc_time13; % The weighted mean of the thirteenth score.
%Write cumulative weighted mean to output file
int_avg = (weightedMean1 + weightedMean2 + weightedMean3 + weightedMean4 + weightedMean5 + weightedMean6 + ...
weightedMean7 + weightedMean8 + weightedMean9 + weightedMean10 + weightedMean11 + weightedMean12 +...
weightedMean13);
currentInt = num2str(i);%naming the interval
fprintf(fid,'%s\t%.3f\t%s\t%s\t%s\n',currentInt,int_avg,phase,valence,subID);%write to output file
else
fprintf('\nYou have encountered an error. Please restart the script.\n')
break
end
end
%% Close up shop
fclose('all');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment