Search in sources :

Example 11 with RowColumnResultSet

use of cbit.vcell.math.RowColumnResultSet in project vcell by virtualcell.

the class OptContext method computeSolution.

public RowColumnResultSet computeSolution(double[] parameterValues, NormalizedSampleFunction[] rois, double[] times) {
    double[][] simData = optModel.getSolution(parameterValues, times);
    ArrayList<String> colNames = new ArrayList<String>();
    colNames.add("t");
    for (NormalizedSampleFunction roi : rois) {
        colNames.add(roi.getName());
    }
    RowColumnResultSet results = new RowColumnResultSet(colNames.toArray(new String[0]));
    for (int i = 0; i < times.length; i++) {
        double[] row = new double[rois.length + 1];
        row[0] = times[i];
        for (int j = 0; j < rois.length; j++) {
            row[j + 1] = simData[j][i];
        }
        results.addRow(row);
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 12 with RowColumnResultSet

use of cbit.vcell.math.RowColumnResultSet in project vcell by virtualcell.

the class OptContext method getExperimentalData.

public RowColumnResultSet getExperimentalData(NormalizedSampleFunction[] rois) {
    ArrayList<String> colNames = new ArrayList<String>();
    colNames.add("t");
    for (NormalizedSampleFunction roi : rois) {
        colNames.add(roi.getName());
    }
    RowColumnResultSet results = new RowColumnResultSet(colNames.toArray(new String[0]));
    for (int i = 0; i < expTimePoints.length; i++) {
        double[] row = new double[rois.length + 1];
        row[0] = expTimePoints[i];
        for (int j = 0; j < rois.length; j++) {
            row[j + 1] = expData[j][i];
        }
        results.addRow(row);
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 13 with RowColumnResultSet

use of cbit.vcell.math.RowColumnResultSet in project vcell by virtualcell.

the class WorkflowObjectsPanel method hasDisplayData.

private boolean hasDisplayData(TaskContext taskContext, WorkflowObject workflowObject) {
    if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
        String title = parametersFunctionsTableModel.getName(workflowObject);
        WindowListener listener = new WindowAdapter() {
        };
        Object data = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            data = taskContext.getRepository().getData(dataHolder);
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
        }
        if (data instanceof RowColumnResultSet || data instanceof ROI || data instanceof ProfileData[] || data instanceof Image || data instanceof ImageTimeSeries) {
            return true;
        }
    }
    return false;
}
Also used : DataOutput(org.vcell.workflow.DataOutput) WindowListener(java.awt.event.WindowListener) WindowAdapter(java.awt.event.WindowAdapter) ProfileData(org.vcell.optimization.ProfileData) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) DataInput(org.vcell.workflow.DataInput) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 14 with RowColumnResultSet

use of cbit.vcell.math.RowColumnResultSet in project vcell by virtualcell.

the class WorkflowObjectsPanel method displayData.

private void displayData(TaskContext taskContext, WorkflowObject workflowObject) {
    if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
        String title = parametersFunctionsTableModel.getName(workflowObject);
        WindowListener listener = new WindowAdapter() {
        };
        Object data = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            data = taskContext.getRepository().getData(dataHolder);
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
        }
        if (data instanceof RowColumnResultSet) {
            RowColumnResultSet rc = (RowColumnResultSet) data;
            try {
                new DisplayPlotOp().displayPlot(rc, title, listener);
            } catch (ExpressionException e) {
                e.printStackTrace();
            }
        } else if (data instanceof ROI) {
            ROI roi = (ROI) data;
            Image image = roi.getRoiImages()[0];
            new DisplayImageOp().displayImage(image, title, listener);
        } else if (data instanceof ProfileData[]) {
            ProfileData[] profileData = (ProfileData[]) data;
            new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(profileData, title, listener);
        } else if (data instanceof Image) {
            Image image = (Image) data;
            new DisplayImageOp().displayImage(image, title, listener);
        } else if (data instanceof ImageTimeSeries) {
            ImageTimeSeries imageTimeSeries = (ImageTimeSeries) data;
            try {
                DisplayTimeSeries.displayImageTimeSeries(imageTimeSeries, title, listener);
            } catch (ImageException | IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : DataOutput(org.vcell.workflow.DataOutput) DisplayProfileLikelihoodPlotsOp(org.vcell.vmicro.op.display.DisplayProfileLikelihoodPlotsOp) WindowListener(java.awt.event.WindowListener) ImageException(cbit.image.ImageException) WindowAdapter(java.awt.event.WindowAdapter) ProfileData(org.vcell.optimization.ProfileData) IOException(java.io.IOException) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) ExpressionException(cbit.vcell.parser.ExpressionException) DataInput(org.vcell.workflow.DataInput) DisplayPlotOp(org.vcell.vmicro.op.display.DisplayPlotOp) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 15 with RowColumnResultSet

use of cbit.vcell.math.RowColumnResultSet in project vcell by virtualcell.

the class OptModelParamPanel method plotDerivedSimulationResults.

private void plotDerivedSimulationResults() {
    try {
        RowColumnResultSet simulatedData = optContext.computeSolution(getCurrentParameterValues(), fittedROIs, optContext.getExperimentalTimePoints());
        RowColumnResultSet experimentalData = optContext.getExperimentalData(fittedROIs);
        DataSource simDataSource = new DataSource.DataSourceRowColumnResultSet("opt", simulatedData, false);
        DataSource expDataSource = new DataSource.DataSourceRowColumnResultSet("exp", experimentalData, true);
        DataSource[] newDataSourceArr = new DataSource[2];
        newDataSourceArr[ARRAY_INDEX_EXPDATASOURCE] = expDataSource;
        newDataSourceArr[ARRAY_INDEX_SIMDATASOURCE] = simDataSource;
        // double valid ROI colors (not include cell and background)
        int roiSize = fittedROIs.length;
        Color[] uniqueColors = ColorUtil.generateAutoColor(roiSize, getBackground(), new Integer(0));
        Color[] colors = new Color[roiSize * 2];
        for (int i = 0; i < roiSize; i++) {
            colors[i] = uniqueColors[i];
            colors[i + roiSize] = uniqueColors[i];
        }
        int[] selectedIndices = multisourcePlotPane.getUnsortedSelectedIndices();
        multisourcePlotPane.setDataSources(newDataSourceArr, colors);
        if (selectedIndices.length == 0) {
            multisourcePlotPane.selectAll();
        } else {
            multisourcePlotPane.setUnsortedSelectedIndices(selectedIndices);
        }
    } catch (Exception e2) {
        e2.printStackTrace();
        DialogUtils.showErrorDialog(this, "Error graphing Optimizer data " + e2.getMessage());
    }
}
Also used : Color(java.awt.Color) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) DataSource(cbit.vcell.modelopt.DataSource)

Aggregations

RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)34 ROI (cbit.vcell.VirtualMicroscopy.ROI)10 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)7 File (java.io.File)6 FloatImage (cbit.vcell.VirtualMicroscopy.FloatImage)5 CSV (cbit.vcell.math.CSV)5 UserCancelException (org.vcell.util.UserCancelException)5 Generate2DOptContextOp (org.vcell.vmicro.op.Generate2DOptContextOp)5 ErrorFunction (org.vcell.vmicro.workflow.data.ErrorFunction)5 NormalizedSampleFunction (org.vcell.vmicro.workflow.data.NormalizedSampleFunction)5 OptContext (org.vcell.vmicro.workflow.data.OptContext)5 OptModel (org.vcell.vmicro.workflow.data.OptModel)5 Image (cbit.vcell.VirtualMicroscopy.Image)4 ReferenceData (cbit.vcell.opt.ReferenceData)4 SimpleReferenceData (cbit.vcell.opt.SimpleReferenceData)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 ComputeMeasurementErrorOp (org.vcell.vmicro.op.ComputeMeasurementErrorOp)4 GenerateReducedDataOp (org.vcell.vmicro.op.GenerateReducedDataOp)4 DisplayPlotOp (org.vcell.vmicro.op.display.DisplayPlotOp)4 DisplayTimeSeriesOp (org.vcell.vmicro.op.display.DisplayTimeSeriesOp)4