use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class FRAPParamTest method runProfileLikelihood.
public void runProfileLikelihood() {
String errorMsg = checkFrapStudyValidity();
if (!errorMsg.equals("")) {
System.out.println("Application terminated due to " + errorMsg);
System.exit(1);
} else {
try {
ClientTaskStatusSupport ctss = new ClientTaskStatusSupport() {
public void setProgress(int progress) {
System.out.println(progress);
}
public void setMessage(String message) {
System.out.println(message);
}
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");
}
};
// get startign index
if (frapStudy.getStartingIndexForRecovery() == null) {
int index = FRAPDataAnalysis.calculateRecoveryIndex(frapStudy.getFrapData());
frapStudy.setStartingIndexForRecovery(index);
}
// get dependent rois
if (frapStudy.getFrapData().getRois().length < 4) {
frapStudy.refreshDependentROIs();
}
// get selected ROIs
if (frapStudy.getSelectedROIsForErrorCalculation() == null) {
boolean[] selectedROIs = new boolean[FRAPData.VFRAP_ROI_ENUM.values().length];
int counter = 0;
for (FRAPData.VFRAP_ROI_ENUM roiEnum : FRAPData.VFRAP_ROI_ENUM.values()) {
if (roiEnum.name().equals(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()) || roiEnum.name().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name())) {
counter++;
continue;
}
if (frapStudy.getFrapData().getRoi(roiEnum.name()).getNonzeroPixelsCount() > 0) {
selectedROIs[counter] = true;
counter++;
}
}
frapStudy.setSelectedROIsForErrorCalculation(selectedROIs);
}
// get frap opt data
if (frapStudy.getFrapOptData() == null) {
if (!FRAPWorkspace.areExternalDataOK(getLocalWorkspace(), frapStudy.getFrapDataExternalDataInfo(), frapStudy.getRoiExternalDataInfo())) {
// if external files are missing/currupt or ROIs are changed, create keys and save them
frapStudy.setFrapDataExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.IMAGE_EXTDATA_NAME));
frapStudy.setRoiExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_EXTDATA_NAME));
frapStudy.saveROIsAsExternalData(localWorkspace, frapStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
frapStudy.saveImageDatasetAsExternalData(localWorkspace, frapStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
}
// run ref sim
frapStudy.setFrapOptData(new FRAPOptData(frapStudy, FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF, localWorkspace, ctss));
}
FRAPOptData optData = frapStudy.getFrapOptData();
// create frapModels
if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT] == null) {
frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT] = new FRAPModel(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT], null, null, null);
if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters() == null) {
frapStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF);
Parameter[] initialParams = FRAPModel.getInitialParameters(frapStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT], frapStudy.getStartingIndexForRecovery());
Parameter[] bestParameters = frapStudy.getFrapOptData().getBestParamters(initialParams, frapStudy.getSelectedROIsForErrorCalculation());
frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].setModelParameters(bestParameters);
}
}
if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS] == null) {
frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS] = new FRAPModel(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS], null, null, null);
if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters() == null) {
frapStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF);
Parameter[] initialParams = FRAPModel.getInitialParameters(frapStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS], frapStudy.getStartingIndexForRecovery());
Parameter[] bestParameters = frapStudy.getFrapOptData().getBestParamters(initialParams, frapStudy.getSelectedROIsForErrorCalculation());
frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].setModelParameters(bestParameters);
}
}
// try diffusion with one diffusing component model
System.out.println("Evaluating parameters in diffusion with one diffusing compoent model...");
Parameter[] bestParameters = frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters();
ProfileData[] profileData = optData.evaluateParameters(bestParameters, ctss);
// output profile likelihood
File outputDir_oneComponent = new File(getLocalWorkspace().getDefaultWorkspaceDirectory() + SUB_DIRECTORY + "OneComponent_SAVED_AT_" + BeanUtils.generateDateTimeString() + System.getProperty("file.separator"));
if (!outputDir_oneComponent.exists()) {
outputDir_oneComponent.mkdirs();
}
for (int i = 0; i < profileData.length; i++) {
ProfileDataElement profileDataElement = profileData[i].getProfileDataElements().get(0);
outputProfileLikelihood(profileData[i].getProfileDataElements(), profileDataElement.getParamName(), outputDir_oneComponent);
}
// try diffusion with two diffusing components model
System.out.println("Evaluating parameters in diffusion with two diffusing compoents model...");
bestParameters = frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters();
profileData = optData.evaluateParameters(bestParameters, ctss);
// output profile likelihood
File outputDir_twoComponents = new File(getLocalWorkspace().getDefaultWorkspaceDirectory() + SUB_DIRECTORY + "TwoComponents_SAVED_AT_" + BeanUtils.generateDateTimeString() + System.getProperty("file.separator"));
if (!outputDir_twoComponents.exists()) {
outputDir_twoComponents.mkdirs();
}
for (int i = 0; i < profileData.length; i++) {
ProfileDataElement profileDataElement = profileData[i].getProfileDataElements().get(0);
outputProfileLikelihood(profileData[i].getProfileDataElements(), profileDataElement.getParamName(), outputDir_twoComponents);
}
} catch (Exception e) {
e.printStackTrace(System.out);
System.exit(1);
}
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class KenworthyWorkflowTest method main.
public static void main(String[] args) {
try {
File baseDir = new File(".");
// File baseDir = new File("/Users/schaff/Documents/workspace/VCell_5.4");
// initialize computing environment
//
File workingDirectory = new File(baseDir, "workingDir");
LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
//
// import raw image time series data from VFRAP file format (can have noise, background, etc ... can be actual microscopy data)
//
ClientTaskStatusSupport progressListener = 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) {
}
};
//
// generate fake data (and save?)
//
// ImageTimeSeries<UShortImage> simulatedFluorescence = generateFakeData(localWorkspace, progressListener);
// new ExportRawTimeSeriesToVFrapOp().exportToVFRAP(vfrapFile, simulatedFluorescence, null);
//
// analyze raw data (from file?) using Keyworthy method.
//
File vfrapFile = new File(baseDir, "vfrapPaper/rawData/sim3/workflow.txt.save");
// File vfrapFile = new File(baseDir, "tryit.vfrap");
ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
analyzeKeyworthy(fluorTimeSeriesImages, localWorkspace);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class WorkflowModelPanel method main.
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
JFrame frame = new javax.swing.JFrame();
WorkflowModelPanel aWorkflowModelPanel;
aWorkflowModelPanel = new WorkflowModelPanel();
frame.setContentPane(aWorkflowModelPanel);
frame.setSize(aWorkflowModelPanel.getSize());
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
LocalWorkspace localWorkspace = new LocalWorkspace(new File("C:\\temp"));
Workflow workflow = new Workflow("temp");
class Task1 extends Task {
final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);
final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);
public Task1() {
super("t1");
addInput(in);
addOutput(out);
}
@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
System.out.println("executing task " + getName());
}
}
;
class Task2 extends Task {
final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);
final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);
public Task2() {
super("t2");
addInput(in);
addOutput(out);
}
@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
System.out.println("executing task " + getName());
}
}
;
Task1 task1 = new Task1();
workflow.addTask(task1);
Task2 task2 = new Task2();
workflow.addTask(task2);
workflow.connect2(task1.out, task2.in);
aWorkflowModelPanel.setWorkflow(workflow);
frame.setVisible(true);
java.awt.Insets insets = frame.getInsets();
frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class ImportRawTimeSeriesFrom2DVCellConcentrationsOp method importRawTimeSeries.
public ImageTimeSeries<UShortImage> importRawTimeSeries(File vcellSimLogFile, String fluorFunctionName, double maxIntensity, boolean bNoise) throws Exception {
ClientTaskStatusSupport clientTaskStatusSupport = null;
ImageDataset timeRawData = importRawTimeSeries(vcellSimLogFile, fluorFunctionName, maxIntensity, bNoise, clientTaskStatusSupport);
ImageTimeSeries<UShortImage> imageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, timeRawData.getAllImages(), timeRawData.getImageTimeStamps(), 1);
return imageTimeSeries;
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class ImportRawTimeSeriesFromExperimentImagesOp method importRawTimeSeries.
public ImageTimeSeries<UShortImage> importRawTimeSeries(File[] expTimeSeriesFiles, double timeInterval) throws Exception {
boolean isTimeSeries = true;
ClientTaskStatusSupport clientTaskStatusSupport = null;
ImageDataset rawTimeData = ImageDatasetReaderService.getInstance().getImageDatasetReader().readImageDatasetFromMultiFiles(expTimeSeriesFiles, clientTaskStatusSupport, isTimeSeries, timeInterval);
ImageTimeSeries<UShortImage> imageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, rawTimeData.getAllImages(), rawTimeData.getImageTimeStamps(), 1);
return imageTimeSeries;
}
Aggregations