Skip to content

Instantly share code, notes, and snippets.

View jstutters's full-sized avatar

Jon Stutters jstutters

View GitHub Profile
@jstutters
jstutters / vimrc
Last active March 23, 2022 12:14
Global vimrc for RHEL-like distros
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim
endif
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
@jstutters
jstutters / bpf.py
Last active January 27, 2020 11:19
Calculate brain parenchymal fraction from a GIFv2 segmentation
#!/usr/bin/env python3.7
"""Calculate brain parenchymal fraction from a GIFv2 segmentation.
Intracranial volume (ICV) is grey-matter + CSF + white-matter.
Brain parenchymal fraction is (grey-matter + white-matter) / ICV.
"""
import os
import subprocess
@jstutters
jstutters / MemoryError.log
Created September 30, 2019 13:20
nicMSlesions MemoryError
WM lesion segmentation #
# #
# ------------------------------- #
# (c) Sergi Valverde 2019 #
# Neuroimage Computing Group #
# ------------------------------- #
##################################################
DEBUG: 1
Using TensorFlow backend.
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.FileInputStream;
public class Main {
from collections import defaultdict
import os.path
import nibabel
import numpy as np
from pirec.artefacts import NiiGzImage
from skimage.measure import label as sklabel
def make_lesional_masks(masks):
"""Separate lesions to individual masks with 4D connectivity."""
@jstutters
jstutters / .gitignore
Created January 10, 2017 11:51
Python .gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
@jstutters
jstutters / Makefile
Last active October 3, 2021 07:53
Makefile for testing and linting python projects
PROJECT:= name
.PHONY: check test codestyle docstyle lint pip
check: test codestyle docstyle lint
test:
py.test --cov=$(PROJECT) tests
codestyle:
@jstutters
jstutters / setup.py
Last active January 24, 2017 12:53
Skeleton setup.py
import codecs
import os.path
from setuptools import find_packages, setup
NAME = ''
with codecs.open(os.path.join(NAME, 'VERSION'), encoding='utf-8') as f:
version = f.read().strip()
with codecs.open('README.rst', encoding='utf-8') as f:
long_description = f.read()
@jstutters
jstutters / zfs_cleanup.sh
Last active March 23, 2024 13:05
Find and delete multiple ZFS snapshots
zfs list -t snapshot -H -o name | grep "201509[0-9].*" | xargs -n1 echo
# zfs list -t snapshot -H -o name | grep "201509[0-9].*" | xargs -n1 zfs destroy