Skip to content

Instantly share code, notes, and snippets.

View wjhopper's full-sized avatar

Will Hopper wjhopper

View GitHub Profile
@wjhopper
wjhopper / Psyc240_HWanalysis
Last active August 29, 2015 14:08
Psyc240_HWanalysis. Compare means across TA's
hwanalysis <- function(hwnumber = NULL, base_graphing=FALSE) {
# A standalone R function, so to use it, use source("hwanalysis.R") from the command line and then call hwanalysis() with
# 1). the numeric number of the HW you want to analyze grades for and
# 2). the graphing style you want. The default base_graphing= FALSE uses ggplot (requires ggplot2 and dplyr be
# installed). base_graphing=TRUE gives you old school base R plots, thus no additional dependencies. (but we should all
# have ggplot2 and dplyr anyway right?)
if (is.null(hwnumber)) {
stop('hwnumber must be an integer which defines which hw you want to analyze grades for!')
@wjhopper
wjhopper / getSubjectInfo.m
Last active August 29, 2015 14:13
My more 'full featured' version of matlabs 'inputdlg' function
function resps = getSubjectInfo(varargin)
<<<<<<< HEAD
% Calling
% c=struct('radio',struct('eeg',struct('label','EEG Experiment?')), ...
% 'textinput',struct('subNum',struct('label','Subject Number')),...
% 'dropdown',struct('session',struct('label','Session','val',[1 2])));
=======
% Calling Example
% c = { struct('name','sub_num','type','textinput','label','Subject Number','classcheck',@(x) (isnumeric(x) && ~isnan(x))), ...
@wjhopper
wjhopper / factor_magic.m
Created January 21, 2015 14:20
Generate the 'wide format' coding of experimental factors based on the factors with any combination of levesl and weights for those factors
function factor_cell_mat = factor_magic(nrow, factors)
% Calling example:
% factors = {[1,2],[.25,.75] ;
% [1,2],[.5,.5] ;
% [1,2,3],[1/3,1/3,1/3] }
% factor_magic(2,48,factors)
factor_cell_mat = cell(nrow,size(factors,1));
for i=1:size(factors,1)
nFactors = length(unique(factors{i,1}));
@wjhopper
wjhopper / run_experiment.bat
Last active December 11, 2015 13:56
run_experiment.bat
matlab -r "cd('C:\Users\will\Documents\CEMNL\Testing Differentially Strengthens Recovery\Runfiles\');path(path,pwd);main"
@wjhopper
wjhopper / echoresp
Created February 22, 2015 20:22
drawing for cued recall
function onset = draw(cue,msg,string,drawExtra)
drawExtra(params{:})
DrawFormattedText(windowPtr,cue,'right', 'center',[],[],[],[],[],[],left-[0 0 spacing 0]);
DrawFormattedText(windowPtr,msg, 'center','center');
DrawFormattedText(windowPtr,string,right(1)+spacing, 'center');
[~, onset] = Screen('Flip', windowPtr);
end
@wjhopper
wjhopper / ratingsROC_MLE.R
Last active June 30, 2017 17:51
Function to fit unequal variance SDT model to confidence ratings data
ratingsROC <- function(Fcount =c(2,8,37,23,30), Hcount = c(61,15,15,5,4)) {
#R script to fit ROC data from confidence rating task
#CMR + WJH Mar 26 2015
#data from Macmillan & Creelman 2005 Example 3b
#Low Frequency words, confidence rating recognition task
# Counts are ordered from 'sure old' to 'sure new' response for each stim class
fa_probs <- cumsum(Fcount)/sum(Fcount)
h_probs <- cumsum(Hcount)/sum(Hcount)
@wjhopper
wjhopper / binom_vs_t.R
Created April 17, 2015 16:28
Testing rejection thresholds in t and binomial distribution for binary data
library(dplyr)
library(reshape2)
library(ggplot2)
n <- 500
null <- .75
obs_n <- seq(1,n-1)
binom_probs_low <- pbinom(obs_n, n, null)
binom_probs_upp <- pbinom(obs_n, n, null,lower.tail = FALSE)
binom_probs <- pmin(binom_probs_low, binom_probs_upp)
@wjhopper
wjhopper / apt-search.sh
Created September 25, 2015 11:38
searching the apt log
cat /var/log/dpkg.log |awk '/ removed / {printf "%s\n",$0}'
@wjhopper
wjhopper / functional_madness.R
Created November 29, 2015 20:48
Observe the amazing obscurity of 100% "functional" R code!
## Some sort of list comprehension using only functional programming
## techniques that returns a list holding the coefficients of variation
## (i.e. the mean divided by the standard deviation) for each column in the
## mtcars data set.
## This isn't the clearest code (i.e. its really hard to tell its dividing
## the mean by the standard deviation) but it uses absolutely no imperative control
## flow structures and no vectorized R functions, so if you can read and understand
## this you can do you some functional programming for great good =). I can't believe I
## actually figured this out, much less that I figured it out in like 5 minutes,
@wjhopper
wjhopper / demographics.m
Created December 11, 2015 13:57
Demographic Info for Experiments
%--------------------------------------------------------%
% Onscreen script to record race/ethnic/sex demographics %
% for Matlab %
% Updated 09/21/2015 %
%--------------------------------------------------------%
%{
Purpose:
A Matlab script which will generate a set of dialog boxes that ask
participants an assortment of questions regarding demographics (in