Search in sources :

Example 1 with RowColumnResultSet

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

the class ReferenceDataPanel method updateReferenceDataFromFile.

/**
 * Comment
 */
private void updateReferenceDataFromFile() {
    try {
        VCFileChooser fileChooser = new VCFileChooser();
        fileChooser.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
        fileChooser.setMultiSelectionEnabled(false);
        fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_CSV);
        // Set the default file filter...
        fileChooser.setFileFilter(FileFilters.FILE_FILTER_CSV);
        // remove all selector
        fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
        File defaultPath = null;
        if (getUserPreferences() != null) {
            defaultPath = getUserPreferences().getCurrentDialogPath();
            if (defaultPath != null) {
                fileChooser.setCurrentDirectory(defaultPath);
            }
        }
        fileChooser.setDialogTitle("Import Data File");
        if (fileChooser.showOpenDialog(this) != javax.swing.JFileChooser.APPROVE_OPTION) {
            // user didn't choose save
            throw UserCancelException.CANCEL_FILE_SELECTION;
        } else {
            File selectedFile = fileChooser.getSelectedFile();
            if (selectedFile == null) {
                // no file selected (no name given)
                throw UserCancelException.CANCEL_FILE_SELECTION;
            } else {
                if (getUserPreferences() != null) {
                    File newPath = selectedFile.getParentFile();
                    if (!newPath.equals(defaultPath)) {
                        getUserPreferences().setCurrentDialogPath(newPath);
                    }
                }
                CSV csv = new CSV();
                RowColumnResultSet rowColumnResultSet = csv.importFrom(new java.io.FileReader(selectedFile));
                double[] weights = new double[rowColumnResultSet.getDataColumnCount()];
                java.util.Arrays.fill(weights, 1.0);
                ReferenceData referenceData = new SimpleReferenceData(rowColumnResultSet, weights);
                updateReferenceData(referenceData);
            }
        }
    } catch (UserCancelException e) {
    // ignore
    } catch (Exception e) {
        e.printStackTrace();
        if (e instanceof ParseException) {
            showHelp((ParseException) e);
        } else {
            DialogUtils.showErrorDialog(this, e.getMessage(), e);
        }
    }
}
Also used : SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) ReferenceData(cbit.vcell.opt.ReferenceData) CSV(cbit.vcell.math.CSV) VCFileChooser(org.vcell.util.gui.VCFileChooser) UserCancelException(org.vcell.util.UserCancelException) ParseException(java.text.ParseException) File(java.io.File) SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) ParseException(java.text.ParseException) UserCancelException(org.vcell.util.UserCancelException) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 2 with RowColumnResultSet

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

the class ReferenceDataPanel method subsample.

/**
 * Comment
 */
private ReferenceData subsample() {
    ReferenceData refData = fieldParameterEstimationTask.getModelOptimizationSpec().getReferenceData();
    if (refData == null) {
        return refData;
    }
    RowColumnResultSet rc = new RowColumnResultSet();
    String[] columnNames = refData.getColumnNames();
    for (int i = 0; i < columnNames.length; i++) {
        rc.addDataColumn(new ODESolverResultSetColumnDescription(i == timeIndex ? ReservedVariable.TIME.getName() : columnNames[i]));
    }
    for (int i = 0; i < refData.getNumDataRows(); i++) {
        rc.addRow((double[]) refData.getDataByRow(i).clone());
    }
    int desiredNumRows = refData.getNumDataRows() / 2;
    if (desiredNumRows < 3) {
        return refData;
    }
    try {
        rc.trimRows(desiredNumRows);
        double[] weights = null;
        if (refData.getColumnWeights() != null) {
            weights = (double[]) refData.getColumnWeights().clone();
        } else {
            weights = new double[refData.getColumnNames().length];
            java.util.Arrays.fill(weights, 1.0);
        }
        SimpleReferenceData srd = new SimpleReferenceData(rc, weights);
        return srd;
    } catch (Exception e) {
        e.printStackTrace(System.out);
        DialogUtils.showErrorDialog(this, e.getMessage(), e);
        return refData;
    }
}
Also used : SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) ReferenceData(cbit.vcell.opt.ReferenceData) ODESolverResultSetColumnDescription(cbit.vcell.math.ODESolverResultSetColumnDescription) SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) ParseException(java.text.ParseException) UserCancelException(org.vcell.util.UserCancelException) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 3 with RowColumnResultSet

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

the class ImportTimeSeriesFromCSV method compute0.

@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    CSV csv = new CSV();
    File inputFile = new File(context.getData(csvFile));
    RowColumnResultSet resultSet = csv.importFrom(new FileReader(inputFile));
    context.setData(timeSeries, resultSet);
}
Also used : CSV(cbit.vcell.math.CSV) FileReader(java.io.FileReader) File(java.io.File) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 4 with RowColumnResultSet

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

the class NormalizeRawBleachData method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    RowColumnResultSet rawExpDataset = context.getData(rawExpData);
    // do op
    NormalizeRawBleachDataOp op = new NormalizeRawBleachDataOp();
    RowColumnResultSet normExpDataset = op.normalizeRawBleachData(rawExpDataset);
    // set output
    context.setData(normExpData, normExpDataset);
}
Also used : RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) NormalizeRawBleachDataOp(org.vcell.vmicro.op.NormalizeRawBleachDataOp)

Example 5 with RowColumnResultSet

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

the class DisplayPlot method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    String titleString = context.getDataWithDefault(title, "no title");
    RowColumnResultSet plotdata = context.getData(plotData);
    // do op
    DisplayPlotOp op = new DisplayPlotOp();
    op.displayPlot(plotdata, titleString, null);
    // set output
    context.setData(displayed, true);
}
Also used : DisplayPlotOp(org.vcell.vmicro.op.display.DisplayPlotOp) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

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