Skip to content

Instantly share code, notes, and snippets.

@satra
Last active August 29, 2015 14:14
Show Gist options
  • Save satra/3b65ac3d5ad534329858 to your computer and use it in GitHub Desktop.
Save satra/3b65ac3d5ad534329858 to your computer and use it in GitHub Desktop.
QQA: compute the volume of contrasts and sort them by size
from glob import glob
import os
import numpy as np
fl = glob('model01/task001/SAD_???/copes/mni/model001/task001_cope01.nii.gz')
os.system('fslmerge -t output.nii.gz %s' % ' '.join(fl))
os.system('fslmaths output.nii.gz -abs -thr 1 -bin output2')
os.system('fslstats -t output2 -V > output2.txt')
foo = np.genfromtxt('output2.txt')
idx = np.argsort(foo[:, 1])
zip(np.array(fl)[idx], foo[idx, 1])
# from working directory
ls openfmri/registration/_model_id_1_subject_id_SAD_???_task_id_1/bbregister/_report/report.rst | xargs -I fname bash -c "grep \"Min cost\" fname | tail -n 1"
# from working directory
ls openfmri/_model_id_1_subject_id_SAD_???_task_id_1/art/mapflow/_art0/art.bold_dtype_mcf_outliers.txt | sort | xargs wc | sort -n | cut -c 1-4,76-82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment