O2Plib.misc
Class CalibrateOD

java.lang.Object
  extended by O2Plib.misc.CalibrateOD

public class CalibrateOD
extends java.lang.Object

Class CalibrateOD calibrates image grayscale to OD or other unigs values where calibration standards are available. It will analyze a calibration (typically Neutral Density (ND)) step wedge in the image, compute its histogram, find the peaks of the histogram and then associate these peaks with the calibration values (supplied by the caller). Then it will generate a piecewise linear map between grayscale in the image and the calibrated units in the map. The map calib.mapGrayToCal[0:maxGrayValue-1] can then be used as a table lookup in image analysis software.

This code was derived and refactored the Open2Dprot Flicker program (http://open2dprot.sourceforge.net/Flicker). The CalibrateOD code in Flicker was derived from some of the GELLAB-II code Gellab was first described in Lipkin L.E, Lemkin P.F. (1980) Database techniques for multiple two-dimensional polyacrylamide gel electrophoresis analyses. Clinical Chemistry 26, 1403-1412. See http://www.lecb.ncifcrf.gov/gellab for more info.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://open2dprot.sourceforge.net/

Version:
$Date: 2005/10/21 16:33:51 $ $Revision: 1.21 $
Author:
P. Lemkin (LECB/NCI), G. Thornwall (SAIC), Frederick, MD
See Also:
Open2Dprot Home

Field Summary
 int[] cal2gray
          map pixel gray values to calibrated value (e.g., OD) by scaling it as: calibration value*1000 to gray size [0:maxGrayPixel]
 int calCWx1
          calibration wedge computing window ULHC coordinate x
 int calCWx2
          ( calibration wedge computing window LRHC coordinate x
 int calCWy1
          calibration wedge computing window ULHC coordinate y
 int calCWy2
          calibration wedge computing window LRHC coordinate y
 java.lang.String calFileDate
          Date associated with the .cal file.
static int calibCtr
          Master Calibration counter
 java.lang.String calImageFile
          Image file associated with the .cal file if not null.
private  DbSample dbSample
          Global instances
private static boolean DBUG_CALIB
          Local debugging flag set in CalibrateOD.main() test code
private static boolean DBUG_DEF_DATA
          debugging
 int[] gHist
          Histogram of pix4 AVERAGE Size [0:maxGrayPixel+1]
 int[] gray2cal
           
 boolean hasCalMapFlag
          Indicates that there is an valid mapGrayToCal map else if it was set to 1:1 the flag is set false.
 int[] hist
          histogram of pixel data in ND computing window of [0:255]
 int histSize
          Histogram size is maxGrayPixel+1
 int initialMaxPeaks
          the value of maxPeaks BEFORE running the peak finder
 java.lang.String manufacturerPartNbr
          optional manufacturer part number for the step wedge
 float[] mapGrayToCal
           
static int MAX_GRAY
          Maximum gray value possible defaults to 8-bits, but could overide if the image has more bits/pixel (i.e.
static int MAX_WEDGE_STEPS
          Maximum # of calibration Wedge and peak values in the peak table
 int maxCalSteps
          eg.
 int maxGhist
          Histogram statistics [for use in FUTURE]
 int maxGrayValue
          max gray value found in the image and it is <= 255
 int maxPeaks
          eg.
 int meanGhist
          Histogram statistics [for use in FUTURE]
 int minGhist
          Histogram statistics [for use in FUTURE]
 int nbrWedgePeaks
          Number of peaks in the calibration step wedge if it is not 0.
 int pTileGhist
          Histogram statistics [for use in FUTURE]
 int scaledMaxOD
          This is the max value index for cal2gray[] it is computed as cal2gray.length-1
 java.lang.String units
          full name units used in the step wedge.
 java.lang.String unitsAbbrev
          abbreviation of units name used in the step wedge E.g., "od"
static java.lang.String VERSION
          Version for this module
 float[] wedgeCalValues
          Calibration value (could be OD) for corresponding wedge point [0:maxCalSteps-1].
 int[] wedgeGrayValues
          Gray value for corresponding wedge point [0:maxPeaks-1].
 boolean wedgeRoiOKflag
          Had a valid calibration wedge ROI when came into the wizard
 
Constructor Summary
CalibrateOD()
          CalibrateOD() - constructor for base instance.
CalibrateOD(DbSample dbSample, int maxGray)
          CalibrateOD() - constructor to set up the initial map.
CalibrateOD(int maxGray)
          CalibrateOD() - constructor to set up the initial map.
 
Method Summary
 float[] calcCalib()
          calcCalib() - continuous piecewise linear calibration od(gray)
 boolean calcFindHistPeaksAndExtrapolate(int[] hist)
          calcFindHistPeaksAndExtrapolate() - set up histogram, peaks and extrapolate map for the current Wedge ROI histogram.
 boolean calcHistFindPeaksAndExtrapolate()
          calcHistFindPeaksAndExtrapolate() - set up histogram, peaks and extrapolate map for the current Wedge ROI.
 boolean calcHistogramFromPeaks(float[] calDataList, int[] grayDataList, int nCalSteps, int nGrayPeaks)
          calcHistogramFromPeaks() - compute "pseudo" grayscale histogram from lists peaks of peaks.
 boolean calcO2CandC2OscaledMaps()
          calcO2CandC2OscaledMaps() - setup gray2cal[] and cal2gray[] scaled maps given mapGrayToCal[] map.
 boolean calcWedgeHistogram(int x1, int y1, int x2, int y2)
          calcWedgeHistogram() - compute grayscale histogram in the image specified as dbSample.pix under the specified by the Wedge computing window region of interest (ROI)[x1:x2, y1:y2].
 void clean()
          clean() - clean up before init or when kill instance before GC
 boolean demo_setDefaultWedgeData_LeukemiaGels()
          demo_setDefaultWedgeData_LeukemiaGels() - setup the ND wedge data for the 4 demo GELLAB-II PPX leukemia gels release with Open2Dprot.
 java.lang.String extrapolateNDwedgeMap()
          extrapolateNDwedgeMap() - extrapolate the maxCalSteps ND wedge peaks in wedgeCalValues[0:maxCalSteps-1] with corresponding gray values wedgeGrayValues[0:maxCalSteps-1] into a piecewise linear mapGrayToCal[0:maxGray] array.
 java.lang.String extrapolateNDwedgeMap(int maxGray, int maxCalSteps, int maxPeaks, int[] wedgeGrayValues, float[] wedgeCalValues)
          extrapolateNDwedgeMap() - extrapolate the maxCalSteps ND wedge peaks in wedgeCalValues[0:maxCalSteps-1] with corresponding gray values wedgeGrayValues[0:maxCalSteps-1] into a piecewise linear mapGrayToCal[0:maxGray] array.
 int[] findPeaks(int maxGray, int maxPeaksAllowed, int[] sHist, int startRange, int avgDist, int minDist, int lookBackWidth, float freqStoN, int minHistFreqPeakValue, boolean smoothpeakIdxListFlag, boolean useShrinkingMinDistanceFlag)
          findPeaks() - Find the peaks in the histogram sHist[].
 boolean findPeakTableSizes()
          findPeakTableSizes() - find the current maxPeaks and maxNDvalues from non-zero values in the peaks table.
 float[] getCalTable()
          getCalTable() - get calibration wedgeCalValues[0:maxCalSteps-1] values
 int[] getGrayValueTable()
          getGrayValueTable() - get calibration grayscale[0:maxPeaks-1]
 boolean getHasCalMapFlag()
          getHasCalMapFlag() - return the status of the Gray to calibration map.
 float[] getMapGrayToCal()
          getmapGrayToCal() - return the mapGrayToCal[0:maxGray-1].
(package private)  java.lang.String getStateStr()
          getStateStr() - get this calibration state as a string
 java.lang.String getUnits()
          getUnits() - get Wedge units, e.g.
 java.lang.String getUnitsAbbrev()
          getUnitsAbbrev() - get Wedge units abbreviation, e.g.
 java.lang.String getUnitsManufacturerPartNbr()
          getUnitsManufacturerPartNbr() - get Wedge manufacturerPartNbr
 void init()
          init() - init the calibration, default to 256 gray value 1:1
 void init(int maxGray)
          init() - init the calibration with calibration map
 void init(int maxGray, float[] mapGrayToCal)
          init() - init the calibration with calibration map
 boolean isValidROI(int rX1, int rY1, int rX2, int rY2)
          isValidROI() - check if current region of interest (ROI) is valid
 boolean isValidWedgeROI()
          isValidWedgeROI() - check if Wedge ROI is valid
static void main(java.lang.String[] args)
          main() - for testing and optimizing parameters for findPeak method using preset data from GELLAb-II Leukemia-AML gel image (gel 0324.1).
 void setCalTable(float[] calValues, int nCalValues)
          setCalTable() - set calibration wedgeCalValues[0:maxCalSteps-1] values
 void setDbSample(DbSample dbSample)
          setDbSample() - set the database sample object on this calibration instance.
 void setDefaultUnits()
          setDefaultUnits() - set the default to units to "Optical density", unitsAbbrev to "od" and unitsManufacturerPartNbr to "< opt.
 void setGrayValueTable(int[] grayValues, int nGrayValues)
          setGrayValueTable() - get calibration grayscale[0:maxPeaks-1] values
 void setMapGrayToCal(float[] newGrayToODMap, int maxGray)
          setMapGrayToCal() - change the mapGrayToCal to the specified Gray to OD map.
 void setNDwedgeTable(int[] wedgeGrayValues, float[] wedgeCalValues, int maxCalSteps, int maxPeaks, int maxGrayValue)
          setNDwedgeTable() - set ND step wedge calibration set of (grayscale,OD) wedge values, # of steps and max grayvalue [CHECK] we may want to copy the data to fixed size arrays [0:MAX_WEDGE_STEPS-1].
 void setUnits(java.lang.String units)
          setUnits() - set Wedge units, e.g.
 void setUnitsAbbrev(java.lang.String unitsAbbrev)
          setUnitsAbbrev() - set Wedge units abbreviation, e.g.
 void setUnitsManufacturerPartNbr(java.lang.String manufacturerPartNbr)
          setUnitsManufacturerPartNbr() - set Wedge manufacturerPartNbr
 boolean setupCalAndGrayMaps(int maxGray, float[] mapGrayToCal)
          setupCalAndGrayMaps() - set up the mapGrayToCal, gray2cal, and cal2gray maps.
 boolean setWedgeCalData(float[] mapGrayToCalA, float[] wedgeCalValuesA, int[] wedgeGrayValuesA, int maxGrayPixelA, int maxCalStepsA, int maxPeaksA, java.lang.String unitsA, java.lang.String unitsAbbrevA)
          setWedgeCalData() - setup gray2cal from either gray to OD map or from wedge calibration (peaks,od) list of values.
 boolean setWedgeROI(int calCWx1, int calCWy1, int calCWx2, int calCWy2)
          setWedgeROI() - set the Wedge Region of Interest
 boolean setWedgeROIforce(int calCWx1, int calCWy1, int calCWx2, int calCWy2)
          setWedgeROIforce() - force setting the Wedge Region of Interest reguardless of whether it is valid or not.
 int[] smoothHistogram(int[] hDataOrig, int nTimes, int windowWidth, int noiseThreshold)
          smoothHistogram() - Compute smoothed histogram of hist[0:maxGray] into hData[0:maxGray] using 'Disaster Analysis'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version for this module

See Also:
Constant Field Values

DBUG_DEF_DATA

private static final boolean DBUG_DEF_DATA
debugging

See Also:
Constant Field Values

dbSample

private DbSample dbSample
Global instances


DBUG_CALIB

private static boolean DBUG_CALIB
Local debugging flag set in CalibrateOD.main() test code


calibCtr

public static int calibCtr
Master Calibration counter


MAX_WEDGE_STEPS

public static final int MAX_WEDGE_STEPS
Maximum # of calibration Wedge and peak values in the peak table

See Also:
Constant Field Values

MAX_GRAY

public static int MAX_GRAY
Maximum gray value possible defaults to 8-bits, but could overide if the image has more bits/pixel (i.e. 10, 12, 16 bits).


nbrWedgePeaks

public int nbrWedgePeaks
Number of peaks in the calibration step wedge if it is not 0.


wedgeGrayValues

public int[] wedgeGrayValues
Gray value for corresponding wedge point [0:maxPeaks-1]. It is allocated as [0:MAX_WEDGE_STEPS-1].


wedgeCalValues

public float[] wedgeCalValues
Calibration value (could be OD) for corresponding wedge point [0:maxCalSteps-1]. It is allocated as [0:MAX_WEDGE_STEPS-1].


maxCalSteps

public int maxCalSteps
eg. # of values in the Neutral density step wedge


maxPeaks

public int maxPeaks
eg. # of gray value peaks corresponding to steps in the Neutral density step wedge. Note you can have 0 peaks but a non-zero # of calibration steps in an uncalibrated sample.


initialMaxPeaks

public int initialMaxPeaks
the value of maxPeaks BEFORE running the peak finder


units

public java.lang.String units
full name units used in the step wedge. E.g., "Optical density"


unitsAbbrev

public java.lang.String unitsAbbrev
abbreviation of units name used in the step wedge E.g., "od"


manufacturerPartNbr

public java.lang.String manufacturerPartNbr
optional manufacturer part number for the step wedge


hist

public int[] hist
histogram of pixel data in ND computing window of [0:255]


histSize

public int histSize
Histogram size is maxGrayPixel+1


wedgeRoiOKflag

public boolean wedgeRoiOKflag
Had a valid calibration wedge ROI when came into the wizard


calCWx1

public int calCWx1
calibration wedge computing window ULHC coordinate x


calCWx2

public int calCWx2
( calibration wedge computing window LRHC coordinate x


calCWy1

public int calCWy1
calibration wedge computing window ULHC coordinate y


calCWy2

public int calCWy2
calibration wedge computing window LRHC coordinate y


mapGrayToCal

public float[] mapGrayToCal

gray2cal

public int[] gray2cal

cal2gray

public int[] cal2gray
map pixel gray values to calibrated value (e.g., OD) by scaling it as: calibration value*1000 to gray size [0:maxGrayPixel]


scaledMaxOD

public int scaledMaxOD
This is the max value index for cal2gray[] it is computed as cal2gray.length-1


gHist

public int[] gHist
Histogram of pix4 AVERAGE Size [0:maxGrayPixel+1]


minGhist

public int minGhist
Histogram statistics [for use in FUTURE]


maxGhist

public int maxGhist
Histogram statistics [for use in FUTURE]


meanGhist

public int meanGhist
Histogram statistics [for use in FUTURE]


pTileGhist

public int pTileGhist
Histogram statistics [for use in FUTURE]


hasCalMapFlag

public boolean hasCalMapFlag
Indicates that there is an valid mapGrayToCal map else if it was set to 1:1 the flag is set false.


maxGrayValue

public int maxGrayValue
max gray value found in the image and it is <= 255


calImageFile

public java.lang.String calImageFile
Image file associated with the .cal file if not null. This is extra info that we may not use, but that documents the .cal file. The cal file key is "imageFile".


calFileDate

public java.lang.String calFileDate
Date associated with the .cal file. This extra info that we may not use, but that documents the .cal file. The cal file key is "date".

Constructor Detail

CalibrateOD

public CalibrateOD()
CalibrateOD() - constructor for base instance. No initialization.


CalibrateOD

public CalibrateOD(int maxGray)
CalibrateOD() - constructor to set up the initial map. Note: use setMapGrayToCal() to force a particular calibration map. Use setNDwedgeTable() to force the calibration input data prior to extrapolation. Use extrapolateNDwedgeMap() to extrapolate the calibration into the map.

Parameters:
maxGray - is the maximum number of gray values possible in image
See Also:
clean(), setMapGrayToCal(float[], int), setNDwedgeTable(int[], float[], int, int, int)

CalibrateOD

public CalibrateOD(DbSample dbSample,
                   int maxGray)
CalibrateOD() - constructor to set up the initial map. Note: use setMapGrayToCal() to force a particular calibration map. Use setNDwedgeTable() to force the calibration input data prior to extrapolation. Use extrapolateNDwedgeMap() to extrapolate the calibration into the map.

Parameters:
cs - is instance of Accession
dbSample - is instance of the sample using the calibration
maxGray - is maximum number of gray values possible in image
See Also:
clean(), setMapGrayToCal(float[], int), setNDwedgeTable(int[], float[], int, int, int)
Method Detail

setDbSample

public void setDbSample(DbSample dbSample)
setDbSample() - set the database sample object on this calibration instance.

Parameters:
dbSample - is instance of the sample using the calibration

init

public void init()
init() - init the calibration, default to 256 gray value 1:1


init

public void init(int maxGray)
init() - init the calibration with calibration map

Parameters:
maxGray - is maximum number of gray values possible in image
See Also:
clean(), setMapGrayToCal(float[], int), setNDwedgeTable(int[], float[], int, int, int)

init

public void init(int maxGray,
                 float[] mapGrayToCal)
init() - init the calibration with calibration map

Parameters:
maxGray - is maximum number of gray values possible in image
mapGrayToCal - is the default gray to OD calibration if it is not null. If null, then generate a 1:1 gray map.

clean

public void clean()
clean() - clean up before init or when kill instance before GC


calcO2CandC2OscaledMaps

public boolean calcO2CandC2OscaledMaps()
calcO2CandC2OscaledMaps() - setup gray2cal[] and cal2gray[] scaled maps given mapGrayToCal[] map. The gray2cal[] and cal2gray[] are int[] scaled by 1000 so we can do fast integer computations. The gray2cal.length is (maxGrayPixel+1 and cal2gray.length is 1000*max(wedgeGrayValues[i=0:maxGrayPixel])+1.

Returns:
true if succeed, false if no mapGrayToCal[] data.

setupCalAndGrayMaps

public boolean setupCalAndGrayMaps(int maxGray,
                                   float[] mapGrayToCal)
setupCalAndGrayMaps() - set up the mapGrayToCal, gray2cal, and cal2gray maps.

Parameters:
maxGray - is maximum number of gray values possible in image
mapGrayToCal - is the default gray to OD calibration if it is not null. If null, then generate a 1:1 gray map
return - true if setup OD map, else false implies a 1:1 gray map.

isValidWedgeROI

public boolean isValidWedgeROI()
isValidWedgeROI() - check if Wedge ROI is valid

Returns:
true if valid

setDefaultUnits

public void setDefaultUnits()
setDefaultUnits() - set the default to units to "Optical density", unitsAbbrev to "od" and unitsManufacturerPartNbr to "< opt. part # >".


setUnits

public void setUnits(java.lang.String units)
setUnits() - set Wedge units, e.g. "Optical density", "Counts Per Minute", etc.

Parameters:
units - to use. It is "gray-value" if never defined.

getUnits

public java.lang.String getUnits()
getUnits() - get Wedge units, e.g. "Optical density", "Counts Per Minute", etc.

Returns:
units, it is "gray-value" if never defined.

setUnitsAbbrev

public void setUnitsAbbrev(java.lang.String unitsAbbrev)
setUnitsAbbrev() - set Wedge units abbreviation, e.g. "od", "CPM", etc.

Parameters:
units - to use. It is "gray-value" if never defined.

getUnitsAbbrev

public java.lang.String getUnitsAbbrev()
getUnitsAbbrev() - get Wedge units abbreviation, e.g. "od", "CPM", etc.

Returns:
unitsAbbrev, it is "gray" if never defined.

setUnitsManufacturerPartNbr

public void setUnitsManufacturerPartNbr(java.lang.String manufacturerPartNbr)
setUnitsManufacturerPartNbr() - set Wedge manufacturerPartNbr

Parameters:
units - to use. It is "gray-value" if never defined.

getUnitsManufacturerPartNbr

public java.lang.String getUnitsManufacturerPartNbr()
getUnitsManufacturerPartNbr() - get Wedge manufacturerPartNbr

Returns:
unitsAbbrev, it is "gray" if never defined.

setMapGrayToCal

public void setMapGrayToCal(float[] newGrayToODMap,
                            int maxGray)
setMapGrayToCal() - change the mapGrayToCal to the specified Gray to OD map. However, if the map does not exist then make a (maxGray+1) level 1:1 map.

Parameters:
newGrayToODMap - is the new map [0:maxGray] or null
maxGray - is the number of gray values in the 1:1 map to create if the newGrayToODMap is null.

getMapGrayToCal

public float[] getMapGrayToCal()
getmapGrayToCal() - return the mapGrayToCal[0:maxGray-1].

Returns:
mapGrayToCal map.

getHasCalMapFlag

public boolean getHasCalMapFlag()
getHasCalMapFlag() - return the status of the Gray to calibration map.

Returns:
true if it exists

getGrayValueTable

public int[] getGrayValueTable()
getGrayValueTable() - get calibration grayscale[0:maxPeaks-1]

Returns:
gray value list from gray to OD calibration

getCalTable

public float[] getCalTable()
getCalTable() - get calibration wedgeCalValues[0:maxCalSteps-1] values

Returns:
list of calibrated values

setGrayValueTable

public void setGrayValueTable(int[] grayValues,
                              int nGrayValues)
setGrayValueTable() - get calibration grayscale[0:maxPeaks-1] values

Parameters:
grayValues - list of gray values
nGrayValues - is size of list that is used

setCalTable

public void setCalTable(float[] calValues,
                        int nCalValues)
setCalTable() - set calibration wedgeCalValues[0:maxCalSteps-1] values

Parameters:
calValues - list of calibrated values
nCalValues - is size of list that is used

setWedgeCalData

public boolean setWedgeCalData(float[] mapGrayToCalA,
                               float[] wedgeCalValuesA,
                               int[] wedgeGrayValuesA,
                               int maxGrayPixelA,
                               int maxCalStepsA,
                               int maxPeaksA,
                               java.lang.String unitsA,
                               java.lang.String unitsAbbrevA)
setWedgeCalData() - setup gray2cal from either gray to OD map or from wedge calibration (peaks,od) list of values.
  ND step wedge calibration:
      [wedgeGrayValues[], wedgeCalValues[], units]
  This will the extrapolating the ND wedge calibration into
  gray2cal[] given GRAYSCALE to OD values by calling
     extrapolateNDWedgeMap(false,wedgeGrayValues,wedgeCalValues,
                           gray2cal)

Parameters:
mapGrayToCalA - is [0:maxGrayPixelA-1] map if not null
wedgeCalValuesA - is[0:maxCalStepsA-1] list of Wedge calib. values
wedgeGrayValuesA - is[0:maxPeaksA-1] list of Wedge gray values
maxGrayPixelA -
maxCalStepsA -
maxPeaksA -
unitsA - units
unitsAbbrevA -
Returns:
true if found calibration

setNDwedgeTable

public void setNDwedgeTable(int[] wedgeGrayValues,
                            float[] wedgeCalValues,
                            int maxCalSteps,
                            int maxPeaks,
                            int maxGrayValue)
setNDwedgeTable() - set ND step wedge calibration set of (grayscale,OD) wedge values, # of steps and max grayvalue [CHECK] we may want to copy the data to fixed size arrays [0:MAX_WEDGE_STEPS-1].

Parameters:
wedgeGrayValues - of calibration step wedge [0:maxCalSteps-1]
wedgeCalValues - of calibration step wedge [0:maxCalSteps-1]
maxCalSteps - of Step wedge calibration values
maxGrayValue - is max gray value of calibration

findPeakTableSizes

public boolean findPeakTableSizes()
findPeakTableSizes() - find the current maxPeaks and maxNDvalues from non-zero values in the peaks table. NOTE: includes debugging tools.

Returns:
true if maxNDvalues and maxPeaks are > 0.

calcCalib

public float[] calcCalib()
calcCalib() - continuous piecewise linear calibration od(gray)

Returns:
piecewise linear OD calibration, null if failed. [TODO]

extrapolateNDwedgeMap

public java.lang.String extrapolateNDwedgeMap()
extrapolateNDwedgeMap() - extrapolate the maxCalSteps ND wedge peaks in wedgeCalValues[0:maxCalSteps-1] with corresponding gray values wedgeGrayValues[0:maxCalSteps-1] into a piecewise linear mapGrayToCal[0:maxGray] array. If the Wedge data is not well formed, the mapGrayToCal[0:maxGray] contains a 1:1 mapping of grayscale data. Otherwise, it computes the PWL interpolation of Grayvalue to OD between successive peaks.

NOTE: Use setNDwedgeTable() to set the calibration input data prior to doing the extrapolation.

This code was drived from GELLAB-II, Lemkin etal., NCI.

Returns:
null if succeed and setup the mapGrayToCal [0:maxGray] lookup table in the class instance. If not null, it is the error message.
See Also:
setNDwedgeTable(int[], float[], int, int, int)

extrapolateNDwedgeMap

public java.lang.String extrapolateNDwedgeMap(int maxGray,
                                              int maxCalSteps,
                                              int maxPeaks,
                                              int[] wedgeGrayValues,
                                              float[] wedgeCalValues)
extrapolateNDwedgeMap() - extrapolate the maxCalSteps ND wedge peaks in wedgeCalValues[0:maxCalSteps-1] with corresponding gray values wedgeGrayValues[0:maxCalSteps-1] into a piecewise linear mapGrayToCal[0:maxGray] array. If the Wedge data is not well formed, the mapGrayToCal[0:maxGray] contains a 1:1 mapping of grayscale data. Otherwise, it computes the PWL interpolation of Grayvalue to OD between successive peaks.

This code was drived from GELLAB-II, Lemkin etal., NCI.

Parameters:
maxGray - is max # of gray values (i.e. maxGrayValue)
maxCalSteps - is number of OD steps
maxPeaks - is current number of peaks
wedgeGrayValues - is the gray value peak [0:maxPeaks -1]
wedgeCalValues - is the OD wedge value [0:maxCalSteps -1]
Returns:
null if succeed and setup the mapGrayToCal [0:maxGray] lookup table in the class instance. If not null, it is the error message.

findPeaks

public int[] findPeaks(int maxGray,
                       int maxPeaksAllowed,
                       int[] sHist,
                       int startRange,
                       int avgDist,
                       int minDist,
                       int lookBackWidth,
                       float freqStoN,
                       int minHistFreqPeakValue,
                       boolean smoothpeakIdxListFlag,
                       boolean useShrinkingMinDistanceFlag)
findPeaks() - Find the peaks in the histogram sHist[]. This is used for finding the gray scale values for the ND wedge peaks. Set the peaks (indices of the sHist[]) into histPeaksFound[0:#peaks-1].
NOTE this assumes a decreasing distance between the peaks for higher gray values indices.
This code was drived from GELLAB-II, Lemkin et al., NCI. NOTE: This was optimized for scans from the RTPP and probably needs to be retuned when looking at different data.
 Suggested parameter values:
   startRange                  = 15   
   avgDist                     = 3
   minDist                     = 5
   lookBackWidth=              = 2
   freqStoN                    = 10.0
   minHistFreqPeakValue = 100 (for CCD camera, 20 for VIDICON)
   smoothpeakIdxListFlag     = true
   useShrinkingMinDistanceFlag = true

Parameters:
maxGray - is max gray value in the histogram
maxPeaksAllowed - is max # steps allowed
sHist - is the smoothed histogram of the data [0:maxGray-1]. For example, you could use the smoothHistogram() method to smooth them.
startRange - is 1st gray value to search from. If was 0, then we might pick up false noise peaks
avgDist - is expected distance between peaks in sHist[]
minDist - is minimum distance allowed between peaks in sHist[]
lookBackWidth - is the number of bins to look back in sHist[] when tracking a peak so as to ignore a few noisy data when "climbing" a peak. The min is 1, max is minDist-1.
freqStoN - is the frequency signalToNoise (S/N) used in computing the minHistFreqPeakValue if the user specified it as > 0.0. If the user specifies 1.0, it defaults freqStoN is 10.0. I.e., if maxFreq is 400, then the default estimated minHistFreqPeakValue is computed as 40. The actual value of minHistFreqPeakValue used is the max of the S/N estimated value and the value specified by the user in the next parameter.
minHistFreqPeakValue - is minimum histogram peak value for it to be considered as a peak
smoothpeakIdxListFlag - is do local smoothing optimization
useShrinkingMinDistanceFlag - to shrink the minimum distance between peaks as we find more peaks in going from min gray to max gray values. We may need this for some scanner data (e.g., CCD scanners since they a log response).
Returns:
list of gray value peaks in the histogram histPeaksFound[]

smoothHistogram

public int[] smoothHistogram(int[] hDataOrig,
                             int nTimes,
                             int windowWidth,
                             int noiseThreshold)
smoothHistogram() - Compute smoothed histogram of hist[0:maxGray] into hData[0:maxGray] using 'Disaster Analysis'.

This code was drived from GELLAB-II, Lemkin etal., NCI.

Parameters:
hDataOrig - histogram of size [0:maxGray] to be smoothed.
nTimes - is number of times to iterate
windowWidth - smoothing window width
noiseThreshold - noise threshold to ensure just find the peaks
Returns:
the smoothed histogram [0:maxGray]

getStateStr

java.lang.String getStateStr()
getStateStr() - get this calibration state as a string

Parameters:
dbSample - is the sample data to use
Returns:
state string

isValidROI

public boolean isValidROI(int rX1,
                          int rY1,
                          int rX2,
                          int rY2)
isValidROI() - check if current region of interest (ROI) is valid

Parameters:
rX1 - - ULHC x coordinate
rY1 - - ULHC y coordinate
rX2 - - LRHC x coordinate
rY2 - - LRHC y coordinate
Returns:
true if valid

calcWedgeHistogram

public boolean calcWedgeHistogram(int x1,
                                  int y1,
                                  int x2,
                                  int y2)
calcWedgeHistogram() - compute grayscale histogram in the image specified as dbSample.pix under the specified by the Wedge computing window region of interest (ROI)[x1:x2, y1:y2]. The result is in this.hist[] which is created here.

Parameters:
x1 - - ULHC x coordinate
y1 - - ULHC y coordinate
x2 - - LRHC x coordinate
y2 - - LRHC y coordinate
Returns:
test and set the Wedge ROI, compute the ROI histogram and then return true; else return false
See Also:
setWedgeROI(int, int, int, int)

calcHistogramFromPeaks

public boolean calcHistogramFromPeaks(float[] calDataList,
                                      int[] grayDataList,
                                      int nCalSteps,
                                      int nGrayPeaks)
calcHistogramFromPeaks() - compute "pseudo" grayscale histogram from lists peaks of peaks. The maximum gray value is dbSample.maxGrayPixel.

Parameters:
calDataList - is [0:nCalSteps-1] of calibrated data
grayDataList - is [0:nGrayPeaks-1] of gray level peaks (sorted)
nCalSteps - # of calibgrated values
nGrayPeaks - # of gray value peaks
Returns:
true if generate a pseudo histogram from grayDataList, false if problems

setWedgeROI

public boolean setWedgeROI(int calCWx1,
                           int calCWy1,
                           int calCWx2,
                           int calCWy2)
setWedgeROI() - set the Wedge Region of Interest

Parameters:
calCWx1 -
calCWy1 -
calCWx2 -
calCWy2 -
Returns:
true and set the Wedge ROI if valid window, else return false
See Also:
isValidROI(int, int, int, int)

setWedgeROIforce

public boolean setWedgeROIforce(int calCWx1,
                                int calCWy1,
                                int calCWx2,
                                int calCWy2)
setWedgeROIforce() - force setting the Wedge Region of Interest reguardless of whether it is valid or not. Do Not check if args are valid. This lets you set an invalid ROI.

Parameters:
calCWx1 -
calCWy1 -
calCWx2 -
calCWy2 -
Returns:
true if ROI if valid window, else return false
See Also:
isValidROI(int, int, int, int)

calcHistFindPeaksAndExtrapolate

public boolean calcHistFindPeaksAndExtrapolate()
calcHistFindPeaksAndExtrapolate() - set up histogram, peaks and extrapolate map for the current Wedge ROI. Compute the Wedge ROI histogram in from a subset of dbSample.pix[dbSample.pixWidth*dbSample.pixHeight]. Only extrapolate the # of OD values > 0.0. There may be more gray peaks than OD values, but leave them there since we may want to delete false-peaks in the middle which would move valid-peaks down (to the proper place) in the gray peaks list.

NOTE: you must set the wedge ROI first using setWedgeROI().

Returns:
true if success, false if ND CW ROI does not exist.
See Also:
isValidROI(int, int, int, int), calcWedgeHistogram(int, int, int, int), calcFindHistPeaksAndExtrapolate(int[])

calcFindHistPeaksAndExtrapolate

public boolean calcFindHistPeaksAndExtrapolate(int[] hist)
calcFindHistPeaksAndExtrapolate() - set up histogram, peaks and extrapolate map for the current Wedge ROI histogram. Only extrapolate the # of OD values > 0.0. There may be more gray peaks than OD values, but leave them there since we may want to delete false-peaks in the middle which would move valid-peaks down (to the proper place) in the gray peaks list.

NOTE: you must set the wedge ROI first using setWedgeROI().

Parameters:
hist - is raw calibration histogram [0:histSize-1].
Returns:
true if success, false if ND CW ROI does not exist.
See Also:
findPeaks(int, int, int[], int, int, int, int, float, int, boolean, boolean), findPeakTableSizes(), extrapolateNDwedgeMap()

demo_setDefaultWedgeData_LeukemiaGels

public boolean demo_setDefaultWedgeData_LeukemiaGels()
demo_setDefaultWedgeData_LeukemiaGels() - setup the ND wedge data for the 4 demo GELLAB-II PPX leukemia gels release with Open2Dprot. Setup the ROI for the ND wedge for the gel. Only extrapolate the # of OD values > 0.0. There may be more gray peaks than OD values, but leave them there since we may want to delete false-peaks in the middle which would move valid-peaks down (to the proper place) in the gray peaks list.

Returns:
true if it is a valid leukemia gel

main

public static void main(java.lang.String[] args)
main() - for testing and optimizing parameters for findPeak method using preset data from GELLAb-II Leukemia-AML gel image (gel 0324.1).

Parameters:
args - is the command line arg list