|
53 | 53 | else:
|
54 | 54 | print("File previously downloaded {0}".format(localFilename))
|
55 | 55 |
|
56 |
| -input_images=[ |
57 |
| -os.path.join(mydatadir,'01_T1_half.nii.gz'), |
58 |
| -os.path.join(mydatadir,'02_T1_half.nii.gz'), |
59 |
| -os.path.join(mydatadir,'03_T1_half.nii.gz') |
60 |
| -] |
61 |
| -input_passive_images=[ |
62 |
| -{'INV_T1':os.path.join(mydatadir,'01_T1_inv_half.nii.gz')}, |
63 |
| -{'INV_T1':os.path.join(mydatadir,'02_T1_inv_half.nii.gz')}, |
64 |
| -{'INV_T1':os.path.join(mydatadir,'03_T1_inv_half.nii.gz')} |
| 56 | + |
| 57 | +""" |
| 58 | +ListOfImagesDictionaries - a list of dictionaries where each dictionary is |
| 59 | +for one scan session, and the mappings in the dictionary are for all the |
| 60 | +co-aligned images for that one scan session |
| 61 | +""" |
| 62 | +ListOfImagesDictionaries=[ |
| 63 | +{'T1':os.path.join(mydatadir,'01_T1_half.nii.gz'),'INV_T1':os.path.join(mydatadir,'01_T1_inv_half.nii.gz'),'LABEL_MAP':os.path.join(mydatadir,'01_T1_inv_half.nii.gz')}, |
| 64 | +{'T1':os.path.join(mydatadir,'02_T1_half.nii.gz'),'INV_T1':os.path.join(mydatadir,'02_T1_inv_half.nii.gz'),'LABEL_MAP':os.path.join(mydatadir,'02_T1_inv_half.nii.gz')}, |
| 65 | +{'T1':os.path.join(mydatadir,'03_T1_half.nii.gz'),'INV_T1':os.path.join(mydatadir,'03_T1_inv_half.nii.gz'),'LABEL_MAP':os.path.join(mydatadir,'03_T1_inv_half.nii.gz')} |
65 | 66 | ]
|
66 | 67 |
|
| 68 | +""" |
| 69 | +registrationImageTypes - A list of the image types to be used actively during |
| 70 | +the estimation process of registration, any image type not in this list |
| 71 | +will be passively resampled with the estimated transforms. |
| 72 | +['T1','T2'] |
| 73 | +""" |
| 74 | +registrationImageTypes=['T1'] |
| 75 | + |
| 76 | +""" |
| 77 | +interpolationMap - A map of image types to interpolation modes. If an |
| 78 | +image type is not listed, it will be linearly interpolated. |
| 79 | +{ 'labelmap':'NearestNeighbor', 'FLAIR':'WindowedSinc' } |
| 80 | +""" |
| 81 | +interpolationMapping={'INV_T1':'LanczosWindowedSinc','LABEL_MAP':'NearestNeighbor','T1':'Linear'} |
67 | 82 |
|
68 | 83 | """
|
69 | 84 | 3. Define the workflow and its working directory
|
|
74 | 89 | """
|
75 | 90 | 4. Define data sources. In real life these would be replace by DataGrabbers
|
76 | 91 | """
|
| 92 | +InitialTemplateInputs=[ mdict['T1'] for mdict in ListOfImagesDictionaries ] |
| 93 | + |
77 | 94 | datasource = pe.Node(interface=util.IdentityInterface(fields=
|
78 |
| - ['imageList', 'passiveImagesDictionariesList']), |
| 95 | + ['InitialTemplateInputs', 'ListOfImagesDictionaries', |
| 96 | + 'registrationImageTypes','interpolationMapping']), |
79 | 97 | run_without_submitting=True,
|
80 | 98 | name='InputImages' )
|
81 |
| -datasource.inputs.imageList=input_images |
82 |
| -datasource.inputs.passiveImagesDictionariesList=input_passive_images |
| 99 | +datasource.inputs.InitialTemplateInputs=InitialTemplateInputs |
| 100 | +datasource.inputs.ListOfImagesDictionaries=ListOfImagesDictionaries |
| 101 | +datasource.inputs.registrationImageTypes=registrationImageTypes |
| 102 | +datasource.inputs.interpolationMapping=interpolationMapping |
83 | 103 |
|
84 | 104 | """
|
85 |
| -5. Template is initialized by a simple average |
| 105 | +5. Template is initialized by a simple average in this simple example, |
| 106 | + any reference image could be used (i.e. a previously created template) |
86 | 107 | """
|
87 | 108 | initAvg = pe.Node(interface=ants.AverageImages(), name ='initAvg')
|
88 | 109 | initAvg.inputs.dimension = 3
|
89 | 110 | initAvg.inputs.normalize = True
|
90 | 111 |
|
91 |
| -tbuilder.connect(datasource, "imageList", initAvg, "images") |
| 112 | +tbuilder.connect(datasource, "InitialTemplateInputs", initAvg, "images") |
92 | 113 |
|
93 | 114 | """
|
94 | 115 | 6. Define the first iteration of template building
|
95 | 116 | """
|
96 | 117 |
|
97 | 118 | buildTemplateIteration1=antsRegistrationTemplateBuildSingleIterationWF('iteration01')
|
98 | 119 | tbuilder.connect(initAvg, 'output_average_image', buildTemplateIteration1, 'InputSpec.fixed_image')
|
99 |
| -tbuilder.connect(datasource, 'imageList', buildTemplateIteration1, 'InputSpec.images') |
100 |
| -tbuilder.connect(datasource, 'passiveImagesDictionariesList', buildTemplateIteration1, 'InputSpec.ListOfPassiveImagesDictionaries') |
| 120 | +tbuilder.connect(datasource, 'ListOfImagesDictionaries', buildTemplateIteration1, 'InputSpec.ListOfImagesDictionaries') |
| 121 | +tbuilder.connect(datasource, 'registrationImageTypes', buildTemplateIteration1, 'InputSpec.registrationImageTypes') |
| 122 | +tbuilder.connect(datasource, 'interpolationMapping', buildTemplateIteration1, 'InputSpec.interpolationMapping') |
101 | 123 |
|
102 | 124 | """
|
103 | 125 | 7. Define the second iteration of template building
|
104 | 126 | """
|
105 |
| - |
106 | 127 | buildTemplateIteration2 = antsRegistrationTemplateBuildSingleIterationWF('iteration02')
|
107 | 128 | tbuilder.connect(buildTemplateIteration1, 'OutputSpec.template', buildTemplateIteration2, 'InputSpec.fixed_image')
|
108 |
| -tbuilder.connect(datasource, 'imageList', buildTemplateIteration2, 'InputSpec.images') |
109 |
| -tbuilder.connect(datasource, 'passiveImagesDictionariesList', buildTemplateIteration2, 'InputSpec.ListOfPassiveImagesDictionaries') |
| 129 | +tbuilder.connect(datasource, 'ListOfImagesDictionaries', buildTemplateIteration2, 'InputSpec.ListOfImagesDictionaries') |
| 130 | +tbuilder.connect(datasource, 'registrationImageTypes', buildTemplateIteration2, 'InputSpec.registrationImageTypes') |
| 131 | +tbuilder.connect(datasource, 'interpolationMapping', buildTemplateIteration2, 'InputSpec.interpolationMapping') |
110 | 132 |
|
111 | 133 | """
|
112 | 134 | 8. Move selected files to a designated results folder
|
113 | 135 | """
|
114 |
| - |
115 | 136 | datasink = pe.Node(io.DataSink(), name="datasink")
|
116 | 137 | datasink.inputs.base_directory = os.path.join(requestedPath, "results")
|
117 | 138 |
|
|
0 commit comments