Skip to content

Instantly share code, notes, and snippets.

View mgxd's full-sized avatar

Mathias Goncalves mgxd

  • Stanford University
  • Boston, MA
View GitHub Profile
@mgxd
mgxd / list.md
Last active May 18, 2021 17:53
NMinD coding standards checklist

Documentation

  • Brief description of what program does is listed.
  • An example of its usage is shown.
  • Description of required input parameters.
  • Description of output parameters.
  • Extensive documentation of available parameters

Infrastructure

import os
import nibabel as nb
import numpy as np
from nipype.interfaces.base import isdefined
from nipype.interfaces import fsl, ants, afni
import nipype.pipeline.engine as pe
from niworkflows.interfaces.registration import (
EstimateReferenceImage,

FMRIPrep Long Term Support (LTS)

===================================

Versioning

fMRIPrep has adopted cal-sem versioning. This can be broken down by the following example, X.Y.Z.e, where:

X = major version, signals year of the release. A release from 2020 will start with a 20. major version. Y = minor version, signals API breaking and/or output altering changes. Upgrading minor version will not be backwards compatible. Z = patch version, AKA bug fix releases. Patch versions will be backwards compatible with all minor version releases.

@mgxd
mgxd / hook1.py
Last active September 3, 2019 20:52
Pydra Hooks
from pydra import mark, Workflow
@mark.task
def add1(x):
return x + 1
# start workflow
wf = Workflow(name='wf', input_spec=['x'])
wf.inputs.x = 2
@mgxd
mgxd / asyncio_pydra.py
Last active May 21, 2019 19:38
asyncio_pydra.py
import asyncio
import concurrent.futures as cf
# from multiprocessing.context import ForkServerContext
import time
import functools
# used to bypass Event Loop error in Jupyter Notebooks
import nest_asyncio
nest_asyncio.apply()
#!/usr/bin/env python
import pandas as pd
import numpy as np
from argparse import ArgumentParser
import sys
import os
def parse_outliers(outliers, volumes):
if not outliers:
import os
def create_key(template, outtype=('nii.gz'), annotation_classes=None):
if template is None or not template:
raise ValueError('Template must be a valid format string')
return (template, outtype, annotation_classes)
def infotodict(seqinfo):
"""Heuristic evaluator for determining which runs belong where
@mgxd
mgxd / submit_mindboggle.sh
Created February 11, 2018 17:50
submitting mindboggle per subject
submit_mindboggle.sh
-------------------------------------------------------------------
#!/bin/bash
base={{FULL PATH TO DATA}}
# first go to data directory, grab all subjects,
# and assign to an array
pushd $base
subjs=($(ls sub-* -d -1)) # this is set up for BIDS, but you can alter the search pattern
# A little helper to show /om usage information for user + group,
# as well as some SLURM usage
# For easiest use - add function to .bashrc that sources this with a simple input
import subprocess
from getpass import getuser
from collections import Counter
import re