Last active
December 29, 2015 08:19
-
-
Save JohnGriffiths/7642891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"gist_id": "7642891", | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "heading", | |
"level": 1, | |
"metadata": {}, | |
"source": [ | |
"Mrtrix y inversion test" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"FSL2mrtrix has an option to invert the bvecs in the y direction when converting from FSL format bvals + bvecs. This isn't part of the mrtrix documentation, which is concerned with processing directly from dicoms. Whether or not to use it appears to be a scanner specific thing. \n", | |
"\n", | |
"Here we run two mrtrix workflows and compare the outputs after inverting and not inverting the y vector.\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "heading", | |
"level": 2, | |
"metadata": {}, | |
"source": [ | |
"Setup" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"from nipype.workflows.dmri.mrtrix import create_mrtrix_dti_pipeline as cmdp\n", | |
"from os import mkdir, chdir, system\n", | |
"\n", | |
"\n", | |
"test_subs = ['CBU100017', 'CBU100023', 'CBU10024']\n", | |
"\n", | |
"dwi_dir = '/media/sf_WINDOWS_C_DRIVE/Users/John/CloudStorage/Dropbox/dwi_dat_temp/raw_dat/cslb/dwi'\n", | |
"out_dir = '/home/adminuser/mrtrix_y_inversion_test'\n", | |
"system('mkdir ' + out_dir)\n", | |
"\n", | |
"chdir(out_dir)\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "OSError", | |
"evalue": "[Errno 2] No such file or directory: '/home/adminuser/mrtrix_y_inversion_test'", | |
"output_type": "pyerr", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mOSError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-1-0905d9dedf18>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[0msystem\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'mkdir '\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mout_dir\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 11\u001b[1;33m \u001b[0mchdir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mout_dir\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[1;31mOSError\u001b[0m: [Errno 2] No such file or directory: '/home/adminuser/mrtrix_y_inversion_test'" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"matplotlib not available. Can not plot matrix\n" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stderr", | |
"text": [ | |
"/usr/local/lib/python2.7/site-packages/nipype-0.8.0-py2.7.egg/nipype/interfaces/cmtk/nbs.py:20: UserWarning: ConnectomeViewer not installed\n", | |
" warnings.warn('ConnectomeViewer not installed')\n", | |
"/usr/local/lib/python2.7/site-packages/nipype-0.8.0-py2.7.egg/nipype/interfaces/mrtrix/convert.py:28: UserWarning: dipy not installed\n", | |
" warnings.warn('dipy not installed')\n", | |
"/usr/local/lib/python2.7/site-packages/nipype-0.8.0-py2.7.egg/nipype/interfaces/dipy/tracks.py:17: UserWarning: dipy not installed\n", | |
" warnings.warn('dipy not installed')\n", | |
"/usr/local/lib/python2.7/site-packages/nipype-0.8.0-py2.7.egg/nipype/interfaces/dipy/tensors.py:26: UserWarning: dipy not installed\n", | |
" warnings.warn('dipy not installed')\n" | |
] | |
} | |
], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "heading", | |
"level": 2, | |
"metadata": {}, | |
"source": [ | |
"Workflow" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"\n", | |
"wfs = {} # workflows\n", | |
"for t in test_subs[0:1]:\n", | |
" \n", | |
" wfs[t] = cmdp('mrtrix_dti_%s' %t)\n", | |
" \n", | |
" wfs[t].inputs.inputnode.dwi = join(dwi_dir,t,'data.nii.gz') \n", | |
" wfs[t].inputs.inputnode.bvals = join(dwi_dir, t, 'bvals') \n", | |
" wfs[t].inputs.inputnode.bvecs = join(dwi_dir, t, 'bvecs')\n", | |
"\n", | |
" #wfs[t].iterables = [ ('fsl2mrtrix.invert_x', ['True', 'False'] ),\n", | |
" # ('fsl2mrtrix.invert_y', ['True', 'False'] ), \n", | |
" # ('fsl2mrtrix.invert_z', ['True', 'False'] ) ] \n", | |
" wfs[t].iterables = ('fsl2mrtrix.invert_y', ['True', 'False'])" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"wfs[t].run()" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment