This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remove_trackloss <- function(data='', subject_col='', trial_col='', trackloss_col='', threshold=0.5){ | |
| # print start | |
| print(paste('Removing trackloss trials from...', deparse(substitute(data)), sep = ' ')) | |
| # create an empty data frame to store track loss trials | |
| dat_exclude <- data.frame(matrix(ncol=3,nrow=0)) | |
| c <- c(subject_col, trial_col, 'exclude') | |
| colnames(dat_exclude) <- c | |
| # get the number of the columns of interest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remove_outliers <- function(x, na.rm = TRUE, ...) { | |
| mean = mean(x) | |
| std = sd(x) | |
| Tmin = mean-(3*std) | |
| Tmax = mean+(3*std) | |
| y <- x | |
| y[which(x < Tmin)] <- NA | |
| y[which(x > Tmax)] <- NA | |
| print(paste('Removed:', sum(is.na(y)), sep=' ')) | |
| y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from pydub import AudioSegment, effects | |
| import numpy as np | |
| import noisereduce as nr | |
| ########## | |
| # set working directory to the python file's directory | |
| os.chdir(os.path.dirname(os.path.abspath(__file__))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pygame, csv, os, sys, random | |
| from datetime import datetime | |
| ########## | |
| # Appearances | |
| ########## | |
| white = '#FFFFFF' | |
| black = '#000000' | |
| blue = '#0000FF' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from pydub import AudioSegment | |
| # set working directory to the python file's directory | |
| os.chdir(os.path.dirname(os.path.abspath(__file__))) | |
| # force pydub to find ffmpeg | |
| AudioSegment.converter = "C:\\ffmpeg\\bin\\ffmpeg.exe" | |
| AudioSegment.ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg.exe" | |
| AudioSegment.ffprobe ="C:\\ffmpeg\\bin\\ffprobe.exe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This script compares images from two folders, write down duplicate images, and optionally copy all unique images from the two folders into a new folder. | |
| # Created by Yiling Huo, 30 March 2023 | |
| import os, csv, shutil, ntpath | |
| from PIL import Image | |
| import imagehash | |
| # Set working directory to the location of this .py file | |
| os.chdir(os.path.dirname(os.path.abspath(__file__))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| form Get by-interval average formants | |
| word Sound_file_extension .wav | |
| sentence Output_file_name formants.csv | |
| integer Tier_number 1 | |
| comment Press OK to choose a directory. | |
| endform | |
| procedure getFiles: .dir$, .ext$ | |
| .obj = Create Strings as file list: "files", .dir$ + "/*" + .ext$ | |
| .length = Get number of strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Created by Yiling Huo 30/09/2022 | |
| # File selection procedure from Scott Seyfarth annotation.Praat (https://gist.github.com/scjs/ffbbba71cc8b3ff9d0476c82b2df9d0f) | |
| # What this script does: | |
| # 1. Takes sound files and textgrid files with the same name, | |
| # 2. extract all intervals with a name in the selected tier, | |
| # 3. divide each interval into a pre-determined amount of equal-length mini-intervals, | |
| # 4. extract pitch at each boundary of the mini-intervals, | |
| # 5. and save all the pitch information in a csv file. | |
| # What this script is good for: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| form Get audio file duration | |
| word Sound_file_extension .mp3 | |
| sentence Output_file_name output.csv | |
| comment Press OK to choose a directory. | |
| endform | |
| procedure getFiles: .dir$, .ext$ | |
| .obj = Create Strings as file list: "files", .dir$ + "/*" + .ext$ | |
| .length = Get number of strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Praat script Create Speech Stimulus Onset Asynchrony (SOA) Stimuli using Textgrids | |
| # inspired by script by Daniel Hirst and Zhenghan Qi | |
| # created by Yiling Huo | |
| # 12 Aug 2022 | |
| # What this script does: | |
| # load sound file | |
| # load textgrid file | |
| # extract every non-empty interval as separate sound object | |
| # calculate how much silence is needed and create silent sound object |
NewerOlder