Skip to content

Instantly share code, notes, and snippets.

View gpiantoni's full-sized avatar

Gio Piantoni gpiantoni

View GitHub Profile
@gpiantoni
gpiantoni / count_aal_voxels_in_vasc_territories.py
Created July 24, 2018 07:52
Compare AAL atlas to Cortical Vascular Territories Atlas
from nibabel import load
from subprocess import check_output
from numpy import unique
AAL_ATLAS = '/usr/share/mricron/templates/aal.nii.gz'
VASC_TERR_ATLAS = 'CortVascTerritoriesTatu.nii'
vasc_terr_atlas_aal = 'CortVascTerritoriesTatu_aal.nii.gz'
OUTPUT_CSV = 'n_voxels_in_vascterr.csv'
out = check_output([
@gpiantoni
gpiantoni / sleepscoring_wonambi
Last active November 16, 2018 09:13
convert sleep scoring from matlab format to wonambi xml format
#!/usr/bin/env python3
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from datetime import timedelta, datetime
from json import dump
from logging import getLogger, StreamHandler, Formatter, DEBUG
from pathlib import Path
from sys import version
from numpy import ndarray, savetxt
% parameters
F = 160;
A = 1;
n_trl = 100;
fs = 1000;
T = [-1, 1];
labels = {'chan0'
'chan1'
'chan2'
'chan3'
@gpiantoni
gpiantoni / read_phypno.m
Last active April 4, 2016 15:56
read phypno data (.phy/.dat)
function data = read_phypno(phy_file, begtime, endtime)
%READ_PHYPNO read phypno .phy/.dat files
%
% phy_file : path to .phy file
% begtime : start of time of interest in s
% endtime : end of time of interest in s
%
% data : data in fieldtrip format, trials are memory-mapped
%
% It needs jsonlab to read the header file, so download and add to your
@gpiantoni
gpiantoni / vispy_custom_visual.py
Created September 3, 2015 16:03
3D mesh rendering in vispy
from numpy import float32, load
from vispy.geometry import MeshData
from vispy.gloo import VertexBuffer
from vispy.io.image import write_png
from vispy.plot import Fig
from vispy.scene.visuals import create_visual_node
from vispy.visuals import Visual
# download https://dl.dropboxusercontent.com/u/66601/fsaverage.npz
surf = load('fsaverage.npz')