/// <summary> /// Performs DiviK clustering on the specified data. /// </summary> /// <param name="dataset">Input dataset.</param> /// <param name="options">Configuration.</param> /// <returns>Segmentation result.</returns> /// <exception cref="System.ObjectDisposedException">thrown if this object has been disposed.</exception> public DivikResult Divik(IDataset dataset, DivikOptions options) { // This is needed to not to make MCR go wild const int numberOfOutputArgs = 2; var coordinates = dataset.GetRawSpacialCoordinates(is2D: true); var coords = new double[coordinates.GetLength(dimension: 0), coordinates.GetLength(dimension: 1)]; for (var i = 0; i < coordinates.GetLength(dimension: 0); ++i) { for (var j = 0; j < coordinates.GetLength(dimension: 1); ++j) { coords[i, j] = coordinates[i, j]; } } var varargin = options.ToVarargin(); var matlabDivikResult = _segmentation.divik( numberOfOutputArgs, dataset.GetRawIntensities(), coordinates, varargin); // matlabResult[0] is equal to the "partition" field in matlabResult[1], that's why we only use matlabResult[1] // Besides it helps to create recursive single constructor for DivikResult var result = new DivikResult(matlabResult: matlabDivikResult[Segmentation.DivikStructureLocation]); return(result); }
public void DivikBigData() { // path to directory with test project var path = TestDirectory + "\\hnc1_tumor.txt"; var dataset = new BasicTextDataset(path); var options = DivikOptions.ForLevels(levels: 2); var result = _segmentation.Divik(dataset, options); // Assert Assert.IsNotNull(result); }
/// <summary> /// Gets divik config of divik result. /// </summary> /// <param name="id">Preparation identifier.</param> /// <param name="divikId">Identifier of divik.</param> /// <returns>DivikConfig</returns> public DivikOptions GetConfig(int id, int divikId) { if (divikId < 0) { throw new ArgumentException(message: nameof(divikId)); } if (id != 1) { return(DivikOptions.Default()); } var jsonText = File.ReadAllText("C:\\spectre_data\\expected_divik_results\\hnc1_tumor\\euclidean\\config.json"); return(JsonConvert.DeserializeObject <DivikOptions>(jsonText)); }
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); }
public void EqualsAgainstDifferentInstance() { 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.UsingVarianceFiltration = false; var result = _segmentation.Divik(dataset, options); Assert.False(condition: result.Equals(_result), message: "Unequal objects not indicated."); }
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); }
/// <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)); }