use of cbit.vcell.solver.Simulation in project vcell by virtualcell.
the class FRAPStudyPanel method refreshPDEDisplay.
protected void refreshPDEDisplay(DisplayChoice choice) throws Exception {
Simulation sim = null;
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy == null || fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
return;
}
sim = fStudy.getBioModel().getSimulations()[0];
FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
}
PDEDataViewer flourViewer = getFlourDataViewer();
PDEDataManager dataManager = null;
if (choice == DisplayChoice.EXTTIMEDATA) {
flourViewer.setSimulation(null);
flourViewer.setPdeDataContext(null);
flourViewer.setDataIdentifierFilter(new DataIdentifierFilter() {
private String ALL_DATAIDENTIFIERS = "All";
private String EXP_NORM_FLUOR = "Exp. Norm. Fluor";
private String SIM_NORM_FLUOR = "Sim. Norm. Fluor";
private String DEFAULT_VIEW = "Default View (more...)";
private String[] filterSetNames = new String[] { ALL_DATAIDENTIFIERS, EXP_NORM_FLUOR, SIM_NORM_FLUOR, DEFAULT_VIEW };
public boolean accept(String filterSetName, List<AnnotatedFunction> myFunctionList, DataIdentifier dataidentifier) {
if (filterSetName.equals(ALL_DATAIDENTIFIERS)) {
return true;
} else if (filterSetName.equals(EXP_NORM_FLUOR)) {
return dataidentifier.getName().indexOf(NORM_FLUOR_VAR) != -1;
} else if (filterSetName.equals(SIM_NORM_FLUOR)) {
boolean a = (dataidentifier.getName().indexOf(REACTION_RATE_PREFIX) == -1) && ((dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_COMBINED) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_IMMOBILE) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_MOBILE) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_SLOW_MOBILE) != -1));
return a;
} else if (filterSetName.equals(DEFAULT_VIEW)) {
boolean a = (dataidentifier.getName().indexOf(REACTION_RATE_PREFIX) == -1) && ((dataidentifier.getName().indexOf(NORM_FLUOR_VAR) != -1) || (dataidentifier.getName().indexOf(NORM_SIM_VAR) != -1));
return a;
}
throw new IllegalArgumentException("DataIdentifierFilter: Unknown filterSetName " + filterSetName);
}
public String getDefaultFilterName() {
return DEFAULT_VIEW;
}
public String[] getFilterSetNames() {
return filterSetNames;
}
public boolean isAcceptAll(String filterSetName) {
return filterSetName.equals(ALL_DATAIDENTIFIERS);
}
@Override
public void setPostProcessingMode(boolean bPostProcessingMode) {
// TODO Auto-generated method stub
}
@Override
public boolean isPostProcessingMode() {
// TODO Auto-generated method stub
return false;
}
@Override
public ArrayList<DataIdentifier> accept(String filterSetName, List<AnnotatedFunction> myFunctionList, DataIdentifier[] dataidentifiers) {
if (filterSetName.equals(DEFAULT_VIEW)) {
ArrayList<DataIdentifier> dataIds = new ArrayList<>();
if (dataidentifiers != null) {
for (int i = 0; i < dataidentifiers.length; i++) {
dataIds.add(dataidentifiers[i]);
}
}
return dataIds;
}
throw new RuntimeException("Not Implemented for FRAP");
}
});
ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
// add sim
int jobIndex = 0;
SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
// add function to display normalized fluorence data
Norm_Exp_Fluor = new Expression(Norm_Exp_Fluor_Str);
SimulationSymbolTable simSymbolTable = simJob.getSimulationSymbolTable();
if (// one diffusing component
simSymbolTable.getVariable(FRAPStudy.SPECIES_NAME_PREFIX_SLOW_MOBILE) == null) {
Norm_Sim = new Expression(Norm_Sim_One_Diff_Str);
} else // two diffusing components
{
Norm_Sim = new Expression(Norm_Sim_Two_Diff_Str);
}
AnnotatedFunction[] func = { new AnnotatedFunction(NORM_FLUOR_VAR, Norm_Exp_Fluor, null, null, VariableType.VOLUME, FunctionCategory.OLDUSERDEFINED), new AnnotatedFunction(NORM_SIM_VAR, Norm_Sim, null, null, VariableType.VOLUME, FunctionCategory.OLDUSERDEFINED) };
VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
outputContext = new OutputContext(func);
dataManager = new PDEDataManager(outputContext, getLocalWorkspace().getVCDataManager(), vcDataId);
ClientPDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
pdeDataContext.refreshIdentifiers();
flourViewer.setSimulation(sim);
flourViewer.setPdeDataContext(pdeDataContext);
SimulationModelInfo simModelInfo = new SimulationWorkspaceModelInfo(fStudy.getBioModel().getSimulationContext(sim), sim.getName());
flourViewer.setSimulationModelInfo(simModelInfo);
getLocalWorkspace().getDataSetControllerImpl().addDataJobListener(flourViewer);
((VirtualFrapWindowManager) flourViewer.getDataViewerManager()).setLocalWorkSpace(getLocalWorkspace());
// do now show post data processing for VFRAP
flourViewer.setPostProcessingPanelVisible(false);
flourViewer.repaint();
}
}
use of cbit.vcell.solver.Simulation in project vcell by virtualcell.
the class FRAPStudyPanel method showMovie.
private void showMovie() {
AsynchClientTask createMovieTask = new AsynchClientTask("Buffering movie data...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy == null) {
return;
}
if (fStudy.getMovieURLString() != null && fStudy.getMovieFileString() != null) {
hashTable.put("FrapStudy", fStudy);
return;
}
// create export specs
Simulation sim = null;
if (fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
return;
} else {
sim = fStudy.getBioModel().getSimulations()[0];
}
FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
}
ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
// add sim
int jobIndex = 0;
SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
PDEDataManager dataManager = new PDEDataManager(null, getLocalWorkspace().getVCDataManager(), vcDataId);
PDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
ExportFormat format = ExportFormat.QUICKTIME;
String[] variableNames = new String[] { NORM_FLUOR_VAR, NORM_SIM_VAR };
VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
// int endTimeIndex = (int)Math.round(sim.getSolverTaskDescription().getTimeBounds().getEndingTime()/((UniformOutputTimeSpec)sim.getSolverTaskDescription().getOutputTimeSpec()).getOutputTimeStep());
int endTimeIndex = getFRAPSimDataViewerPanel().getOriginalDataViewer().getPdeDataContext().getTimePoints().length - 1;
TimeSpecs timeSpecs = new TimeSpecs(0, endTimeIndex, pdeDataContext.getTimePoints(), ExportConstants.TIME_RANGE);
int geoMode = ExportConstants.GEOMETRY_SLICE;
GeometrySpecs geometrySpecs = new GeometrySpecs(null, Coordinate.Z_AXIS, 0, geoMode);
// 10s
double duration = 10000;
DisplayPreferences pref1 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
DisplayPreferences pref2 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
DisplayPreferences[] displayPref = new DisplayPreferences[] { pref1, pref2 };
int imageScale = 1;
int membraneScale = 1;
int scaleMode = ImagePaneModel.MESH_MODE;
// the default setting in MediaSettingsPanel.
int volVarMemOutlineThickness = 1;
MovieSpecs mSpec = new MovieSpecs(duration, true, displayPref, ExportFormat.QUICKTIME, ExportConstants.NO_MIRRORING, volVarMemOutlineThickness, imageScale, membraneScale, scaleMode, FormatSpecificSpecs.CODEC_JPEG, 1.0f, /*lossless*/
false, FormatSpecificSpecs.PARTICLE_NONE);
// mSpec.setViewZoom(1);
ExportSpecs exSpecs = new ExportSpecs(vcDataId, format, variableSpecs, timeSpecs, geometrySpecs, mSpec, fStudy.getName(), null);
// pass the request
ExportEvent exportEvt = ((VirtualFrapWindowManager) getFlourDataViewer().getDataViewerManager()).startExportMovie(exSpecs, outputContext, this.getClientTaskStatusSupport());
hashTable.put("ExportEvt", exportEvt);
hashTable.put("FrapStudy", fStudy);
}
};
AsynchClientTask showMovieTask = new AsynchClientTask("Showing movie ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
ExportEvent exportEvt = (ExportEvent) hashTable.get("ExportEvt");
FRAPStudy fStudy = (FRAPStudy) hashTable.get("FrapStudy");
// show movie if successfully exported
if (exportEvt != null) {
final String fileURLString = System.getProperty(PropertyLoader.exportBaseURLProperty) + exportEvt.getJobID() + ".mov";
final String fileString = System.getProperty(PropertyLoader.exportBaseDirInternalProperty) + exportEvt.getJobID() + ".mov";
fStudy.setMovieURLString(fileURLString);
fStudy.setMovieFileString(fileString);
}
showMovieInDialog(fStudy.getMovieURLString(), fStudy.getMovieFileString());
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { createMovieTask, showMovieTask }, true, true, null, true);
}
use of cbit.vcell.solver.Simulation in project vcell by virtualcell.
the class MeshTabPanel method setSimulation.
/**
* Sets the meshSpecification property (cbit.vcell.mesh.MeshSpecification) value.
* @param meshSpecification The new value for the property.
* @throws ChomboInvalidGeometryException
* @throws ChomboGeometryException
* @see #getMeshSpecification
*/
public void setSimulation(Component parent, Simulation newValue) throws ChomboInvalidGeometryException {
Simulation oldValue = simulation;
if (oldValue != null) {
oldValue.getSolverTaskDescription().removePropertyChangeListener(eventListener);
}
simulation = newValue;
if (simulation != null) {
simulation.getSolverTaskDescription().addPropertyChangeListener(eventListener);
}
updateDisplay();
chomboSolverSpecPanel.setSimulation(simulation);
meshSpecificationPanel.setSimulation(simulation);
try {
chomboMeshSpecificationPanel.setSimulation(simulation);
} catch (ChomboGeometryException exc) {
exc.printStackTrace(System.out);
DialogUtils.showWarningDialog(parent, exc.getMessage());
}
}
use of cbit.vcell.solver.Simulation in project vcell by virtualcell.
the class SimulationSummaryPanel method setSimulation.
/**
* Sets the simulation property (cbit.vcell.solver.Simulation) value.
* @param newValue The new value for the property.
* @see #getSimulation
*/
public void setSimulation(Simulation newValue) {
Simulation oldValue = fieldSimulation;
if (oldValue != null) {
oldValue.removePropertyChangeListener(ivjEventHandler);
oldValue.getSolverTaskDescription().removePropertyChangeListener(ivjEventHandler);
MeshSpecification meshSpecification = oldValue.getMeshSpecification();
if (meshSpecification != null) {
meshSpecification.removePropertyChangeListener(ivjEventHandler);
}
}
fieldSimulation = newValue;
if (newValue != null) {
// also set up a listener that will refresh when simulation is edited in place
newValue.addPropertyChangeListener(ivjEventHandler);
newValue.getSolverTaskDescription().addPropertyChangeListener(ivjEventHandler);
MeshSpecification meshSpecification = newValue.getMeshSpecification();
if (meshSpecification != null) {
meshSpecification.addPropertyChangeListener(ivjEventHandler);
}
}
refreshDisplay();
}
use of cbit.vcell.solver.Simulation in project vcell by virtualcell.
the class SolverTaskDescriptionAdvancedPanel method updateSensitivityParameterDisplay.
private void updateSensitivityParameterDisplay(Constant sensParam) {
Simulation simulation = getTornOffSolverTaskDescription().getSimulation();
if (simulation.isSpatial() || simulation.getMathDescription().isNonSpatialStoch()) {
sensitivityAnalysisComboBox.setVisible(false);
performSensitivityAnalysisCheckBox.setVisible(false);
} else {
sensitivityAnalysisComboBox.setVisible(true);
performSensitivityAnalysisCheckBox.setVisible(true);
}
if (sensParam == null) {
if (performSensitivityAnalysisCheckBox.isSelected()) {
performSensitivityAnalysisCheckBox.setSelected(false);
}
sensitivityAnalysisComboBox.setEnabled(false);
} else {
sensitivityAnalysisCollapsiblePanel.expand(true);
if (!performSensitivityAnalysisCheckBox.isSelected()) {
performSensitivityAnalysisCheckBox.setSelected(true);
}
sensitivityAnalysisComboBox.setEnabled(true);
if (sensitivityAnalysisComboBox.getModel().getSize() > 0) {
sensitivityAnalysisComboBox.setSelectedItem(sensParam.getName());
}
}
}
Aggregations