use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class TwoDDataSet method run.
@Override
public void run() {
status = TaskStatus.PROCESSING;
for (int index = 0; index < totalScans; index++) {
// Cancel?
if (status == TaskStatus.CANCELED)
return;
Scan scan = scans[index];
DataPoint scanBasePeak = scan.getHighestDataPoint();
retentionTimes[index] = scan.getRetentionTime();
basePeaks[index] = (scanBasePeak == null ? 0 : scanBasePeak.getIntensity());
DataPoint[] scanDataPoints = scan.getDataPoints();
dataPointMatrix[index] = new SoftReference<DataPoint[]>(scanDataPoints);
processedScans++;
}
fireDatasetChanged();
status = TaskStatus.FINISHED;
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class ParameterSetupDialogWithScanPreview method updateTitle.
private void updateTitle(Scan currentScan) {
// Formats
NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
// Set window and plot titles
String title = "[" + previewDataFile.getName() + "] scan #" + currentScan.getScanNumber();
String subTitle = "MS" + currentScan.getMSLevel() + ", RT " + rtFormat.format(currentScan.getRetentionTime());
DataPoint basePeak = currentScan.getHighestDataPoint();
if (basePeak != null) {
subTitle += ", base peak: " + mzFormat.format(basePeak.getMZ()) + " m/z (" + intensityFormat.format(basePeak.getIntensity()) + ")";
}
spectrumPlot.setTitle(title, subTitle);
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class CombinedXICComponent method paint.
public void paint(Graphics g) {
super.paint(g);
// use Graphics2D for antialiasing
Graphics2D g2 = (Graphics2D) g;
// turn on antialiasing
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// get canvas size
Dimension size = getSize();
int colorIndex = 0;
for (Feature peak : peaks) {
// set color for current XIC
g2.setColor(plotColors[colorIndex]);
colorIndex = (colorIndex + 1) % plotColors.length;
// if we have no data, just return
if ((peak == null) || (peak.getScanNumbers().length == 0))
continue;
// get scan numbers, one data point per each scan
int[] scanNumbers = peak.getScanNumbers();
// for each datapoint, find [X:Y] coordinates of its point in
// painted image
int[] xValues = new int[scanNumbers.length + 2];
int[] yValues = new int[scanNumbers.length + 2];
// find one datapoint with maximum intensity in each scan
for (int i = 0; i < scanNumbers.length; i++) {
double dataPointIntensity = 0;
DataPoint dataPoint = peak.getDataPoint(scanNumbers[i]);
if (dataPoint != null)
dataPointIntensity = dataPoint.getIntensity();
// get retention time (X value)
double retentionTime = peak.getDataFile().getScan(scanNumbers[i]).getRetentionTime();
// calculate [X:Y] coordinates
xValues[i + 1] = (int) Math.floor((retentionTime - rtRange.lowerEndpoint()) / (rtRange.upperEndpoint() - rtRange.lowerEndpoint()) * (size.width - 1));
yValues[i + 1] = size.height - (int) Math.floor(dataPointIntensity / maxIntensity * (size.height - 1));
}
// add first point
xValues[0] = xValues[1];
yValues[0] = size.height - 1;
// add terminal point
xValues[xValues.length - 1] = xValues[xValues.length - 2];
yValues[yValues.length - 1] = size.height - 1;
// draw the peak shape
g2.drawPolyline(xValues, yValues, xValues.length);
}
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class ScanUtils method decodeDataPointsFromBytes.
public static DataPoint[] decodeDataPointsFromBytes(byte[] bytes) {
// each double is 8 bytes and we need one for m/z and one for intensity
int dpCount = bytes.length / 2 / 8;
// make a data input stream
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
DataInputStream peakStream = new DataInputStream(byteStream);
DataPoint[] dataPoints = new DataPoint[dpCount];
for (int i = 0; i < dataPoints.length; i++) {
try {
double mz = peakStream.readDouble();
double intensity = peakStream.readDouble();
dataPoints[i] = new SimpleDataPoint(mz, intensity);
} catch (IOException e) {
e.printStackTrace();
}
}
return dataPoints;
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class ScanUtils method listAllScans.
/**
* List of all scans with n signals >= noiseLevel in the specified or first massList, if none was
* specified
*
* @param massListName the name or null/empty to always use the first masslist
* @param noiseLevel
* @param minNumberOfSignals
* @return
*/
@Nonnull
public static List<Scan> listAllScans(Scan[] scans, @Nullable String massListName, double noiseLevel, int minNumberOfSignals) throws MissingMassListException {
List<Scan> filtered = new ArrayList<>();
for (Scan scan : scans) {
// find mass list: with name or first
final MassList massList = getMassListOrFirst(scan, massListName);
if (massList == null)
throw new MissingMassListException("", massListName);
// minimum number of signals >= noiseLevel
int signals = 0;
for (DataPoint dp : massList.getDataPoints()) if (dp.getIntensity() >= noiseLevel)
signals++;
if (signals >= minNumberOfSignals)
filtered.add(scan);
}
return filtered;
}
Aggregations