double normalizationFactorWeights[] = null;
if (normalizationType == StandardUsageType.Nearest) {
// Search for nearest standard
PeakListRow nearestStandardRow = null;
double nearestStandardRowDistance = Double.MAX_VALUE;
for (int standardRowIndex = 0; standardRowIndex < standardRows.length; standardRowIndex++) {
PeakListRow standardRow = standardRows[standardRowIndex];
double stdMZ = standardRow.getAverageMZ();
double stdRT = standardRow.getAverageRT();
double distance = MZvsRTBalance * Math.abs(mz - stdMZ)
+ Math.abs(rt - stdRT);
if (distance <= nearestStandardRowDistance) {
nearestStandardRow = standardRow;
nearestStandardRowDistance = distance;
}
}
assert nearestStandardRow != null;
// Calc and store a single normalization factor
normalizationFactors = new double[1];
normalizationFactorWeights = new double[1];
ChromatographicPeak standardPeak = nearestStandardRow
.getPeak(file);
if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
normalizationFactors[0] = standardPeak.getHeight();
} else {
normalizationFactors[0] = standardPeak.getArea();
}
logger.finest("Normalizing row #" + row.getID()
+ " using standard peak " + standardPeak
+ ", factor " + normalizationFactors[0]);
normalizationFactorWeights[0] = 1.0f;
}
if (normalizationType == StandardUsageType.Weighted) {
// Add all standards as factors, and use distance as weight
normalizationFactors = new double[standardRows.length];
normalizationFactorWeights = new double[standardRows.length];
for (int standardRowIndex = 0; standardRowIndex < standardRows.length; standardRowIndex++) {
PeakListRow standardRow = standardRows[standardRowIndex];
double stdMZ = standardRow.getAverageMZ();
double stdRT = standardRow.getAverageRT();
double distance = MZvsRTBalance * Math.abs(mz - stdMZ)
+ Math.abs(rt - stdRT);
ChromatographicPeak standardPeak = standardRow
.getPeak(file);
if (standardPeak == null) {
// What to do if standard peak is not
// available? (Currently this is ruled out by the
// setup dialog, which shows only peaks that are