private sitk.VectorOfParameterMap InvertTransformParameters(string parameterFilename)
        {
            sitk.Image fixedImage           = ReadWriteUtils.ReadITKImageFromFile(registrationParameters.FixedImageFilename, sitk.PixelIDValueEnum.sitkFloat32);
            sitk.ElastixImageFilter elastix = null;
            try
            {
                // elastix manual 6.1.6: DisplacementMagnitudePenalty
                elastix = new sitk.ElastixImageFilter();
                elastix.SetInitialTransformParameterFileName(parameterFilename);
                elastix.SetParameterMap(sitk.SimpleITK.GetDefaultParameterMap("rigid"));
                elastix.SetFixedImage(fixedImage);
                elastix.SetMovingImage(fixedImage);
                elastix.SetParameter("HowToCombineTransforms", "Compose");
                elastix.SetParameter("Metric", "DisplacementMagnitudePenalty");
                elastix.SetParameter("NumberOfResolutions", "1");
                elastix.Execute();
                return(elastix.GetTransformParameterMap());

                /*sitk.TransformixImageFilter transformix = new sitk.TransformixImageFilter();
                 * transformix.SetTransformParameterMap(elastix.GetTransformParameterMap());
                 * transformix.SetTransformParameter("InitialTransformParametersFileName", "NoInitialTransform");
                 * transformix.Execute();*/
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            } finally
            {
                elastix.Dispose();
                fixedImage.Dispose();
            }
        }
        public MultipleParameterFileRegistration(sitk.Image fixedImage, sitk.Image movingImage, RegistrationParameters parameters) : base(parameters)
        {
            this.fixedImage  = ImageUtils.CastImageToFloat32(fixedImage);
            this.movingImage = ImageUtils.CastImageToFloat32(movingImage);

            elastix = new sitk.ElastixImageFilter();

            for (int i = 0; i < parameters.ParameterFiles.Count; i++)
            {
                if (i == 0)
                {
                    elastix.SetParameterMap(elastix.ReadParameterFile(parameters.ParameterFiles[i]));
                }
                else
                {
                    elastix.AddParameterMap(elastix.ReadParameterFile(parameters.ParameterFiles[i]));
                }
            }

            // set output dir
            outputDirectory = Path.Combine(registrationParameters.OutputDirectory, "multiple_" + DateTime.Now.ToShortDateString());
            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }
            elastix.SetOutputDirectory(outputDirectory);
            //elastix.SetLogFileName(Path.Combine(outputDirectory, registrationParameters.ElastixLogFileName));
            elastix.LogToFileOn();
        }