use of cbit.vcell.opt.Parameter in project vcell by virtualcell.
the class BatchRunXmlProducer method getXML.
/**
* This method returns a XML representation
* for a frap batch run including
*/
private static Element getXML(FRAPBatchRunWorkspace param) throws XmlParseException, cbit.vcell.parser.ExpressionException {
Element batchRunNode = new Element(MicroscopyXMLTags.FrapBatchRunTag);
// Get selected model index
Element selectedModelIdxElem = new Element(MicroscopyXMLTags.BatchRunSelectedModelTypeTag);
selectedModelIdxElem.setText(mangle(param.getSelectedModel() + ""));
batchRunNode.addContent(selectedModelIdxElem);
// Get average model parameters
Element parametersNode = new Element(MicroscopyXMLTags.ModelParametersTag);
Parameter[] avgParams = param.getAverageParameters();
if (avgParams != null) {
if (param.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF) {
parametersNode.setAttribute(MicroscopyXMLTags.PrimaryRateAttrTag, avgParams[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.PrimaryFractionAttTag, avgParams[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
} else if (param.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF) {
parametersNode.setAttribute(MicroscopyXMLTags.PrimaryRateAttrTag, avgParams[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.PrimaryFractionAttTag, avgParams[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.SecondRateAttrTag, avgParams[FRAPModel.INDEX_SECONDARY_DIFF_RATE].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.SecondFractionAttTag, avgParams[FRAPModel.INDEX_SECONDARY_FRACTION].getInitialGuess() + "");
} else if (param.getSelectedModel() == FRAPModel.IDX_MODEL_REACTION_OFF_RATE && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_REACTION_OFF_RATE) {
parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.BindingSiteConcentrationAttTag, avgParams[FRAPModel.INDEX_BINDING_SITE_CONCENTRATION].getInitialGuess() + "");
parametersNode.setAttribute(MicroscopyXMLTags.ReactionOffRateAttTag, avgParams[FRAPModel.INDEX_OFF_RATE].getInitialGuess() + "");
}
}
batchRunNode.addContent(parametersNode);
// Get frap study file lists
if (param.getFrapStudies() != null && param.getFrapStudies().size() > 0) {
Element frapStudyListNode = new Element(MicroscopyXMLTags.FrapStudyListTag);
frapStudyListNode.setAttribute(MicroscopyXMLTags.NumFrapStudyListAttrTag, Integer.toString(param.getFrapStudies().size()));
ArrayList<FRAPStudy> frapList = param.getFrapStudies();
for (int i = 0; i < frapList.size(); i++) {
if (frapList.get(i).getXmlFilename() != null) {
Element fileNameNode = new Element(MicroscopyXMLTags.FrapFileNameTag);
fileNameNode.addContent(frapList.get(i).getXmlFilename());
frapStudyListNode.addContent(fileNameNode);
}
}
batchRunNode.addContent(frapStudyListNode);
}
return batchRunNode;
}
use of cbit.vcell.opt.Parameter in project vcell by virtualcell.
the class BatchRunDetailsPanel method actionPerformed.
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == addButton) {
// check file before loading into batch run, if the file has .vfrap extension
// check if it has the model that is required by the batch run, if no, run the reference simulation and get the parameters
final Wizard loadWizard = getAddFRAPDataWizard();
if (loadWizard != null) {
loadWizard.showModalDialog(new Dimension(550, 640));
// code return
if (loadWizard.getReturnCode() == Wizard.FINISH_RETURN_CODE) {
// get newly added frapstudy
FRAPStudy fStudy = getBatchRunWorkspace().getWorkingFrapStudy();
// check if the batch run has results already and the newly loaded data should have same model ready
int batchRunSelectedModel = getBatchRunWorkspace().getSelectedModel();
if (getBatchRunWorkspace().isBatchRunResultsAvailable() && fStudy.getModels()[batchRunSelectedModel] != null && fStudy.getFrapModel(batchRunSelectedModel).getModelParameters() != null) {
Parameter[] parameters = fStudy.getFrapModel(batchRunSelectedModel).getModelParameters();
double[][] fitData = null;
if (batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT || batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
FRAPOptData optData = fStudy.getFrapOptData();
// newly loaded frapstudy doesn't have estimation data ready, generate the data
if (optData == null) {
try {
optData = new FRAPOptData(fStudy, parameters.length, getLocalWorkspace(), fStudy.getStoredRefData());
fStudy.setFrapOptData(optData);
fitData = optData.getFitData(parameters);
} catch (Exception ex) {
ex.printStackTrace(System.out);
DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex.getMessage());
}
}
} else if (batchRunSelectedModel == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
FRAPOptFunctions optFunc = fStudy.getFrapOptFunc();
if (optFunc == null) {
try {
optFunc = new FRAPOptFunctions(fStudy);
fStudy.setFrapOptFunc(optFunc);
fitData = optFunc.getFitData(parameters);
} catch (Exception ex2) {
ex2.printStackTrace();
DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex2.getMessage());
}
}
}
fStudy.getModels()[batchRunSelectedModel].setData(fitData);
// add new data into the frapStudy list in batch run.
getBatchRunWorkspace().addFrapStudy(fStudy);
// refresh the results
getBatchRunWorkspace().refreshBatchRunResults();
} else // batch run has no results, simply add the frapStudy into
{
getBatchRunWorkspace().addFrapStudy(fStudy);
}
// set save flag true when a doc has been added successfully
getBatchRunWorkspace().setSaveNeeded(true);
// update tree
DefaultMutableTreeNode newNode = frapBatchRunViewTree.addBatchRunDocNode(new File(getBatchRunWorkspace().getWorkingFrapStudy().getXmlFilename()));
// get the new tree node after sorting
newNode = frapBatchRunViewTree.orderFRAPDocChildren(newNode);
frapBatchRunViewTree.setSelectionPath(new TreePath(newNode.getPath()));
} else {
// load data unsuccessfully, remove the displayed image
getBatchRunWorkspace().clearWorkingSingleWorkspace();
// clear tree selection
frapBatchRunViewTree.clearSelection();
// clear stored tree selection
batchRunWorkspace.clearStoredTreeSelection();
}
}
} else if (source == deleteButton) {
AsynchClientTask deleteFromWorkspaceTask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// remove tree node(doc node removable only)
DefaultMutableTreeNode parent = frapBatchRunViewTree.removeCurrentNode();
// handle differently for doc node and results node
if (// doc node
parent.equals(BatchRunTree.FRAP_BATCHRUN_DOC_NODE)) {
// remove the data & displayed image
getBatchRunWorkspace().removeFrapStudy(getBatchRunWorkspace().getWorkingFrapStudy());
} else if (// results node
parent.equals(BatchRunTree.FRAP_BATCHRUN_RESULT_NODE)) {
getBatchRunWorkspace().clearResultData();
}
getBatchRunWorkspace().clearWorkingSingleWorkspace();
}
};
AsynchClientTask deleteFromUITask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// clear tree selection
frapBatchRunViewTree.clearSelection();
if (batchRunWorkspace.getFrapStudies() == null || batchRunWorkspace.getFrapStudies().size() < 1) {
frapBatchRunViewTree.clearAll();
} else // if doc has been deleted successfully and frapStudyList still has doc, set save flag true.
{
batchRunWorkspace.setSaveNeeded(true);
}
batchRunWorkspace.clearStoredTreeSelection();
// clear parameter display
clearParameterDisplay();
}
};
ClientTaskDispatcher.dispatch(BatchRunDetailsPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { deleteFromWorkspaceTask, deleteFromUITask }, false, false, false, null, true);
} else if (source == delAllButton) {
deleteAllBatchrunDocs();
}
}
use of cbit.vcell.opt.Parameter in project vcell by virtualcell.
the class FRAPStudyPanel method runSimulationForSelectedModel.
private void runSimulationForSelectedModel() {
AsynchClientTask prepareRunBindingReactionTask = new AsynchClientTask("Preparing to run simulation ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
boolean bExtDataOK = FRAPWorkspace.areExternalDataOK(getLocalWorkspace(), fStudy.getFrapDataExternalDataInfo(), fStudy.getRoiExternalDataInfo());
if (!bExtDataOK) {
// refresh rois
refreshROIs();
// if external files are missing/currupt or ROIs are changed, create keys and save them
fStudy.setFrapDataExternalDataInfo(FRAPStudy.createNewExternalDataInfo(getLocalWorkspace(), FRAPStudy.IMAGE_EXTDATA_NAME));
fStudy.setRoiExternalDataInfo(FRAPStudy.createNewExternalDataInfo(getLocalWorkspace(), FRAPStudy.ROI_EXTDATA_NAME));
try {
fStudy.saveROIsAsExternalData(getLocalWorkspace(), fStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), fStudy.getStartingIndexForRecovery());
fStudy.saveImageDatasetAsExternalData(getLocalWorkspace(), fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), fStudy.getStartingIndexForRecovery());
} catch (Exception e) {
e.printStackTrace(System.out);
(getAnalysisResultsPanel()).setResultsButtonEnabled(false);
throw e;
}
}
}
};
// -------------------------------------------------------------------------
AsynchClientTask runReactionBindingTask = new AsynchClientTask("Running simulation ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
Parameter[] bestParams = fStudy.getModels()[fStudy.getBestModelIndex().intValue()].getModelParameters();
if (bestParams.length < 3) {
return;
} else {
if (fStudy != null && fStudy.getBioModel() != null && fStudy.getBioModel().getSimulations() != null && fStudy.getBioModel().getSimulations().length > 0 && fStudy.getBioModel().getSimulations()[0].getVersion() != null && fStudy.getBioModel().getSimulations()[0].getVersion().getVersionKey() != null) {
fStudy.getBioModel().getSimulations()[0].getVersion().getVersionKey();
}
BioModel bioModel = null;
try {
bioModel = FRAPStudy.createNewSimBioModel(fStudy, bestParams, null, LocalWorkspace.createNewKeyValue(), LocalWorkspace.getDefaultOwner(), fStudy.getStartingIndexForRecovery());
// run simulation
FRAPStudy.runFVSolverStandalone(new File(getLocalWorkspace().getDefaultSimDataDirectory()), bioModel.getSimulation(0), fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), fStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), this.getClientTaskStatusSupport(), false);
fStudy.setBioModel(bioModel);
} catch (Exception e) {
if (bioModel != null && bioModel.getSimulations() != null) {
FRAPStudy.removeExternalDataAndSimulationFiles(bioModel.getSimulations()[0].getVersion().getVersionKey(), null, null, getLocalWorkspace());
(getAnalysisResultsPanel()).setResultsButtonEnabled(false);
}
throw e;
}
}
}
};
AsynchClientTask updateUITask = new AsynchClientTask("Simulation Done.", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
VirtualFrapMainFrame.updateStatus("Simulation Done. Click on \'View Spatial Results\' to see simulation results.");
(getAnalysisResultsPanel()).setResultsButtonEnabled(true);
}
};
// dispatch
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { prepareRunBindingReactionTask, runReactionBindingTask, updateUITask }, true, true, true, null, true);
}
use of cbit.vcell.opt.Parameter in project vcell by virtualcell.
the class FRAPStudyPanel method showEstimateParamWizard.
private void showEstimateParamWizard() {
// check if frapOpt data is null? if yes, run ref simulation.
// check if parameters of each selected models are there, if not, run analytic solution, get best parameters and store parameters
AsynchClientTask saveTask = new AsynchClientTask("Preparing for parameter estimation ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy.hasDiffusionOnlyModel()) {
// create optdata
if (fStudy.getFrapOptData() == null) {
if (fStudy.getStoredRefData() != null) {
getFrapWorkspace().getWorkingFrapStudy().setFrapOptData(new FRAPOptData(fStudy, FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF, getLocalWorkspace(), fStudy.getStoredRefData()));
} else {
// check external data info
if (!FRAPWorkspace.areExternalDataOK(getLocalWorkspace(), fStudy.getFrapDataExternalDataInfo(), fStudy.getRoiExternalDataInfo())) {
// if external files are missing/currupt or ROIs are changed, create keys and save them
fStudy.setFrapDataExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.IMAGE_EXTDATA_NAME));
fStudy.setRoiExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_EXTDATA_NAME));
fStudy.saveROIsAsExternalData(localWorkspace, fStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), fStudy.getStartingIndexForRecovery());
fStudy.saveImageDatasetAsExternalData(localWorkspace, fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), fStudy.getStartingIndexForRecovery());
}
// run ref sim
fStudy.setFrapOptData(new FRAPOptData(fStudy, FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF, localWorkspace, this.getClientTaskStatusSupport()));
fStudy.setSaveNeeded(true);
}
}
}
if (fStudy.hasReactionOnlyOffRateModel()) {
if (fStudy.getFrapOptFunc() == null) {
fStudy.setFrapOptFunc(new FRAPOptFunctions(fStudy));
}
}
}
};
AsynchClientTask runOptTask = new AsynchClientTask("Running optimization ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy.getSelectedModels() != null && fStudy.getSelectedModels().size() > 0) {
ArrayList<Integer> models = fStudy.getSelectedModels();
for (int i = 0; i < models.size(); i++) {
if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters() == null) {
fStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF);
Parameter[] initialParams = FRAPModel.getInitialParameters(fStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT], fStudy.getStartingIndexForRecovery());
Parameter[] bestParameters = fStudy.getFrapOptData().getBestParamters(initialParams, fStudy.getSelectedROIsForErrorCalculation());
fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].setModelParameters(bestParameters);
fStudy.setSaveNeeded(true);
}
} else if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters() == null) {
fStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF);
Parameter[] initialParams = FRAPModel.getInitialParameters(fStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS], fStudy.getStartingIndexForRecovery());
Parameter[] bestParameters = fStudy.getFrapOptData().getBestParamters(initialParams, fStudy.getSelectedROIsForErrorCalculation());
fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].setModelParameters(bestParameters);
fStudy.setSaveNeeded(true);
}
} else if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].getModelParameters() == null) {
Parameter[] bestParameters = fStudy.getFrapOptFunc().getBestParamters(fStudy.getFrapData(), null, true);
fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].setModelParameters(bestParameters);
fStudy.setSaveNeeded(true);
}
}
}
}
}
};
AsynchClientTask evaulateCITask = new AsynchClientTask("Evaluating confidence intervals for model parameters ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy.getSelectedModels() != null && fStudy.getSelectedModels().size() > 0) {
ArrayList<Integer> models = fStudy.getSelectedModels();
for (int i = 0; i < models.size(); i++) {
if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters() != null && fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters().length > 0) {
Parameter[] currentParams = fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters();
fStudy.getFrapOptData().setNumEstimatedParams(currentParams.length);
ProfileData[] profileData = null;
if (fStudy.getProfileData_oneDiffComponent() != null) {
profileData = fStudy.getProfileData_oneDiffComponent();
} else {
profileData = fStudy.getFrapOptData().evaluateParameters(currentParams, this.getClientTaskStatusSupport());
fStudy.setProfileData_oneDiffComponent(profileData);
fStudy.setSaveNeeded(true);
}
}
} else if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters() != null && fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters().length > 0) {
Parameter[] currentParams = fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters();
fStudy.getFrapOptData().setNumEstimatedParams(currentParams.length);
ProfileData[] profileData = null;
if (fStudy.getProfileData_twoDiffComponents() != null) {
profileData = fStudy.getProfileData_twoDiffComponents();
} else {
profileData = fStudy.getFrapOptData().evaluateParameters(currentParams, this.getClientTaskStatusSupport());
fStudy.setProfileData_twoDiffComponents(profileData);
fStudy.setSaveNeeded(true);
}
}
} else if ((models.get(i)).intValue() == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
if (fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].getModelParameters() != null && fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].getModelParameters().length > 0) {
Parameter[] currentParams = fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].getModelParameters();
ProfileData[] profileData = null;
if (fStudy.getProfileData_reactionOffRate() != null) {
profileData = fStudy.getProfileData_reactionOffRate();
} else {
profileData = fStudy.getFrapOptFunc().evaluateParameters(currentParams, this.getClientTaskStatusSupport());
fStudy.setProfileData_reactionOffRate(profileData);
fStudy.setSaveNeeded(true);
}
}
}
}
}
hashTable.put(FRAPSTUDY_KEY, fStudy);
}
};
AsynchClientTask showDialogTask = new AsynchClientTask("Showing estimation results ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// get frap models before the wizard
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
FRAPModel[] oldFrapModels = new FRAPModel[FRAPModel.NUM_MODEL_TYPES];
for (int i = 0; i < fStudy.getModels().length; i++) {
if (fStudy.getModels()[i] != null) {
FRAPModel model = fStudy.getModels()[i];
oldFrapModels[i] = new FRAPModel(new String(model.getModelIdentifer()), model.duplicateParameters(), null, model.duplicateTimePoints());
}
}
// get best model index before the wizard
Integer oldBestModelIndex = null;
if (fStudy.getBestModelIndex() != null) {
oldBestModelIndex = new Integer(fStudy.getBestModelIndex().intValue());
// put old best model index into hashtable
hashTable.put(BEST_MODEL_KEY, oldBestModelIndex);
}
// put old frapmodels in hashtable
hashTable.put(FRAPMODELS_KEY, oldFrapModels);
// show wizard
final Wizard estParamWizard = getEstimateParametersWizard();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
estParamWizard.showModalDialog(new Dimension(1000, 750));
}
});
// put wizard in hashtable in order to check return code in next task
hashTable.put(EST_PARAM_WIZARD_KEY, estParamWizard);
}
};
AsynchClientTask updateSaveStatusTask = new AsynchClientTask("...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
Wizard estParamWizard = (Wizard) hashTable.get(EST_PARAM_WIZARD_KEY);
// get old values from hashtable
FRAPModel[] oldFrapModels = (FRAPModel[]) hashTable.get(FRAPMODELS_KEY);
Integer oldBestModelIndex = (Integer) hashTable.get(BEST_MODEL_KEY);
// get new values
Integer newBestModelIndex = getFrapWorkspace().getWorkingFrapStudy().getBestModelIndex();
if (estParamWizard.getReturnCode() == Wizard.FINISH_RETURN_CODE) {
if (!getFrapWorkspace().getWorkingFrapStudy().areFRAPModelsEqual(oldFrapModels) || (oldBestModelIndex == null && newBestModelIndex != null) || (oldBestModelIndex != null && newBestModelIndex == null) || (oldBestModelIndex != null && newBestModelIndex != null && oldBestModelIndex.intValue() != newBestModelIndex.intValue())) {
getFrapWorkspace().getWorkingFrapStudy().setSaveNeeded(true);
}
}
}
};
// dispatch
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { saveTask, runOptTask, evaulateCITask, showDialogTask, updateSaveStatusTask }, true, true, true, null, true);
}
use of cbit.vcell.opt.Parameter in project vcell by virtualcell.
the class EstParams_OneDiffComponentPanel method loadBatchRunParameters.
public void loadBatchRunParameters(File inFile) {
String xmlString;
try {
xmlString = XmlUtil.getXMLString(inFile.getAbsolutePath());
BatchRunXmlReader batchRunXmlReader = new BatchRunXmlReader();
FRAPBatchRunWorkspace tempBatchRunWorkspace = batchRunXmlReader.getBatchRunWorkspace(XmlUtil.stringToXML(xmlString, null).getRootElement());
Parameter[] parameters = tempBatchRunWorkspace.getAverageParameters();
if (parameters != null && parameters.length > 0 && parameters.length == FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF) {
String paramMsg = "Replace the current parameters with the following parameter values: \n\n";
for (int i = 0; i < parameters.length; i++) {
paramMsg = paramMsg + parameters[i].getName() + ": " + parameters[i].getInitialGuess() + "\n";
}
String choice = DialogUtils.showWarningDialog(this, paramMsg, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (choice == UserMessage.OPTION_OK) {
getPureDiffusionPanel().setParameterValues(parameters[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess(), parameters[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess(), parameters[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess());
}
} else {
throw new Exception("Parameters are null or number of applied parameters don't match the number (3) of parameters for diffusion with one diffusing component.");
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, e.getMessage());
}
}
Aggregations