|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +Created on Thu May 16 20:39:00 2013 |
| 4 | +
|
| 5 | +@author: bao |
| 6 | +""" |
| 7 | +import os |
| 8 | +import nipype.interfaces.utility as util |
| 9 | +import nipype.pipeline.engine as pe |
| 10 | + |
| 11 | +from nipype.interfaces import fsl |
| 12 | +from nipype.workflows.dmri.fsl.dti import create_eddy_correct_pipeline |
| 13 | + |
| 14 | +from dmri_classInterfaces import BrainExtraction, EddyCorrection, ResampleVoxelSize, TensorModel, Tracking |
| 15 | + |
| 16 | +path ='/home/bao/tiensy/Nipype_tutorial/data/dmri/temp6/' |
| 17 | +data = path+ 'raw.nii.gz' |
| 18 | + |
| 19 | +###### WORKFLOW DEFINITION ####### |
| 20 | +wf=pe.Workflow(name="reconstructing_tractography") |
| 21 | +wf.base_dir= path + 'results' |
| 22 | +wf.config['execution'] = {'remove_unnecessary_outputs': 'False', |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | +###### NODE DEFINITION ####### |
| 27 | +brain_extraction_node = pe.Node(fsl.BET(), name="brain_extraction_node") |
| 28 | +eddy_current_correction_node = create_eddy_correct_pipeline("nipype_eddycorrect_wkf") |
| 29 | +resample_voxel_size_node = pe.Node(ResampleVoxelSize(), name='resample_voxel_size_node') |
| 30 | +tensor_model_node = pe.Node(TensorModel(), name='tensor_model_node') |
| 31 | +tracking_node = pe.Node(Tracking(), name='tracking_node') |
| 32 | + |
| 33 | + |
| 34 | +###### INPUT NODE DEFINITION ####### |
| 35 | +#inputs: brain_extraction_node |
| 36 | +brain_extraction_node.inputs.in_file=data |
| 37 | +brain_extraction_node.inputs.frac = 0.2 |
| 38 | +brain_extraction_node.inputs.functional = True |
| 39 | +#brain_extraction_node.inputs.robust = True |
| 40 | +brain_extraction_node.inputs.vertical_gradient = 0 |
| 41 | +brain_extraction_node.inputs.out_file = path + 'raw_bet.nii.gz' |
| 42 | + |
| 43 | + |
| 44 | +#inputs: eddy_current_correction_node |
| 45 | +#eddy_current_correction_node.inputs.inputnode.in_file = path + 'raw_bet.nii.gz' |
| 46 | +eddy_current_correction_node.inputs.inputnode.ref_num = 0 |
| 47 | + |
| 48 | +#inputs: resample_voxel_size_node |
| 49 | +resample_voxel_size_node.inputs.output_filename = path + 'data_bet_ecc_iso.nii.gz' |
| 50 | + |
| 51 | + |
| 52 | +#inputs: tensor_model_node |
| 53 | +tensor_model_node.inputs.input_filename_bvecs = path + 'raw.bvec' |
| 54 | +tensor_model_node.inputs.input_filename_bvals = path + 'raw.bval' |
| 55 | + |
| 56 | +tensor_model_node.inputs.output_filename_fa = path + 'tensor_fa.nii.gz' |
| 57 | +tensor_model_node.inputs.output_filename_evecs = path + 'tensor_evecs.nii.gz' |
| 58 | + |
| 59 | +#inputs: tracking_node |
| 60 | +tracking_node.inputs.num_seeds = 1000 |
| 61 | +tracking_node.inputs.low_thresh = 0.2 |
| 62 | +tracking_node.inputs.output_filename = path + 'dti_tracks.dpy' |
| 63 | + |
| 64 | +###### NODE CONNECTIONS ####### |
| 65 | +wf.connect(brain_extraction_node,'out_file', eddy_current_correction_node, 'inputnode.in_file') |
| 66 | +wf.connect(eddy_current_correction_node,'outputnode.eddy_corrected', resample_voxel_size_node ,'input_filename') |
| 67 | +wf.connect(resample_voxel_size_node,'resample_file',tensor_model_node ,'input_filename_data') |
| 68 | +wf.connect(tensor_model_node, 'tensor_fa_file', tracking_node,'input_filename_fa') |
| 69 | +wf.connect(tensor_model_node, 'tensor_evecs_file', tracking_node , 'input_filename_evecs') |
| 70 | + |
| 71 | + |
| 72 | +###### GRAPH and RUN ####### |
| 73 | +wf.write_graph() |
| 74 | +wf.run() |
0 commit comments