Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Krause fladd

View GitHub Profile
@fladd
fladd / changing_image_luminance.md
Last active Feb 2, 2022
Change the luminance of an image
View changing_image_luminance.md

Changing the luminance of an image

The following Python script allows to change the (overall) luminance of an image. This can be interesting when trying to match the luminance of several images (to their mean luminance for instance).

def change_image_luminance(image, luminance, precision=4):
    """Change the luminance of an image.

    Parameters
    ----------
View tkinter_treeview_tooltip.py
class TreeviewTooltip:
def __init__(self, treeview, texts=[]):
self._treeview = treeview
self._texts = texts
self._tooltip_window = None
self._tooltip_x = self.tooltip_y = 0
self._last_idd = self._last_col = None
self._waittime = 500
self._id = None
View ExpyrimentForumComment_21444.md

Sorry I misunderstood before.

What you want to achieve is possible in two ways.

  1. Within Expyriment, by manually defining how to process control keys (e.g. ESC) in all wait functions you use:
def custom_process_control_keys():
    expyriment.io.Keyboard.process_control_keys(quit_confirmed_function=convert_variables)
@fladd
fladd / fladd_CM2.xrnc
Created Oct 8, 2020
fladd's Renoise theme (a variation on hlv_autumn_cm)
View fladd_CM2.xrnc
<?xml version="1.0" encoding="UTF-8"?>
<SkinColors doc_version="12">
<Main_Back>0,0,0</Main_Back>
<Main_Font>228,228,228</Main_Font>
<Alternate_Main_Back>121,156,199</Alternate_Main_Back>
<Alternate_Main_Font>217,217,217</Alternate_Main_Font>
<Body_Back>87,87,87</Body_Back>
<Body_Font>191,191,191</Body_Font>
<Strong_Body_Font>255,255,255</Strong_Body_Font>
<Button_Back>40,40,40</Button_Back>
@fladd
fladd / SPM_vs_FSL.ipynb
Last active Sep 24, 2020
Comparing GLM modelling approaches of SPM and FSL
View SPM_vs_FSL.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fladd
fladd / spm_vs_fsl.md
Last active Sep 23, 2020
Differences in GLM modelling approaches between SPM and FSL
View spm_vs_fsl.md

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)))
@fladd
fladd / licensing_info.py
Last active Nov 10, 2020
Get licencing information of packages and their dependencies from pip
View licensing_info.py
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 / show_progress.md
Last active Oct 19, 2021
Show the progress of a process with a simple text-based progress bar
View show_progress.md

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 / zoom_security.md
Last active Apr 3, 2020
Detailed step-by-step tutorial on how to fix Zoom security issues
View zoom_security.md

Steps to fix Zoom security issues:

  1. Don't use Zoom
@fladd
fladd / style.py
Created Mar 15, 2020
Python style guide
View style.py
#!/usr/bin/env python
"""Summary of module.
Description of module.
Can contain multiple lines.
"""
__author__ = 'Name Surname <Email address>'