<commit_before>/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2012 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej.core.commands.debug;

import net.imglib2.ops.pointset.HyperVolumePointSet;
import net.imglib2.ops.pointset.PointSet;
import net.imglib2.ops.pointset.RoiPointSet;
import imagej.command.Command;
import imagej.data.Dataset;
import imagej.data.display.ImageDisplay;
import imagej.data.display.OverlayService;
import imagej.data.measure.StatisticsService;
import imagej.data.overlay.Overlay;
import imagej.event.StatusService;
import imagej.plugin.Parameter;
import imagej.plugin.Plugin;
import imagej.widget.Button;

/**
 * Shows how to use the StatisticsService.
 * 
 * @author <NAME>
 *
 */
@Plugin(menuPath = "Plugins>Sandbox>Statistics Demo")
public class StatisticsDemo implements Command {

	// -- Parameters --
	
	@Parameter
	private StatisticsService statSrv;
	
	@Parameter
	private OverlayService oSrv;
	
	@Parameter
	private StatusService sSrv;
	
	@Parameter
	private ImageDisplay display;
	
	@Parameter
	private Dataset dataset;
	
	@Parameter(label="Measure mean", callback = "mean")
	private Button mean;
	
	@Parameter(label="Measure variance", callback = "variance")
	private Button variance;

	@Parameter(label="Measure std dev", callback = "stdDev")
	private Button stdDev;

	@Parameter(label="Measure skew", callback = "skew")
	private Button skew;

	@Parameter(label="Measure kurtosis excess", callback = "kurtosisExcess")
	private Button kurtosis;

	@Parameter(label="Measure min", callback = "min")
	private Button min;
	
	@Parameter(label="Measure max", callback = "max")
	private Button max;

	@Parameter(label="Measure median", callback = "median")
	private Button median;

	@Parameter(label="Measure midpoint", callback = "midpoint")
	private Button midpoint;

	private PointSet getRegion() { 
		Overlay overlay = oSrv.getActiveOverlay(display);
		if (overlay != null) {
			return new RoiPointSet(overlay.getRegionOfInterest());
		}
		long[] dims = display.getDims();
		// 1st plane only
		for (int i = 2; i < dims.length; i++) {
			dims[i] = 1;
		}
		return new HyperVolumePointSet(dims);
	}
	
	// -- Command methods --
	
	@Override
	public void run() {
		// does nothing. the whole of this plugin is the interactivity of the button
		// presses with updates to the status line.
	}<commit_msg>StatisticsDemo: now calc values for current plane<commit_after>/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2012 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej.core.commands.debug;

import imagej.command.Command;
import imagej.data.Dataset;
import imagej.data.display.ImageDisplay;
import imagej.data.display.OverlayService;
import imagej.data.measure.StatisticsService;
import imagej.data.overlay.Overlay;
import imagej.event.StatusService;
import imagej.plugin.Parameter;
import imagej.plugin.Plugin;
import imagej.widget.Button;
import net.imglib2.ops.pointset.HyperVolumePointSet;
import net.imglib2.ops.pointset.PointSet;
import net.imglib2.ops.pointset.RoiPointSet;

/**
 * Shows how to use the StatisticsService.
 * 
 * @author <NAME>
 *
 */
@Plugin(menuPath = "Plugins>Sandbox>Statistics Demo")
public class StatisticsDemo implements Command {

	// -- Parameters --
	
	@Parameter
	private StatisticsService statSrv;
	
	@Parameter
	private OverlayService oSrv;
	
	@Parameter
	private StatusService sSrv;
	
	@Parameter
	private ImageDisplay display;
	
	@Parameter
	private Dataset dataset;
	
	@Parameter(label="Measure mean", callback = "mean")
	private Button mean;
	
	@Parameter(label="Measure variance", callback = "variance")
	private Button variance;

	@Parameter(label="Measure std dev", callback = "stdDev")
	private Button stdDev;

	@Parameter(label="Measure skew", callback = "skew")
	private Button skew;

	@Parameter(label="Measure kurtosis excess", callback = "kurtosisExcess")
	private Button kurtosis;

	@Parameter(label="Measure min", callback = "min")
	private Button min;
	
	@Parameter(label="Measure max", callback = "max")
	private Button max;

	@Parameter(label="Measure median", callback = "median")
	private Button median;

	@Parameter(label="Measure midpoint", callback = "midpoint")
	private Button midpoint;

	private PointSet getRegion() { 
		Overlay overlay = oSrv.getActiveOverlay(display);
		if (overlay != null) {
			return new RoiPointSet(overlay.getRegionOfInterest());
		}
		long[] dims = display.getDims();
		long[] pt1 = new long[dims.length];
		long[] pt2 = pt1.clone();
		// current plane only
		pt1[0] = 0;
		pt1[1] = 0;
		pt2[0] = dims[0] - 1;
		pt2[1] = dims[1] - 1;
		for (int i = 2; i < dims.length; i++) {
			pt1[i] = pt2[i] = display.getLongPosition(i);
		}
		return new HyperVolumePointSet(pt1, pt2);
	}
	
	// -- Command methods --
	
	@Override
	public void run() {
		// does nothing. the whole of this plugin is the interactivity of the button
		// presses with updates to the status line.
	}
{'fraction_non_alphanumeric': 0.08878784252722269, 'fraction_numerical': 0.006102668421682422, 'mean_word_length': 4.455613577023499, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7490819', 'n_tokens_mistral': 2506, 'n_tokens_neox': 2252, 'n_words': 907}