}
// An empty scan needs some special attention..
if (scanLength[0] == 0) {
scanNum++;
return new SimpleScan(null, scanNum, 1,
retentionTime.doubleValue(), -1, 0, 0, null,
new DataPoint[0], false);
}
// Read mass and intensity values
Array massValueArray;
Array intensityValueArray;
try {
massValueArray = massValueVariable.read(scanStartPosition,
scanLength);
intensityValueArray = intensityValueVariable.read(
scanStartPosition, scanLength);
} catch (Exception e) {
logger.log(
Level.SEVERE,
"Could not read from variables mass_values and/or intensity_values.",
e);
throw (new IOException(
"Could not read from variables mass_values and/or intensity_values."));
}
Index massValuesIndex = massValueArray.getIndex();
Index intensityValuesIndex = intensityValueArray.getIndex();
int arrayLength = massValueArray.getShape()[0];
DataPoint completeDataPoints[] = new DataPoint[arrayLength];
for (int j = 0; j < arrayLength; j++) {
Index massIndex0 = massValuesIndex.set0(j);
Index intensityIndex0 = intensityValuesIndex.set0(j);
double mz = massValueArray.getDouble(massIndex0)
* massValueScaleFactor;
double intensity = intensityValueArray.getDouble(intensityIndex0)
* intensityValueScaleFactor;
completeDataPoints[j] = new SimpleDataPoint(mz, intensity);
}
scanNum++;
// Auto-detect whether this scan is centroided
boolean centroided = ScanUtils.isCentroided(completeDataPoints);
// Remove zero data points
DataPoint optimizedDataPoints[] = ScanUtils.removeZeroDataPoints(
completeDataPoints, centroided);
SimpleScan buildingScan = new SimpleScan(null, scanNum, 1,
retentionTime.doubleValue(), -1, 0, 0, null,
optimizedDataPoints, centroided);
return buildingScan;