use of cbit.vcell.microscopy.FRAPStudy in project vcell by virtualcell.
the class FRAPStudyPanel method refreshROIs.
protected void refreshROIs() throws Exception {
try {
// check if all the data for generating spatial model are ready.
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy == null) {
throw new Exception("No FrapStudy is defined");
}
if (fStudy.getFrapData() == null) {
throw new Exception("No FrapData is defined");
}
if (fStudy.getFrapData().getImageDataset() == null) {
throw new Exception("No ImageDataSet is defined");
}
fStudy.refreshDependentROIs();
} catch (Exception e) {
throw e;
}
}
use of cbit.vcell.microscopy.FRAPStudy 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.microscopy.FRAPStudy 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.microscopy.FRAPStudy in project vcell by virtualcell.
the class BatchRunXmlReader method getBatchRunWorkspace.
/**
* This method returns a Biomodel object from a XML Element.
* Creation date: (3/13/2001 12:35:00 PM)
* @param param org.jdom.Element
* @return cbit.vcell.biomodel.BioModel
* @throws XmlParseException
*/
public FRAPBatchRunWorkspace getBatchRunWorkspace(Element param) throws XmlParseException {
FRAPBatchRunWorkspace tempBatchRunWorkspace = new FRAPBatchRunWorkspace();
// Element param = root.getChild(MicroscopyXMLTags.FrapBatchRunTag);
// selected model index
Element selectedModexIndexElement = param.getChild(MicroscopyXMLTags.BatchRunSelectedModelTypeTag);
String selectedModexIndexStr = selectedModexIndexElement.getText();
int selectedModelIndex = (new Integer(selectedModexIndexStr).intValue());
if (selectedModexIndexStr != null && selectedModexIndexStr.length() > 0) {
tempBatchRunWorkspace.setSelectedModel(selectedModelIndex);
}
// get average model parameters when there is selected model
Element averageParametersElement = param.getChild(MicroscopyXMLTags.ModelParametersTag);
Parameter[] params = null;
if (averageParametersElement != null && averageParametersElement.getAttributes().size() > 0) {
if (selectedModelIndex == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT) {
params = new Parameter[FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF];
double primaryDiffRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.PrimaryRateAttrTag));
params[FRAPModel.INDEX_PRIMARY_DIFF_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_PRIMARY_DIFF_RATE], FRAPModel.REF_DIFFUSION_RATE_PARAM.getLowerBound(), FRAPModel.REF_DIFFUSION_RATE_PARAM.getUpperBound(), FRAPModel.REF_DIFFUSION_RATE_PARAM.getScale(), primaryDiffRate);
double primaryFraction = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.PrimaryFractionAttTag));
params[FRAPModel.INDEX_PRIMARY_FRACTION] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_PRIMARY_FRACTION], FRAPModel.REF_MOBILE_FRACTION_PARAM.getLowerBound(), FRAPModel.REF_MOBILE_FRACTION_PARAM.getUpperBound(), FRAPModel.REF_MOBILE_FRACTION_PARAM.getScale(), primaryFraction);
double bwmRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag));
params[FRAPModel.INDEX_BLEACH_MONITOR_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_BLEACH_MONITOR_RATE], FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getLowerBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getUpperBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getScale(), bwmRate);
} else if (selectedModelIndex == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
params = new Parameter[FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF];
double primaryDiffRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.PrimaryRateAttrTag));
params[FRAPModel.INDEX_PRIMARY_DIFF_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_PRIMARY_DIFF_RATE], FRAPModel.REF_DIFFUSION_RATE_PARAM.getLowerBound(), FRAPModel.REF_DIFFUSION_RATE_PARAM.getUpperBound(), FRAPModel.REF_DIFFUSION_RATE_PARAM.getScale(), primaryDiffRate);
double primaryFraction = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.PrimaryFractionAttTag));
params[FRAPModel.INDEX_PRIMARY_FRACTION] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_PRIMARY_FRACTION], FRAPModel.REF_MOBILE_FRACTION_PARAM.getLowerBound(), FRAPModel.REF_MOBILE_FRACTION_PARAM.getUpperBound(), FRAPModel.REF_MOBILE_FRACTION_PARAM.getScale(), primaryFraction);
double bwmRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag));
params[FRAPModel.INDEX_BLEACH_MONITOR_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_BLEACH_MONITOR_RATE], FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getLowerBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getUpperBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getScale(), bwmRate);
double secDiffRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.SecondRateAttrTag));
params[FRAPModel.INDEX_SECONDARY_DIFF_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_SECONDARY_DIFF_RATE], FRAPModel.REF_SECOND_DIFFUSION_RATE_PARAM.getLowerBound(), FRAPModel.REF_SECOND_DIFFUSION_RATE_PARAM.getUpperBound(), FRAPModel.REF_SECOND_DIFFUSION_RATE_PARAM.getScale(), secDiffRate);
double secFraction = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.SecondFractionAttTag));
params[FRAPModel.INDEX_SECONDARY_FRACTION] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_SECONDARY_FRACTION], FRAPModel.REF_SECOND_MOBILE_FRACTION_PARAM.getLowerBound(), FRAPModel.REF_SECOND_MOBILE_FRACTION_PARAM.getUpperBound(), FRAPModel.REF_SECOND_MOBILE_FRACTION_PARAM.getScale(), secFraction);
} else if (selectedModelIndex == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
params = new Parameter[FRAPModel.NUM_MODEL_PARAMETERS_REACTION_OFF_RATE];
double bwmRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag));
params[FRAPModel.INDEX_BLEACH_MONITOR_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_BLEACH_MONITOR_RATE], FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getLowerBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getUpperBound(), FRAPModel.REF_BLEACH_WHILE_MONITOR_PARAM.getScale(), bwmRate);
double fittingParam = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.BindingSiteConcentrationAttTag));
params[FRAPModel.INDEX_BINDING_SITE_CONCENTRATION] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_BINDING_SITE_CONCENTRATION], FRAPModel.REF_BS_CONCENTRATION_OR_A.getLowerBound(), FRAPModel.REF_BS_CONCENTRATION_OR_A.getUpperBound(), FRAPModel.REF_BS_CONCENTRATION_OR_A.getScale(), fittingParam);
double offRate = Double.parseDouble(averageParametersElement.getAttributeValue(MicroscopyXMLTags.ReactionOffRateAttTag));
params[FRAPModel.INDEX_OFF_RATE] = new Parameter(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_OFF_RATE], FRAPModel.REF_REACTION_OFF_RATE.getLowerBound(), FRAPModel.REF_REACTION_OFF_RATE.getUpperBound(), FRAPModel.REF_REACTION_OFF_RATE.getScale(), offRate);
params[FRAPModel.INDEX_PRIMARY_DIFF_RATE] = null;
params[FRAPModel.INDEX_PRIMARY_FRACTION] = null;
params[FRAPModel.INDEX_SECONDARY_DIFF_RATE] = null;
params[FRAPModel.INDEX_SECONDARY_FRACTION] = null;
params[FRAPModel.INDEX_ON_RATE] = null;
}
tempBatchRunWorkspace.setAverageParameters(params);
}
// get FrapStudy file list
Element frapStudyListElement = param.getChild(MicroscopyXMLTags.FrapStudyListTag);
String numFrapStudiesStr = frapStudyListElement.getAttributeValue(MicroscopyXMLTags.NumFrapStudyListAttrTag);
Integer.parseInt(numFrapStudiesStr);
// get each individual FRAPStudy
@SuppressWarnings("unchecked") List<Element> fileNameList = frapStudyListElement.getChildren(MicroscopyXMLTags.FrapFileNameTag);
for (int i = 0; i < fileNameList.size(); i++) {
String fileName = fileNameList.get(i).getText();
// create empty frap study to put in temporay batchrunworkspace
FRAPStudy fStudy = new FRAPStudy();
fStudy.setXmlFilename(fileName);
tempBatchRunWorkspace.addFrapStudy(fStudy);
}
return tempBatchRunWorkspace;
}
use of cbit.vcell.microscopy.FRAPStudy in project vcell by virtualcell.
the class FRAPBatchRunWorkspace method refreshMSESummaryData.
public void refreshMSESummaryData() {
int studySize = getFrapStudies().size();
analysisMSESummaryData = new double[studySize][FRAPData.VFRAP_ROI_ENUM.values().length - 2 + 1];
for (int i = 0; i < studySize; i++) {
FRAPStudy fStudy = getFrapStudies().get(i);
fStudy.createAnalysisMSESummaryData();
analysisMSESummaryData[i] = fStudy.getAnalysisMSESummaryData()[getSelectedModel()];
}
}
Aggregations