Skip to content

Instantly share code, notes, and snippets.

@cbrnr
cbrnr / .SRCINFO
Last active May 2, 2024 05:35
rstudio-desktop-bin AUR PKGBUILD
pkgbase = rstudio-desktop-bin
pkgdesc = An integrated development environment (IDE) for R (binary from RStudio official repository)
pkgver = 2024.04.0.735
pkgrel = 1
url = https://posit.co/products/open-source/rstudio/
arch = x86_64
license = AGPL
depends = r>=3.3.0
depends = clang
depends = libxkbcommon-x11
@cbrnr
cbrnr / delay_analysis.py
Created October 1, 2021 14:29
Measure delay in PsychoPy visual stimulus presentation
import numpy as np
import pandas as pd
import mne
files = ["data/black-white_gaming1.bdf", "data/black-white_standard3.bdf"]
rows = []
n = 100 # expected number of events
mne.set_log_level("ERROR")
@cbrnr
cbrnr / mne_sample_data.py
Created September 29, 2021 13:25
MNE sample data using pathlib
from pathlib import Path
import mne
fpath = Path(mne.datasets.sample.data_path()) / "MEG" / "sample"
raw = mne.io.read_raw_fif(fpath / "sample_audvis_filt-0-40_raw.fif")
@cbrnr
cbrnr / ans_animation.py
Last active September 29, 2021 13:19
Visualization of approximate number system
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np
from scipy.stats import norm
fps = 25
fig, ax = plt.subplots(figsize=(8, 6))
x = np.linspace(0, 20, 1000)
@cbrnr
cbrnr / package_versions.R
Last active October 8, 2020 14:54
Get package versions (by default use all attached packages)
package_versions <- function(packages=NULL, base=FALSE, sort=FALSE) {
#' Determine package versions.
#'
#' @param packages Packages to query; if not specified (or \code{NULL}),
#' all currently attached packages are queried.
#' @param base If \code{TRUE}, include the base package (R version).
#' @param sort If \code{TRUE}, sort package names alphabetically.
#' @return Data frame with package names and corresponding versions.
if (is.null(packages))
packages <- names(sessionInfo()$otherPkgs)
@cbrnr
cbrnr / dependence_factor.py
Last active September 29, 2021 10:54
Compute measure of dependence
import numpy as np
def dependence_factor(a, b, norm=True):
"""Compute measure of dependence between a and b.
Independent means that Pab(i,j) - Pa(i) * Pa(j) == 0 for all i and j, where
i and j are the individual values that the variables a and b can take.
If norm=True, this function returns a value between 0 and 1, where 1 means