Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import Dense, Activation, Input
from tensorflow.keras import Model
from tensorflow.keras.optimizers import SGD
# Implement activation function
def dCaAP_activation(x):
@CYHSM
CYHSM / euclidean_distance_nn.py
Last active November 21, 2022 07:50
Build a neural network to predict euclidean distance to goal object from XY location
# Standard imports
import numpy as np
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Keras
from keras.layers import Dense
from keras.models import Model, Input
@CYHSM
CYHSM / transform_to_template.py
Last active August 21, 2019 12:35
Register functional MRI images (fMRI) to template
def transform_to_template(fn_func, fn_template, save=False):
"""
Reads (4D)-functional images and transforms directly to template image
Inputs:
- fn_func : Path to functional images
- fn_template : Path to template brain, e.g. MNI template
- save : Whether to save transformed image to same folder as functional
Outputs:
- func_template : functional images transformed to template brain
"""
# Imports
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
plt.xkcd();
import seaborn as sns
sns.set_style('white')
# Set transparency off when exporting / Only if you want to save the figure
from matplotlib import patheffects, rcParams
rcParams['path.effects'] = [patheffects.withStroke(linewidth=0)]
"""Creates a 3D surface plot, can be used as an example for demonstrating gradient descent
Author: Markus Frey
E-mail: markus.frey1@gmail.com
"""
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt