Skip to content

Instantly share code, notes, and snippets.

View oesteban's full-sized avatar
🦄

Oscar Esteban oesteban

🦄
View GitHub Profile
@oesteban
oesteban / check_node_duration.py
Created April 17, 2020 23:49
Check all nodes of a nipype 1.0 workflow and extract node name and duration
"""Check node duration in a Nipype workflow."""
from pathlib import path
import numpy as np
import pandas as pd
data = {'node': [], 'duration': []}
for pth in Path().glob("**/report.rst"):
rst = pth.read_text()
info = [l.split(":")[-1].strip() for l in rst.splitlines() if "duration" in l or "Hierarchy" in l]
data['node'].append(info[0])

Problem

A lot of GitHub projects need to have pretty math formulas in READMEs, wikis or other markdown pages. The desired approach would be to just write inline LaTeX-style formulas like this:

$e^{i \pi} = -1$

Unfortunately, GitHub does not support inline formulas. The issue is tracked here.

Investigation

@oesteban
oesteban / sample_openfmri.py
Created March 23, 2020 02:47
Sample OpenfMRI (scraps from *fMRIPrep*)
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
A tool to sample OpenfMRI datasets using a datalad installation
Please run this first: ::
# install openfmri dataset
datalad install -r ///openfmri
@oesteban
oesteban / FD test.ipynb
Last active January 30, 2020 20:47
Testing framewise displacement
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oesteban
oesteban / Makefile
Created December 26, 2019 08:21 — forked from jakevdp/Makefile
Test of specializing sphinx autodoc
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
@oesteban
oesteban / mriqc_webapi_ratings.py
Created July 23, 2019 16:37
Pull the ratings associated to a given MD5 checksum.
from os import getenv
from pathlib import Path
from json import load
import urllib.request, json
import pandas as pd
def get_rating(checksum):
"""
Grab the latest rating found for a given MD5 checksum.
@oesteban
oesteban / BOLD-to-T2w_individual.sh
Last active October 5, 2018 17:27
Work on rodents
antsRegistration -d 3 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,1.0,32,Random,0.2] -t Affine[0.01] -c [100x100x100,1.0e-8,25] -s 0.6x0.4x0.2mm -f 2x1x1 -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -u -v -o ts2_epi0 -a 1
antsRegistration -d 3 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,32,Random,0.2] -m CC[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,5,Random,0.2] -t SyN[1,2.0,1.75] -c [200x50,1.0e-8,5] -s 0.4x0mm -f 2x1 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,32,Random,0.2] -m CC[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,5,Random,0.2] -t SyN[1,1.0,0.75] -c [200x50,1.0e-8,5] -s 0.6x0.2mm -f 2x1 -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -u -v -o ts2_epiA -a 1 -r ts2_epi0Composite.h5 &> ts2.log
antsApplyTransforms -d 3 -i ~/Data/LC_dfMRI/tpl-Schwarz/tpl-Schwarz_rois.nii.gz -r time2_hmc_avg_inu.nii.gz -o time2_rois.
@oesteban
oesteban / bash-tricks.sh
Created August 18, 2018 03:28
Some useful snippets in bash
# Find empty folders starting with ds
for dir in ds*; do [ -z "`find $dir -maxdepth 1 -type f`" ] && echo "$dir is empty"; done
@oesteban
oesteban / fmriprep.sbatch
Last active April 6, 2024 19:52
Submitting many FMRIPREP/MRIQC tasks in Sherlock
#!/bin/bash
#
#SBATCH -J fmriprep
#SBATCH --array=1-257%7
#SBATCH --time=24:00:00
#SBATCH -n 1
#SBATCH --cpus-per-task=16
#SBATCH --mem-per-cpu=4G
#SBATCH -p russpold,owners,normal
@oesteban
oesteban / gifti_surfs.py
Last active February 21, 2018 17:55
GIFTI
import nibabel as nb
from nipype.utils.filemanip import fname_presuffix
def center_surface(in_gifti, newpath=None,
offset_from=['VolGeomC_R', 'VolGeomC_A', 'VolGeomC_S']):
gii = nb.load(in_gifti)
offset = [float(gii.darrays[0].meta.metadata[v]) for v in offset_from]
data = gii.darrays[0].data + offset
meta = gii.darrays[0].meta.metadata
for k in offset_from:
meta[k] = '%f' % 0.0