|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object O2Plib.misc.CalibrateOD
public class CalibrateOD
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/
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 |
---|
public static final java.lang.String VERSION
private static final boolean DBUG_DEF_DATA
private DbSample dbSample
private static boolean DBUG_CALIB
public static int calibCtr
public static final int MAX_WEDGE_STEPS
public static int MAX_GRAY
public int nbrWedgePeaks
public int[] wedgeGrayValues
public float[] wedgeCalValues
public int maxCalSteps
public int maxPeaks
public int initialMaxPeaks
public java.lang.String units
public java.lang.String unitsAbbrev
public java.lang.String manufacturerPartNbr
public int[] hist
public int histSize
public boolean wedgeRoiOKflag
public int calCWx1
public int calCWx2
public int calCWy1
public int calCWy2
public float[] mapGrayToCal
public int[] gray2cal
public int[] cal2gray
public int scaledMaxOD
public int[] gHist
public int minGhist
public int maxGhist
public int meanGhist
public int pTileGhist
public boolean hasCalMapFlag
public int maxGrayValue
public java.lang.String calImageFile
public java.lang.String calFileDate
Constructor Detail |
---|
public CalibrateOD()
public CalibrateOD(int maxGray)
maxGray
- is the maximum number of gray values possible in imageclean()
,
setMapGrayToCal(float[], int)
,
setNDwedgeTable(int[], float[], int, int, int)
public CalibrateOD(DbSample dbSample, int maxGray)
cs
- is instance of AccessiondbSample
- is instance of the sample using the calibrationmaxGray
- is maximum number of gray values possible in imageclean()
,
setMapGrayToCal(float[], int)
,
setNDwedgeTable(int[], float[], int, int, int)
Method Detail |
---|
public void setDbSample(DbSample dbSample)
dbSample
- is instance of the sample using the calibrationpublic void init()
public void init(int maxGray)
maxGray
- is maximum number of gray values possible in imageclean()
,
setMapGrayToCal(float[], int)
,
setNDwedgeTable(int[], float[], int, int, int)
public void init(int maxGray, float[] mapGrayToCal)
maxGray
- is maximum number of gray values possible in imagemapGrayToCal
- is the default gray to OD calibration if
it is not null. If null, then generate a 1:1 gray map.public void clean()
public boolean calcO2CandC2OscaledMaps()
public boolean setupCalAndGrayMaps(int maxGray, float[] mapGrayToCal)
maxGray
- is maximum number of gray values possible in imagemapGrayToCal
- is the default gray to OD calibration if
it is not null. If null, then generate a 1:1 gray mapreturn
- true if setup OD map, else false implies a 1:1 gray map.public boolean isValidWedgeROI()
public void setDefaultUnits()
public void setUnits(java.lang.String units)
units
- to use. It is "gray-value" if never defined.public java.lang.String getUnits()
public void setUnitsAbbrev(java.lang.String unitsAbbrev)
units
- to use. It is "gray-value" if never defined.public java.lang.String getUnitsAbbrev()
public void setUnitsManufacturerPartNbr(java.lang.String manufacturerPartNbr)
units
- to use. It is "gray-value" if never defined.public java.lang.String getUnitsManufacturerPartNbr()
public void setMapGrayToCal(float[] newGrayToODMap, int maxGray)
newGrayToODMap
- is the new map [0:maxGray] or nullmaxGray
- is the number of gray values in the 1:1 map to
create if the newGrayToODMap is null.public float[] getMapGrayToCal()
public boolean getHasCalMapFlag()
public int[] getGrayValueTable()
public float[] getCalTable()
public void setGrayValueTable(int[] grayValues, int nGrayValues)
grayValues
- list of gray valuesnGrayValues
- is size of list that is usedpublic void setCalTable(float[] calValues, int nCalValues)
calValues
- list of calibrated valuesnCalValues
- is size of list that is usedpublic boolean setWedgeCalData(float[] mapGrayToCalA, float[] wedgeCalValuesA, int[] wedgeGrayValuesA, int maxGrayPixelA, int maxCalStepsA, int maxPeaksA, java.lang.String unitsA, java.lang.String unitsAbbrevA)
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)
mapGrayToCalA
- is [0:maxGrayPixelA-1] map if not nullwedgeCalValuesA
- is[0:maxCalStepsA-1] list of Wedge calib. valueswedgeGrayValuesA
- is[0:maxPeaksA-1] list of Wedge gray valuesmaxGrayPixelA
- maxCalStepsA
- maxPeaksA
- unitsA
- unitsunitsAbbrevA
-
public void setNDwedgeTable(int[] wedgeGrayValues, float[] wedgeCalValues, int maxCalSteps, int maxPeaks, int maxGrayValue)
wedgeGrayValues
- of calibration step wedge [0:maxCalSteps-1]wedgeCalValues
- of calibration step wedge [0:maxCalSteps-1]maxCalSteps
- of Step wedge calibration valuesmaxGrayValue
- is max gray value of calibrationpublic boolean findPeakTableSizes()
public float[] calcCalib()
public java.lang.String extrapolateNDwedgeMap()
NOTE: Use setNDwedgeTable() to set the calibration input data prior to doing the extrapolation.
This code was drived from GELLAB-II, Lemkin etal., NCI.
setNDwedgeTable(int[], float[], int, int, int)
public java.lang.String extrapolateNDwedgeMap(int maxGray, int maxCalSteps, int maxPeaks, int[] wedgeGrayValues, float[] wedgeCalValues)
This code was drived from GELLAB-II, Lemkin etal., NCI.
maxGray
- is max # of gray values (i.e. maxGrayValue)maxCalSteps
- is number of OD stepsmaxPeaks
- is current number of peakswedgeGrayValues
- is the gray value peak [0:maxPeaks -1]wedgeCalValues
- is the OD wedge value [0:maxCalSteps -1]
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)
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
maxGray
- is max gray value in the histogrammaxPeaksAllowed
- is max # steps allowedsHist
- 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 peaksavgDist
- 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 peaksmoothpeakIdxListFlag
- is do local smoothing optimizationuseShrinkingMinDistanceFlag
- 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).
public int[] smoothHistogram(int[] hDataOrig, int nTimes, int windowWidth, int noiseThreshold)
This code was drived from GELLAB-II, Lemkin etal., NCI.
hDataOrig
- histogram of size [0:maxGray] to be smoothed.nTimes
- is number of times to iteratewindowWidth
- smoothing window widthnoiseThreshold
- noise threshold to ensure just find the peaks
java.lang.String getStateStr()
dbSample
- is the sample data to use
public boolean isValidROI(int rX1, int rY1, int rX2, int rY2)
rX1
- - ULHC x coordinaterY1
- - ULHC y coordinaterX2
- - LRHC x coordinaterY2
- - LRHC y coordinate
public boolean calcWedgeHistogram(int x1, int y1, int x2, int y2)
x1
- - ULHC x coordinatey1
- - ULHC y coordinatex2
- - LRHC x coordinatey2
- - LRHC y coordinate
setWedgeROI(int, int, int, int)
public boolean calcHistogramFromPeaks(float[] calDataList, int[] grayDataList, int nCalSteps, int nGrayPeaks)
calDataList
- is [0:nCalSteps-1] of calibrated datagrayDataList
- is [0:nGrayPeaks-1] of gray level peaks (sorted)nCalSteps
- # of calibgrated valuesnGrayPeaks
- # of gray value peaks
public boolean setWedgeROI(int calCWx1, int calCWy1, int calCWx2, int calCWy2)
calCWx1
- calCWy1
- calCWx2
- calCWy2
-
isValidROI(int, int, int, int)
public boolean setWedgeROIforce(int calCWx1, int calCWy1, int calCWx2, int calCWy2)
calCWx1
- calCWy1
- calCWx2
- calCWy2
-
isValidROI(int, int, int, int)
public boolean calcHistFindPeaksAndExtrapolate()
NOTE: you must set the wedge ROI first using setWedgeROI().
isValidROI(int, int, int, int)
,
calcWedgeHistogram(int, int, int, int)
,
calcFindHistPeaksAndExtrapolate(int[])
public boolean calcFindHistPeaksAndExtrapolate(int[] hist)
NOTE: you must set the wedge ROI first using setWedgeROI().
hist
- is raw calibration histogram [0:histSize-1].
findPeaks(int, int, int[], int, int, int, int, float, int, boolean, boolean)
,
findPeakTableSizes()
,
extrapolateNDwedgeMap()
public boolean demo_setDefaultWedgeData_LeukemiaGels()
public static void main(java.lang.String[] args)
args
- is the command line arg list
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |