Skip to content

Commit 5899dec

Browse files
nicholsnMathieu Dubois
authored andcommitted
fix: documentation indentation and highlighting
1 parent 0fab2e4 commit 5899dec

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

examples/rsfmri_vol_surface_preprocessing_nipy.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
4040
specifically the 2mm versions of:
4141
42-
- `Joint Fusion Atlas <http://mindboggle.info/data/atlases/jointfusion/OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152_2mm_v2.nii.gz>`_
43-
- `MNI template <http://mindboggle.info/data/templates/ants/OASIS-30_Atropos_template_in_MNI152_2mm.nii.gz>`_
42+
* `Joint Fusion Atlas <http://mindboggle.info/data/atlases/jointfusion/OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152_2mm_v2.nii.gz>`_
43+
* `MNI template <http://mindboggle.info/data/templates/ants/OASIS-30_Atropos_template_in_MNI152_2mm.nii.gz>`_
4444
45+
Import necessary modules from nipype.
4546
"""
4647

4748
import os
@@ -70,6 +71,10 @@
7071
import scipy as sp
7172
import nibabel as nb
7273

74+
"""
75+
A list of modules and functions to import inside of nodes
76+
"""
77+
7378
imports = ['import os',
7479
'import nibabel as nb',
7580
'import numpy as np',
@@ -78,6 +83,10 @@
7883
'from scipy.special import legendre'
7984
]
8085

86+
"""
87+
Define utility functions for use in workflow nodes
88+
"""
89+
8190

8291
def get_info(dicom_files):
8392
"""Given a Siemens dicom file return metadata
@@ -340,28 +349,35 @@ def combine_hemi(left, right):
340349
fmt=','.join(['%d'] + ['%.10f'] * (all_data.shape[1] - 1)))
341350
return os.path.abspath(filename)
342351

352+
"""
353+
Create a Registration Workflow
354+
"""
355+
343356

344357
def create_reg_workflow(name='registration'):
345358
"""Create a FEAT preprocessing workflow together with freesurfer
346359
347360
Parameters
348361
----------
349-
350362
name : name of workflow (default: 'registration')
351363
352-
Inputs::
364+
Inputs:
353365
354366
inputspec.source_files : files (filename or list of filenames to register)
355367
inputspec.mean_image : reference image to use
356368
inputspec.anatomical_image : anatomical image to coregister to
357369
inputspec.target_image : registration target
358370
359-
Outputs::
371+
Outputs:
360372
361373
outputspec.func2anat_transform : FLIRT transform
362374
outputspec.anat2target_transform : FLIRT+FNIRT transform
363375
outputspec.transformed_files : transformed files in target space
364376
outputspec.transformed_mean : mean image in target space
377+
378+
Example
379+
-------
380+
See code below
365381
"""
366382

367383
register = Workflow(name=name)
@@ -463,16 +479,17 @@ def create_reg_workflow(name='registration'):
463479
convert2itk.inputs.fsl2ras = True
464480
convert2itk.inputs.itk_transform = True
465481
register.connect(bbregister, 'out_fsl_file', convert2itk, 'transform_file')
466-
register.connect(inputnode, 'mean_image',convert2itk, 'source_file')
482+
register.connect(inputnode, 'mean_image', convert2itk, 'source_file')
467483
register.connect(stripper, 'out_file', convert2itk, 'reference_file')
468484

469485
"""
470486
Compute registration between the subject's structural and MNI template
471-
This is currently set to perform a very quick registration. However, the
472-
registration can be made significantly more accurate for cortical
473-
structures by increasing the number of iterations
474-
All parameters are set using the example from:
475-
#https://github.com/stnava/ANTs/blob/master/Scripts/newAntsExample.sh
487+
488+
* All parameters are set using the example from: \
489+
`newAntsExample.sh <https://github.com/stnava/ANTs/blob/master/Scripts/newAntsExample.sh>`_
490+
* This is currently set to perform a very quick registration. However,\
491+
the registration can be made significantly more accurate for cortical\
492+
structures by increasing the number of iterations.
476493
"""
477494

478495
reg = Node(ants.Registration(), name='antsRegister')
@@ -505,7 +522,6 @@ def create_reg_workflow(name='registration'):
505522
register.connect(stripper, 'out_file', reg, 'moving_image')
506523
register.connect(inputnode,'target_image', reg,'fixed_image')
507524

508-
509525
"""
510526
Concatenate the affine and ants transforms into a list
511527
"""
@@ -514,7 +530,6 @@ def create_reg_workflow(name='registration'):
514530
register.connect(convert2itk, 'itk_transform', merge, 'in2')
515531
register.connect(reg, 'composite_transform', merge, 'in1')
516532

517-
518533
"""
519534
Transform the mean image. First to anatomical and then to target
520535
"""
@@ -532,7 +547,6 @@ def create_reg_workflow(name='registration'):
532547
register.connect(inputnode, 'mean_image', warpmean, 'input_image')
533548
register.connect(merge, 'out', warpmean, 'transforms')
534549

535-
536550
"""
537551
Assign all the output files
538552
"""
@@ -555,7 +569,6 @@ def create_reg_workflow(name='registration'):
555569

556570
return register
557571

558-
559572
"""
560573
Creates the main preprocessing workflow
561574
"""
@@ -637,7 +650,6 @@ def create_workflow(files,
637650
art.inputs.mask_type = 'spm_global'
638651
art.inputs.parameter_source = 'NiPy'
639652

640-
641653
"""Here we are connecting all the nodes together. Notice that we add the merge node only if you choose
642654
to use 4D. Also `get_vox_dims` function is passed along the input volume of normalise to set the optimal
643655
voxel sizes.

0 commit comments

Comments
 (0)