Skip to content

Instantly share code, notes, and snippets.

View drammock's full-sized avatar

Daniel McCloy drammock

View GitHub Profile
@drammock
drammock / 1s2d.R
Created September 20, 2014 12:32
phonR snippet for 1S2D
library(phonR)
# if you want to go straight to PDF, uncomment this line, and the "dev.off()" line at the end:
# cairo_pdf("myfile.pdf", width=6, height=6, pointsize=12)
# assuming that your dataframe is called "mydata":
# first, create columns for the normalized data:
z <- with(mydata, norm.vowels("lobanov", f1=f1, f2=f2, f3=f3, group=speaker))
colnames(z) <- paste(colnames(z), "z", sep="")
mydata <- cbind(mydata, z)
@drammock
drammock / BruneiVsChinaVowels.R
Last active August 29, 2015 14:12
Sample translation from phonR 0.4-2 to 1.0-0
# install the new version:
download.file("https://raw.githubusercontent.com/drammock/phonR/master/R/phonR.R", "phonR.R")
source("phonR.R")
# or, if you have devtools package, can use
# devtools::source_url("https://raw.githubusercontent.com/drammock/phonR/master/R/phonR.R")
# do the bark normalization before plotting:
BNF$f1bark <- normBark(BNF$f1)
BNF$f2bark <- normBark(BNF$f2)
@drammock
drammock / vowel-ellipse-overlap.R
Last active November 19, 2019 07:22
Example of calculating and plotting ellipse overlap with phonR, sp, and rgeos
library(phonR)
data(indoVowels)
library(sp) # SpatialPolygons, etc
library(rgeos) # gIntersection
fem2 <- indo[indo$subj %in% "F02",]
vowels <- unique(as.character(fem2$vowel))
## important! ellipse.conf defaults to 0.6827 (2 s.d.) for plotVowels, but
## defaults internally to 0.95 for phonR:::ellipse. You must specify the
@drammock
drammock / r-sig-clmm.R
Last active August 29, 2015 14:23
issues setting up cumulative-link mixed model
## "reduction" is the response variable (ordered factor, none < devoiced < deleted)
table(cleandata$reduction)
## none devoiced deleted
## 20776 360 420
## "speaker" is a nuisance predictor, which I intend to model as a random effect
with(cleandata, table(reduction, speaker))
## speaker
## reduction F1 F2 F3 M1 M2 M3
## none 3559 3482 3325 3569 3360 3481
@drammock
drammock / mne-logo.py
Last active April 4, 2016 01:22
script to generate proposed new logo for MNE
# -*- coding: utf-8 -*-
"""
===============================================================================
Script 'mne logo'
===============================================================================
This script makes the logo for MNE.
"""
# @author: drmccloy
# Created on Mon Jul 20 11:28:16 2015
@drammock
drammock / n_edges_draw_time_test.py
Created September 11, 2015 23:23
testing effect of number of vertices on expyfun circle draw times
import expyfun
import numpy as np
import matplotlib.pyplot as plt
plt.ioff()
n_iter = 10000
edges = np.arange(4, 17, dtype=int)
edges = [10, 100, 500]
times = np.zeros(n_iter)
with expyfun.ExperimentController('wait_test', output_dir=None,
@drammock
drammock / test-el-interactive.py
Created October 15, 2015 17:15
Test EyeLink connectivity within expyfun
# -*- coding: utf-8 -*-
"""
===============================================================================
Script 'test-eyelink-interactive.py'
===============================================================================
This script tests the connection to the EyeLink eye tracker.
"""
# @author: drmccloy
# Created on Thu Oct 15 09:11:04 2015
@drammock
drammock / test-ec-set-bg-col.py
Created October 16, 2015 19:49
test script for setting background color in ExperimentController
# -*- coding: utf-8 -*-
import numpy as np
from expyfun import ExperimentController
kwargs = dict(exp_name='test', session='000', participant='foo')
with ExperimentController(**kwargs) as ec:
ec.flip()
ec.set_background_color('red')
ec.screen_text('red', color='k')
@drammock
drammock / deconv.py
Created December 2, 2015 17:35 — forked from larsoner/deconv.py
# -*- coding: utf-8 -*-
# see:
# http://eeweb.poly.edu/iselesni/lecture_notes/least_squares/
# LeastSquares_SPdemos/deconvolution/html/deconv_demo.html
import numpy as np
from scipy import linalg, sparse
import matplotlib.pyplot as plt
from pyeparse.utils import pupil_kernel
@drammock
drammock / test_tdt.py
Created December 15, 2015 00:03
attempts to connect to TDT in PBB226
# -*- coding: utf-8 -*-
import expyfun as ef
import tdt
circuit = 'C:\\Users\\labuser\\Builds\\expyfun\\expyfun\\data\\expCircuitF32_RM1.rcx'
interface = 'USB'
model = 'RP2'
# approach #1