diff --git a/Export/Export - Batch Variables CSV.rb b/Export/Export - Batch Variables CSV.rb new file mode 100644 index 0000000..5720c41 --- /dev/null +++ b/Export/Export - Batch Variables CSV.rb @@ -0,0 +1,219 @@ +# Updated 4.24.20 + +require "Datavyu_API.rb" +require "csv" + +# Batch operation: Analyses on multiple files, outputs to csv file called "Batch Analyses" + +begin + # Begin Function Definitions ------------------------------------------------------------------------------------------------------------------------ + + def createCellArray(column, list) + for cell in column.cells + list << [cell.onset, cell.offset] + end + end + + def sumCellsColumn(column) + sum = 0.0 + for cell in column.cells + sum = sum + (cell.offset - cell.onset) + end + return sum + end + + def sumCellsArray(list) + sum = 0.0 + for cell in list + sum = sum + (cell[1] - cell[0]) + end + return sum + end + + # End Function Definitions -------------------------------------------------------------------------------------------------------------------------- + + # File Loading -------------------------------------------------------------------------------------------------------------------------------------- + + relPathString = "~/Desktop/BatchFolder" + filedir = File.expand_path(relPathString) + filenames = Dir.new(filedir).entries + + csvString = "~/Desktop/AnalysesOutput.csv" + csvFile = File.expand_path(csvString) + + for file in filenames + if (file.include?(".opf")) and file[0].chr != '.' + + $db,$pj = load_db(filedir+"/"+file) + + # Begin Column Collection --------------------------------------------------------------------------------------------------------------------------- + + slCol = getColumn("speaker_listener") + peerCol = getColumn("peer") + partCol = getColumn("participant") + ecCol = getColumn("eye_contact") + greetingColumn = getColumn("greeting") + + if (greetingColumn == nil) + greetingColumn = getColumn("greeting_goodbye") + end + + # End Column Collection ----------------------------------------------------------------------------------------------------------------------------- + + # Begin Conversation Duration ----------------------------------------------------------------------------------------------------------------------- + + offsets = Array.new + cols = get_column_list() + + for col in cols + curr = getColumn(col) + if curr.cells.last == nil + next + end + offsets << curr.cells.last.offset + end + + convoDur = offsets.max + + # End Conversation Duration ------------------------------------------------------------------------------------------------------------------------ + + # Begin Sum of Participant and Peer Durations ------------------------------------------------------------------------------------------------------ + + peerTimes = Array.new + partTimes = Array.new + peerDur = 0.0 + partDur = 0.0 + + createCellArray(peerCol, peerTimes) + createCellArray(partCol, partTimes) + + peerDur = sumCellsArray(peerTimes) + partDur = sumCellsArray(partTimes) + + totalSpeakingDur = peerDur + partDur + + # End Sum of Peer and Participant Speaking Durations ------------------------------------------------------------------------------------------------ + + # Begin Amount of time participant is on-topic relative to their own speaking duration -------------------------------------------------------------- + + slOTtimes = Array.new + slOFFTtimes = Array.new + + for cell in slCol.cells + if (cell.argvals[1] == "OT") + slOTtimes << [cell.onset, cell.offset] + end + + if (cell.argvals[1] == "OFFT") + slOFFTtimes << [cell.onset, cell.offset] + end + end + + participantOT = 0.0 + participantOFFT = 0.0 + + for times in partTimes + for range in slOTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOT = participantOT + (times[1] - times[0]) + end + end + + for range in slOFFTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOFFT = participantOFFT + (times[1] - times[0]) + end + end + end + + # End Amount of time participant is on-topic relative to their own speaking duration ---------------------------------------------------------------- + + # Begin Questions and Responses --------------------------------------------------------------------------------------------------------------------- + + total_qs = 0 + ot_qs = 0 + offt_qs = 0 + total_rs = 0 + ot_rs = 0 + offt_rs = 0 + + for cell in slCol.cells + if (cell.argvals[1] == "OT" and cell.argvals[2] == "Q") + ot_qs = ot_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "Q") + offt_qs = offt_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OT" and cell.argvals[2] == "R") + ot_rs = ot_rs + 1 + total_rs = total_rs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "R") + offt_rs = offt_rs + 1 + total_rs = total_rs + 1 + end + end + + # End Questions and Responses ----------------------------------------------------------------------------------------------------------------------- + + # Begin eye_contact durations ----------------------------------------------------------------------------------------------------------------------- + + ecDur = sumCellsColumn(ecCol) + + # End eye_contact durations ------------------------------------------------------------------------------------------------------------------------- + + # Begin Participant Listening ----------------------------------------------------------------------------------------------------------------------- + + part_listening = 0.0 + count_listen = 0 + + for cell in slCol.cells + if (cell.argvals[0] == "L" or cell.argvals[0] == "l") + part_listening = part_listening + (cell.offset - cell.onset) + count_listen = count_listen + 1 + end + end + + # End Participant Listening ------------------------------------------------------------------------------------------------------------------------- + + # Begin Fillers Count ------------------------------------------------------------------------------------------------------------------------------- + + countFiller = 0 + + for cell in slCol.cells + if (cell.argvals[2] == "F") + countFiller = countFiller + 1 + end + end + + # End Fillers Count --------------------------------------------------------------------------------------------------------------------------------- + + # Begin Greeting Boolean ---------------------------------------------------------------------------------------------------------------------------- + + # Exclude goodbyes + + greetingBoolean = 0 + + for cell in greetingColumn.cells + if (cell.argvals[0] == "G") and (cell.onset < 60000) + greetingBoolean = 1 + end + end + + # End Greeting Boolean ------------------------------------------------------------------------------------------------------------------------------ + + # Excel File Output --------------------------------------------------------------------------------------------------------------------------------- + + puts file.to_s + ", " + (convoDur/1000.0).to_s + ", " + (totalSpeakingDur/1000.0).to_s + ", " + (peerDur/1000.0).to_s + ", " + (partDur/1000.0).to_s + ", " + (partDur/totalSpeakingDur).to_s + ", " + (peerDur/totalSpeakingDur).to_s + ", " + (participantOT/partDur).to_s + ", " + (participantOT/(participantOT + participantOFFT)).to_s + ", " + (participantOFFT/partDur).to_s + ", " + ot_qs.to_s + ", " + offt_qs.to_s + ", " + (ot_qs/total_qs.to_f).to_s + ", " + (offt_qs/total_qs.to_f).to_s + ", " + ot_rs.to_s + ", " + offt_rs.to_s + ", " + (ot_rs/total_rs.to_f).to_s + ", " + (offt_rs.to_f/total_rs.to_f).to_s + ", " + (part_listening/1000).to_s + ", " + (ecDur/1000).to_s + ", " + (ecDur/convoDur).to_s + ", " + count_listen.to_s + ", " + (part_listening/peerDur).to_s + ", " + countFiller.to_s + ", " + greetingBoolean.to_s + "\n\n" + + # CSV Output ---------------------------------------------------------------------------------------------------------------------------------------- + + CSV.open(csvFile, "a+") do |csv| + csv << [file.to_s + ", " + (convoDur/1000.0).to_s + ", " + (totalSpeakingDur/1000.0).to_s + ", " + (peerDur/1000.0).to_s + ", " + (partDur/1000.0).to_s + ", " + (partDur/totalSpeakingDur).to_s + ", " + (peerDur/totalSpeakingDur).to_s + ", " + (participantOT/partDur).to_s + ", " + (participantOT/(participantOT + participantOFFT)).to_s + ", " + (participantOFFT/partDur).to_s + ", " + ot_qs.to_s + ", " + offt_qs.to_s + ", " + (ot_qs/total_qs.to_f).to_s + ", " + (offt_qs/total_qs.to_f).to_s + ", " + ot_rs.to_s + ", " + offt_rs.to_s + ", " + (ot_rs/total_rs.to_f).to_s + ", " + (offt_rs.to_f/total_rs.to_f).to_s + ", " + (part_listening/1000).to_s + ", " + (ecDur/1000).to_s + ", " + (ecDur/convoDur).to_s + ", " + count_listen.to_s + ", " + (part_listening/peerDur).to_s + ", " + countFiller.to_s + ", " + greetingBoolean.to_s] + end + end + end + +end \ No newline at end of file diff --git a/Export/Export - Cell Length Durations.rb b/Export/Export - Cell Length Durations.rb new file mode 100644 index 0000000..ded2259 --- /dev/null +++ b/Export/Export - Cell Length Durations.rb @@ -0,0 +1,97 @@ +# Updated 4.24.20 + +require 'Datavyu_API.rb' +require "csv" + +def format_ec_icc(directory, outFile) + + tot_pri_icc = Array.new + tot_rel_icc = Array.new + + filenames = Dir.new(directory).entries + + for file in filenames + if (file.include?(".opf")) and file[0].chr != '.' + + $db,pj = load_db(directory + "/" + file) + puts "\nLoading " + file.to_s + "...\n" + + pri = getColumn("eye_contact") + rel = getColumn("eye_contact_2") + + pri_arr = Array.new + + rel_arr = Array.new + + pri_icc = Array.new + rel_icc = Array.new + + for pri_cell in pri.cells + pri_arr << [pri_cell.onset, pri_cell.offset] + end + + for rel_cell in rel.cells + rel_arr << [rel_cell.onset, rel_cell.offset] + end + + if (pri_arr.length >= rel_arr.length) + for pri_times in pri_arr + i = false + pri_icc << ((pri_times[1] - pri_times[0])/1000.0) + for rel_times in rel_arr + if ((pri_times[0] - rel_times[0]).abs <= 5000) and ((pri_times[1] - rel_times[1]).abs <= 5000) + rel_icc << ((rel_times[1] - rel_times[0])/1000.0) + rel_arr = rel_arr - [rel_times] + i = true + break + end + end + if (i == false) + rel_icc << 0 + end + end + end + + if (pri_arr.length < rel_arr.length) + for rel_times in rel_arr + i = false + rel_icc << ((rel_times[1] - rel_times[0])/1000.0) + for pri_times in pri_arr + if ((rel_times[0] - pri_times[0]).abs <= 5000) and ((rel_times[1] - rel_times[0]).abs <= 5000) + pri_icc << ((pri_times[1] - pri_times[0])/1000.0) + i = true + break + end + end + if (i == false) + pri_icc << 0 + end + end + end + + if (pri_icc.length != rel_icc.length) + raise "Error" + end + + for dur in pri_icc + tot_pri_icc << dur + end + + for dur in rel_icc + tot_rel_icc << dur + end + + end + + CSV.open(outFile, "w") do |csv| + csv << tot_pri_icc + csv << tot_rel_icc + end + end +end + +filedir = File.expand_path("~/Desktop/BatchFolder/") +csvString = "~/Desktop/ecICC.csv" +csvFile = File.expand_path(csvString) + +format_ec_icc(filedir, csvFile) \ No newline at end of file diff --git a/Export/Export - Variables for Batch.rb b/Export/Export - Variables for Batch.rb new file mode 100644 index 0000000..96ee7c3 --- /dev/null +++ b/Export/Export - Variables for Batch.rb @@ -0,0 +1,217 @@ +require 'Datavyu_API.rb' + +begin + # Begin Function Definitions ------------------------------------------------------------------------------------------------------------------------ + + # Create a 2-Dimensional array of the onset/offset times of cells in a given column + + def createCellArray(column, list) + for cell in column.cells + list << [cell.onset, cell.offset] + end + end + + # sumCellsColumn is used to get the total duration of cells in a given column + + def sumCellsColumn(column) + sum = 0.0 + for cell in column.cells + sum = sum + (cell.offset - cell.onset) + end + return sum + end + + # sumCellsList is used to get the total duration of cells in a given 2-D Array + + def sumCellsArray(list) + sum = 0.0 + for cell in list + sum = sum + (cell[1] - cell[0]) + end + return sum + end + + # End Function Definitions -------------------------------------------------------------------------------------------------------------------------- + + # File Loading -------------------------------------------------------------------------------------------------------------------------------------- + + # This block tells Datavyu which files to open + + relPathString = ("~/Desktop/BatchFolder") + filedir = File.expand_path(relPathString) + filenames = Dir.new(filedir).entries + + for file in filenames + if (file.include?(".opf")) and file[0].chr != '.' + + $db,$pj = load_db(filedir+"/"+file) + + # Begin Column Collection --------------------------------------------------------------------------------------------------------------------------- + + slCol = getColumn("speaker_listener") + peerCol = getColumn("peer") + partCol = getColumn("participant") + ecCol = getColumn("eye_contact") + greetingColumn = getColumn("greeting") + + if (greetingColumn == nil) + greetingColumn = getColumn("greeting_goodbye") + end + + # End Column Collection ----------------------------------------------------------------------------------------------------------------------------- + + # Begin Conversation Duration ----------------------------------------------------------------------------------------------------------------------- + + # Check to see if participant or peer has maximum offset for conversation duration + + offsets = Array.new + cols = get_column_list() + + for col in cols + curr = getColumn(col) + if curr.cells.last == nil + next + end + offsets << curr.cells.last.offset + end + + convoDur = offsets.max + + + # End Conversation Duration ------------------------------------------------------------------------------------------------------------------------ + + # Begin Sum of Participant and Peer Durations ------------------------------------------------------------------------------------------------------ + + peerTimes = Array.new + createCellArray(peerCol, peerTimes) + + partTimes = Array.new + peerDur = 0.0 + partDur = 0.0 + + createCellArray(partCol, partTimes) + + peerDur = sumCellsArray(peerTimes) + partDur = sumCellsArray(partTimes) + + totalSpeakingDur = peerDur + partDur + + # End Sum of Peer and Participant Speaking Durations ------------------------------------------------------------------------------------------------ + + # Begin Amount of time participant is on-topic relative to their own speaking duration -------------------------------------------------------------- + + # Check participant cells against speaker-listener cells + + slOTtimes = Array.new + slOFFTtimes = Array.new + + for cell in slCol.cells + if (cell.argvals[1] == "OT") + slOTtimes << [cell.onset, cell.offset] + end + + if (cell.argvals[1] == "OFFT") + slOFFTtimes << [cell.onset, cell.offset] + end + end + + participantOT = 0.0 + participantOFFT = 0.0 + + for times in partTimes + for range in slOTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOT = participantOT + (times[1] - times[0]) + end + end + + for range in slOFFTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOFFT = participantOFFT + (times[1] - times[0]) + end + end + end + + # End Amount of time participant is on-topic relative to their own speaking duration ---------------------------------------------------------------- + + # Begin Questions and Responses --------------------------------------------------------------------------------------------------------------------- + + total_qs = 0 + ot_qs = 0 + offt_qs = 0 + total_rs = 0 + ot_rs = 0 + offt_rs = 0 + + for cell in slCol.cells + if (cell.argvals[1] == "OT" and cell.argvals[2] == "Q") + ot_qs = ot_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "Q") + offt_qs = offt_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OT" and cell.argvals[2] == "R") + ot_rs = ot_rs + 1 + total_rs = total_rs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "R") + offt_rs = offt_rs + 1 + total_rs = total_rs + 1 + end + end + + # End Questions and Responses ----------------------------------------------------------------------------------------------------------------------- + + # Begin eye_contact durations ----------------------------------------------------------------------------------------------------------------------- + + ecDur = sumCellsColumn(ecCol) + + # End eye_contact durations ------------------------------------------------------------------------------------------------------------------------- + + # Begin Participant Listening ----------------------------------------------------------------------------------------------------------------------- + + part_listening = 0.0 + count_listen = 0 + + for cell in slCol.cells + if (cell.argvals[0] == "L" or cell.argvals[0] == "l") + part_listening = part_listening + (cell.offset - cell.onset) + count_listen = count_listen + 1 + end + end + + # End Participant Listening ------------------------------------------------------------------------------------------------------------------------- + + # Begin Fillers Count ------------------------------------------------------------------------------------------------------------------------------- + + countFiller = 0 + + for cell in slCol.cells + if (cell.argvals[2] == "F") + countFiller = countFiller + 1 + end + end + + # End Fillers Count --------------------------------------------------------------------------------------------------------------------------------- + + # Begin Greeting Boolean ---------------------------------------------------------------------------------------------------------------------------- + + greetingBoolean = 0 + + for cell in greetingColumn.cells + if (cell.argvals[0] == "G") and (cell.onset < 60000) # Greeting must happen before one minute + greetingBoolean = 1 + end + end + + # End Greeting Boolean ------------------------------------------------------------------------------------------------------------------------------ + + # Excel File Output --------------------------------------------------------------------------------------------------------------------------------- + + puts file.to_s + ", " + (convoDur/1000.0).to_s + ", " + (totalSpeakingDur/1000.0).to_s + ", " + (peerDur/1000.0).to_s + ", " + (partDur/1000.0).to_s + ", " + (partDur/totalSpeakingDur).to_s + ", " + (peerDur/totalSpeakingDur).to_s + ", " + (participantOT/partDur).to_s + ", " + (participantOT/(participantOT + participantOFFT)).to_s + ", " + (participantOFFT/partDur).to_s + ", " + ot_qs.to_s + ", " + offt_qs.to_s + ", " + (ot_qs/total_qs.to_f).to_s + ", " + (offt_qs/total_qs.to_f).to_s + ", " + ot_rs.to_s + ", " + offt_rs.to_s + ", " + (ot_rs/total_rs.to_f).to_s + ", " + (offt_rs.to_f/total_rs.to_f).to_s + ", " + (part_listening/1000).to_s + ", " + (ecDur/1000).to_s + ", " + (ecDur/convoDur).to_s + ", " + count_listen.to_s + ", " + (part_listening/peerDur).to_s + ", " + countFiller.to_s + ", " + greetingBoolean.to_s + "\n\n" + end + end + +end \ No newline at end of file diff --git a/Export/Export - Variables.rb b/Export/Export - Variables.rb new file mode 100644 index 0000000..77237e6 --- /dev/null +++ b/Export/Export - Variables.rb @@ -0,0 +1,233 @@ +# Updated 4.24.20 + +require "Datavyu_API.rb" +require "csv" + +# Batch operation: Analyses on multiple files, outputs to csv file called "Batch Analyses" + +begin + # Begin Function Definitions ------------------------------------------------------------------------------------------------------------------------ + + def createCellArray(column, list) + for cell in column.cells + list << [cell.onset, cell.offset] + end + end + + def sumCellsColumn(column) + sum = 0.0 + for cell in column.cells + sum = sum + (cell.offset - cell.onset) + end + return sum + end + + def sumCellsArray(list) + sum = 0.0 + for cell in list + sum = sum + (cell[1] - cell[0]) + end + return sum + end + + # End Function Definitions -------------------------------------------------------------------------------------------------------------------------- + + # File Loading -------------------------------------------------------------------------------------------------------------------------------------- + + #out_file = File.expand_path("~/Desktop/AnalysesOutput.txt/") # C:\Users\jhlia\Desktop\AnalysesOutput + #out = File.new(out_file, 'w') + + # Begin Column Collection --------------------------------------------------------------------------------------------------------------------------- + + slCol = getColumn("speaker_listener") + peerCol = getColumn("peer") + partCol = getColumn("participant") + ecCol = getColumn("eye_contact") + greetingColumn = getColumn("greeting") + + if (greetingColumn == nil) + greetingColumn = getColumn("greeting_goodbye") + end + + # End Column Collection ----------------------------------------------------------------------------------------------------------------------------- + + # Begin Conversation Duration ----------------------------------------------------------------------------------------------------------------------- + + offsets = Array.new + cols = get_column_list() + + for col in cols + curr = getColumn(col) + if curr.cells.last == nil + next + end + offsets << curr.cells.last.offset + end + + convoDur = offsets.max + + # End Conversation Duration ------------------------------------------------------------------------------------------------------------------------ + + # Begin Sum of Participant and Peer Durations ------------------------------------------------------------------------------------------------------ + + peerTimes = Array.new + partTimes = Array.new + peerDur = 0.0 + partDur = 0.0 + + createCellArray(peerCol, peerTimes) + createCellArray(partCol, partTimes) + + peerDur = sumCellsArray(peerTimes) + partDur = sumCellsArray(partTimes) + + totalSpeakingDur = peerDur + partDur + + # End Sum of Peer and Participant Speaking Durations ------------------------------------------------------------------------------------------------ + + # Begin Amount of time participant is on-topic relative to their own speaking duration -------------------------------------------------------------- + + slOTtimes = Array.new + slOFFTtimes = Array.new + + for cell in slCol.cells + if (cell.argvals[1] == "OT") + slOTtimes << [cell.onset, cell.offset] + end + + if (cell.argvals[1] == "OFFT") + slOFFTtimes << [cell.onset, cell.offset] + end + end + + participantOT = 0.0 + participantOFFT = 0.0 + + for times in partTimes + for range in slOTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOT = participantOT + (times[1] - times[0]) + end + end + + for range in slOFFTtimes + if (times[0] >= range[0]) and (times[1] <= range[1]) + participantOFFT = participantOFFT + (times[1] - times[0]) + end + end + end + + + # End Amount of time participant is on-topic relative to their own speaking duration ---------------------------------------------------------------- + + # Begin Questions and Responses --------------------------------------------------------------------------------------------------------------------- + + total_qs = 0 + ot_qs = 0 + offt_qs = 0 + total_rs = 0 + ot_rs = 0 + offt_rs = 0 + + for cell in slCol.cells + if (cell.argvals[1] == "OT" and cell.argvals[2] == "Q") + ot_qs = ot_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "Q") + offt_qs = offt_qs + 1 + total_qs = total_qs + 1 + end + if (cell.argvals[1] == "OT" and cell.argvals[2] == "R") + ot_rs = ot_rs + 1 + total_rs = total_rs + 1 + end + if (cell.argvals[1] == "OFFT" and cell.argvals[2] == "R") + offt_rs = offt_rs + 1 + total_rs = total_rs + 1 + end + end + + # End Questions and Responses ----------------------------------------------------------------------------------------------------------------------- + + # Begin eye_contact durations ----------------------------------------------------------------------------------------------------------------------- + + ecDur = sumCellsColumn(ecCol) + + # End eye_contact durations ------------------------------------------------------------------------------------------------------------------------- + + # Begin Participant Listening ----------------------------------------------------------------------------------------------------------------------- + + part_listening = 0.0 + count_listen = 0 + + for cell in slCol.cells + if (cell.argvals[0] == "L" or cell.argvals[0] == "l") + part_listening = part_listening + (cell.offset - cell.onset) + count_listen = count_listen + 1 + end + end + + # End Participant Listening ------------------------------------------------------------------------------------------------------------------------- + + # Begin Fillers Count ------------------------------------------------------------------------------------------------------------------------------- + + countFiller = 0 + + for cell in slCol.cells + if (cell.argvals[2] == "F") + countFiller = countFiller + 1 + end + end + + # End Fillers Count --------------------------------------------------------------------------------------------------------------------------------- + + # Begin Greeting Boolean ---------------------------------------------------------------------------------------------------------------------------- + + # Exclude goodbyes + + greetingBoolean = 0 + + for cell in greetingColumn.cells + if (cell.argvals[0] == "G") and (cell.onset < 60000) + greetingBoolean = 1 + end + end + + # End Greeting Boolean ------------------------------------------------------------------------------------------------------------------------------ + + # Console Output + + puts "\nConversation duration: " + (convoDur/1000.0).to_s + " seconds\n" + puts "Total speaking duration: " + (totalSpeakingDur/1000.0).to_s + " seconds\n" + puts "Total peer speaking duration: " + (peerDur/1000.0).to_s + " seconds\n" + puts "Total participant speaking duration: " + (partDur/1000.0).to_s + " seconds\n" + puts "Percentage of time participant speaks during whole conversation: " + ((partDur/totalSpeakingDur)*100).to_s + "% \n" + puts "Percentage of time peer speaks during whole conversation: " + ((peerDur/totalSpeakingDur)*100).to_s + "% \n\n" + puts "Amount of time participant is on-topic: " + (participantOT/1000.0).to_s + " seconds \n" + puts "Amount of time participant is on-topic relative to own speaking duration: " + ((participantOT/(participantOT + participantOFFT)) * 100).to_s + "% \n" + puts "Amount of time participant is off-topic relative to own speaking duration: " + ((participantOFFT/(participantOT + participantOFFT))*100).to_s + "% \n" + puts "\nNumber of on-topic questions: " + ot_qs.to_s + " out of " + total_qs.to_s + " total questions \n" + puts "Number of off-topic questions: " + offt_qs.to_s + " out of " + total_qs.to_s + " total questions \n" + puts "Percentage of on-topic questions: " + ((ot_qs.to_f/total_qs)*100).to_s + "% \n" + puts "Percentage of off-topic questions: " + ((offt_qs.to_f/total_qs)*100).to_s + "% \n" + puts "Number of on-topic responses: " + ot_rs.to_s + " out of " + total_rs.to_s + " total responses \n" + puts "Number of off-topic responses: " + offt_rs.to_s + " out of " + total_rs.to_s + " total responses \n" + puts "Percentage of on-topic responses: " + ((ot_rs.to_f/total_rs)*100).to_s + "% \n" + puts "Percentage of off-topic responses: " + ((offt_rs.to_f/total_rs)*100).to_s + "% \n\n" + puts "Eye contact duration: " + (ecDur/1000).to_s + " seconds \n" + puts "Percentage of eye contact over conversation duration: " + ((ecDur/convoDur)*100).to_s + "%\n" + puts "Number of Listening Behaviors: " + count_listen.to_s + "\n" + puts "Amount of time participant displays listening behaviors: " + (part_listening/1000).to_s + " seconds \n" + puts "Percentage of time participant is listening while peer speaking: " + ((part_listening/peerDur)*100).to_s + " % \n\n" + puts "Number of Fillers: " + countFiller.to_s + "\n\n" + puts "Greeting? " + greetingBoolean.to_s + "\n\n" + + + # Excel File Output --------------------------------------------------------------------------------------------------------------------------------- + + puts ("Excel Output: \n") + puts (convoDur/1000.0).to_s + ", " + (totalSpeakingDur/1000.0).to_s + ", " + (peerDur/1000.0).to_s + ", " + (partDur/1000.0).to_s + ", " + (partDur/totalSpeakingDur).to_s + ", " + (peerDur/totalSpeakingDur).to_s + ", " + (participantOT/partDur).to_s + ", " + (participantOT/participantOT + participantOFFT).to_s + ", " + (participantOFFT/partDur).to_s + ", " + ot_qs.to_s + ", " + offt_qs.to_s + ", " + (ot_qs/total_qs.to_f).to_s + ", " + (offt_qs/total_qs.to_f).to_s + ", " + ot_rs.to_s + ", " + offt_rs.to_s + ", " + (ot_rs/total_rs.to_f).to_s + ", " + (offt_rs.to_f/total_rs.to_f).to_s + ", " + (part_listening/1000).to_s + ", " + (ecDur/1000).to_s + ", " + (ecDur/convoDur).to_s + ", " + count_listen.to_s + ", " + (part_listening/peerDur).to_s + ", " + countFiller.to_s + ", " + greetingBoolean.to_s + "\n\n" + + # CSV Output ---------------------------------------------------------------------------------------------------------------------------------------- +end \ No newline at end of file diff --git a/Reliability/file_check_reliability.rb b/Reliability/file_check_reliability.rb new file mode 100644 index 0000000..1da64ac --- /dev/null +++ b/Reliability/file_check_reliability.rb @@ -0,0 +1,213 @@ +# Updated 4.24.20 + +require 'Datavyu_API.rb' + + puts ("EYE CONTACT: \n") + + main_col = getColumn("eye_contact") + rel_col = getColumn("eye_contact_2") + + if (rel_col == nil) or (rel_col.cells == nil) + puts file.to_s + " is not coded for reliability\n\n" + next + end + + main_col_times = Array.new + + for mc in main_col.cells + main_col_times << [mc.onset, mc.offset] # << appends to array + end + + rel_col_times = Array.new + + for rc in rel_col.cells + rel_col_times << [rc.onset, rc.offset] + end + + total_successes = 0 + total_rel_cells = 0 + errors = Array.new + not_errors = Array.new + + for cell in rel_col.cells + total_rel_cells = total_rel_cells + 1 + errors << cell.onset + end + + for pair1 in rel_col_times + for pair2 in main_col_times + if ((pair1[0] - pair2[0]).abs <= 2000) and ((pair1[1] - pair2[1]).abs <= 2000) + total_successes = total_successes + 1 + not_errors << pair1[0] + break + end + end + end + + errors = errors - not_errors + i = 1 + + for error in errors + error = (error/1000.0) + puts "(" + i.to_s + ") No match for reliability cell at onset time: " + error.to_s + " seconds\n\n" + i = i + 1 + end + + total_rel_cells = total_rel_cells.to_f + total_successes = total_successes.to_f + + percent_reliability1 = (total_successes / total_rel_cells) * 100 + + print "Total number of reliability cells: " + total_rel_cells.to_s + "\n" + print "Total number of reliability cells with matching times: " + total_successes.to_s + "\n" + puts "Percentage of reliable cells: " + percent_reliability1.to_s + "% \n" + + total_duration_main_col = 0.0 + total_duration_rel_col = 0.0 + + for cell in main_col.cells + duration = (cell.offset - cell.onset) + total_duration_main_col = total_duration_main_col + duration + end + + total_duration_main_col = total_duration_main_col/1000.0 + + print "Total duration reported for eye_contact: " + total_duration_main_col.to_s + " seconds.\n" + + for cell in rel_col.cells + duration = (cell.offset - cell.onset) + total_duration_rel_col = total_duration_rel_col + duration + end + + total_duration_rel_col = total_duration_rel_col/1000.0 + + print "Total duration reported for eye_contact_2: " + total_duration_rel_col.to_s + " seconds.\n" + + peer_col = getColumn("peer") + peer_times = Array.new + for cell in peer_col.cells + peer_times << [cell.onset, cell.offset] + end + + puts "\n--------------------------------------------------------------------------------------------------------- \n" + puts "\nSPEAKER_LISTENER: \n " + s_l_col = getColumn("speaker_listener") + rel_col = getColumn("speaker_listener_2") + match_arg = "onset" + time_tol = 5 + checkReliability(s_l_col, rel_col, match_arg, time_tol) + + s_args_main = 0.0 + s_args_rel = 0.0 + l_args_main = 0.0 + l_args_rel = 0.0 + + for cell in s_l_col.cells + if cell.argvals[0] == "S" + s_args_main = s_args_main + 1 + end + if cell.argvals[0] == "L" + l_args_main = l_args_main + 1 + end + end + + for cell in rel_col.cells + if cell.argvals[0] == "S" + s_args_rel = s_args_rel + 1 + end + if cell.argvals[0] == "L" + l_args_rel = l_args_rel + 1 + end + end + + rel_speaker_only = 0.0 + rel_listener_only = 0.0 + + rel_speaker_only = ((s_args_main/s_args_rel)*100) + rel_listener_only = ((l_args_main/l_args_rel)*100) + + if s_args_main > s_args_rel + rel_speaker_only = 100 + end + if l_args_main > l_args_rel + rel_listener_only = 100 + end + + puts "\nPercent agreement for SPEAKER ONLY: " + rel_speaker_only.to_s + "% \n" + puts "Percent agreement for LISTENER ONLY: " + rel_listener_only.to_s + "%\n" # Counting cells method + + main_col = getColumn("speaker_listener") + rel_col = getColumn("speaker_listener_2") + + main_col_times = Array.new + for mc in main_col.cells + if (mc.argvals[0] == "L") + main_col_times << [mc.onset, mc.offset] + end + end + rel_col_times = Array.new + for rc in rel_col.cells + if (rc.argvals[0] == "L") + rel_col_times << [rc.onset, rc.offset] + end + end + + # Now check each pair in rel times to see if they are within the range of one of the pairs in main col times using accumulators + + total_successes = 0 + total_rel_cells = 0 + + for cell in rel_col.cells + if cell.argvals[0] == "L" + total_rel_cells = total_rel_cells + 1 + end + end + + for pair1 in rel_col_times + for pair2 in main_col_times + if (pair1[0] - pair2[0]).abs <= 2000 and (pair1[1] - pair2[1]).abs <= 2000 + total_successes = total_successes + 1 + break + end + end + end + + total_rel_cells = total_rel_cells.to_f + total_successes = total_successes.to_f + + percent_reliability_listener = (total_successes / total_rel_cells) * 100 + puts "Percentage of reliable cells for listener (using two-second method): " + percent_reliability_listener.to_s + "% \n" + + # End Speaker_Listener ------------------------------------------------------------------------------------------------------------------------------ + + # Begin Greeting_goodbye ---------------------------------------------------------------------------------------------------------------------------- + + puts "\n-------------------------------------------------------------------------------------------------\n" + puts "\nGREETING\n" + main_col = getColumn("greeting") + rel_col = getColumn("greeting_2") + + if (main_col == nil) or (rel_col == nil) + main_col == getColumn("greeting_goodbye") + rel_col == getColumn("greeting_goodbye_2") + end + + for cell in main_col.cells + if cell.onset > 60000 + deleteCell(cell) + setColumn(main_col) + end + end + + for cell in rel_col.cells + if cell.onset > 60000 + deleteCell(cell) + setColumn(rel_col) + end + end + + checkReliability(main_col, rel_col, "onset", 10) + puts "\n\n\n\n" +# End Greeting_goodbye ------------------------------------------------------------------------------------------------------------------------------ + +# Excel Output: Comma scripted values, copy in one cell --> data --> text to columns --> delimit by columns ----------------------------------------- diff --git a/Reliability/file_make_reliability.rb b/Reliability/file_make_reliability.rb new file mode 100644 index 0000000..a11171e --- /dev/null +++ b/Reliability/file_make_reliability.rb @@ -0,0 +1,19 @@ +# Updated 4.24.20 + +require 'Datavyu_API.rb' + +begin + ec = getColumn("eye_contact") + slcol = getColumn("speaker_listener") + greetcol = getColumn("greeting") + + [ec, slcol, greetcol].each do |col| + col.set_hidden(true) + setColumn(col) + end + + makeReliability("speaker_listener_2", slcol, 1, "onset", "offset") + ec2 = createColumn("eye_contact_2") + setColumn(ec2) + makeReliability("greeting_2", greetcol, 1, "onset", "offset", "ordinal") +end \ No newline at end of file