示例#1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (filename == null)
            {
                string[] parameters = richTextBox1.Text.Split('\n');

                foreach (var param in parameters)
                {
                    string[]          splitted = param.Split(' ');
                    sitk.VectorString vec      = GetVectorFromString(param);
                    if (vec != null)
                    {
                        if (Parametermap.ContainsKey(splitted[0]))
                        {
                            Parametermap[splitted[0]] = vec;
                        }
                        else
                        {
                            Parametermap.Add(splitted[0], vec);
                        }
                    }
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                sitk.ElastixImageFilter elx = new sitk.ElastixImageFilter();
                elx.WriteParameterFile(Parametermap, filename);
                elx.Dispose();
            }
        }
        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();
            }
        }
示例#3
0
 /// <summary>
 /// Dispose all created instances.
 /// </summary>
 public virtual void Dispose()
 {
     if (elastix != null)
     {
         elastix.Dispose();
     }
     if (fixedImage != null)
     {
         fixedImage.Dispose();
     }
     if (movingImage != null)
     {
         movingImage.Dispose();
     }
     if (fixedMask != null)
     {
         fixedMask.Dispose();
     }
     if (movingMask != null)
     {
         movingMask.Dispose();
     }
     if (transformedImage != null)
     {
         transformedImage.Dispose();
     }
 }
示例#4
0
        public EditParametersForm(string parameterFilename)
        {
            InitializeComponent();

            filename = parameterFilename;
            sitk.ElastixImageFilter elx = new sitk.ElastixImageFilter();
            Parametermap = elx.ReadParameterFile(filename);
            elx.Dispose();
        }