# Path: samri/optimization/newreg.py
# def single_generic(in_func, in_anat, template,
# 	target_in_func=False,
# 	mask=False,
# 	phases=GENERIC_PHASES,
# 	out_base='/var/tmp/samri_optimize',
# 	**kwargs):
# 	in_anat=os.path.abspath(os.path.expanduser(in_anat))
# 	in_func=os.path.abspath(os.path.expanduser(in_func))
# 	template=os.path.abspath(os.path.expanduser(template))
# 
# 	from samri.pipelines.nodes import generic_registration
# 
# 	in_anat_name = os.path.basename(in_anat).split('.nii')[0]
# 	in_func_name = os.path.basename(in_func).split('.nii')[0]
# 
# 	try:
# 		os.makedirs(out_base)
# 	except OSError:
# 		pass
# 	s_biascorrect_outfile = '{}/{}_biascorrected.nii.gz'.format(out_base,in_anat_name)
# 	try:
# 		os.remove(s_biascorrect_outfile)
# 	except OSError:
# 		pass
# 
# 	s_biascorrect = pe.Node(interface=ants.N4BiasFieldCorrection(), name="s_biascorrect")
# 	s_biascorrect.inputs.dimension = 3
# 	s_biascorrect.inputs.bspline_fitting_distance = 10
# 	s_biascorrect.inputs.bspline_order = 4
# 	s_biascorrect.inputs.shrink_factor = 2
# 	s_biascorrect.inputs.n_iterations = [150,100,50,30]
# 	s_biascorrect.inputs.convergence_threshold = 1e-16
# 	s_biascorrect.inputs.input_image = in_anat
# 	s_biascorrect.inputs.output_image = s_biascorrect_outfile
# 	s_biascorrect_run = s_biascorrect.run()
# 
# 	f_biascorrect = pe.Node(interface=ants.N4BiasFieldCorrection(), name="f_biascorrect")
# 	f_biascorrect.inputs.dimension = 3
# 	f_biascorrect.inputs.bspline_fitting_distance = 10
# 	f_biascorrect.inputs.bspline_order = 4
# 	f_biascorrect.inputs.shrink_factor = 2
# 	f_biascorrect.inputs.n_iterations = [150,100,50,30]
# 	f_biascorrect.inputs.convergence_threshold = 1e-11
# 	f_biascorrect.inputs.input_image = in_func
# 	f_biascorrect_run = f_biascorrect.run()
# 
# 	s_register_outfile = '{}/{}_warped.nii.gz'.format(out_base,in_anat_name)
# 	f_register_outfile = '{}/{}_semi_warped.nii.gz'.format(out_base,in_func_name)
# 	f_registered = '{}/{}_warped.nii.gz'.format(out_base,in_func_name)
# 	try:
# 		os.remove(s_register_outfile)
# 	except OSError:
# 		pass
# 	s_register, s_warp, f_register, f_warp = generic_registration(template,mask,None,4,phases,
# 		**kwargs)
# 	s_register.inputs.moving_image = s_biascorrect_run.outputs.output_image
# 	s_register.inputs.output_warped_image = s_register_outfile
# 	s_register_run = s_register.run()
# 	f_register.inputs.fixed_image = s_biascorrect_run.outputs.output_image
# 	f_register.inputs.moving_image = f_biascorrect_run.outputs.output_image
# 	f_register.inputs.output_warped_image = f_register_outfile
# 	f_register_run = f_register.run()
# 
# 	merge = util.Merge(2)
# 	merge.inputs.in1 = s_register_run.outputs.composite_transform
# 	merge.inputs.in2 = f_register_run.outputs.composite_transform
# 	merge_run= merge.run()
# 	if target_in_func:
# 		target_in_func=os.path.abspath(os.path.expanduser(target_in_func))
# 		f_warp.inputs.input_image = target_in_func
# 	else:
# 		f_warp.inputs.input_image = in_func
# 	f_warp.inputs.transforms = merge_run.outputs.out
# 	f_warp.inputs.output_image = f_registered
# 	f_warp_run = f_warp.run()


