/// <summary>
        /// Transform a pointset for given transform parameters.
        /// </summary>
        /// <param name="transformParameters">transform params</param>
        /// <param name="parameters">registration params</param>
        /// <returns>filename of transformed point set</returns>
        public static string TransfromPointSet(List <sitk.VectorOfParameterMap> transformParameters, RegistrationParameters parameters, string movingImageName = null)
        {
            sitk.TransformixImageFilter transformix = null;
            try
            {
                transformix = new sitk.TransformixImageFilter();
                transformix.SetTransformParameterMap(transformParameters.First());
                transformix.LogToConsoleOn();
                transformix.LogToFileOn();
                transformix.SetLogFileName("transformix.log");
                //transformix.SetLogToFile(true);

                if (transformParameters.Count > 1)
                {
                    for (int i = 1; i < transformParameters.Count; i++)
                    {
                        var vectorParameterMap = transformParameters[i];
                        foreach (var paramMap in vectorParameterMap.AsEnumerable())
                        {
                            transformix.AddTransformParameterMap(paramMap);
                        }
                    }
                }

                if (parameters.Type == RegistrationType.Rigid)
                {
                    transformix.SetFixedPointSetFileName(parameters.FixedImagePointSetFilename);
                }
                else
                {
                    transformix.SetFixedPointSetFileName(parameters.MovingImagePointSetFilename);
                }
                transformix.SetOutputDirectory(ReadWriteUtils.GetOutputDirectory(parameters));
                //transformix.SetTransformParameter(0, "UseBinaryFormatForTransformationParameters", "true" );
                var par = transformix.GetTransformParameter(0, "TransformParameters");

                if (movingImageName != null)
                {
                    sitk.Image movImg = ReadWriteUtils.ReadITKImageFromFile(movingImageName, sitk.PixelIDValueEnum.sitkFloat32);
                    transformix.SetMovingImage(movImg);
                }

                sitk.Image image  = transformix.Execute();
                string     output = ReadWriteUtils.GetOutputDirectory(parameters) + "\\outputpoints.txt";
                image.Dispose();
                return(output);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            } finally
            {
                transformix.Dispose();
            }
        }
        /// <summary>
        /// Transform a pointset for given transform parameters.
        /// </summary>
        /// <param name="transformParameters"></param>
        /// <param name="pointSetFilename"></param>
        /// <param name="outputDir"></param>
        /// <param name="movingImageName"></param>
        public static void TransfromPointSet(List <sitk.VectorOfParameterMap> transformParameters, string pointSetFilename, string outputDir, string movingImageName = null)
        {
            sitk.TransformixImageFilter transformix = null;
            try
            {
                transformix = new sitk.TransformixImageFilter();
                transformix.SetTransformParameterMap(transformParameters.First());
                transformix.LogToConsoleOn();
                transformix.LogToFileOn();
                transformix.SetLogFileName("transformix.log");

                if (transformParameters.Count > 1)
                {
                    for (int i = 1; i < transformParameters.Count; i++)
                    {
                        var vectorParameterMap = transformParameters[i];
                        foreach (var paramMap in vectorParameterMap.AsEnumerable())
                        {
                            transformix.AddTransformParameterMap(paramMap);
                        }
                    }
                }

                transformix.SetFixedPointSetFileName(pointSetFilename);
                transformix.SetOutputDirectory(Path.GetDirectoryName(pointSetFilename));

                if (movingImageName != null)
                {
                    sitk.Image movImg = ReadWriteUtils.ReadITKImageFromFile(movingImageName, sitk.PixelIDValueEnum.sitkFloat32);
                    transformix.SetMovingImage(movImg);
                }

                sitk.Image image = transformix.Execute();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                transformix.Dispose();
            }
        }