# Possibly useful code for psychological tasks

Online questionnaires, assessment and training. System for running online experiments. The code provides an example of an Attentional Bias Modification design including timed invitations to sessions via email, questionnaires, a dot-probe task in Javascript, and integration with Sona systems.

Geomaker. The "Points on a Wonky Arc" (POWA) algorithm to generate abstract geometric shapes for stimuli, from basic regular polygons to weird wobbly vaguely organic Rorschach-y shapes. Implemented in R.

# Data analysis functions

## Statistics

NumNomS. Permutation-based set-wise multiple correction method that aims to balance statistical power with precise information. Could be useful in situations in which it might not matter exactly which tests are and are not significant, but it does matter whether some of them are. The code also provides a permutation-based critical p-value with familywise error rate control that takes dependencies between variables into account; this can be much more powerful than Bonferroni correction (imagine the toy example that you just copied one variable a hundred times - you don't actually need to adjust the critical p-value at all, regardless of how many copies you have).

teg_RMA. Repeated measures analyses (be aware of implementation details!).

teg_regression. Basic linear regression.

teg_crosstab. Crosstab and Chi squared test (automatically removes rows or columns with low expected counts).

teg_ftest. F-test.

teg_ttest. One-sample t-test.

teg_ttest2. Independent samples t-test.

teg_PCA. Returns principal components using the NIPALS algorithm: avoids having to make the covariance matrix so it's usable where the normal method would cause an Out of Memory error.

teg_scree. Function for getting the scree citerion for PCA.

## Data preprocessing and transformations

Psychophysiological Interactions (PPI). Function for running a PPI analysis.

teg_calc_D600. Calculates the D600 score for IAT data.

hiro3. Interactive plot program for resliced SPM data. Includes blob identification, anatomical labelling, command-line PPI function.

Aztec. Removes physiological confounds from fMRI data.

antici. Evolving EEG toolbox and GUI.

textToValueRecoder. Function to recode questionnaire data saved as the text of response options into numerical values.

## Signal processing

EZfilt. Simple (or just oversimplistic...) filtering function.

Wavelet toolbox. A basic toolbox (integrated in antici) for doing wavelet analysis. The functions provide transformations of vectors to instantaneous amplitude and phase-difference vectors, and averaging to event-related amplitude and the PLV. There's also a data-simulator and example program.

## Input / Output

teg_parse2nested. Reads ASCII trialwise data into nested means per condition.

gen_read_data. Reads binary .BED genetic data.

teg_read. Simple ASCII file reader, for when you might have missing values or non-number elements to ignore. Updated 24 - 05 - 2009.

## Plotting

teg_plot. Basic plotting of lines with error bars from matrices of observations.

teg_stemleaf. Stem-and-leaf plot showing descriptives of vectors.

cLine. Plots lines with standard-error bars.

cvec. An interactive vector-visualization function, allows quick navigation through a vector at changing time scales.

cmat. Util for visualization and manipulation of 3D matrices.

arrow. Function to plot arrows.

tg_pcolor. A 2-D color-coded plotter for matrices adapted from the default function pcolor.

tg_surf3d. Plots a surface in 3D, you specify x, y, z coordinates and associated value and it color-codes it. Nice for EEG scalp maps.

## General

rec_loop. A recursive looping function that allows an arbitrary depth of nested loops.

KESN. Function that finds the optimal partitioning of a set of values.

## Random

Trial event function. A function to generate timelines for experiment trials.

Smooth corners. Build a road where corners are replaced by arcs so that the direction is continuous. Example of a function that generates input for roadwarrior3.

Balanced latin square generator. A latin square is an N x N matrix in which every row and column contains exactly one of each of N elements. If the square is balanced, every element is followed and preceded exactly once by each other element. This script generates such squares randomly.

gameSolver. Solves finite strategic games using the pivot method.

Task. Example of how to program a cognitive task.

# C++

The zips contain source code and executables. They won't delete your hard drive or anything but the "Fractals 2" executable can generate impressive errors if you crank up the parameters, so be prepared to ctrl-alt-del and kill the process if you start experimenting :)Fractals 1. Messing about with visualizing recursive functions. The zip includes the (C++ Builder) source code. Line and Frac toggle two types of recursion. Line gives you virus-like wormish things crawling around. Frac generates a spreading blob. The number in the text box determines the length of elements of the form. Activating "Flow" and clicking Start generates a wave pattern.

Fractals 2. A spreading network. This one's rather sensitive to parameters, and crashing can be a bit spectacular...

Rocky III, neural network simulation environment based on Wang (1999). Includes a scripting language for designing and running networks and their input.