Skip to content

Instantly share code, notes, and snippets.


Ning Mei nmningmei

View GitHub Profile
nmningmei / pdist_correlation_comparison_same
Last active Sep 28, 2021
To show scipy.spatial.distance.pdist produce the same RDM when using 'correlation' regardless of normalization or not.
View pdist_correlation_comparison_same
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 /
Created Apr 29, 2019 — forked from dilawar/
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