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;
}
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;
}
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;
}
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();
}
}
}
}
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());
}
}
Aggregations