def makeCombinations(self): # Make a line for the different objects and their rooms: self.roomsOfTheObjectsLine = "object,room1,room2\n" numberOfObjects = len(self.roomsOfTheObjects) objectsProcessed = 0 for object in self.roomsOfTheObjects: self.roomsOfTheObjectsLine += object + "," \ + self.roomsOfTheObjects[object][0] + "," \ + self.roomsOfTheObjects[object][1] objectsProcessed += 1 if objectsProcessed != numberOfObjects: # if this is not the last item, add a linebreak self.roomsOfTheObjectsLine += "\n" # Make a line for the different rooms and their objects: self.objectsOfTheRoomsLine = "room,object1,object2\n" numberOfRooms = len(self.objectsOfTheRooms) roomsProcessed = 0 for room in self.objectsOfTheRooms: self.objectsOfTheRoomsLine += room + "," \ + self.objectsOfTheRooms[room][0] + "," \ + self.objectsOfTheRooms[room][1] roomsProcessed += 1 if roomsProcessed != numberOfRooms: # if this is not the last item, add a linebreak self.objectsOfTheRoomsLine += "\n" self.totalCombinations = self.roomsOfTheObjectsLine + "\n\n\n" + self.objectsOfTheRoomsLine # Making into a CSV # makeIntoCSV(csvName=self.pathToParticipantDirectory + self.participantID + "_combinations.csv", stringToWrite=self.totalCombinations)
def makeExperimentResults(self): # Making just the experiment results into a CSV # makeIntoCSV(csvName=self.pathToParticipantDirectory + self.participantID + "_experimentResults.csv", stringToWrite=self.experimentResults) # Making the experiment results combined to the demographics into a CSV # # Creating a new first line: self.demographicsAndResults = "id,age,gender,education,student,fieldOfStudy,timeToCompleteDemographics," \ "quizAttempts,phaseType,isPractice,blockNb,trialNb,trialType,postType,leftObjects," \ "rightObjects,responseSide,responseTime,ghostSelected,ghostRejected,room1," \ "rewardProbability1,isTreasure1,room2,rewardProbability2,isTreasure2\n" # Taking all but the first line of the experiment results experimentResults = self.experimentResults.split("\n") experimentResults = experimentResults[1:] # Taking all but the first line of the demographics demographics = self.demographicsLine.split("\n") demographics = demographics[1:] # Putting all the parts together for i in range(len(experimentResults) - 1): # for some reason the last line is empty so we must get rid of that self.demographicsAndResults += self.participantID + "," \ + demographics[0] + "," \ + self.quizAttempts + "," \ + experimentResults[i] if i != (len(experimentResults) - 2): # if this is not the last line (before empty line) add a line break self.demographicsAndResults += "\n" # Making the CSV makeIntoCSV(csvName=self.pathToParticipantDirectory + self.participantID + "_demographicsAndResults.csv", stringToWrite=self.demographicsAndResults)
def generateExperimentSetUp(self): # prepare the experiment set up information: self.experimentSetUp = { "standardPractice": { "blocks": int(self.window.standardPracticeBlocksSpinBox.text()), "trials": int(self.window.standardPracticeTrialsSpinBox.text()) }, "standardExperimental": { "blocks": int(self.window.standardExperimentalBlocksSpinBox.text()), "trials": int(self.window.standardExperimentalTrialsSpinBox.text()) }, "tripletPractice": { "blocks": int(self.window.tripletPracticeBlocksSpinBox.text()), "trials": int(self.window.tripletPracticeTrialsSpinBox.text()) }, "tripletExperimental": { "blocks": int(self.window.tripletExperimentalBlocksSpinBox.text()), "trials": int(self.window.tripletExperimentalTrialsSpinBox.text()) } } # quiz 100% accuracy: if self.window.quizYes.isChecked(): self.quiz100 = True # This variable is used for the setting of the quiz quizForFile = "yes" # This variable is used for the settings.csv file else: # not checked self.quiz100 = False quizForFile = "no" # If this is a new experiment (there is no settings file for it) create one: self.experimentID = self.window.expIDLine.text() if self.experimentID + "_settings.csv" not in self.window.files: # the header and value lines are created here: settingsText = f"id,quiz100,standardPracticeBlocks,standardPracticeTrials,standardExperimentalBlocks," \ f"standardExperimentalTrials,tripletPracticeBlocks,tripletPracticeTrials," \ f"tripletExperimentalBlocks,tripletExperimentalTrials\n" \ f"{self.experimentID}," \ f"{quizForFile}," \ f"{self.window.standardPracticeBlocksSpinBox.text()}," \ f"{self.window.standardPracticeTrialsSpinBox.text()}," \ f"{self.window.standardExperimentalBlocksSpinBox.text()}," \ f"{self.window.standardExperimentalTrialsSpinBox.text()}," \ f"{self.window.tripletPracticeBlocksSpinBox.text()}," \ f"{self.window.tripletPracticeTrialsSpinBox.text()}," \ f"{self.window.tripletExperimentalBlocksSpinBox.text()}," \ f"{self.window.tripletExperimentalBlocksSpinBox.text()}" makeIntoCSV(csvName="experimentFormats/" + self.experimentID + "_settings.csv", stringToWrite=settingsText)
def makeDemographics(self): # Make a line with all the demographics information: self.demographicsLine = "age,gender,education,student,fieldOfStudy,timeToCompleteDemographics\n" numberOfDemographicItems = len(self.demographics) itemsProcessed = 0 for key in self.demographics: self.demographicsLine += self.demographics[key] itemsProcessed += 1 if itemsProcessed != numberOfDemographicItems: # if this is not the last item, add a comma self.demographicsLine += "," # Making into a CSV # makeIntoCSV(csvName=self.pathToParticipantDirectory + self.participantID + "_demographics.csv", stringToWrite=self.demographicsLine)
def updateAllResultsFile(self): # if the total file already exits... if self.totalFileName in self.allFilesInResults: # ...we want to take the demographics and results of the participant without the column names: demographicsAndResults = self.demographicsAndResults.split("\n") demographicsAndResults = demographicsAndResults[1:] demographicsAndResults = "\n".join(demographicsAndResults) demographicsAndResults = "\n" + demographicsAndResults # Otherwise we do want the column names: else: demographicsAndResults = self.demographicsAndResults # Append this participant's data to the total results data file: # # If there is no previous data file, opening with "a" will create a new one makeIntoCSV(csvName=self.pathToResults + self.totalFileName, stringToWrite=demographicsAndResults, openingStyle="a")
def makeQuizAttempts(self): makeIntoCSV(csvName=self.pathToParticipantDirectory + self.participantID + "_quizAttempts.csv", stringToWrite=self.quizAttempts)