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