Source code for WORC.resources.fastr_tests.elastix_test
#!/usr/bin/env python# Copyright 2017-2018 Biomedical Imaging Group Rotterdam, Departments of# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.IS_TEST=True
[docs]defcreate_network():# Import the faster environment and set it upimportfastrnetwork=fastr.Network(id_="elastix_test")source1=network.create_source('ITKImageFile',id_='fixed_img')source2=network.create_source('ITKImageFile',id_='moving_img')param1=network.create_source('ElastixParameterFile',id_='param_file')elastix_node=network.create_node('elastix_dev',id_='elastix')elastix_node.inputs['fixed_image']=source1.outputelastix_node.inputs['moving_image']=source2.outputlink_param=network.create_link(param1.output,elastix_node.inputs['parameters'])link_param.converge=0outtrans=network.create_sink('ElastixTransformFile',id_='sink_trans')outtrans.inputs['input']=elastix_node.outputs['transform']transformix_node=network.create_node('transformix_dev',id_='transformix')transformix_node.inputs['image']=source2.outputtransformix_node.inputs['transform']=elastix_node.outputs['transform'][-1]outimage=network.create_sink('ITKImageFile',id_='sink_image')outimage.inputs['input']=transformix_node.outputs['image']network.draw_network(img_format='svg')network.dumpf('{}.json'.format(network.id),indent=2)returnnetwork