<commit_before>//
// LociFunctions.java
//

/*
LOCI Plugins for ImageJ: a collection of ImageJ plugins including the
Bio-Formats Importer, Bio-Formats Exporter, Data Browser, Stack Colorizer,
Stack Slicer, and OME plugins. Copyright (C) 2005-@year@ <NAME>,
<NAME>, <NAME> and <NAME>.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.plugins;

import ij.IJ;
import ij.ImagePlus;
import ij.process.ImageProcessor;
import java.awt.Rectangle;
import java.io.IOException;
import loci.formats.*;
import loci.formats.meta.MetadataRetrieve;

/**
 * This class provides macro extensions for ImageJ for Bio-Formats and other
 * LOCI tools. Currently, it is a fairly tight mirror to the
 * {@link loci.formats.IFormatReader} interface, with some additional
 * functions to control the type of format reader used.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/plugins/LociFunctions.java">Trac</a>,
 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/plugins/LociFunctions.java">SVN</a></dd></dl>
 *
 * @author <NAME> <EMAIL>ueden at wisc.edu
 */
public class LociFunctions extends MacroFunctions {

  // -- Fields --

  private IFormatReader r;

  // -- Constructor --

  public LociFunctions() {
    r = new FileStitcher(true);
    r.setMetadataStore(MetadataTools.createOMEXMLMetadata());
  }

  // -- LociFunctions API methods - loci.formats.IFormatReader --

  public void getImageCount(Integer[] imageCount) {
    imageCount[0] = new Integer(r.getImageCount());
  }

  public void getSizeX(Double[] sizeX) { sizeX[0] = new Double(r.getSizeX()); }
  public void getSizeY(Double[] sizeY) { sizeY[0] = new Double(r.getSizeY()); }
  public void getSizeZ(Double[] sizeZ) { sizeZ[0] = new Double(r.getSizeZ()); }
  public void getSizeC(Double[] sizeC) { sizeC[0] = new Double(r.getSizeC()); }
  public void getSizeT(Double[] sizeT) { sizeT[0] = new Double(r.getSizeT()); }

  public void getPixelType(String[] pixelType) {
    pixelType[0] = FormatTools.getPixelTypeString(r.getPixelType());
  }

  public void getEffectiveSizeC(Double[] effectiveSizeC) {
    effectiveSizeC[0] = new Double(r.getEffectiveSizeC());
  }

  public void getRGBChannelCount(Double[] rgbChannelCount) {
    rgbChannelCount[0] = new Double(r.getRGBChannelCount());
  }

  public void isIndexed(String[] indexed) {
    indexed[0] = r.isIndexed() ? "true" : "false";
  }

  public void getChannelDimCount(Double[] channelDimCount) {
    channelDimCount[0] = new Double(r.getChannelDimLengths().length);
  }

  public void getChannelDimLength(Double i, Double[] channelDimLength) {
    channelDimLength[0] = new Double(r.getChannelDimLengths()[i.intValue()]);
  }

  public void getChannelDimType(Double i, Double[] channelDimType) {
    channelDimType[0] = new Double(r.getChannelDimTypes()[i.intValue()]);
  }

//  public void getThumbSizeX(Double[] thumbSizeX) {
//    thumbSizeX[0] = new Double(r.getThumbSizeX());
//  }

//  public void getThumbSizeY(Double[] thumbSizeY) {
//    thumbSizeY[0] = new Double(r.getThumbSizeY());
//  }

  public void isLittleEndian(String[] littleEndian) {
    littleEndian[0] = r.isLittleEndian() ? "true" : "false";
  }

  public void getDimensionOrder(String[] dimOrder) {
    dimOrder[0] = r.getDimensionOrder();
  }

  public void isOrderCertain(String[] orderCertain) {
    orderCertain[0] = r.isOrderCertain() ? "true" : "false";
  }

  public void isInterleaved(String[] interleaved) {
    interleaved[0] = r.isInterleaved() ? "true" : "false";
  }

  public void isInterleavedSubC(Double subC, String[] interleaved) {
    interleaved[0] = r.isInterleaved(subC.intValue()) ? "true" : "false";
  }

  public void openImage(String title, Integer no)
    throws FormatException, IOException
  {
    ImageProcessor ip = Util.openProcessor(r, no.intValue());
    new ImagePlus(title, ip).show();
  }

  public void openImage(String title, Integer no, Integer x, Integer y,
    Integer width, Integer height) throws FormatException, IOException
  {
    Rectangle crop = new Rectangle(x.intValue(), y.intValue(),
      width.intValue(), height.intValue());
    ImageProcessor ip = Util.openProcessor(r, no.intValue(), crop);
    new ImagePlus(title, ip).show();
  }

  public void close() throws IOException { r.close(); }
  public void closeFileOnly() throws IOException { r.close(true); }

  public void getSeriesCount(Double[] seriesCount) {
    seriesCount[0] = new Double(r.getSeriesCount());
  }

  public void setSeries(Double seriesNum) {
    r.setSeries(seriesNum.intValue());
  }

  public void getSeries(Double[] seriesNum) {
    seriesNum[0] = new Double(r.getSeries());
  }

  public void setNormalized(Boolean normalize) {
    r.setNormalized(normalize.booleanValue());
  }

