public void EqualsAgainstIdenticalInstance()
        {
            var dataset = new BasicTextDataset(_testFilePath);
            var options = DivikOptions.ForLevels(levels: 1);

            options.MaxK                             = 2;
            options.Caching                          = false;
            options.PlottingPartitions               = false;
            options.PlottingDecomposition            = false;
            options.PlottingDecompositionRecursively = false;
            options.PlottingRecursively              = false;
            options.UsingAmplitudeFiltration         = false;
            var result = _segmentation.Divik(dataset, options);

            Assert.True(condition: result.Equals(_result), message: "Equal objects not indicated.");
        }
Exemplo n.º 2
0
        public void DivikSimple()
        {
            double[] mz = { 1, 2, 3, 4 };
            double[,] data     = { { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 } };
            int[,] coordinates = { { 1, 1 }, { 2, 2 }, { 1, 2 }, { 2, 1 } };
            IDataset dataset = new BasicTextDataset(mz, data, coordinates);

            var options = DivikOptions.ForLevels(levels: 1);

            options.UsingVarianceFiltration  = false;
            options.UsingAmplitudeFiltration = false;
            options.MaxK   = 2;
            options.Metric = Metric.Euclidean;

            var result = _segmentation.Divik(dataset, options);

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Function for starting divik calculation.
 /// </summary>
 private void StartDivikButtonExecute()
 {
     if (StartDivikLabel == "Start Divik")
     {
         ThreadPool.QueueUserWorkItem(
             callBack: s =>
         {
             ToggleDivikProgressDisplay();
             var token = (CancellationToken)s;
             if (token.IsCancellationRequested)
             {
                 EnableStartDivik = true;
                 ToggleDivikProgressDisplay();
                 MessageBox.Show(text: "Divik was successfully cancelled.", caption: "Cancelled!");
                 return;
             }
             _divikService = _divikService ?? new Segmentation();
             var fileName  = "\\divik-result-"
                             + DateTime.Now.ToString(format: "yyyy-MM-dd-HH-mm-ss")
                             + ".json";
             if (token.IsCancellationRequested)
             {
                 EnableStartDivik = true;
                 ToggleDivikProgressDisplay();
                 MessageBox.Show(text: "Divik was successfully cancelled.", caption: "Cancelled!");
                 return;
             }
             using (var consoleCapture = new ConsoleCaptureService(updateInterval: 1000))
             {
                 Log = string.Empty;
                 consoleCapture.Written += (sender, appended) => Log += appended;
                 _divikService.Divik(
                     dataset: GetDatasetFromVm(),
                     options: GetDivikOptionsFromVm())
                 .Save(path: OutputPath + fileName, indentation: PrettyPrint);
             }
             ToggleDivikProgressDisplay();
             MessageBox.Show(
                 text: "Divik was successfully calculated. The result file was saved as: "
                 + OutputPath
                 + fileName,
                 caption: "Success!");
         },
             state: _cancellationTokenSource.Token);
     }
     else
     {
         EnableStartDivik = false;
         ProgressBarLabel = "Cancelling divik...";
         _cancellationTokenSource.Cancel();
         _cancellationTokenSource = new CancellationTokenSource();
         (_divikService as IDisposable)?.Dispose();
         _divikService = null;
     }
 }
        public void SetUpFixture()
        {
            var dataset = new BasicTextDataset(_testFilePath);
            var options = DivikOptions.ForLevels(levels: 1);

            options.MaxK                             = 2;
            options.Caching                          = false;
            options.PlottingPartitions               = false;
            options.PlottingDecomposition            = false;
            options.PlottingDecompositionRecursively = false;
            options.PlottingRecursively              = false;
            options.UsingAmplitudeFiltration         = false;
            _segmentation                            = new Segmentation();
            _result = _segmentation.Divik(dataset, options);
        }
Exemplo n.º 5
0
 /// <summary>
 ///     Service method for calculating divik.
 /// </summary>
 /// <param name="dataset">The source dataset being passed to the target.</param>
 /// <param name="options">The options passed to the divik algorithm.</param>
 /// <returns><see cref="DivikResult" /> of a given divik calculation.</returns>
 public DivikResult CalculateDivik(IDataset dataset, DivikOptions options)
 {
     return(_segmentation.Divik(dataset, options));
 }