use of cbit.vcell.microscopy.FRAPStudy 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.microscopy.FRAPStudy in project vcell by virtualcell.
the class FRAPBatchRunWorkspace method addFrapStudy.
public void addFrapStudy(FRAPStudy newFrapStudy) {
File newFile = new File(newFrapStudy.getXmlFilename());
ArrayList<FRAPStudy> frapStudies = getFrapStudies();
int size = frapStudies.size();
int insertIdx = size;
for (int i = 0; i < size; i++) {
File xmlFile = new File(frapStudies.get(i).getXmlFilename());
if (newFile.getName().compareTo(xmlFile.getName()) == 0) {
if (newFile.getAbsolutePath().compareTo(xmlFile.getAbsolutePath()) < 0) {
insertIdx = i;
break;
}
} else if (newFile.getName().compareTo(xmlFile.getName()) < 0) {
insertIdx = i;
break;
}
}
if (insertIdx == size) {
frapStudies.add(newFrapStudy);
} else {
frapStudies.add(insertIdx, newFrapStudy);
}
// enable save button
VirtualFrapBatchRunFrame.enableSave(frapStudies != null && frapStudies.size() > 0);
}
use of cbit.vcell.microscopy.FRAPStudy in project vcell by virtualcell.
the class FRAPBatchRunWorkspace method getSaveSingleFilesTask.
// get client task for saving single vfrap files
public AsynchClientTask getSaveSingleFilesTask() {
AsynchClientTask saveSingleFileTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
int size = getFrapStudies().size();
for (int i = 0; i < getFrapStudies().size(); i++) {
FRAPStudy fStudy = getFrapStudies().get(i);
File outFile = new File(fStudy.getXmlFilename());
this.getClientTaskStatusSupport().setMessage("Saving file " + (i + 1) + " of " + size + " :" + outFile.getAbsolutePath() + " ...");
saveProcedure(outFile, fStudy, this.getClientTaskStatusSupport());
}
}
};
return saveSingleFileTask;
}
use of cbit.vcell.microscopy.FRAPStudy in project vcell by virtualcell.
the class FRAPBatchRunWorkspace method updateDisplayForTreeSelection.
public void updateDisplayForTreeSelection(Object selection) {
String oldString = null;
if (// doc
displaySelection instanceof File) {
oldString = ((File) displaySelection).getAbsolutePath();
} else if (// results
displaySelection instanceof String) {
oldString = ((String) displaySelection);
}
displaySelection = selection;
if (// doc
selection instanceof File) {
String newString = ((File) selection).getAbsolutePath();
FRAPStudy selectedFrapStudy = getFRAPStudy(newString);
setWorkingFRAPStudy(selectedFrapStudy);
firePropertyChange(PROPERTY_CHANGE_BATCHRUN_DISPLAY_IMG, oldString, newString);
} else if (// results
selection instanceof String) {
firePropertyChange(PROPERTY_CHANGE_BATCHRUN_DISPLAY_PARAM, oldString, (selection));
}
}
use of cbit.vcell.microscopy.FRAPStudy in project vcell by virtualcell.
the class MultiFileDescriptor method preNextProcess.
// load the data before the panel disappears
public ArrayList<AsynchClientTask> preNextProcess() {
// create AsynchClientTask arraylist
ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
final File[] files = multiFilePanel.getSelectedFiles();
if (files.length > 0) {
final String filePath = files[0].getParent();
final String LOADING_MESSAGE = "Loading files from directory " + filePath + "...";
AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
VirtualFrapMainFrame.updateStatus(LOADING_MESSAGE);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
};
AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy newFRAPStudy = null;
newFRAPStudy = FRAPWorkspace.loadFRAPDataFromMultipleFiles(files, this.getClientTaskStatusSupport(), multiFilePanel.isTimeSeries(), multiFilePanel.getTimeInterval());
isFileLoaded = true;
// for all loaded files
hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
}
};
AsynchClientTask afterLoadingSwingTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
// setFrapStudy fires property change, so we have to put it in Swing thread.
getFrapWorkspace().setWorkingFRAPStudy(newFRAPStudy);
VirtualFrapLoader.mf.setMainFrameTitle("");
VirtualFrapMainFrame.updateProgress(0);
if (isFileLoaded) {
VirtualFrapMainFrame.updateStatus("Loaded files from " + filePath);
} else {
VirtualFrapMainFrame.updateStatus("Failed loading files from " + filePath + ".");
}
}
};
taskArrayList.add(updateUIBeforeLoadTask);
taskArrayList.add(loadTask);
taskArrayList.add(afterLoadingSwingTask);
} else {
DialogUtils.showErrorDialog(multiFilePanel, "No file is selected. Please input one or more file names to continue.");
throw new RuntimeException("No file is selected. Please input one or more file names to continue.");
}
return taskArrayList;
}
Aggregations