  public void isNormalized(Boolean[] normalize) {
    normalize[0] = new Boolean(r.isNormalized());
  }
<commit_msg>Must use Double rather than Integer.<commit_after>//
// LociFunctions.java
//

/*
LOCI Plugins for ImageJ: a collection of ImageJ plugins including the
Bio-Formats Importer, Bio-Formats Exporter, Data Browser, Stack Colorizer,
Stack Slicer, and OME plugins. Copyright (C) 2005-@year@ <NAME>,
<NAME>, <NAME> and <NAME>.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.plugins;

import ij.IJ;
import ij.ImagePlus;
import ij.process.ImageProcessor;
import java.awt.Rectangle;
import java.io.IOException;
import loci.formats.*;
import loci.formats.meta.MetadataRetrieve;

/**
 * This class provides macro extensions for ImageJ for Bio-Formats and other
 * LOCI tools. Currently, it is a fairly tight mirror to the
 * {@link loci.formats.IFormatReader} interface, with some additional
 * functions to control the type of format reader used.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/plugins/LociFunctions.java">Trac</a>,
 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/plugins/LociFunctions.java">SVN</a></dd></dl>
 *
 * @author <NAME> <EMAIL>ueden at wisc.edu
 */
public class LociFunctions extends MacroFunctions {

  // -- Fields --

  private IFormatReader r;

  // -- Constructor --

  public LociFunctions() {
    r = new FileStitcher(true);
    r.setMetadataStore(MetadataTools.createOMEXMLMetadata());
  }

  // -- LociFunctions API methods - loci.formats.IFormatReader --

  public void getImageCount(Double[] imageCount) {
    imageCount[0] = new Double(r.getImageCount());
  }

  public void getSizeX(Double[] sizeX) { sizeX[0] = new Double(r.getSizeX()); }
  public void getSizeY(Double[] sizeY) { sizeY[0] = new Double(r.getSizeY()); }
  public void getSizeZ(Double[] sizeZ) { sizeZ[0] = new Double(r.getSizeZ()); }
  public void getSizeC(Double[] sizeC) { sizeC[0] = new Double(r.getSizeC()); }
  public void getSizeT(Double[] sizeT) { sizeT[0] = new Double(r.getSizeT()); }

  public void getPixelType(String[] pixelType) {
    pixelType[0] = FormatTools.getPixelTypeString(r.getPixelType());
  }

  public void getEffectiveSizeC(Double[] effectiveSizeC) {
    effectiveSizeC[0] = new Double(r.getEffectiveSizeC());
  }

  public void getRGBChannelCount(Double[] rgbChannelCount) {
    rgbChannelCount[0] = new Double(r.getRGBChannelCount());
  }

  public void isIndexed(String[] indexed) {
    indexed[0] = r.isIndexed() ? "true" : "false";
  }

  public void getChannelDimCount(Double[] channelDimCount) {
    channelDimCount[0] = new Double(r.getChannelDimLengths().length);
  }

  public void getChannelDimLength(Double i, Double[] channelDimLength) {
    channelDimLength[0] = new Double(r.getChannelDimLengths()[i.intValue()]);
  }

  public void getChannelDimType(Double i, Double[] channelDimType) {
    channelDimType[0] = new Double(r.getChannelDimTypes()[i.intValue()]);
  }

//  public void getThumbSizeX(Double[] thumbSizeX) {
//    thumbSizeX[0] = new Double(r.getThumbSizeX());
//  }

//  public void getThumbSizeY(Double[] thumbSizeY) {
//    thumbSizeY[0] = new Double(r.getThumbSizeY());
//  }

  public void isLittleEndian(String[] littleEndian) {
    littleEndian[0] = r.isLittleEndian() ? "true" : "false";
  }

  public void getDimensionOrder(String[] dimOrder) {
    dimOrder[0] = r.getDimensionOrder();
  }

  public void isOrderCertain(String[] orderCertain) {
    orderCertain[0] = r.isOrderCertain() ? "true" : "false";
  }

  public void isInterleaved(String[] interleaved) {
    interleaved[0] = r.isInterleaved() ? "true" : "false";
  }

  public void isInterleavedSubC(Double subC, String[] interleaved) {
    interleaved[0] = r.isInterleaved(subC.intValue()) ? "true" : "false";
  }

  public void openImage(String title, Double no)
    throws FormatException, IOException
  {
    ImageProcessor ip = Util.openProcessor(r, no.intValue());
    new ImagePlus(title, ip).show();
  }

  public void openImage(String title, Double no, Double x, Double y,
    Double width, Double height) throws FormatException, IOException
  {
    Rectangle crop = new Rectangle(x.intValue(), y.intValue(),
      width.intValue(), height.intValue());
    ImageProcessor ip = Util.openProcessor(r, no.intValue(), crop);
    new ImagePlus(title, ip).show();
  }

  public void close() throws IOException { r.close(); }
  public void closeFileOnly() throws IOException { r.close(true); }

  public void getSeriesCount(Double[] seriesCount) {
    seriesCount[0] = new Double(r.getSeriesCount());
  }

  public void setSeries(Double seriesNum) {
    r.setSeries(seriesNum.intValue());
  }

  public void getSeries(Double[] seriesNum) {
    seriesNum[0] = new Double(r.getSeries());
  }

  public void setNormalized(Boolean normalize) {
    r.setNormalized(normalize.booleanValue());
  }

  public void isNormalized(Boolean[] normalize) {
    normalize[0] = new Boolean(r.isNormalized());
  }

{'fraction_non_alphanumeric': 0.12846754645838945, 'fraction_numerical': 0.007541071909507137, 'mean_word_length': 4.3378054623862, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 4, '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': '644716', 'n_tokens_mistral': 3612, 'n_tokens_neox': 3491, 'n_words': 953}