Skip to content

Instantly share code, notes, and snippets.

@JohnGriffiths
Last active December 29, 2015 08:19
Show Gist options
  • Save JohnGriffiths/7642891 to your computer and use it in GitHub Desktop.
Save JohnGriffiths/7642891 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"gist_id": "7642891",
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Mrtrix y inversion test - CSLB system"
]
},
{
"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",
"test_subs = ['CBU100017', 'CBU100023', 'CBU10024']\n",
"\n",
"#dwi_dir = '/work/imaging5/DTI/CBU_DTI/raw_data/DTI_sequence_64D_2A'\n",
"out_dir = '/work/imaging5/DTI/CBU_DTI/mrtrix_invert_y_test'\n",
"dwi_dir = out_dir\n",
"\n",
"system('mkdir ' + out_dir)\n",
"\n",
"chdir(out_dir)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Workflow"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"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') \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'])\n",
" \n",
" wfs[t].inputs.bet.output_type = 'NIFTI'\n",
" wfs[t].inputs.CSDstreamtrack.desired_number_of_tracks = 1 \n",
" \n",
" wfs[t].run()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment