Skip to content

Instantly share code, notes, and snippets.

@fladd
fladd / fade_between_stims.py
Created July 26, 2018 11:55
Fade between stimuli in Expyriment
import expyriment, os, pygame, time
from expyriment import design, control, stimuli, io
from expyriment.misc import constants
#expyriment.control.defaults.open_gl = 0
control.set_develop_mode(True)
exp = expyriment.design.Experiment(background_colour=[150,150,150])
expyriment.control.initialize(exp)
@fladd
fladd / .vimrc
Last active March 7, 2021 21:42
" Title: .vimrc
" Author: Florian Krause <florian.krause@fladd.de>
" Date: 2021-03-07
" " GLOBAL SETTINGS
"
if has('win32') || has ('win64')
let $VIMHOME = $HOME."/vimfiles"
else
from collections import OrderedDict
import nibabel as nib
from brainvoyagertools import voi # Get it from https://github.com/fladd/brainvoyagertools
v1 = voi.VOIsDefinition(framing_cube=256, reference_space="MNI")
v2 = voi.VOIsDefinition(framing_cube=256, reference_space="MNI")
import time
titles = ("Clock", "Implementation", "Monotonic", "Adjustable", "Resolution")
print("".join(str(x).ljust(30) for x in titles))
print("".join(("-" * len(x)).ljust(30) for x in titles))
for clock in ("time",
"clock",
"monotonic",
"perf_counter",
def stimulus_size_as_visual_angles(stim_size, screen_size, screen_angles):
"""Convert stimulus size (in pixels) to visual viewing angle (in degree).
Parameters
----------
stim_size : (int, int)
the size of the stimulus in pixels (width, height)
screen_dims : (int, int)
the pixel dimensions of the screen (width, height)
screen_angles : (float, float)
@fladd
fladd / style.py
Created March 15, 2020 11:12
Python style guide
#!/usr/bin/env python
"""Summary of module.
Description of module.
Can contain multiple lines.
"""
__author__ = 'Name Surname <Email address>'
@fladd
fladd / zoom_security.md
Last active April 3, 2020 08:16
Detailed step-by-step tutorial on how to fix Zoom security issues

Steps to fix Zoom security issues:

  1. Don't use Zoom
@fladd
fladd / show_progress.md
Last active October 19, 2021 10:05
Show the progress of a process with a simple text-based progress bar

show_progress

Show the progress of a process with a simple text-based progress bar

Code

def show_progress(progress, info="", length=40, symbols="[= ]", decimals=1):
    """Show the progress of a process with a simple text-based progress bar.

    Parameters
    ----------
@fladd
fladd / licensing_info.py
Last active November 10, 2020 22:43
Get licencing information of packages and their dependencies from pip
from email import message_from_string
from pkg_resources import get_distribution
def get_pkg_info(package, extras=False):
"""Get information about an installed package.
This function will also attempt to get the licence text from a bundled
licence file, if available.
Parameters
@fladd
fladd / spm_vs_fsl.md
Last active September 23, 2020 13:06
Differences in GLM modelling approaches between SPM and FSL

Script demonstrating differences in GLM modelling approaches between SPM and FSL:

import numpy as np
from nipy.modalities.fmri.glm import GeneralLinearModel


# Simulated data (20 'rest' volumes followed by 20 'task' volumes)
Y = np.hstack((np.random.normal(4200, 50, size=20),
               np.random.normal(4300, 50, size=20)))