Skip to content

Instantly share code, notes, and snippets.


Victor Saase vsaase

View GitHub Profile
View crash-20151003-165858-brain-b0_avg.pklz
File: crash-20151003-165858-brain-b0_avg.pklz
Node: hmc_sdc_ecc.eddy_correct.b0_avg
Working directory: /tmp/tmpyq3yMf/hmc_sdc_ecc/eddy_correct/b0_avg
Node inputs:
function_str = S'def b0_average(in_dwi, in_bval, max_b=10.0, out_file=None):\n """\n A function that averages the *b0* volumes from a DWI dataset.\n As current dMRI data are being acquired with all b-values > 0.0,\n the *lowb* volumes are selected by specifying the parameter max_b.\n\n .. warning:: *b0* should be already registered (head motion artifact should\n be corrected).\n\n """\n import numpy as np\n import nibabel as nb\n import os.path as op\n\n if out_file is None:\n fname, ext = op.splitext(op.basename(in_dwi))\n if ext == ".gz":\n fname, ext2 = op.splitext(fname)\n ext = ext2 + ext\n out_file = op.abspath("%s_avg_b0%s" % (fname, ext))\n\n imgs = np.array(nb.four_to_three(nb.load(in_dwi)))\n index = b0_indices(in_bval, max_b=max_b)\n b0s = [im.get_da