from samri.optimization.newreg import single_generic
		"convergence_threshold":1.e-8,
		"convergence_window_size":10,
		"smoothing_sigmas":[0],
		"sigma_units":"vox",
		"shrink_factors":[1],
		"use_estimate_learning_rate_once":False,
		"use_histogram_matching":False,
		},
	"s_rigid":{
		"transforms":"Rigid",
		"transform_parameters":(0.1,),
		"number_of_iterations":[2000,3000],
		"metric":"GC",
		"metric_weight":1,
		"radius_or_number_of_bins":64,
		"sampling_strategy":"Regular",
		"sampling_percentage":0.2,
		"convergence_threshold":1.e-16,
		"convergence_window_size":30,
		"smoothing_sigmas":[1,0],
		"sigma_units":"vox",
		"shrink_factors":[2,1],
		"use_estimate_learning_rate_once":False,
		"use_histogram_matching":True,
		},
	"affine":{
		"transforms":"Affine",
		"transform_parameters":(0.1,),
		"number_of_iterations":[200,100],
		"metric":"MI",

# Path: samri/optimization/newreg.py
# def single_generic(in_func, in_anat, template,
# 	target_in_func=False,
# 	mask=False,
# 	phases=GENERIC_PHASES,
# 	out_base='/var/tmp/samri_optimize',
# 	**kwargs):
# 	in_anat=os.path.abspath(os.path.expanduser(in_anat))
# 	in_func=os.path.abspath(os.path.expanduser(in_func))
# 	template=os.path.abspath(os.path.expanduser(template))
# 
# 	from samri.pipelines.nodes import generic_registration
# 
# 	in_anat_name = os.path.basename(in_anat).split('.nii')[0]
# 	in_func_name = os.path.basename(in_func).split('.nii')[0]
# 
# 	try:
# 		os.makedirs(out_base)
# 	except OSError:
# 		pass
# 	s_biascorrect_outfile = '{}/{}_biascorrected.nii.gz'.format(out_base,in_anat_name)
# 	try:
# 		os.remove(s_biascorrect_outfile)
# 	except OSError:
# 		pass
# 
# 	s_biascorrect = pe.Node(interface=ants.N4BiasFieldCorrection(), name="s_biascorrect")
# 	s_biascorrect.inputs.dimension = 3
# 	s_biascorrect.inputs.bspline_fitting_distance = 10
# 	s_biascorrect.inputs.bspline_order = 4
# 	s_biascorrect.inputs.shrink_factor = 2
# 	s_biascorrect.inputs.n_iterations = [150,100,50,30]
# 	s_biascorrect.inputs.convergence_threshold = 1e-16
# 	s_biascorrect.inputs.input_image = in_anat
# 	s_biascorrect.inputs.output_image = s_biascorrect_outfile
# 	s_biascorrect_run = s_biascorrect.run()
# 
# 	f_biascorrect = pe.Node(interface=ants.N4BiasFieldCorrection(), name="f_biascorrect")
# 	f_biascorrect.inputs.dimension = 3
# 	f_biascorrect.inputs.bspline_fitting_distance = 10
# 	f_biascorrect.inputs.bspline_order = 4
# 	f_biascorrect.inputs.shrink_factor = 2
# 	f_biascorrect.inputs.n_iterations = [150,100,50,30]
# 	f_biascorrect.inputs.convergence_threshold = 1e-11
# 	f_biascorrect.inputs.input_image = in_func
# 	f_biascorrect_run = f_biascorrect.run()
# 
# 	s_register_outfile = '{}/{}_warped.nii.gz'.format(out_base,in_anat_name)
# 	f_register_outfile = '{}/{}_semi_warped.nii.gz'.format(out_base,in_func_name)
# 	f_registered = '{}/{}_warped.nii.gz'.format(out_base,in_func_name)
# 	try:
# 		os.remove(s_register_outfile)
# 	except OSError:
# 		pass
# 	s_register, s_warp, f_register, f_warp = generic_registration(template,mask,None,4,phases,
# 		**kwargs)
# 	s_register.inputs.moving_image = s_biascorrect_run.outputs.output_image
# 	s_register.inputs.output_warped_image = s_register_outfile
# 	s_register_run = s_register.run()
# 	f_register.inputs.fixed_image = s_biascorrect_run.outputs.output_image
# 	f_register.inputs.moving_image = f_biascorrect_run.outputs.output_image
# 	f_register.inputs.output_warped_image = f_register_outfile
# 	f_register_run = f_register.run()
# 
# 	merge = util.Merge(2)
# 	merge.inputs.in1 = s_register_run.outputs.composite_transform
# 	merge.inputs.in2 = f_register_run.outputs.composite_transform
# 	merge_run= merge.run()
# 	if target_in_func:
# 		target_in_func=os.path.abspath(os.path.expanduser(target_in_func))
# 		f_warp.inputs.input_image = target_in_func
# 	else:
# 		f_warp.inputs.input_image = in_func
# 	f_warp.inputs.transforms = merge_run.outputs.out
# 	f_warp.inputs.output_image = f_registered
# 	f_warp_run = f_warp.run()


# Path: samri/optimization/tests/test_reg.py
from samri.optimization.newreg import single_generic

		"convergence_threshold":1.e-8,
		"convergence_window_size":10,
		"smoothing_sigmas":[0],
		"sigma_units":"vox",
		"shrink_factors":[1],
		"use_estimate_learning_rate_once":False,
		"use_histogram_matching":False,
		},
	"s_rigid":{
		"transforms":"Rigid",
		"transform_parameters":(0.1,),
		"number_of_iterations":[2000,3000],
		"metric":"GC",
		"metric_weight":1,
		"radius_or_number_of_bins":64,
		"sampling_strategy":"Regular",
		"sampling_percentage":0.2,
		"convergence_threshold":1.e-16,
		"convergence_window_size":30,
		"smoothing_sigmas":[1,0],
		"sigma_units":"vox",
		"shrink_factors":[2,1],
		"use_estimate_learning_rate_once":False,
		"use_histogram_matching":True,
		},
	"affine":{
		"transforms":"Affine",
		"transform_parameters":(0.1,),
		"number_of_iterations":[200,100],
		"metric":"MI",

		"metric_weight":1,