Skip to content

Instantly share code, notes, and snippets.

@magsol
magsol / opencv-cuda.py
Last active May 24, 2017 00:24
Simple script to edit the OpenCV conda-forge feedstock's build script to enable CUDA support.
#!/opt/python/bin/python
# Installs a GPU-enabled OpenCV from the conda-forge feedstock.
# Assumes you already have Python 3 installed and the conda-forge channel on.
import argparse
import os.path
import subprocess
import sys
# These are the options we want to make sure are set to the values listed here.
# This function was written as part of the analysis pipeline in
# Lu et al 2018, IEEE ISBI: https://arxiv.org/abs/1803.07534
#
# The purpose of this function was to convert the predicted mask
# of cilia into an empirical probability density function that we
# would then sample "seeds" from to extract patches of ciliary motion
# (with high probability; hence, the empirical PDF) to feed to the
# downstream Conv-LSTM for classification. The reason we didn't
# just uniformly sample from the masked areas of cilia was to try
# and minimize uncertainty in the mask edges (hence, the distance
@magsol
magsol / gist:f2961e0c8bfeee56339973773c8b6d8a
Last active August 5, 2020 16:37
ffmpeg video format conversion
# converts vidfile.avi to vidfile.mov
# re-encodes video using h264 codec
# This is good for, e.g., creating a video to post to instagram.
ffmpeg -i vidfile.avi -c:v h264 vidfile.mov
# This is good for, e.g., creating a video to embed in PPTX.
ffmpeg -i vidfile.avi -pix_fmt yuv420p vidfile.mov
# see the list of available codecs
@magsol
magsol / gist:eba6c40b33eb6cd31be8627cdc18d6b4
Last active September 1, 2020 19:43
Initial setup and configuration of the Kubernetes cluster
@magsol
magsol / running_mileage.py
Created October 4, 2023 14:43
Monthly running mileage plot
# coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
# Dates (by month: October 2019 through September 2023)
dates = ['Oct19', 'Nov19', 'Dec19', 'Jan20', 'Feb20', 'Mar20', 'Apr20', 'May20', 'Jun20', 'Jul20', 'Aug20', 'Sep20', 'Oct20', 'Nov20', 'Dec20', 'Jan21', 'Feb21', 'Mar21', 'Apr21', 'May21', 'Jun21', 'Jul21', 'Aug21', 'Sep21', 'Oct21', 'Nov21', 'Dec21', 'Jan22', 'Feb22', 'Mar22', 'Apr22', 'May22', 'Jun22', 'Jul22', 'Aug22', 'Sep22', 'Oct22', 'Nov22', 'Dec22', 'Jan23', 'Feb23', 'Mar23', 'Apr23', 'May23', 'Jun23', 'Jul23', 'Aug23', 'Sep23']
# Mileages (per month)
mileages = [153.49, 100.30, 101.19, 80.82, 139.45, 125.23, 101.14, 97.93, 82.42, 49.97, 0.0, 0.0, 23.76, 8.41, 5.68, 33.96, 14.08, 17.80, 30.97, 40.24, 16.40, 29.37, 23.41, 30.10, 35.08, 18.06, 18.79, 52.87, 33.71, 58.27, 21.67, 25.81, 14.68, 16.24, 38.55, 41.04, 50.35, 8.96, 15.77, 14.19, 48.73, 64.55, 73.92, 63.36, 60.10, 62.67, 85.22, 101.28]