40
40
41
41
specifically the 2mm versions of:
42
42
43
- - `Joint Fusion Atlas <http://mindboggle.info/data/atlases/jointfusion/OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152_2mm_v2.nii.gz>`_
44
- - `MNI template <http://mindboggle.info/data/templates/ants/OASIS-30_Atropos_template_in_MNI152_2mm.nii.gz>`_
43
+ * `Joint Fusion Atlas <http://mindboggle.info/data/atlases/jointfusion/OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_MNI152_2mm_v2.nii.gz>`_
44
+ * `MNI template <http://mindboggle.info/data/templates/ants/OASIS-30_Atropos_template_in_MNI152_2mm.nii.gz>`_
45
45
46
+ Import necessary modules from nipype.
46
47
"""
47
48
48
49
import os
71
72
import scipy as sp
72
73
import nibabel as nb
73
74
75
+ """
76
+ A list of modules and functions to import inside of nodes
77
+ """
78
+
74
79
imports = ['import os' ,
75
80
'import nibabel as nb' ,
76
81
'import numpy as np' ,
79
84
'from scipy.special import legendre'
80
85
]
81
86
87
+ """
88
+ Define utility functions for use in workflow nodes
89
+ """
90
+
82
91
83
92
def get_info (dicom_files ):
84
93
"""Given a Siemens dicom file return metadata
@@ -341,25 +350,26 @@ def combine_hemi(left, right):
341
350
fmt = ',' .join (['%d' ] + ['%.10f' ] * (all_data .shape [1 ] - 1 )))
342
351
return os .path .abspath (filename )
343
352
353
+ """
354
+ Create a Registration Workflow
355
+ """
356
+
344
357
345
358
def create_reg_workflow (name = 'registration' ):
346
359
"""Create a FEAT preprocessing workflow together with freesurfer
347
360
348
361
Parameters
349
362
----------
350
-
351
- ::
352
-
353
363
name : name of workflow (default: 'registration')
354
364
355
- Inputs::
365
+ Inputs:
356
366
357
367
inputspec.source_files : files (filename or list of filenames to register)
358
368
inputspec.mean_image : reference image to use
359
369
inputspec.anatomical_image : anatomical image to coregister to
360
370
inputspec.target_image : registration target
361
371
362
- Outputs::
372
+ Outputs:
363
373
364
374
outputspec.func2anat_transform : FLIRT transform
365
375
outputspec.anat2target_transform : FLIRT+FNIRT transform
@@ -368,7 +378,7 @@ def create_reg_workflow(name='registration'):
368
378
369
379
Example
370
380
-------
371
-
381
+ See code below
372
382
"""
373
383
374
384
register = Workflow (name = name )
@@ -438,6 +448,7 @@ def create_reg_workflow(name='registration'):
438
448
"""
439
449
Apply inverse transform to take segmentations to functional space
440
450
"""
451
+
441
452
applyxfm = MapNode (freesurfer .ApplyVolTransform (inverse = True ,
442
453
interp = 'nearest' ),
443
454
iterfield = ['target_file' ],
@@ -450,6 +461,7 @@ def create_reg_workflow(name='registration'):
450
461
"""
451
462
Apply inverse transform to aparc file
452
463
"""
464
+
453
465
aparcxfm = Node (freesurfer .ApplyVolTransform (inverse = True ,
454
466
interp = 'nearest' ),
455
467
name = 'aparc_inverse_transform' )
@@ -467,16 +479,17 @@ def create_reg_workflow(name='registration'):
467
479
convert2itk .inputs .fsl2ras = True
468
480
convert2itk .inputs .itk_transform = True
469
481
register .connect (bbregister , 'out_fsl_file' , convert2itk , 'transform_file' )
470
- register .connect (inputnode , 'mean_image' ,convert2itk , 'source_file' )
482
+ register .connect (inputnode , 'mean_image' , convert2itk , 'source_file' )
471
483
register .connect (stripper , 'out_file' , convert2itk , 'reference_file' )
472
484
473
485
"""
474
486
Compute registration between the subject's structural and MNI template
475
- This is currently set to perform a very quick registration. However, the
476
- registration can be made significantly more accurate for cortical
477
- structures by increasing the number of iterations
478
- All parameters are set using the example from:
479
- #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.
480
493
"""
481
494
482
495
reg = Node (ants .Registration (), name = 'antsRegister' )
@@ -509,7 +522,6 @@ def create_reg_workflow(name='registration'):
509
522
register .connect (stripper , 'out_file' , reg , 'moving_image' )
510
523
register .connect (inputnode ,'target_image' , reg ,'fixed_image' )
511
524
512
-
513
525
"""
514
526
Concatenate the affine and ants transforms into a list
515
527
"""
@@ -520,10 +532,10 @@ def create_reg_workflow(name='registration'):
520
532
register .connect (convert2itk , 'itk_transform' , merge , 'in2' )
521
533
register .connect (reg , ('composite_transform' , pickfirst ), merge , 'in1' )
522
534
523
-
524
535
"""
525
536
Transform the mean image. First to anatomical and then to target
526
537
"""
538
+
527
539
warpmean = Node (ants .ApplyTransforms (), name = 'warpmean' )
528
540
warpmean .inputs .input_image_type = 3
529
541
warpmean .inputs .interpolation = 'BSpline'
@@ -536,7 +548,6 @@ def create_reg_workflow(name='registration'):
536
548
register .connect (inputnode , 'mean_image' , warpmean , 'input_image' )
537
549
register .connect (merge , 'out' , warpmean , 'transforms' )
538
550
539
-
540
551
"""
541
552
Assign all the output files
542
553
"""
@@ -557,7 +568,6 @@ def create_reg_workflow(name='registration'):
557
568
558
569
return register
559
570
560
-
561
571
"""
562
572
Creates the main preprocessing workflow
563
573
"""
@@ -607,15 +617,16 @@ def create_workflow(files,
607
617
name = 'median' )
608
618
wf .connect (tsnr , 'detrended_file' , calc_median , 'in_files' )
609
619
610
- """Segment and Register
611
620
"""
621
+ Segment and Register
622
+ """
623
+
612
624
registration = create_reg_workflow (name = 'registration' )
613
625
wf .connect (calc_median , 'median_file' , registration , 'inputspec.mean_image' )
614
626
registration .inputs .inputspec .subject_id = subject_id
615
627
registration .inputs .inputspec .subjects_dir = subjects_dir
616
628
registration .inputs .inputspec .target_image = target_file
617
629
618
-
619
630
"""Use :class:`nipype.algorithms.rapidart` to determine which of the
620
631
images in the functional series are outliers based on deviations in
621
632
intensity or movement.
@@ -629,7 +640,6 @@ def create_workflow(files,
629
640
art .inputs .mask_type = 'spm_global'
630
641
art .inputs .parameter_source = 'NiPy'
631
642
632
-
633
643
"""Here we are connecting all the nodes together. Notice that we add the merge node only if you choose
634
644
to use 4D. Also `get_vox_dims` function is passed along the input volume of normalise to set the optimal
635
645
voxel sizes.
0 commit comments