use of net.imagej.Dataset in project vcell by virtualcell.
the class DatasetSelectionPanel method addComboBox.
public void addComboBox(Dataset[] datasets, String description) {
JComboBox<Dataset> comboBox = new JComboBox<>(datasets);
add(new JLabel(description));
add(comboBox);
datasetMap.put(description, comboBox);
}
use of net.imagej.Dataset in project vcell by virtualcell.
the class PlotROIStats method run.
@Override
public void run() {
Plot plot = new ColorPlot("ROI Mean Intensity", "Time", "Mean Intensity");
StringBuilder legendLabels = new StringBuilder();
for (RandomAccessibleInterval<T> data : datasetROIsMap.keySet()) {
if (data instanceof Dataset) {
legendLabels.append(((Dataset) data).getName());
legendLabels.append(": ");
}
List<Overlay> overlays = datasetROIsMap.get(data);
for (int i = 0; i < overlays.size(); i++) {
Overlay overlay = overlays.get(i);
RandomAccessibleInterval<T> cropped = crop(data, overlay);
Pair<double[], double[]> xyPair = (Pair<double[], double[]>) ops.run("imageStatsForPlotting", ImageStatsForPlotting.MEAN, cropped);
plot.addPoints(xyPair.getA(), xyPair.getB(), Plot.LINE);
legendLabels.append("ROI ");
legendLabels.append(i + 1);
legendLabels.append("\n");
}
}
plot.addLegend(legendLabels.toString());
plot.show();
}
use of net.imagej.Dataset in project vcell by virtualcell.
the class VCellResultService method importCsv.
public Dataset importCsv(File directory) throws FileNotFoundException {
File[] files = directory.listFiles();
// TODO: Better handling
if (files == null)
return null;
ArrayList<ArrayList<Float>> timeSeries = new ArrayList<>(files.length);
Scanner scanner;
int dataSize = 0;
for (File file : files) {
scanner = new Scanner(file);
scanner.useDelimiter("[,\n]");
while (scanner.hasNext() && !scanner.hasNextDouble()) {
scanner.next();
}
if (!scanner.hasNextDouble()) {
scanner.close();
return null;
}
ArrayList<Float> data = new ArrayList<>();
while (scanner.hasNextDouble()) {
data.add(scanner.nextFloat());
}
scanner.close();
timeSeries.add(data);
dataSize = data.size();
}
int[] dimensions = { dataSize, timeSeries.size() };
Img<FloatType> img = new ArrayImgFactory<FloatType>().create(dimensions, new FloatType());
Cursor<FloatType> cursor = img.localizingCursor();
while (cursor.hasNext()) {
cursor.next();
int xPos = cursor.getIntPosition(0);
int tPos = cursor.getIntPosition(1);
Float val = timeSeries.get(tPos).get(xPos);
cursor.get().set(val);
}
Dataset dataset = datasetService.create(img);
// Drop single dimensions
@SuppressWarnings("unchecked") ImgPlus<FloatType> imgPlus = (ImgPlus<FloatType>) dataset.getImgPlus();
FinalInterval interval = Intervals.createMinMax(0, 0, imgPlus.dimension(0) - 1, imgPlus.dimension(1) - 1);
ImgPlus<FloatType> cropped = ops.transform().crop(imgPlus, interval, true);
dataset.setImgPlus(cropped);
System.out.println(dataset.numDimensions());
dataset.setName(directory.getName());
return dataset;
}
use of net.imagej.Dataset in project vcell by virtualcell.
the class CompareController method getMaskFromGeometry.
private RandomAccessibleInterval<BitType> getMaskFromGeometry() {
DatasetSelectionPanel panel = new DatasetSelectionPanel();
List<Dataset> geometryList = model.getProject().getGeometry();
final String description = "Geometry: ";
panel.addComboBox(geometryList.toArray(new Dataset[geometryList.size()]), description);
int returnVal = JOptionPane.showConfirmDialog(view, panel, "Select cell geometry", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (returnVal == JOptionPane.OK_OPTION) {
Dataset geometry = panel.getSelectedDatasetForDescription(description);
@SuppressWarnings("unchecked") RandomAccessibleInterval<BitType> mask = (RandomAccessibleInterval<BitType>) opService.run("largestRegionSlice", geometry);
return mask;
}
return null;
}
use of net.imagej.Dataset in project vcell by virtualcell.
the class CompareView method setContent.
@Override
public void setContent(DisplayPanel displayPanel) {
for (int i = 0; i < panels.size(); i++) {
if (i >= datasets.size())
break;
JPanel panel = panels.get(i);
if (panel.getComponentCount() == 0) {
SwingImageDisplayPanel imagePanel = (SwingImageDisplayPanel) displayPanel;
Dataset dataset = datasets.get(i);
datasetImagePanelMap.put(dataset, imagePanel.getDisplay());
panel.add(imagePanel, BorderLayout.CENTER);
labels.get(i).setText(dataset.getName());
break;
}
}
}
Aggregations