Buggy code:
protected double s030 ; protected double s120 ; protected double s021 ; protected double s003 ; protected double s102 ; protected double s012 ; protected double s111 ; protected double s400 = Double . NaN ; protected double s040 ; protected double s004 ; protected double s220 ; protected double s202 ; protected double s022 ; protected double s121 ; protected double s112 ; protected double s211 ; protected double s103 ; protected double s301 ; protected double s130 ; protected double s310 ; protected double s013 ; protected double s031 ; protected EigenvalueDecomposition eigen = null ; protected ImageInt miniLabelImage = null ; protected ImageInt labelImage = null ; protected ImageHandler currentQuantifImage = null ; protected double resXY = 1 ; protected double resZ = 1 ; protected String units = "pixels" ; public boolean verbose = false ; public boolean multiThread = false ; public static final byte MEASURE_NONE = 0 ; public static final byte MEASURE_VOLUME_PIX = 1 ; public static final byte MEASURE_VOLUME_UNIT = 2 ; public static final byte MEASURE_MAIN_ELONGATION = 3 ; public static final byte MEASURE_COMPACTNESS_VOXELS = 4 ; public static final byte MEASURE_COMPACTNESS_UNITS = 12 ; public static final byte MEASURE_SPHERICITY = 5 ; public static final byte MEASURE_AREA_PIX = 6 ; public static final byte MEASURE_AREA_UNIT = 7 ; public static final byte MEASURE_DC_AVG = 8 ; public static final byte MEASURE_DC_SD = 9 ; public static final byte MEASURE_INTENSITY_AVG = 10 ; public static final byte MEASURE_INTENSITY_SD = 11 ; public void setResXY ( double rxy ) { } public void setResZ ( double rz ) { } public void setUnits ( String u ) { } public double getResXY ( ) { } public double getResZ ( ) { } public String getUnits ( ) { } public Calibration getCalibration ( ) { } public void setCalibration ( Calibration cal ) { } public final void setCalibration ( double rxy , double rz , String u ) { } public String getName ( ) { } public void setName ( String name ) { } public int getType ( ) { } public void setType ( int type ) { } public String getComment ( ) { } public void setComment ( String comment ) { } public ImageInt getLabelImage ( ) { } public void setLabelImage ( ImageInt labelImage ) { } public int getVolumePixels ( ) { } public double getMeasure ( int Measure ) { } private void computeVolume ( ) { } public double getVolumeUnit ( ) { } protected abstract void computeCenter ( ) { } protected abstract void computeMassCenter ( ImageHandler ima ) { } protected abstract void computeMassCenter ( ImageHandler ima , ImageHandler mask ) { } public float [ ] getArrayValues ( ImageHandler ima ) { } public double getQuantilePixValue ( ImageHandler ima , double quantile ) { if ( quantile == 1 ) { return getPixMaxValue ( ima ) ; } else if ( quantile == 0 ) { return getPixMinValue ( ima ) ; } float [ ] vals = getArrayValues ( ima ) ; if ( ( vals . length ) == 0 ) { return Double . NaN ; } Arrays . sort ( vals ) ; <START_BUG> double index = quantile * ( vals . length ) ; <END_BUG> if ( index <= 0 ) { return vals [ 0 ] ; } else if ( index >= ( ( vals . length ) - 1 ) ) { return vals [ ( ( vals . length ) - 1 ) ] ; } double d = index - ( ( int ) ( index ) ) ; if ( d == 0 ) { return vals [ ( ( int ) ( index ) ) ] ; } double val1 = vals [ ( ( int ) ( index ) ) ] ; double val2 = vals [ ( ( int ) ( index + 1 ) ) ] ; return ( d * val2 ) + ( ( 1 - d ) * val1 ) ; } protected abstract void computeBounding ( ) { } public abstract void computeContours ( ) { } protected abstract void computeMoments2 ( boolean normalize ) { } protected abstract void computeMoments3 ( ) { } protected abstract void computeMoments4 ( ) { } public double [ ] getMomentsRaw2 ( ) { } public double [ ] getMomentsRaw3 ( ) { } public double [ ] getMomentsRaw4 ( ) { } public double [ ] getGeometricInvariants ( ) { } public double [ ] getHomogeneousInvariants ( ) { } public double [ ] getMoments3D ( ) { } public static int getNbMoments3D ( ) { } public abstract Voxel3D getPixelMax ( ImageHandler ima ) { } public ArrayList < Voxel3D > listVoxels ( ImageHandler ima ) { } public abstract ArrayUtil listValues ( ImageHandler ima ) { } public abstract ArrayUtil listValues ( ImageHandler ima , float thresh ) { } public abstract ArrayList < Voxel3D > listVoxels ( ImageHandler ima , double thresh ) { } public abstract ArrayList < Voxel3D > listVoxels ( ImageHandler ima , double thresh0 , double thres1 ) { } public ArrayList < Voxel3D > listVoxelsByDistance ( Point3D P0 , double dist0 , double dist1 , boolean contourOnly ) { } public Object3DVoxels getObject3DVoxels ( ) { } public Object3DSurface getObject3DSurface ( ) { } public double pcColoc ( Object3D obj ) { } public abstract void draw ( ObjectCreator3D obj , int col ) { } public abstract void draw ( ByteProcessor mask , int z , int col ) { } public abstract void draw ( ImageStack mask , int col ) { } public abstract void draw ( ImageHandler mask , int col ) { } public abstract void draw ( ImageHandler mask , int col , int tx , int ty , int tz ) { } public void draw ( ImageHandler mask ) { }

Fix:
double index = quantile * ( ( vals . length ) - 1 ) ;