def getMeanMedSDFreMaxMinSound(data): #create special for only sound no sound #get the mean median sd and frequency in the set of data (x,y) = data.shape mean = np.zeros((2)) median = np.zeros((2)) std = np.zeros((2)) fre = np.zeros((2)) maxi = np.zeros((2)) mini = np.zeros((2)) desData = (mean,median,std,fre,maxi,mini) setOfAction = ATS.countAction(data,[1]) desData = ATS.updateMeanMedSDFreMaxMin(desData,0,setOfAction) setOfAction = ATS.countAction(data,[3]) desData = ATS.updateMeanMedSDFreMaxMin(desData,1,setOfAction) return desData
def updateDiscriptiveData(ori,data,GoT,nameFile,dyad,section): start = 0 end = 0 i = 0 (x,y) = data.shape ####test### # data[x-7][2] = 2 # data[x-6][2] = 2 # data[x-5][2] = 2 count = 0 while i < x: if i == x-1 or data[i+1][1] != data[start][1] : end = i line = [] line.append(int(nameFile)) line.append(dyad) line.append(section) line.append(count) line.append(data[start][0]) #"end-1" is because to prevent out of bound for "end = x" #+1 at the is because we want to take into acount of the last number. Ex, from 0 to 20, there is 21 # line.append(data[end][0]) line.append(end-start+1) line.append(data[start][1]) #get the actions of either gaze or talk of the line action action1 = data[start:end+1,[0,2]] action2 = data[start:end+1,[0,3]] if GoT == 0: line = ATS.updateDiscriptiveData(line,action1,1) else: line = ATS.updateDiscriptiveData(line,action1,0) line = ATS.updateDiscriptiveData(line,action2,1) start = end + 1 count = count + 1 ori.append(line) i = i + 1 return ori
def getReliability(inpath, Start, End, GoTSize): BoC = np.zeros((End, GoTSize), dtype=np.float64) #best of coder ori = [] for i in ["52", "65", "79"]: for j in ["C1", "C2"]: for root, dirs, files in walk(inpath): BoC = np.zeros((End, GoTSize), dtype=np.float64) #best of coder for file in files: if file.endswith(".csv"): if i in file and j in file: print(file) nameOutput = file data = np.genfromtxt(join(root, file), dtype=np.float64, delimiter=',') dyad = int(splitext(file)[0][2:4]) conv = int(splitext(file)[0][6:7]) coder = int(getCoderName(splitext(file)[0][15:17])) beg = getDyadCovCoderInfor(dyad, conv, coder, End) #beg is begining data = AT.shortenData(data, Start, End) combData = AT.combineData(beg, data, End) ori.extend(combData) BoC = bestOfCoderTag(BoC, data, coder, End) data = getBestOfCoderTag(BoC, End) beg = getDyadCovCoderInfor(dyad, conv, 105, End) combData = np.c_[beg, data] ori.extend(combData) time = np.arange(End).reshape([End, 1]) output = np.c_[time, data] np.savetxt(nameOutput + "_combined.csv", output, fmt='%1.3f', delimiter=',') return ori
def getDiscriptiveWithWidth(inpath, Start, End, nameFiles, DynEnd, Width, GazeType): # get discription information of the data # width mean how long do you want to check the characteristics # DynEnd dynamic ending # GazeType ori = [] for nameFile in nameFiles: print (nameFile) for i in [1, 2]: print (i) (dataTHroot, dataTSroot, dataGroot) = ATS.readInput(inpath, nameFile, i) if DynEnd: # using dynamic ending (yTH, xTH) = (dataTHroot.shape) (yTS, xTS) = (dataTSroot.shape) (yG, xG) = (dataGroot.shape) End = np.amin(np.asarray([yTH, yTS, yG])) # get the actual end time dataTHroot = ATS.shortenData(dataTHroot, Start, End) dataTSroot = ATS.shortenData(dataTSroot, Start, End) dataGroot = ATS.shortenData(dataGroot, Start, End) j = 0 while j < End: startSub = j if j + Width > End: endSub = End else: endSub = j + Width dataTH = ATS.shortenData(dataTHroot, startSub, endSub) dataTS = ATS.shortenData(dataTSroot, startSub, endSub) dataG = ATS.shortenData(dataGroot, startSub, endSub) dataGTH = ATS.combineData(dataG, dataTH, endSub) dataGTHS = ATS.combineData(dataGTH, dataTS, endSub) # print (dataGTHS) j = j + Width # for i in ori: # print (i) return ori
def getDiscriptiveTwoTalkWithWidth(inpath, Start,End, nameFiles, DynEnd, Width,GoT): #get discription information of the data #width mean how long do you want to check the characteristics #DynEnd dynamic ending ori = [] for nameFile in nameFiles: print (nameFile) for i in [1,2]: print (i) (dataTHroot, dataTSroot, dataGroot) = ATS.readInput(inpath, nameFile,i) if DynEnd: #using dynamic ending (yTH, xTH) = (dataTHroot.shape) (yTS, xTS) = (dataTSroot.shape) (yG, xG) = (dataGroot.shape) End = np.amin(np.asarray([yTH,yTS,yG])) #get the actual end time dataTHroot = ATS.shortenData(dataTHroot,Start,End) dataTSroot = ATS.shortenData(dataTSroot,Start,End) dataGroot = ATS.shortenData(dataGroot,Start,End) dataTHSroot = combinedTwoTalkTogether(dataTHroot,dataTSroot) j = 0 while j < End: startSub = j if j+Width > End: endSub = End else: endSub = j+Width dataG = ATS.shortenData(dataGroot,startSub,endSub) dataTHS = ATS.shortenData(dataTHSroot,startSub,endSub) if GoT == 0: dataGTHS = ATS.combineData(dataG,dataTHS,endSub) else: dataGTHS = ATS.combineData(dataTHS,dataG,endSub) ori = updateDiscriptiveDataForBothTalks(ori,dataGTHS,GoT,nameFile,i,j) j = j + Width return ori
def updateDiscriptiveDataForBothTalks(ori,data,GoT,nameFile,dyad,section): # start = 0 end = 0 i = 0 (x,y) = data.shape count = 0 while i < x: # let i == x-1 first because it will check this first and skip the second one if it reach the end # you i+1 because we are counting forward if i == x-1 or data[i+1][1] != data[start][1] : end = i line = [] line.append(int(nameFile)) line.append(dyad) line.append(section) line.append(count) line.append(data[start][0]) #"end-1" is because to prevent out of bound for "end = x" #+1 at the is because we want to take into acount of the last number. Ex, from 0 to 20, there is 21 # line.append(data[end][0]) line.append(end-start+1) line.append(data[start][1]) #get the actions of either gaze or talk of the line action gazeAction = data[start:end+1,[0,2]] if GoT == 0: line = updateDiscriptiveDataSound(line,gazeAction) else : line = ATS.updateDiscriptiveData(line,gazeAction,0) count = count + 1 start = end +1 ori.append(line) i = i + 1 # for i in ori: # print (i) return ori
import numpy as np import AnalysisToolForSingleSet as AT if __name__ == "__main__": # should have more varriable REMEMBER: DON'T CHANGE THIS CODE FIRST, CHANGE THE CODE FOR CONVERTING DATA FROM SRT TO SVN FIRST IF YOU DECIDE TO COMBINING CATEGORIES Start = 0 End = 9000 inpath = "Input/" nameFiles = np.loadtxt("NameFile.txt", dtype='S') print nameFiles title = ["Dyad", "Cov", "Time", "Gaze", "Talking Hawking", "Talking Shake"] ori1 = AT.getOverallResult(inpath, Start, End, nameFiles, False) name = "Output/OverallData_EndTime_5min.csv" AT.printResult(ori1, title, name) ori1 = AT.getOverallResult(inpath, Start, End, nameFiles, True) name = "Output/OverallData_EndTime_Actual.csv" AT.printResult(ori1, title, name)
inpath = "Input/" nameFiles = np.loadtxt("NameFile.txt", dtype='S') title = [ "Dyad", "Cov", "SectionStartTime", "TalkID", "Start", "End", "Duration", "TalkType" ] TalkType = (1, 2, 3, 4, 5) Person = "H" PersonTile = "S_" nameOutput1 = "Output/CombinedOneLayer/Talk/DiscriptiveData_5talks_H_5mins.csv" title1 = getTitle(title, GazeType, SpeakType, PersonTile, Character) ori1 = AMS.getDiscriptiveTalkWithWidth(inpath, Start, End, nameFiles, False, 9000, TalkType, Person) ATS.printResult(ori1, title1, nameOutput1) nameOutput2 = "Output/CombinedOneLayer/Talk/DiscriptiveData_5talks_H_100sec.csv" title2 = getTitle(title, GazeType, SpeakType, PersonTile, Character) ori2 = AMS.getDiscriptiveTalkWithWidth(inpath, Start, End, nameFiles, False, 3000, TalkType, Person) ATS.printResult(ori2, title2, nameOutput2) Person = "S" PersonTile = "H_" nameOutput3 = "Output/CombinedOneLayer/Talk/DiscriptiveData_S_5mins.csv" title3 = getTitle(title, GazeType, SpeakType, PersonTile, Character) ori3 = AMS.getDiscriptiveTalkWithWidth(inpath, Start, End, nameFiles, False, 9000, TalkType, Person) ATS.printResult(ori3, title3, nameOutput3)
GazeType = [ "Around_", "Monitor_", "Keyboard_", "Face_", "NoFace_", "CompOnly_" ] SpeakType = [ "NoSpeak_", "Typing_", "Speaking_", "SSS_", "Hovering_", "Sound_", "NoSound_" ] Person = ["H_", "S_"] Character = ["Mean", "Median", "PopularSD", "Frequency", "Max", "Min"] inpath = "Input/" nameFiles = np.loadtxt("NameFile.txt", dtype='S') print nameFiles nameOutput1 = "Output/TTestData_5mins.csv" title1 = getTitle(GazeType, SpeakType, Person, Character) ori1 = AST.getDiscriptiveData(inpath, Start, End, nameFiles, False) checkIndex = 1 groupCompaired = (1, 2) startIndex = 2 endIndex = len(ori1[0]) result1 = ST.TTestPaired(ori1, checkIndex, groupCompaired, startIndex, endIndex).tolist() data = [] data.append(title1) data.append(result1) with open(nameOutput1, "wb") as t: writer = csv.writer(t)
"BodyOnly_" ] SpeakType = [ "NoSpeak_", "Typing_", "Speaking_", "SSS_", "Hovering_", "Sound_", "NoSound_" ] Person = ["H_", "S_"] Character = ["Mean", "Median", "PopularSD", "Frequency", "Max", "Min"] inpath = "Input/" nameFiles = np.loadtxt("NameFile.txt", dtype='S') print nameFiles title1 = ["Dyad", "Cov"] nameOutput1 = "Output/DiscriptiveData_5mins.csv" title1 = getTitle(title1, GazeType, SpeakType, Person, Character) ori1 = AT.getDiscriptiveData(inpath, Start, End, nameFiles, False) AT.printResult(ori1, title1, nameOutput1) title2 = ["Dyad", "Cov", "StartFrame"] nameOutput2 = "Output/DiscriptiveData_100secs.csv" title2 = getTitle(title2, GazeType, SpeakType, Person, Character) ori2 = AT.getDiscriptiveDataWithWidth(inpath, Start, End, nameFiles, False, 3000) AT.printResult(ori2, title2, nameOutput2) title3 = ["Dyad", "Cov", "StartFrame"] nameOutput3 = "Output/DiscriptiveData_60secs.csv" title3 = getTitle(title3, GazeType, SpeakType, Person, Character) ori3 = AT.getDiscriptiveDataWithWidth(inpath, Start, End, nameFiles, False, 1800) AT.printResult(ori3, title3, nameOutput3)
import AnalysisToolForSingleSet as AT import CoderAgreement as CA if __name__ == "__main__": inpath = "InRe/Talking/Hawking/" #double slash because codec is difference Start = 0 End = 9000 GoTSize = 5 ori = CA.getReliability(inpath, Start, End, GoTSize) title = ["Dyad", "Cov", "Coder", "Time", "talking"] name = "Output/Reliability_Data_Talking_Hawking_5min.csv" AT.printResult(ori, title, name) inpath = "InRe/Talking/Shake/" #double slash because codec is difference ori = CA.getReliability(inpath, Start, End, GoTSize) name = "Output/Reliability_Data_Talking_Shakespear_5min.csv" AT.printResult(ori, title, name)
End = 9000 SpeakType = ["NoSound_", "Sound_"] GazeType = [ "Around_", "Monitor_", "Keyboard_", "Face_", "NoFace_", "CompOnly_", "BodyOnly_" ] Character = ["Mean", "Median", "PopularSD", "Frequency", "Max", "Min"] inpath = "Input/" nameFiles = np.loadtxt("NameFile.txt", dtype='S') GoT = 0 nameOutput1 = "Output/CombinedTwoLayer/DiscriptiveData_Gaze_Sound_5mins.csv" title1 = getTitle(GoT, GazeType, SpeakType, Character) ori1 = AMS.getDiscriptiveTwoTalkWithWidth(inpath, Start, End, nameFiles, False, 9000, GoT) ATS.printResult(ori1, title1, nameOutput1) nameOutput2 = "Output/CombinedTwoLayer/DiscriptiveData_Gaze_Sound_100secs.csv" title2 = getTitle(GoT, GazeType, SpeakType, Character) ori2 = AMS.getDiscriptiveTwoTalkWithWidth(inpath, Start, End, nameFiles, False, 3000, GoT) ATS.printResult(ori2, title2, nameOutput2) GoT = 1 nameOutput3 = "Output/CombinedTwoLayer/DiscriptiveData_Sound_Gaze_5mins.csv" title3 = getTitle(GoT, GazeType, SpeakType, Character) ori3 = AMS.getDiscriptiveTwoTalkWithWidth(inpath, Start, End, nameFiles, False, 9000, GoT) ATS.printResult(ori3, title3, nameOutput3) nameOutput4 = "Output/CombinedTwoLayer/DiscriptiveData_Sound_Gaze_100secs.csv"