Skip to content

Instantly share code, notes, and snippets.

View effigies's full-sized avatar

Chris Markiewicz effigies

  • Stanford University
  • New Hampshire
  • 15:43 (UTC -04:00)
View GitHub Profile
@effigies
effigies / openneuro-diff.md
Last active July 22, 2022 15:51
How to view changes to an OpenNeuro dataset draft

How to view changes to an OpenNeuro dataset draft

OpenNeuro has implemented a data retention policy, stating that datasets that have been in draft state for greater than 28 days may be reverted to the latest snapshot. Unfortunately, we don't currently have an interface for viewing what changes have been made since the last snapshot, so users may not know whether they want to create a new snapshot or not.

This gist shows two ways to view the changes using the OpenNeuro CLI. We will use ds000001 as an example.

Download and diff

The easy but slow approach would be to use the CLI to download two copies of your dataset, the most recent tag and the draft, and run diff -r on the pair:

@effigies
effigies / CaretSpecFile.dtd
Created November 15, 2021 20:03
CaretSpecFile (Connectome Workbench spec file) DTD
<!--
Initially provided by John Harwell on the HCP user list [0].
Modified by Chris Markiewicz based on example wb.spec files.
[0] https://groups.google.com/a/humanconnectome.org/g/hcp-users/c/EGuwdaTVFuw/m/Pir-LpbHAQAJ
-->
<!ELEMENT CaretSpecFile (MetaData?, DataFile+)>
<!ATTLIST CaretSpecFile
Version ( 1.0 ) #REQUIRED
@effigies
effigies / compression_check.py
Created January 9, 2021 16:00
Comparing sizes of identical .nii.gz data saved as int16, float32, float64
import os
import nibabel as nb
import numpy as np
# Create an image with a "plausible" range of fMRI values
img = nb.Nifti1Image(np.random.uniform(500, 2000, (256,256,256,1)), np.eye(4))
# Verify numpy's giving us float64
assert img.get_data_dtype() == np.float64
# Quantize to 16 bits and reload
@effigies
effigies / python_packaging_2020.md
Last active January 25, 2024 13:42
Contemporary Python Packaging - 2020

Contemporary Python Packaging

This document lays out a set of Python packaging practices. I don't claim they are best practices, but they fit my needs, and might fit yours.

Validity

This document has been superseded as of January 2023.

This was written in July 2020, superseding this gist from 2019.

@effigies
effigies / model-narps_smdl.json
Last active September 9, 2020 18:58
NARPS model
{
"Name": "NARPS",
"Description": "Basic NARPS model",
"Input": {
"task": "MGT"
},
"Steps": [
{
"Level": "run",
"Transformations": [
@effigies
effigies / python_packaging_2019.md
Last active October 12, 2020 19:10
Contemporary Python Packaging - August 2019

Contemporary Python Packaging

This document lays out a set of Python packaging practices. I don't claim they are best practices, but they fit my needs, and might fit yours.

Validity

This document has been superseded as of July 2020.

This was written in July 2019. As of this writing Python 2.7 and Python 3.5 still have not

@effigies
effigies / partial_permutation_testing.md
Created July 24, 2018 14:25
Markiewicz and Bohland, 2016 permutation testing

Partially-parametric permutation testing

Cluster thresholding in multi-voxel pattern analysis (MVPA) is an open problem, as many figures of merit are possible, few (if any) of which have been sufficiently analyzed to permit a parametric solution or a guarantee of compatibility with pre-computed simulations. Stelzer, et al. 2012 represents probably the most conservative approach, constructing voxel-wise and then cluster-wise null distributions at the group level, based on permuting the training labels at the individual level.

In Mapping the cortical representation of speech sounds in a syllable repetition task, we adapted this approach to skip the voxel-wise null distribution,

@effigies
effigies / nspn.yml
Created May 30, 2018 16:57
NSPN conda environment
name: base
channels:
- conda-forge
- defaults
dependencies:
- apptools=4.4.0=py27_0
- ca-certificates=2018.4.16=0
- cairo=1.14.6=0
- conda=4.5.4=py27_0
- conda-env=2.6.0=0
@effigies
effigies / traitlet_extension.py
Last active April 27, 2017 16:32
Traitlet extension draft
import traitlets
class _Undefined(object):
obj = None
def __new__(cls):
if cls.obj is None:
cls.obj = object.__new__(cls)
return cls.obj
class _UseDefault(_Undefined):
@effigies
effigies / fmriprep.py
Created January 27, 2017 22:25
FMRIPREP Wrapper
#!/usr/bin/env python3
import sys
import os
import re
import argparse
import subprocess
import tempfile
from functools import partial
__version__ = 0.1