Skip to content

Instantly share code, notes, and snippets.

View wronk's full-sized avatar

Mark Wronkiewicz wronk

  • Southern California
View GitHub Profile
#Generate an inverse solution via python
import mne
import os
fwdName = "fwd.fif"
rawName = "raw.fif"
covName = "noiseCov.fif"
fSaveInv = os.path.join(os.getcwd(), "invPython.fif")
@wronk
wronk / postUpdate_TODO_missingEEGReference.html
Created September 10, 2013 22:46
Difference in fif read/write output before and after PR #753
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0021)file:///tmp/tmpnc7vEt -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<style type="text/css">
table.diff {font-family:Courier; border:medium;}
.diff_header {background-color:#e0e0e0}
td.diff_header {text-align:right}
.diff_next {background-color:#c0c0c0}
@wronk
wronk / plyfun.py
Created October 28, 2015 22:00
Sample python code to convert a surface into .ply file for use in Blender or other 3D CAD programs.
"""
plyfun
@author:wronk
Write surface to a .ply (Stanford 3D mesh file) in a way that preserves
vertex order in the MNE sense. Extendable for colors or other vertex/face properties.
.ply format: https://en.wikipedia.org/wiki/PLY_(file_format)
"""
@wronk
wronk / epochsToNpy.py
Created October 28, 2015 22:09
Convert epochs to stc and save as array for use in Blender.
"""
epochsToStc
@author:wronk
Convert epochs to stc and save as array for use in Blender.
"""
import mne
import numpy as np
@wronk
wronk / vertexColors_v1.py
Created October 28, 2015 22:11
vertexColors_v1.py
"""
vertexColors_v1.py
@author: wronk
Script meant to be run within blender to load source estimate data and create a series of images
(one for each time point) that can be converted into a movie. This requires that the brain surface
first be loaded into blender.
"""
# Blender specific libraries:
@wronk
wronk / Tutorial_EC2_with_Python.ipynb
Last active July 17, 2017 19:26
A basic tutorial on getting an Amazon EC2 instance running with Python for cloud computing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wronk
wronk / python_environment_setup.md
Last active November 27, 2023 16:18
Setting up your python development environment (with pyenv, virtualenv, and virtualenvwrapper)

Overview of Python Virtual Environments

This guide is targetted at intermediate or expert users who want low-level control over their Python environments.

When you're working on multiple coding projects, you might want a couple different version of Python and/or modules installed. This helps keep each workflow in its own sandbox instead of trying to juggle multiple projects (each with different dependencies) on your system's version of Python. The guide here covers one way to handle multiple Python versions and Python environments on your own (i.e., without a package manager like conda). See the Using the workflow section to view the end result.


h/t @sharkinsspatial for linking me to the perfect cartoon

@wronk
wronk / TF_servingPost_serving_receiver_fn.py
Created February 13, 2019 19:27
TF Serving blog post: serving receiver function
import os
import os.path as op
import tensorflow as tf
HEIGHT, WIDTH, CHANNELS = 256, 256, 3
def serving_input_receiver_fn():
"""Convert string encoded images (like base64 strings) into preprocessed tensors"""
@wronk
wronk / TF_servingPost_export_estimator.py
Created February 13, 2019 19:33
TF Serving blog post: creating and saving TF estimator object
# Define a place to save your compiled model
export_dir = '/path/to/my_exported_models/001'
# Define a path to your trained keras model and load it in as a `tf.keras.models.Model`
# If you just trained your model, you may already have it in memory and can skip the below 2 lines
model_save_fpath = '/path/to/my_model.h5'
keras_model = tf.keras.models.load_model(model_save_fpath)
# Create an Estimator object
estimator_save_dir = '/path/to/save/estimator'
@wronk
wronk / TF_servingPost_docker_image.sh
Created February 13, 2019 19:36
TF Serving blog post: Docker image
######################################
# Pseudocode for creating Docker image
# Get the Docker TF Serving image we'll use as a foundation to build our custom image
docker pull tensorflow/serving
# Start up this TF Docker image as a container named `serving_base`
docker run -d --name serving_base tensorflow/serving
# Copy the Estimator from our local folder to the Docker container