|
| 1 | +say "Import nipype building blocks" |
| 2 | +show "Import nipype building blocks" |
| 3 | +run "from nipype import Node, Workflow" |
| 4 | + |
| 5 | +say "Import relevant interfaces" |
| 6 | +show "Import relevant interfaces" |
| 7 | +run "from nipype.interfaces.fsl import SliceTimer, MCFLIRT, Smooth" |
| 8 | + |
| 9 | +say "Create SliceTime correction node" |
| 10 | +show "Create SliceTime correction node" |
| 11 | +run "slicetimer = Node(SliceTimer(index_dir=False, |
| 12 | + interleaved=True, |
| 13 | + time_repetition=2.5), |
| 14 | + name='slicetimer') |
| 15 | +" |
| 16 | + |
| 17 | +say "Create Motion correction node" |
| 18 | +show "Create Motion correction node" |
| 19 | +run "mcflirt = Node(MCFLIRT(mean_vol=True, |
| 20 | + save_plots=True), |
| 21 | + name='mcflirt') |
| 22 | +" |
| 23 | + |
| 24 | +say "Create Smoothing node" |
| 25 | +show "Create Smoothing node" |
| 26 | +run "smooth = Node(Smooth(fwhm=4), name='smooth')" |
| 27 | + |
| 28 | +say "Create Workflow" |
| 29 | +show "Create Workflow" |
| 30 | +run "preproc01 = Workflow(name='preproc01', base_dir='.')" |
| 31 | + |
| 32 | +say "Connect nodes within the workflow" |
| 33 | +show "Connect nodes within the workflow" |
| 34 | +run "preproc01.connect([(slicetimer, mcflirt, [('slice_time_corrected_file', 'in_file')]), |
| 35 | + (mcflirt, smooth, [('out_file', 'in_file')])]) |
| 36 | +" |
| 37 | + |
| 38 | +say "Create a visualization of the workflow" |
| 39 | +show "Create a visualization of the workflow" |
| 40 | +run "preproc01.write_graph(graph2use='orig')" |
| 41 | + |
| 42 | +say "Visualize the figure" |
| 43 | +show "Visualize the figure" |
| 44 | +run "!eog preproc01/graph_detailed.png |
| 45 | +" |
| 46 | + |
| 47 | +say "Feed some input to the workflow" |
| 48 | +show "Feed some input to the workflow" |
| 49 | +run "slicetimer.inputs.in_file = 'path/to/your/func.nii.gz'" |
| 50 | + |
| 51 | +say "Run the Workflow and stop the time" |
| 52 | +show "Run the Workflow and stop the time" |
| 53 | +run "%time preproc01.run('MultiProc', plugin_args={'n_procs': 5})" |
| 54 | + |
| 55 | +say "Investigate the output" |
| 56 | +show "Investigate the output" |
| 57 | +run "!tree preproc01 -I '*js|*json|*pklz|_report|*.dot|*html'" |
| 58 | + |
| 59 | +say "Change the size of the smoothing kernel" |
| 60 | +show "Change the size of the smoothing kernel" |
| 61 | +run "smooth.inputs.fwhm = 2" |
| 62 | + |
| 63 | +say "Rerun the workflow" |
| 64 | +show "Rerun the workflow" |
| 65 | +run "%time preproc01.run('MultiProc', plugin_args={'n_procs': 5})" |
| 66 | + |
| 67 | +say "Create 4 additional copies of the workflow" |
| 68 | +show "Create 4 additional copies of the workflow" |
| 69 | +run "preproc02 = preproc01.clone('preproc02') |
| 70 | +preproc03 = preproc01.clone('preproc03') |
| 71 | +preproc04 = preproc01.clone('preproc04') |
| 72 | +preproc05 = preproc01.clone('preproc05') |
| 73 | +" |
| 74 | + |
| 75 | +say "Create a new workflow - metaflow" |
| 76 | +show "Create a new workflow - metaflow" |
| 77 | +run "metaflow = Workflow(name='metaflow', base_dir='.')" |
| 78 | + |
| 79 | +say "Add the 5 workflows to this metaflow" |
| 80 | +show "Add the 5 workflows to this metaflow" |
| 81 | +run "metaflow.add_nodes([preproc01, preproc02, preproc03, |
| 82 | + preproc04, preproc05]) |
| 83 | +" |
| 84 | + |
| 85 | +say "Visualize the workflow" |
| 86 | +show "Visualize the workflow" |
| 87 | +run "metaflow.write_graph(graph2use='flat') |
| 88 | +!eog metaflow/graph_detailed.png |
| 89 | +" |
| 90 | + |
| 91 | +say "Run this metaflow in parallel" |
| 92 | +show "Run this metaflow in parallel" |
| 93 | +run "%time metaflow.run('MultiProc', plugin_args={'n_procs': 5})" |
| 94 | + |
| 95 | +say "Investigate the output" |
| 96 | +show "Investigate the output" |
| 97 | +run "!tree metaflow -I '*js|*json|*pklz|_report|*.dot|*html'" |
| 98 | + |
| 99 | +say "The End." |
| 100 | +show "The End." |
0 commit comments