use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class WorkflowJGraphProxy method workflowRun.
public void workflowRun() throws Exception {
ClientTaskStatusSupport progress = new ClientTaskStatusSupport() {
String message = "";
int progress = 0;
@Override
public void setProgress(int progress) {
this.progress = progress;
}
@Override
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean isInterrupted() {
return false;
}
@Override
public int getProgress() {
return progress;
}
@Override
public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
}
};
context.getWorkflow().compute(context, progress);
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class ImportRawTimeSeriesFromExperimentImageOp method importRawTimeSeries.
public ImageTimeSeries<UShortImage> importRawTimeSeries(File expTimeSeriesFile) throws Exception {
ClientTaskStatusSupport clientTaskStatusSupport = null;
ImageDataset rawTimeData = ImageDatasetReaderService.getInstance().getImageDatasetReader().readImageDataset(expTimeSeriesFile.getAbsolutePath(), clientTaskStatusSupport);
ImageTimeSeries<UShortImage> imageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, rawTimeData.getAllImages(), rawTimeData.getImageTimeStamps(), 1);
return imageTimeSeries;
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class BioModelsNetJPanel method searchImport.
private void searchImport() {
AsynchClientTask searchTask = new AsynchClientTask("Search BioModels", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Hashtable<String, String> vcellCompatibleBioModels_ID_Name_Hash = readVCellCompatibleBioModels_ID_Name_Hash();
ClientTaskStatusSupport clientTaskStatusSupport = getClientTaskStatusSupport();
// clientTaskStatusSupport.setProgress(0);
clientTaskStatusSupport.setMessage("Initializing BioModels Search...");
BioModelsWebServicesServiceLocator bioModelsWebServicesServiceLocator = new BioModelsWebServicesServiceLocator();
BioModelsWebServices bioModelsWebServices = bioModelsWebServicesServiceLocator.getBioModelsWebServices();
// clientTaskStatusSupport.setProgress(10);
clientTaskStatusSupport.setMessage("Executing BioModels Search...");
TreeSet<String> modelIDsMergedSearch = new TreeSet<String>();
boolean bHasModelEntryID = modelEntryIDTextField.getText() != null && modelEntryIDTextField.getText().length() > 0;
if (bHasModelEntryID) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Model ID matches)...");
// String[] modelIDsAll = bioModelsWebServices.getAllModelsId();
String[] modelIDsAll = vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0]);
for (int i = 0; i < modelIDsAll.length; i++) {
if (modelIDsAll[i].toUpperCase().indexOf(modelEntryIDTextField.getText().toUpperCase()) != -1) {
modelIDsMergedSearch.add(modelIDsAll[i]);
}
}
}
boolean bHasModelName = modelNameTextField.getText() != null && modelNameTextField.getText().length() > 0;
if (bHasModelName) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Model Name matches)...");
TreeSet<String> modelIDsByNameSet = new TreeSet<String>();
// String[] modelIDsByName = bioModelsWebServices.getModelsIdByName(modelNameTextField.getText());
String[] modelIDsAll = vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0]);
for (int i = 0; i < modelIDsAll.length; i++) {
if (vcellCompatibleBioModels_ID_Name_Hash.get(modelIDsAll[i]).toUpperCase().indexOf(modelNameTextField.getText().toUpperCase()) != -1) {
modelIDsByNameSet.add(modelIDsAll[i]);
}
}
// }
if (bHasModelEntryID) {
// intersection
modelIDsMergedSearch.retainAll(modelIDsByNameSet);
} else {
modelIDsMergedSearch = modelIDsByNameSet;
}
}
boolean bHasModelPublication = publicationTextField.getText() != null && publicationTextField.getText().length() > 0;
if (bHasModelPublication) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Publication matches)...");
TreeSet<String> modelIDsByPublicationSet = new TreeSet<String>();
String[] modelIDsbyPublication = bioModelsWebServices.getModelsIdByPublication(publicationTextField.getText());
for (int i = 0; i < modelIDsbyPublication.length; i++) {
modelIDsByPublicationSet.add(modelIDsbyPublication[i]);
}
if (bHasModelEntryID || bHasModelName) {
// intersection
modelIDsMergedSearch.retainAll(modelIDsByPublicationSet);
} else {
modelIDsMergedSearch = modelIDsByPublicationSet;
}
}
if (!(bHasModelEntryID || bHasModelName || bHasModelPublication)) {
// Get all models
// modelIDsMergedSearch.addAll(Arrays.asList(bioModelsWebServices.getAllModelsId()));
modelIDsMergedSearch.addAll(Arrays.asList(vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0])));
}
// clientTaskStatusSupport.setProgress(COLLECTION_PROGRESS);
if (modelIDsMergedSearch.size() > 0) {
// Intersect with supported BioModel IDs
modelIDsMergedSearch.retainAll(Arrays.asList(vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0])));
clientTaskStatusSupport.setMessage("Found " + modelIDsMergedSearch.size() + " VCell compatible BioModels");
String[] modelIDMergedSearchArr = modelIDsMergedSearch.toArray(new String[0]);
TreeMap<String, String> model_ID_Name_Map = new TreeMap<String, String>();
String nameNotfound = "NameNotFound_0";
for (int i = 0; i < modelIDMergedSearchArr.length; i++) {
if (clientTaskStatusSupport.isInterrupted()) {
// DialogUtils.showWarningDialog(BioModelsNetJPanel.this, "Search Cancelled");
throw UserCancelException.CANCEL_GENERIC;
}
try {
// clientTaskStatusSupport.setMessage("Retrieving "+modelIDMergedSearchArr[i]+" "+(i+1)+" of "+modelIDMergedSearchArr.length);
// String modelName = bioModelsWebServices.getModelNameById(modelIDMergedSearchArr[i]);
String modelName = vcellCompatibleBioModels_ID_Name_Hash.get(modelIDMergedSearchArr[i]);
// Assume model names are unique
model_ID_Name_Map.put(modelName, modelIDMergedSearchArr[i]);
} catch (Exception e) {
// For some reason Web Service API sometimes throws java.util.NoSuchElementException
// if id exists but name can't be found.
e.printStackTrace();
model_ID_Name_Map.put(nameNotfound, modelIDMergedSearchArr[i]);
nameNotfound = TokenMangler.getNextEnumeratedToken(nameNotfound);
}
}
// Make name,id rowdata for tablelist to allow user selection
String[] sortedModelNames = model_ID_Name_Map.keySet().toArray(new String[0]);
final String[][] rowData = new String[sortedModelNames.length][2];
for (int i = 0; i < sortedModelNames.length; i++) {
rowData[i][0] = sortedModelNames[i];
rowData[i][1] = model_ID_Name_Map.get(sortedModelNames[i]);
}
// Allow user to select model for opening
final String importNow = "Import";
final String cancel = "Cancel";
DialogUtils.TableListResult result = DialogUtils.showComponentOptionsTableList(BioModelsNetJPanel.this, "Select a BioModel to import", new String[] { "Model Names", "BioModels Entry ID" }, rowData, ListSelectionModel.SINGLE_SELECTION, null, new String[] { importNow, cancel }, importNow, new Comparator<Object>() {
public int compare(Object o1, Object o2) {
if (o1 instanceof String && o2 instanceof String) {
return ((String) o1).compareTo((String) o2);
}
throw new RuntimeException("row data should only be String");
}
});
if (result.selectedOption != null && result.selectedOption.equals(importNow)) {
// Close Dialog showing "this" panel so ProgressPopup not obscured during openDocument
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
disposeParentDialog();
}
});
closeClientTaskStatusSupport(clientTaskStatusSupport);
// Download and open (in new window) SBML document selected by user
String bioModelSBML = bioModelsWebServices.getModelSBMLById(rowData[result.selectedTableRows[0]][1]);
final ExternalDocInfo externalDocInfo = new ExternalDocInfo(bioModelSBML, sortedModelNames[result.selectedTableRows[0]]);
new Thread(new Runnable() {
public void run() {
documentWindow.getTopLevelWindowManager().getRequestManager().openDocument(externalDocInfo, documentWindow.getTopLevelWindowManager(), true);
}
}).start();
}
} else {
closeClientTaskStatusSupport(clientTaskStatusSupport);
DialogUtils.showWarningDialog(BioModelsNetJPanel.this, "No BioModels found matching current search criteria.");
throw UserCancelException.CANCEL_GENERIC;
}
}
};
ClientTaskDispatcher.dispatch(BioModelsNetJPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { searchTask }, true, true, null, true);
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class ROIMultiPaintManager method smoothUnderlay.
private void smoothUnderlay() {
AsynchClientTask smoothTask = new AsynchClientTask("Processing Image...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ClientTaskStatusSupport localClientTaskStatusSupport = new ClientTaskStatusSupport() {
public void setProgress(int progress) {
if (getClientTaskStatusSupport() != null) {
getClientTaskStatusSupport().setProgress((int) (.9 * progress));
}
}
public void setMessage(String message) {
}
public boolean isInterrupted() {
return (getClientTaskStatusSupport() == null ? false : getClientTaskStatusSupport().isInterrupted());
}
public int getProgress() {
return 0;
}
public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
throw new RuntimeException("not yet implemented");
}
};
enhancedImageDatasetChannels = smoothImageDataset(initImageDataSetChannels, enhanceImageAmount, localClientTaskStatusSupport);
if (localClientTaskStatusSupport.isInterrupted()) {
throw UserCancelException.CANCEL_GENERIC;
}
localClientTaskStatusSupport.setMessage("Calculating histogram...");
condensedBinsMapChannels = calculateCondensedBinsChannels0(getImageDataset());
allPixelValuesRangeChannels = calculateAllPixelValuesRangeChannels0(getImageDataset());
}
};
AsynchClientTask updateDisplayTask = new AsynchClientTask("Updating display...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (getClientTaskStatusSupport() != null) {
getClientTaskStatusSupport().setProgress(100);
}
updateUnderlayHistogramDisplay();
}
};
if (calculateCurrentSize() > 2000000) {
// show update progress only if large
ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { smoothTask, updateDisplayTask }, true, true, null, true);
} else {
ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { smoothTask, updateDisplayTask });
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class FRAPOptData method main.
public static void main(String[] args) {
String workingDir = "C:\\";
LocalWorkspace localWorkspace = new LocalWorkspace(new File(workingDir));
String xmlString;
try {
// read original data from file
System.out.println("start loading original data....");
String expFileName = "C:/VirtualMicroscopy/testFastD_4_fastFrac_0p5_slowD_1_slowFrac_0p3_ImmobileFrac_0p2_mwb_0p0015_new.vfrap";
xmlString = XmlUtil.getXMLString(expFileName);
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
FRAPStudy expFrapStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
expFrapStudy.setXmlFilename(expFileName);
System.out.println("experimental data time points" + expFrapStudy.getFrapData().getImageDataset().getSizeT());
System.out.println("finish loading original data....");
// create reference data
System.out.println("creating rederence data....");
FRAPOptData optData = new FRAPOptData(expFrapStudy, 5, localWorkspace, new ClientTaskStatusSupport() {
public void setProgress(int progress) {
// TODO Auto-generated method stub
}
public void setMessage(String message) {
// TODO Auto-generated method stub
}
public boolean isInterrupted() {
// TODO Auto-generated method stub
return false;
}
public int getProgress() {
// TODO Auto-generated method stub
return 0;
}
public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
throw new RuntimeException("not yet implemented");
}
});
// trying 3 parameters
// Parameter diff = new cbit.vcell.opt.Parameter(FRAPOptData.PARAMETER_NAMES[FRAPOptData.DIFFUSION_RATE_INDEX], 0, 100, 1.0, Double.parseDouble(expFrapStudy.getFrapModelParameters().diffusionRate));
// Parameter mobileFrac = new cbit.vcell.opt.Parameter(FRAPOptData.PARAMETER_NAMES[FRAPOptData.MOBILE_FRACTION_INDEX], 0, 1, 1.0, 1/*Double.parseDouble(expFrapStudy.getFrapModelParameters().mobileFraction)*/);
// Parameter bleachWhileMonitoringRate = new cbit.vcell.opt.Parameter(FRAPOptData.PARAMETER_NAMES[FRAPOptData.BLEACH_WHILE_MONITOR_INDEX], 0, 10, 1.0, 0/*Double.parseDouble(expFrapStudy.getFrapModelParameters().monitorBleachRate)*/);
// trying 5 parameters
Parameter diffFastOffset = new cbit.vcell.opt.Parameter("fastDiffOffset", 0, 50, 1.0, 10);
Parameter mFracFast = new cbit.vcell.opt.Parameter("fastMobileFrac", 0, 1, 1.0, 0.5);
Parameter diffSlow = new cbit.vcell.opt.Parameter("slowDiffRate", 0, 10, 1.0, 0.1);
Parameter mFracSlow = new cbit.vcell.opt.Parameter("slowMobileFrac", 0, 1, 1.0, 0.5);
Parameter bleachWhileMonitoringRate = new cbit.vcell.opt.Parameter("bleachWhileMonitoringRate", 0, 20, 1.0, 0.1);
Parameter[] inParams = new Parameter[] { diffFastOffset, mFracFast, diffSlow, mFracSlow, bleachWhileMonitoringRate };
// Parameter diffFast = new cbit.vcell.opt.Parameter("fast_diff_rate", 0, 100, 1.0, 5);
// Parameter mFracFast = new cbit.vcell.opt.Parameter("fast_mobile_fraction", 0, 1, 1.0, 0.5);
// Parameter diffSlowFactor = new cbit.vcell.opt.Parameter("slow_diff_factor", 0, 1, 1.0, 0.2);
// Parameter mFracSlow = new cbit.vcell.opt.Parameter("slow_mobile_fraction", 0, 1, 1.0, 0.5);
// Parameter bleachWhileMonitoringRate = new cbit.vcell.opt.Parameter("bleach_while_monitoring_rate", 0, 1, 1.0, 0.1);
// Parameter[] inParams = new Parameter[]{diffFast, mFracFast, diffSlowFactor, mFracSlow, bleachWhileMonitoringRate};
// add some constraints, like fast mobile fraction + slow mobile fraction should smaller than 1.
// slower rate should be 5 times smaller than fast rate.....??? 5*slowDiffRate < fastDiffRate
// Expression exp1 = new Expression("("+mFracFast.getName()+" + "+mFracSlow.getName()+" - 1)");
// Constraint con1 = new Constraint(ConstraintType.LinearInequality, exp1);
// Expression exp2 = new Expression("( 4 * "+diffSlow.getName()+" - "+ diffFastOffset.getName() +")");
// Constraint con2 = new Constraint(ConstraintType.LinearInequality, exp2);
// Constraint[] cons = new Constraint[2];
// cons[0] = con1;
// cons[1] = con2;
ROI[] rois = expFrapStudy.getFrapData().getRois();
boolean[] errorOfInterest = new boolean[rois.length];
for (int i = 0; i < rois.length; i++) {
if (/*!rois[i].getROIType().equals(RoiType.ROI_BLEACHED)*/
rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name()) || rois[i].getROIName().equals(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name())) {
errorOfInterest[i] = false;
} else {
errorOfInterest[i] = true;
}
}
optData.getBestParamters(inParams, errorOfInterest);
// double[][] result = optData.getFitData(inParams, errorOfInterest); // double[roiLen][timePoints]
// int indexROI = -1;
// for(int j = 0; j < expFrapStudy.getFrapData().getRois().length; j++)
// {
// if(expFrapStudy.getFrapData().getRois()[j].getROIType().equals(RoiType.ROI_BLEACHED))
// {
// indexROI = j;
// break;
// }
// }
// int index = Integer.parseInt(expFrapStudy.getFrapModelParameters().startIndexForRecovery);
// for(int i = 0; i < (expFrapStudy.getFrapData().getImageDataset().getImageTimeStamps().length - index); i++)
// {
// System.out.println(expFrapStudy.getFrapData().getImageDataset().getImageTimeStamps()[i+index]+"\t"+result[indexROI][i]);
// }
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations