Skip to content

Instantly share code, notes, and snippets.

View nmningmei's full-sized avatar

Ning Mei nmningmei

View GitHub Profile
@nmningmei
nmningmei / pdist_correlation_comparison_same
Last active September 28, 2021 12:54
To show scipy.spatial.distance.pdist produce the same RDM when using 'correlation' regardless of normalization or not.
import numpy as np
from matplotlib import pyplot as plt
from scipy.spatial import distance
# create data the center at zero, 36 words by 100 voxels
zero_mean_data = np.random.rand(36,100)
zero_mean_data = zero_mean_data - zero_mean_data.mean(1).reshape(-1,1) # so each row has mean zero
# create data that is not center at zero, 36 words by 100 voxels
sim_data = zero_mean_data.copy()
@nmningmei
nmningmei / white_noise.py
Created April 29, 2019 20:34 — forked from dilawar/white_noise.py
Create white noise stimulus in python using psychopy
# Generate noise frames
# dependencies: psychopy, python-numpy, python-pyglet
from numpy import random
from psychopy import visual
# create a window
win = visual.Window([800, 600], monitor="testMonitor", units="deg")
maskDuration = 180 # Duration of mask in frames
visualNoiseSize = 512 # Dimension in pixels of visual noise. Must be a power of 2