Search in sources :

Example 1 with Dataset

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);
}
Also used : JComboBox(javax.swing.JComboBox) Dataset(net.imagej.Dataset) JLabel(javax.swing.JLabel)

Example 2 with Dataset

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();
}
Also used : ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Dataset(net.imagej.Dataset) Plot(ij.gui.Plot) ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Overlay(net.imagej.overlay.Overlay) Pair(net.imglib2.util.Pair)

Example 3 with Dataset

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;
}
Also used : Scanner(java.util.Scanner) ImgPlus(net.imagej.ImgPlus) Dataset(net.imagej.Dataset) ArrayList(java.util.ArrayList) FloatType(net.imglib2.type.numeric.real.FloatType) FinalInterval(net.imglib2.FinalInterval) File(java.io.File)

Example 4 with 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;
}
Also used : RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) BitType(net.imglib2.type.logic.BitType) Dataset(net.imagej.Dataset)

Example 5 with Dataset

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;
        }
    }
}
Also used : JPanel(javax.swing.JPanel) Dataset(net.imagej.Dataset) SwingImageDisplayPanel(net.imagej.ui.swing.viewer.image.SwingImageDisplayPanel)

Aggregations

Dataset (net.imagej.Dataset)16 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Plot (ij.gui.Plot)3 ImgPlus (net.imagej.ImgPlus)3 Img (net.imglib2.img.Img)3 BitType (net.imglib2.type.logic.BitType)3 ColorPlot (org.vcell.imagej.common.gui.ColorPlot)3 Task (org.vcell.imagej.common.gui.Task)3 VCellModel (org.vcell.imagej.common.vcell.VCellModel)3 Path (java.nio.file.Path)2 Overlay (net.imagej.overlay.Overlay)2 FinalInterval (net.imglib2.FinalInterval)2 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)2 Pair (net.imglib2.util.Pair)2 SimulationState (org.vcell.vcellij.api.SimulationState)2 DatasetIOService (io.scif.services.DatasetIOService)1 BufferedImage (java.awt.image.BufferedImage)1