Skip to content

Instantly share code, notes, and snippets.

# Export your favorite Matplotlib colormap to Imaris look-up table (.pal file)
# Authors: ChatGPT and Nikita Vladimirov
# License: GPL3
import matplotlib.cm as cm
cmap = cm.get_cmap('plasma')
output_file = './plasma_palette_8bit.pal'
with open(output_file, 'w') as f:
# Write the RGB values of each color in the colormap as text strings
for i in range(256):
rgba = cmap(i)
@nvladimus
nvladimus / mooc_finance4non-fin-professionals.ipynb
Created July 8, 2020 21:29
MOOC: Finance for non-finance professionals
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvladimus
nvladimus / getFWHM_2D.py
Last active August 20, 2023 20:43
Computing FWHM of PSF using 2D Gaussian fit
# Compute FWHM(x,y) using 2D Gaussian fit, min-square optimization
# Optimization fits 2D gaussian: center, sigmas, baseline and amplitude
# works best if there is only one blob and it is close to the image center.
# author: Nikita Vladimirov @nvladimus (2018).
# based on code example: https://stackoverflow.com/questions/21566379/fitting-a-2d-gaussian-function-using-scipy-optimize-curve-fit-valueerror-and-m
import numpy as np
import scipy.optimize as opt
def twoD_GaussianScaledAmp((x, y), xo, yo, sigma_x, sigma_y, amplitude, offset):
@nvladimus
nvladimus / python_camera_micromanager.py
Created April 27, 2018 16:16
Python camera control using MicroManager device drivers
# This python code uses MicroManager device drivers to control a camera.
# Tested on Hamamatsu Orca Flash 4 camera, should work similarly on other cameras.
# Original idea: Kay Schink @koschink
# Gist implementation: Nikita Vladimirov @nvladimus
#Environment setup instructions: https://micro-manager.org/wiki/Using_the_Micro-Manager_python_library
import sys
sys.path.append("C:\\Program Files\\Micro-Manager-1.4")
import MMCorePy #load MicroManager for device control
import matplotlib.pyplot as plt
@nvladimus
nvladimus / MicroscopySphAberration.ipynb
Created March 25, 2018 16:44
Ray tracing of spherical aberration due to refractive index mismatch at the coverslip
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvladimus
nvladimus / DAQmxPulseGeneration.py
Created March 22, 2018 19:56
Digital pulse generation with PyDAQmx in Python
# Simple digital pulse generation with PyDAQmx library and NI DAQmx board
# Requires NI DAQmx drivers, Python 2.7 installed, Windows.
# Tested on NI PCIe-6321 board
# Gist author: Nikita Vladimirov @nvladimus
import PyDAQmx as pd
ctr_ini_delay = 0 # sec
ctr_period = 0.1 # sec
ctr_duty_cycle = 0.01
task = pd.Task()
task.CreateCOPulseChanFreq("Dev1/ctr0", "CamTrigger", pd.DAQmx_Val_Hz, pd.DAQmx_Val_Low, ctr_ini_delay, 1/float(ctr_period), ctr_duty_cycle)