diff --git a/pom.xml b/pom.xml
index 440f53d867..b55a0d5917 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,33 +60,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
vcell-admin
-
vcell-api
vcell-apiclient
vcell-client
vcell-core
-
vcell-math
vcell-server
vcell-util
vcell-vmicro
vcell-cli
- vcell-imagej-helper
vcell-web
@@ -97,12 +81,12 @@
https://github.com/virtualcell/vcell
- Bugzilla
- http://code3.cam.uchc.edu/bugzilla/
+ GitHub Issues
+ https://github.com/virtualcell/vcell/issues
- Travis CI
- https://travis-ci.org/virtualcell/vcell
+ GitHub Actions
+ https://github.com/virtualcell/vcell/actions
diff --git a/vcell-imagej-helper/.gitignore b/vcell-imagej-helper/.gitignore
deleted file mode 100644
index da7560e07f..0000000000
--- a/vcell-imagej-helper/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/.apt_generated_tests/
diff --git a/vcell-imagej-helper/Analysis ROI.zip b/vcell-imagej-helper/Analysis ROI.zip
deleted file mode 100644
index e2418d933e..0000000000
Binary files a/vcell-imagej-helper/Analysis ROI.zip and /dev/null differ
diff --git a/vcell-imagej-helper/Display1Var1Time.groovy b/vcell-imagej-helper/Display1Var1Time.groovy
deleted file mode 100644
index 07d472bc1a..0000000000
--- a/vcell-imagej-helper/Display1Var1Time.groovy
+++ /dev/null
@@ -1,193 +0,0 @@
-#@VCellHelper vcHelper
-#@ImageJ imagej
-
-import org.vcell.imagej.helper.VCellHelper
-import net.imagej.ImageJ
-import org.scijava.ui.DialogPrompt
-
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults
-import org.vcell.imagej.helper.VCellHelper.IJData
-import org.vcell.imagej.helper.VCellHelper.IJDataList
-import org.vcell.imagej.helper.VCellHelper.IJVarInfo
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos
-import org.vcell.imagej.helper.VCellHelper.VCellModelVersionTimeRange
-import org.vcell.imagej.helper.VCellHelper.VARTYPE_POSTPROC
-import net.imagej.display.DefaultDatasetView
-import net.imglib2.display.ColorTable
-
-import java.text.SimpleDateFormat
-import java.awt.Frame
-
-import ij.process.LUT
-import net.imglib2.img.array.ArrayImgs
-import org.apache.commons.math.stat.descriptive.SummaryStatistics
-import ij.IJ
-import net.imagej.axis.AxisType
-import net.imagej.axis.Axes
-import net.imglib2.type.numeric.real.DoubleType
-import net.imglib2.type.numeric.real.FloatType
-import net.imglib2.img.planar.PlanarImgFactory
-import ij.WindowManager
-import ij.process.StackStatistics
-import ij.plugin.filter.Analyzer
-import ij.measure.Measurements
-
-try{
- lastVCellApiPort = vcHelper.findVCellApiServerPort();//search for port that vcell is providing IJ related services on
- System.out.println(lastVCellApiPort);
-}catch(Exception e){
- imagej.ui().showDialog(e.getMessage()+"\nCheck VCell running and Tools->'Start FIJI (ImageJ) Service'. is started","Couldn't Communicate with VCell",DialogPrompt.MessageType.ERROR_MESSAGE)
-}
-
-VCellHelper.VCellModelSearch searchCriteria = new VCellHelper.VCellModelSearch(
- VCellHelper.ModelType.bm, "tutorial", "Tutorial_MultiApp", "3D pde", "Simulation4",
- null/*Geom Dimension 0,1,2,3*/,null/*MathType {"Determinsitc","Stochastic"}*/);
-
-SimpleDateFormat easyDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-searchFrom = easyDate.parse("2018-01-01 00:00:00")
-searchTo = easyDate.parse("2100-01-01 00:00:00")
-searchTimeRange = new VCellModelVersionTimeRange(searchFrom,searchTo)
-ArrayList vcellModelSearchResults = vcHelper.getSearchedModelSimCacheKey(false/*Only Open Models*/, searchCriteria,searchTimeRange);
-if(vcellModelSearchResults == null || vcellModelSearchResults.size() == 0){
- imagej.ui().showDialog("No VCell models found matching search criteria","Search Results Empty",DialogPrompt.MessageType.INFORMATION_MESSAGE)
- return;
-}
-int theCacheKey = Integer.valueOf(vcellModelSearchResults.get(0).getCacheKey()).intValue();
-
-var = "C_cyt" //Volume variable name from the variable slection list in Simulation results viewer
-timeIndex = [50] as int[] //Time index (not actual time) found by looking at number directly over time slider in VCell simulation results viewer
-try{
- //Get data at single time for a single variable
- //TimePointData getTimePointData(String simulationDataCacheKey,String variableName,int[] timePointIndexes,int simulationJobIndex)
- ijDataList = vcHelper.getTimePointData(theCacheKey as String,var,VARTYPE_POSTPROC.NotPostProcess,timeIndex,0)
- bsd = ijDataList.ijData[0].stackInfo
- println(bsd.xsize+" "+bsd.ysize+" "+bsd.zsize)
- data = ijDataList.ijData[0].getDoubleData()
- notInDomainVal = ijDataList.ijData[0].notInDomainValue
- //println(bsd.xsize+" "+bsd.ysize+" "+bsd.zsize)
- //ds = imagej.dataset().create(new FloatType(),[5,5,5] as long[],"hello", [Axes.X,Axes.Y,Axes.Z] as AxisType[])
- //imagej.display().createDisplay("dsimg",ds)
-
- dataImg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize,bsd.zsize)
- title = var+"_at_"+timeIndex[0]
- tempDisp = imagej.display().createDisplay("temp",dataImg)
- //println("-----"+tempDisp.getName())
- //Thread.sleep(100)
- IJ.run("Duplicate...", "title="+title+" duplicate");
- //Thread.sleep(100)
- //currDisp = tempDisp //imagej.display().getDisplay(title)
- //while(WindowManager.getWindow(title) == null || !WindowManager.getWindow(title).isShowing()){
- // println("-----"+imagej.display().getActiveDisplay().getName())
- // Thread.sleep(500)
- //}
- currDisp = null
-
-disps = imagej.imageDisplay().getImageDisplays()
-for(int i=0;i vcellModelSearchResults = vcHelper.getSearchedModelSimCacheKey(false, search,null);
-System.out.println(vcellModelSearchResults);
-int theCacheKey = Integer.valueOf(vcellModelSearchResults.get(0).getCacheKey()).intValue();
-final IJVarInfos ijVarInfos = vcHelper.getSimulationInfo(theCacheKey+"");
-ArrayList varList = new ArrayList<>();
-final ArrayList ijVarInfo = ijVarInfos.getIjVarInfo();
-for (int i = 0; i < ijVarInfo.size(); i++) {
- if(ijVarInfo.get(i).getVariableType().equals("Volume")){
- varList.add(ijVarInfo.get(i).getName());
- }
-}
-String[] vars = varList.toArray(new String[0]);
-int[] dataIndexes = [5269,5281];
-double[] times = [5.0,300.0];
-//Get the data values using the cache-key
-//IJTimeSeriesJobResults getTimeSeries(String[] variableNames, int[] indices, double startTime, int step, double endTime,boolean calcSpaceStats, boolean calcTimeStats, int jobid, int cachekey) throws Exception{
-for (int t = 0; t < times.length; t++) {
- IJTimeSeriesJobResults ijTimeSeriesJobResults = vcHelper.getTimeSeries(vars, dataIndexes, times[t], 1, times[t], false, false, 0/*jobid, if parameter scan can be non-zero*/, theCacheKey);
- println("-----Time="+times[t]+"-----");
- if(ijTimeSeriesJobResults.data != null) {//no statistics, just data values
- //ijTimeSeriesJobResults.data[numVars][numDataPoints+1][numTimes] structure of ijTimeSeriesJobResults.data
- //ijTimeSeriesJobResults.data[varIndex][0][0...numTimes-1] contains the timePoints
- //ijTimeSeriesJobResults.data[varIndex][1...numDataPoints][0...numTimes-1] contains the data values at each index for each timePoint
- for (int varIndex = 0; varIndex < ijTimeSeriesJobResults.data.length; varIndex++) {
- for (int dataIndexes1 = 1; dataIndexes1 < ijTimeSeriesJobResults.data[varIndex].length; dataIndexes1++) {
- for (int timeIndexes = 0; timeIndexes < ijTimeSeriesJobResults.data[varIndex][dataIndexes1].length; timeIndexes++) {
- println("var="+vars[varIndex]+" dataIndex="+dataIndexes[dataIndexes1-1]+" val="+ijTimeSeriesJobResults.data[varIndex][dataIndexes1][timeIndexes]);
- }
- }
- }
- }else {//space statistics
- for (int i = 0; i < ijTimeSeriesJobResults.variableNames.length; i++) {
- for (int t2 = 0; t2 < ijTimeSeriesJobResults.times.length; t2++) {
- println(ijTimeSeriesJobResults.variableNames[i]+
- " min="+ijTimeSeriesJobResults.min[i][t2]+" max="+ijTimeSeriesJobResults.max[i][t2]+" mean="+ijTimeSeriesJobResults.unweightedMean[i][t2]+" size="+ijTimeSeriesJobResults.totalSpace[i]);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/vcell-imagej-helper/Seg Geom_2d.zip b/vcell-imagej-helper/Seg Geom_2d.zip
deleted file mode 100644
index 8374ca05f3..0000000000
Binary files a/vcell-imagej-helper/Seg Geom_2d.zip and /dev/null differ
diff --git a/vcell-imagej-helper/Seg Geom_3d.zip b/vcell-imagej-helper/Seg Geom_3d.zip
deleted file mode 100644
index f88d0a69fe..0000000000
Binary files a/vcell-imagej-helper/Seg Geom_3d.zip and /dev/null differ
diff --git a/vcell-imagej-helper/SimpleDemo.ijm.groovy b/vcell-imagej-helper/SimpleDemo.ijm.groovy
deleted file mode 100644
index 42d8841815..0000000000
--- a/vcell-imagej-helper/SimpleDemo.ijm.groovy
+++ /dev/null
@@ -1,180 +0,0 @@
-//@VCellHelper vh
-//@ImageJ ij
-
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.vcell.imagej.helper.VCellHelper.IJSolverStatus;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfo;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-import org.vcell.imagej.helper.VCellHelper;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.jfree.data.xy.DefaultXYDataset;
-import javax.swing.JFrame;
-import ij.WindowManager;
-import java.awt.Window;
-import javax.swing.JRootPane;
-import org.jfree.data.xy.XYDataset;
-import javax.swing.SwingUtilities;
-
-import io.scif.img.SCIFIOImgPlus;
-import net.imagej.ImageJ;
-import net.imagej.ImgPlus;
-import net.imagej.ImgPlusMetadata;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.type.numeric.real.DoubleType;
-
- //Global variable
- EASY_DATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- System.out.println("----------ODE data from stochastic variable----------");
- odeDataTest();
- System.out.println("----------PDE data from 3D volume variable----------");
- pdeDataTest();
- System.out.println("----------Run simulation with overriden parameter----------");
- localSimRunVCellTest();
-
- def localSimRunVCellTest(){
- VCellHelper.VCellModelVersionTimeRange vcellModelVersionTimeRange = new VCellHelper.VCellModelVersionTimeRange(EASY_DATE.parse("2015-01-01 00:00:00"), EASY_DATE.parse("2018-08-01 00:00:00"));
- VCellHelper.VCellModelSearch search = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm, "tutorial", "Tutorial_FRAPbinding", "Spatial", "FRAP binding",null,null);
- // Find the simulation we want to run
- ArrayList vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,vcellModelVersionTimeRange);
- if(vcellModelSearchResults.size() != 1) {
- throw new Exception("Expecting only 1 model from search results");
- }
- // Get cacheKey to reference the found simulation
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-
- // As simple example define new simulation endTime and 'rf_diffusionRate' parameter override (refer to FRAP script for more advanced example)
- final double newDiffusionRate = 1.5;
- HashMap simulationParameterOverrides = new HashMap<>();
- simulationParameterOverrides.put("rf_diffusionRate", ""+newDiffusionRate);
- double newEndTime = 5.0;
- // Start running the solver LOCALLY (solver will run on users local machine, equivalent to 'quickrun')
- System.out.println("Starting solver...");
- IJSolverStatus ijSolverStatus = vh.startVCellSolver(Long.parseLong(cacheKey), null/*keep default geom*/, simulationParameterOverrides, null/*keep default initConditions*/,newEndTime);
- System.out.println(ijSolverStatus.toString());
- String simulationJobId = ijSolverStatus.simJobId;
- // Wait for simulation to finish
- while(true) {
- Thread.sleep(5000);
- ijSolverStatus = vh.getSolverStatus(simulationJobId);
- System.out.println(ijSolverStatus.toString());
- String statusName = ijSolverStatus.statusName.toLowerCase();
- if(statusName.equals("finished") || statusName.equals("stopped") || statusName.equals("aborted")) {
- break;
- }
- }
- //Get reference to simulation data
- String simulationDataCacheKey = vh.getSimulationDataCacheKey(ijSolverStatus.simJobId);
- // Get data for variable 'rf' at timeIndex 5
- VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationDataCacheKey, "rf", [5] as int[], ijSolverStatus.getJobIndex());
- BasicStackDimensions bsd = timePointData.getBasicStackDimensions();
- System.out.print("xsize="+bsd.xsize+" ysize="+bsd.ysize+" zsize="+bsd.zsize+" csize="+bsd.csize+" tsize="+bsd.tsize);
-
- }
- def pdeDataTest(){
- // Set the ModelName, ApplicationName and SimulationName for models we are interested in
- VCellHelper.VCellModelSearch search = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.mm, null/*Any user*/, "Calcium sparks_simple", null/*MathModels have no Applications*/, "seed=18",3,null);
- // Use VCellHelper to contact VCell client and return preliminary info
- ArrayList vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,null/*Any date*/);
- System.out.println("Model name='"+vcellModelSearchResults.get(0).getModelName()+"'");
- System.out.println("Application name='"+vcellModelSearchResults.get(0).getApplicationName()+"'");
- System.out.println("Simulation name='"+vcellModelSearchResults.get(0).getSimulationName()+"'"+" geomDims="+vcellModelSearchResults.get(0).getGeometryDimension()+" mathType="+vcellModelSearchResults.get(0).getMathType());
- // Get the cacheKey that identifies the particular simulation result we are interested in
- String simulationInfoCacheKey = vcellModelSearchResults.get(0).getCacheKey();
- // Get more specific information about our simulation using the cacheKey (times, parameter scan count, variable names,...)
- // (the cacheKey was stored in the running VCell client during the previous search and is used to quickly lookup information)
- VCellHelper.IJVarInfos ijVarInfos = vh.getSimulationInfo(simulationInfoCacheKey);
- final int THE_TIME_INDEX = 2;
- for (IJVarInfo ijVarInfo : ijVarInfos.getIjVarInfo()) {
- if(ijVarInfo.getName().equals("Ca")) {
- // Get the actual data (our simulation is non-spatial ODE)
- System.out.println("getting data for variable '"+ijVarInfo.getName()+"' at timepoint="+ijVarInfos.getTimes()[THE_TIME_INDEX]);
- VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationInfoCacheKey, ijVarInfo.getName(), [THE_TIME_INDEX] as int[],0);
- BasicStackDimensions bsd = timePointData.getBasicStackDimensions();
- if(bsd.csize != 1 || bsd.tsize != 1) {
- throw new Exception("Expecting csize and tsize to be 1");
- }
- ArrayImg data3dAtSingleTimePoint = ArrayImgs.doubles(timePointData.getTimePointData(), bsd.xsize,bsd.ysize,bsd.zsize,bsd.csize,bsd.tsize);
- ImgPlus scifoImg = SCIFIOImgPlus.wrap(data3dAtSingleTimePoint);
- DoubleType max= ij.op().stats().max(scifoImg);
- DoubleType min= ij.op().stats().min(scifoImg);
- System.out.println("name='"+ijVarInfo.getName()+"' type="+ijVarInfo.getVariableType()+" min="+min.get()+" max="+max.get());
- }
- }
- }
-
- def odeDataTest() {
- //
- // SEARCH for a known public simulation (in a BioModel), get information about the simulation and download a portion of the data
- //
- // Set the date range for models we are interested in
- VCellHelper.VCellModelVersionTimeRange vcellModelVersionTimeRange = new VCellHelper.VCellModelVersionTimeRange(EASY_DATE.parse("2016-01-01 00:00:00"), EASY_DATE.parse("2017-01-01 00:00:00"));
- // Set the ModelName, ApplicationName and SimulationName for models we are interested in
- VCellHelper.VCellModelSearch search = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm, "tutorial60", "Rule-based_egfr_tutorial", "*stoch", "Simulation1",null,null);
- // Use VCellHelper to contact VCell client and return preliminary info
- ArrayList vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,vcellModelVersionTimeRange);
- // Our search was constructed such that only 1 simulation should be in the search results
- if(vcellModelSearchResults.size() != 1) {
- throw new Exception("Expecting exactly 1 model from search results");
- }
- System.out.println("Model name='"+vcellModelSearchResults.get(0).getModelName()+"'");
- System.out.println("Application name='"+vcellModelSearchResults.get(0).getApplicationName()+"'");
- System.out.println("Simulation name='"+vcellModelSearchResults.get(0).getSimulationName()+"'"+" geomDims="+vcellModelSearchResults.get(0).getGeometryDimension()+" mathType="+vcellModelSearchResults.get(0).getMathType());
- // Get the cacheKey that identifies the particular simulation result we are interested in
- String simulationInfoCacheKey = vcellModelSearchResults.get(0).getCacheKey();
-
- // Get more specific information about our simulation using the cacheKey (times, parameter scan count, variable names,...)
- // (the cacheKey was stored in the running VCell client during the previous search and is used to quickly lookup information)
- VCellHelper.IJVarInfos ijVarInfos = vh.getSimulationInfo(simulationInfoCacheKey);
- for (IJVarInfo ijVarInfo : ijVarInfos.getIjVarInfo()) {
- if(ijVarInfo.getName().startsWith("Dimer")) {
- // Get the actual data (our simulation is non-spatial ODE)
- VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationInfoCacheKey, ijVarInfo.getName(), null,0);
- // Check the length of the data == length of timepoints (should be true for non-spatial data)
- if(timePointData.getTimePointData().length != ijVarInfos.getTimes().length) {
- throw new Exception("Expecting datalength for variable "+timePointData.getTimePointData().length+" to match number of timepoints "+ijVarInfos.getTimes().length);
- }
-// System.out.println("name='"+ijVarInfo.getName()+"' type="+ijVarInfo.getVariableType());
- makeChart(ijVarInfos.getTimes(),timePointData.getTimePointData(),"Rule Based Stochastic Data","Time vs. Counts","Time","Counts",ijVarInfo.getName());
- }
- }
- }
-
-//Make a new chart if a window with frame title 'chartFrameTitle' doesn't exist, otherwise re-use chart and add data as new series
-def makeChart(double[] domain,double[] range, String chartFrameTitle,String chartHeading,String domainLabel,String rangeLabel,String seriesLabel){
- double[][] newdata =[domain,range] as double[][];
- XYDataset dataset = null;
- if(WindowManager.getWindow(chartFrameTitle) == null){
- dataset = new DefaultXYDataset();
- JFreeChart xyLineChart = ChartFactory.createXYLineChart(chartHeading, domainLabel, rangeLabel, dataset);
- xyLineChart.getXYPlot().getRangeAxis().setAutoRange(true);
- xyLineChart.getXYPlot().getDomainAxis().setAutoRange(true);
- ChartPanel chartPanel = new ChartPanel(xyLineChart);
- JFrame frame = new JFrame(chartFrameTitle);
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.getContentPane().add(chartPanel);
- frame.pack();
- WindowManager.addWindow(frame);
- frame.setVisible(true);
- }else{
- Window chartWin = WindowManager.getWindow(chartFrameTitle);
- chartWin.setVisible(true);
- JFreeChart dataChart = ((ChartPanel)(((JRootPane)chartWin.getComponents()[0]).getContentPane().getComponents()[0])).getChart();
- dataset = dataChart.getXYPlot().getDataset();
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- dataset.addSeries(seriesLabel,newdata);
- }
- });
-}
diff --git a/vcell-imagej-helper/TestJettyService.java b/vcell-imagej-helper/TestJettyService.java
deleted file mode 100644
index 094f06de38..0000000000
--- a/vcell-imagej-helper/TestJettyService.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package scrapbook;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.vcell.imagej.ImageJHelper;
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.vcell.util.gui.DialogUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import net.imglib2.Dimensions;
-import net.imglib2.img.Img;
-import net.imglib2.img.array.ArrayCursor;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgFactory;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.img.display.imagej.ImageJFunctions;
-import net.imglib2.type.numeric.integer.UnsignedByteType;
-import net.imglib2.type.numeric.real.DoubleType;
-
-public class TestJettyService {
-
- public static void main(String[] args) {
- try {
-// ImageJHelper.startService(8010);
- exerciseService();
- System.exit(0);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- public static void printDocument(Document doc, OutputStream out) throws Exception {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(doc),new StreamResult(new OutputStreamWriter(out, "UTF-8")));
- }
- public static void exerciseService() {
- try {
-// HttpClient httpClient = new HttpClient();
-// HostConfiguration hostConfiguration = new HostConfiguration();
-// hostConfiguration.setHost("localhost",8080);
-// HttpMethod method = new GetMethod("/list?type=biom");
-// int var = httpClient.executeMethod(hostConfiguration, method);
-// System.out.println("result="+var);
-//
-// method = new GetMethod("/");
-// var = httpClient.executeMethod(hostConfiguration, method);
-// System.out.println("result="+var);
- int lastVCellApiPort = VCellHelper.findVCellApiServerPort();//search for port that vcell is providing IJ related services on
- System.out.println(VCellHelper.getApiInfo()+"\n");//get rest api
-
- URL[] testUrls = new URL[] {
- new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=true"+"&"+"type"+"="+"quick"),
-// new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=true"+"&"+"type"+"="+"bm"),
-// new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=true"+"&"+"type"+"="+"mm"),
-// new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=false"+"&"+"type"+"="+"quick"),
-// new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=false"+"&"+"type"+"="+"bm"),
-// new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"+"open=false"+"&"+"type"+"="+"mm")
- };
- for (int i = 0; i < testUrls.length; i++) {
- System.out.println("----------Test "+i+": "+testUrls[i].toString());
-// System.out.println(VCellHelper.getRawContent(testUrls[i]));
- Document doc = VCellHelper.getDocument(testUrls[i]);
- printDocument(doc, System.out);
- Node simNode = doc.getElementsByTagName("simInfo").item(0);
- String cachekey = simNode.getAttributes().getNamedItem("cacheKey").getNodeValue();
-
- URL varInfoUrl = new URL("http://localhost:"+lastVCellApiPort+"/"+"getdata"+"?"+"cachekey"+"="+cachekey);
- System.out.println(" --varInfo="+varInfoUrl.toString());
- System.out.println(VCellHelper.getRawContent(varInfoUrl));
- doc = VCellHelper.getDocument(varInfoUrl);
- ArrayList times = new ArrayList<>();
- Node timeNode = doc.getElementsByTagName("times").item(0);
- StringTokenizer st = new StringTokenizer(timeNode.getTextContent(), ",");
- while(st.hasMoreTokens()) {
- StringTokenizer timepointT = new StringTokenizer(st.nextToken(), "='");
- timepointT.nextToken();
- times.add(Double.parseDouble(timepointT.nextToken()));
- }
- String varName = null;
- NodeList varNodes = doc.getElementsByTagName("ijVarInfo");
- for(int j=0;j img = ArrayImgs.doubles(data, dims);
-// ArrayImg img = (ArrayImg)new ArrayImgFactory< DoubleType >().create( basicStackDimensions, new DoubleType() );
-// ArrayCursor cursor = img.cursor();
-// while(cursor.hasNext()) {
-// cursor.next().set
-// }
-
-
-// Img< UnsignedByteType > img = new ArrayImgFactory< UnsignedByteType >().create( new long[] { 400, 320 }, new UnsignedByteType() );
- ImageJFunctions.show( img );
- DialogUtils.showInfoDialog(JOptionPane.getRootFrame(), "blah");
-
-// JAXBContext jaxbContext = JAXBContext.newInstance(IJData.class);
-// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-// IJData ijData = (IJData) jaxbUnmarshaller.unmarshal(new URL("http://localhost:8080/"+ApiEnum.getdata.name()+"?"/*+"open=true"+"&"*/+IJGetDataParams.cachekey.name()+"=0"));
-// System.out.println(ijData);
-
-// URLConnection con = url.openConnection();
-// InputStream in = con.getInputStream();
-// String encoding = con.getContentEncoding();
-// encoding = encoding == null ? "UTF-8" : encoding;
-// String body = IOUtils.toString(in, encoding);
-// System.out.println(body);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-}
diff --git a/vcell-imagej-helper/chart.groovy b/vcell-imagej-helper/chart.groovy
deleted file mode 100644
index 29543c15f2..0000000000
--- a/vcell-imagej-helper/chart.groovy
+++ /dev/null
@@ -1,92 +0,0 @@
-#@VCellHelper vh
-//(See https://github.com/virtualcell/vcell/tree/master/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/VCellHelper.java)
-
-import org.jfree.chart.ChartFactory
-import org.jfree.chart.JFreeChart
-import org.jfree.chart.ChartPanel
-import org.jfree.data.category.CategoryDataset
-import org.jfree.data.xy.XYDataset
-import org.jfree.data.xy.DefaultXYDataset
-import javax.swing.JFrame
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearch
-import org.vcell.imagej.helper.VCellHelper.ModelType
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults
-
-
-//Demo chart in ImageJ of line-scan values from VCell simulation results
-
-// BioModel "Tutorial_FRAPbinding" owned by user "tutorial" in application "Spatial" for simulation "FRAP binding"
-// values for variable="r" at timePoint=22.0
-// line-scan along x-axis at y=0.0
-// start and end indexes found by moving mouse over x,y data points (-9.24,0.0) and (9.24,0,0) and
-// see index in "info' box at the bottom of the sim results viewer in VCell
-
-//Create list of datapoint indexes to extract from data
-startIndex = 1279
-endIndex = 1321
-int[] dataIndexes = new int[endIndex-startIndex]
-for(int i=0;i*/vcmsrArrayList = vh.getSearchedModelSimCacheKey(false/*only open models*/,vcms,null/*only saved models withing this date range*/)
-
-//For this search there should only be 1 result, get the search cache-key from the returned list, used for subsequent data operations
-/*VCellModelSearchResults extends VCellModelSearch*/vcmsr = vcmsrArrayList.get(0)
-/*String*/theCacheKey = vcmsr.getCacheKey();
-println(theCacheKey)
-
-//Get the data values using the cache-key
-//IJTimeSeriesJobResults getTimeSeries(String[] variableNames, int[] indices, double startTime, int step, double endTime,boolean calcSpaceStats, boolean calcTimeStats, int jobid, int cachekey) throws Exception{
-ijTimeSeriesJobResults = vh.getTimeSeries(vars, dataIndexes, 22 as double, 1, 22 as double, false, false, 0/*jobid, if parameter scan can be non-zero*/, theCacheKey as int)
-//ijTimeSeriesJobResults.data[numVars][numDataPoints+1][numTimes] structure of ijTimeSeriesJobResults.data
-//ijTimeSeriesJobResults.data[varIndex][0][0...numTimes-1] contains the timePoints
-//ijTimeSeriesJobResults.data[varIndex][1...numDataPoints][0...numTimes-1] contains the data values at each index for each timePoint
-//Demo TimePoints ijTimeSeriesJobResults.data[0][0] == array of timePoints for var="r", array has 1 value for timePoint=22.0
-//Demo DataPoints ijTimeSeriesJobResults.data[0][1..numDataPoints][0] iterate over dataPoints at each timePoint for each var to get data for var,times
-double[] chartTheseDataPoints = new double[dataIndexes.length]
-for(int i=0;i segmentedGeomValuesMapSubvolumeName = new HashMap();
- segmentedGeomValuesMapSubvolumeName.put(0, "cyt");
- segmentedGeomValuesMapSubvolumeName.put(255, "Nuc");
- VCellHelper.IJGeom overrideGeom = createGeometry(exampleDatasets.segmentedGeom, xIndex, yIndex, assumedZIndex, xsize, ysize, zsize, segmentedGeomValuesMapSubvolumeName);
- double[] diffRates = [
- 1.25,
-// 1.3,
-// 1.4,
-// 1.45,
-// 1.5,
-// 1.55,
-// 1.6
- ] as double[];
- double[] mse = new double[diffRates.length];
- for (int i = 0; i < diffRates.length; i++) {
- String simulationCacheKey = getSimulationCacheKey(vh);
- println(simulationCacheKey)
- IJSimStatus ijSimStatus = runFrapSolver(vh, diffRates[i],simulationCacheKey,overrideGeom);
- String simulationDataCacheKey = waitForSolverGetCacheForData(vh, ijSimStatus);
- SCIFIOImgPlus annotatedZProjectedSimPostBleachData = zProjectNormalizeSimData(vh, "Sim Data "+diffRates[i], simulationDataCacheKey, "rf", 0, ijSimStatus.getJobIndex(), ANALYZE_BEGIN_TIMEINDEX, ANALYZE_END_TIMEINDEX);
- showAndZoom(ij, "Sim Data "+diffRates[i], annotatedZProjectedSimPostBleachData, 4);
- mse[i] = calcMSE(ij, annotatedZProjectedSimPostBleachData,exampleDatasets,analyzeOrigInterval);
- }
- for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- //This search should only find 1
- if(vcellModelSearchResults.size() != 1) {
- ij.IJ.showMessage("Expecting 1 search result for "+search.getModelName()+" but got "+vcellModelSearchResults.size()+", make sure model is open in VCell client");
- throw new Exception("Expecting only 1 model from search results");
- }
-
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
- try{
- //make sure original sim result is open
- //getTimePointData(String simulationDataCacheKey,String variableName,VARTYPE_POSTPROC varTypePostProcess,int[] timePointIndexes,int simulationJobIndex)
- tIndexes = [0] as int[]
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(cacheKey, null, VCellHelper.VARTYPE_POSTPROC.NotPostProcess,tIndexes, 0);
- }catch(Exception e){
- ij.IJ.showMessage("Make sure Application '"+search.getApplicationName()+"' -> Simulation '"+search.getSimulationName()+"' results viewer is open");
- e.printStackTrace()
- println(e.getMessage())
- throw e
- }
-
- return cacheKey;
-
- }
- def IJSimStatus runFrapSolver(VCellHelper vh,double diffusionRate,String cacheKey,VCellHelper.IJGeom overrideGeom) throws Exception{
- //Override Model/Simulation parameter values (user must have knowledge of chosen model to know what parameter names to override)
- HashMap simulationParameterOverrides = new HashMap<>();
- simulationParameterOverrides.put("rf_diffusionRate", ""+diffusionRate);
- HashMap speciesContextInitialConditionsOverrides = new HashMap<>();
- String laserArea = "((x >= "+43+") && (x <= "+47+") && (y >= "+22+") && (y <= "+26+"))";
- speciesContextInitialConditionsOverrides.put("Laser", laserArea);
- double newEndTime = 10.0;
- //Start Frap simulation
- IJSimStatus iJSimStatus = vh.startVCellSolver(Long.parseLong(cacheKey), overrideGeom, simulationParameterOverrides, speciesContextInitialConditionsOverrides,newEndTime);
- return iJSimStatus;
- }
- def String waitForSolverGetCacheForData(VCellHelper vh,IJSimStatus iJSimStatus) throws Exception{
- //Wait for solver to finish
- System.out.println(iJSimStatus.toString());
- ij.IJ.log(iJSimStatus.toString())
- String simulationJobId = iJSimStatus.simJobId;
- while(true) {
- Thread.sleep(5000);
- iJSimStatus = vh.getSolverStatus(simulationJobId);
- System.out.println(iJSimStatus.toString());
- ij.IJ.log(iJSimStatus.toString())
- String statusName = iJSimStatus.statusName.toLowerCase();
- if(statusName.equals("finished") || statusName.equals("stopped") || statusName.equals("aborted")) {
- break;
- }
- }
- return vh.getSimulationDataCacheKey(iJSimStatus.simJobId);
- }
- def SCIFIOImgPlus zProjectNormalizeSimData(VCellHelper vh,
- String newImgPlusName,String simulationDataCachekey,String varToAnalyze,int preBleachTimeIndex,int solverStatus_jobIndex,int ANALYZE_BEGIN_TIMEINDEX,int ANALYZE_END_TIMEINDEX) throws Exception{
-
- int ANALYZE_COUNT = ANALYZE_END_TIMEINDEX - ANALYZE_BEGIN_TIMEINDEX+1;
- // Get the SIMULATION pre-bleach timepoint data for normalizing
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(simulationDataCachekey, varToAnalyze, [preBleachTimeIndex] as int[], solverStatus_jobIndex);
- int xysize = ijDataList.ijData[0].stackInfo.xsize*ijDataList.ijData[0].stackInfo.ysize;
- double[] bleachedTimeStack = new double[ANALYZE_COUNT*xysize];
-// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-// URL dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)(0)+"&"+"jobid="+ijSolverStatus.getJobIndex());
- double[] zProjectedSimNormalizer = getNormalizedZProjected(ijDataList,null);
-//showAndZoom(ij, "Sim Data PreBleach", ArrayImgs.doubles(simNormalizer, xsize,ysize), 4);
-
- // Get the SIMULATION post-bleach data to analyze
- for(int timeIndex = ANALYZE_BEGIN_TIMEINDEX;timeIndex<=ANALYZE_END_TIMEINDEX;timeIndex++){
- ijDataList = vh.getTimePointData(simulationDataCachekey, varToAnalyze, [timeIndex] as int[], solverStatus_jobIndex);
-// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-// dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)timeIndex+"&"+"jobid="+ijSolverStatus.getJobIndex());
- double[] data = getNormalizedZProjected(ijDataList,zProjectedSimNormalizer);
- System.arraycopy(data, 0, bleachedTimeStack, (timeIndex-ANALYZE_BEGIN_TIMEINDEX)*xysize, data.length);
- }
-
- //Turn VCell data into iterableinterval
-// FinalInterval zProjectedSimDataSize = FinalInterval.createMinSize(new long[] {0,0,0, xsize,ysize,ANALYZE_COUNT});//xyzt:origin and xyzt:size
- ArrayImg simImgs = ArrayImgs.doubles(bleachedTimeStack, [ijDataList.ijData[0].stackInfo.xsize,ijDataList.ijData[0].stackInfo.ysize,ANALYZE_COUNT] as long[]);
- SCIFIOImgPlus annotatedZProjectedSimPostBleachData = new SCIFIOImgPlus<>(simImgs,newImgPlusName,[Axes.X,Axes.Y,Axes.TIME] as AxisType[]);
-// RandomAccessibleInterval simExtracted = ij.op().transform().crop(annotatedSimData, simExtractInterval);
-//showAndZoom(ij, "Sim Data "+diffusionRate, annotatedZProjectedSimPostBleachData, 4);
- return annotatedZProjectedSimPostBleachData;
- }
- def double[] getNormalizedZProjected(VCellHelper.IJDataList ijDataList,double[] normalizer) throws Exception{
- VCellHelper.BasicStackDimensions basicStackDimensions = ijDataList.ijData[0].stackInfo;//VCellHelper.getDimensions(nodes.item(0));
- //Sum pixel values in Z direction to match experimental data (open pinhole confocal, essentially brightfield)
- int xysize = basicStackDimensions.xsize*basicStackDimensions.ysize;
- double[] normalizedData = new double[xysize];
- for (int i = 0; i < ijDataList.ijData[0].getDoubleData().length; i++) {
- normalizedData[(i%xysize)]+= ijDataList.ijData[0].getDoubleData()[i];
- }
- if(normalizer != null) {
- for (int i = 0; i < normalizedData.length; i++) {
- if(normalizedData[i] != 0) {
- normalizedData[i] = (normalizedData[i]+Double.MIN_VALUE)/(normalizer[i]+Double.MIN_VALUE);
- }
- }
- }
- return normalizedData;
- }
-// public static void checkSizes(BasicStackDimensions basicStackDimensions,int xsize,int ysize,int zsize) throws Exception{
-// if(basicStackDimensions.xsize != xsize || basicStackDimensions.ysize != ysize || basicStackDimensions.zsize != zsize) {
-// throw new Exception("One or more sim data xyz dimensions="+basicStackDimensions.xsize+","+basicStackDimensions.ysize+","+basicStackDimensions.zsize+" does not match expected xyz sizes="+xsize+","+ysize+","+zsize);
-// }
-// }
-
- def double calcMSE(ImageJ ij,SCIFIOImgPlus annotatedZProjectedSimPostBleachData,ExampleDatasets exampleDatasets,FinalInterval analyzeOrigInterval) throws Exception{
- //Calculate mean-squared-error as example, normalize experimental data by dividing by a prebleach image
- RandomAccessibleInterval extends RealType>> zProjectedExperimentalPostBleach = ij.op().transform().crop(exampleDatasets.experimentalData, analyzeOrigInterval);
- Cursor zProjectedSimPostBleachDataCursor = IterableRandomAccessibleInterval.create(annotatedZProjectedSimPostBleachData).localizingCursor();
- Cursor extends RealType>> zProjectedExpPostBleachDataCursor = IterableRandomAccessibleInterval.create(zProjectedExperimentalPostBleach).localizingCursor();
- IterableRandomAccessibleInterval extends RealType>> zProjectedPreBleachInterval = IterableRandomAccessibleInterval.create(exampleDatasets.preBleachImage);
- BigDecimal sumSquaredDiff = new BigDecimal(0);
- int[] analysisPosition = new int[exampleDatasets.analysisROI.numDimensions()];
- int[] preBleachPosition = new int[zProjectedPreBleachInterval.numDimensions()];
- int[] experimentalPosition = new int[zProjectedExperimentalPostBleach.numDimensions()];
- int[] simulationPosition = new int[annotatedZProjectedSimPostBleachData.numDimensions()];
- int numValsInMask = 0;
- while(zProjectedSimPostBleachDataCursor.hasNext()){
- Cursor analysisCursor = exampleDatasets.analysisROI.localizingCursor();
- Cursor extends RealType>> preBleachNormalizingCursor = zProjectedPreBleachInterval.localizingCursor();
- while(analysisCursor.hasNext()){
- boolean maskBit = !(analysisCursor.next().get() == 0);
- DoubleType simPostBleachVal = zProjectedSimPostBleachDataCursor.next();
- RealType> expPostBleachVal = zProjectedExpPostBleachDataCursor.next();
- RealType> preBleachNormalizingVal = preBleachNormalizingCursor.next();
- if(!maskBit) {//skip areas where analysis mask is 0
- continue;
- }
- //Get the position of all the cursors and check they are in sync
- analysisCursor.localize(analysisPosition);
- preBleachNormalizingCursor.localize(preBleachPosition);
- zProjectedExpPostBleachDataCursor.localize(experimentalPosition);
- zProjectedSimPostBleachDataCursor.localize(simulationPosition);
-// System.out.println("analysis="+Arrays.toString(analysisPosition)+" prebleach="+Arrays.toString(preBleachPosition)+" exp="+Arrays.toString(experimentalPosition)+" sim="+Arrays.toString(simulationPosition));
- if(!Arrays.equals(analysisPosition, preBleachPosition) || !Arrays.equals(experimentalPosition, simulationPosition)){
- throw new Exception("Cursor positions not equal");
- }
- if(analysisPosition[0] != experimentalPosition[0] || analysisPosition[1] != experimentalPosition[1]) {//check xy are same
- throw new Exception("XY Cursor position not equal for analysisROI mask and experimental data");
- }
- double normalizedExpDataVal = 0;
- if(expPostBleachVal.getRealDouble() != 0) {
- normalizedExpDataVal = (expPostBleachVal.getRealDouble())/(preBleachNormalizingVal.getRealDouble()+Double.MIN_VALUE);
- }
- double diff = simPostBleachVal.get()-(normalizedExpDataVal);
- sumSquaredDiff = sumSquaredDiff.add(new BigDecimal(Math.pow(diff,2.0)));
- numValsInMask++;
- }
- }
- return sumSquaredDiff.divide(new BigDecimal(numValsInMask),8, RoundingMode.HALF_UP).doubleValue();
-
- }
- public class ExampleDatasets{
- public ImgPlus extends RealType>> experimentalData;
- public ImgPlus extends RealType>> preBleachImage;
- public ImgPlus segmentedGeom;
- public ImgPlus analysisROI;
- public ExampleDatasets(ImgPlus extends RealType>> experimentalData,
- ImgPlus extends RealType>> preBleachImage, ImgPlus segmentedGeom,
- ImgPlus analysisROI) {
- super();
- this.experimentalData = experimentalData;
- this.preBleachImage = preBleachImage;
- this.segmentedGeom = segmentedGeom;
- this.analysisROI = analysisROI;
- }
- }
- def ExampleDatasets openExample(ImageJ ij,File exampleDataDir) throws Exception{
- final String[] exampleFiles = ["Experimental.zip","Seg Geom_3d.zip","PreBleach.zip","Analysis ROI.zip"] as String[];
-// final String[] exampleFiles = new String[] {"testDiff_1_2.zip","Seg Geom_3d.zip","testPreBleach.zip","Analysis ROI.zip"};// for test
-
-
-// List> displays0 = ij.display().getDisplays();
-// for (Display> display : displays0) {
-// System.out.println("----------disp "+display.getName()+" "+display.getIdentifier());
-// }
- List knownImageDisplays = ij.imageDisplay().getImageDisplays();
-// for (ImageDisplay imageDisplay : imageDisplays0) {
-// System.out.println("----------imgdisp "+imageDisplay.getName()+" "+imageDisplay.getIdentifier());
-// }
-
- ImgPlus extends RealType>> experimentalData = null;// 2D
- ImgPlus segmentedGeom = null;// 2D or 3D (if 3D will be z-project for analysis withg 2D experimental data)
- ImgPlus extends RealType>> preBleachImage = null;// 2D
- ImgPlus analysisROI = null; // 2D
-
- // Open example images if they are not already open
- for (int exampleFilesIndex = 0; exampleFilesIndex < exampleFiles.length; exampleFilesIndex++) {
- DefaultDataset exampleFileDataset = null;
-
- for (ImageDisplay imageDisplay : knownImageDisplays) {
- if(imageDisplay.getName().equals(exampleFiles[exampleFilesIndex])) {
- exampleFileDataset = (DefaultDataset) imageDisplay.getActiveView().getData();
- break;
- }
- }
- if(exampleFileDataset == null) {
- exampleFileDataset = (DefaultDataset)ij.io().open(new File(exampleDataDir,exampleFiles[exampleFilesIndex]).getAbsolutePath());
-// ij.ui().show(exampleFileDataset);
- showAndZoom(ij, exampleFiles[exampleFilesIndex], exampleFileDataset, 4);
- }
- // Print names of axes (x,y,z,time,channel,unknown,...)
- System.out.print(exampleFileDataset.getName()+": ");
- for (int dimensionIndex = 0; dimensionIndex < exampleFileDataset.numDimensions(); dimensionIndex++) {
- System.out.print((exampleFileDataset.axis(dimensionIndex)!=null?exampleFileDataset.axis(dimensionIndex).type().toString()+" ":"null "));
- }
- System.out.println();
-
- // Assign variables (defaultDataset corresponds to open 'exampleFiles' element
- switch (exampleFilesIndex) {
- case 0:
- experimentalData = exampleFileDataset.getImgPlus();
- break;
- case 1:
- segmentedGeom = (ImgPlus) exampleFileDataset.getImgPlus();
- break;
- case 2:
- preBleachImage = exampleFileDataset.getImgPlus();
- break;
- case 3:
- analysisROI = (ImgPlus) exampleFileDataset.getImgPlus();
- break;
- }
- }
- return new ExampleDatasets(experimentalData, preBleachImage, segmentedGeom, analysisROI);
- }
- //Haven't yet found a way to reliably zoom image display programatically so it may display small despite the following code
- def void showAndZoom(ImageJ ij,String displayName,Object thingToDisplay,double zoomFactor) throws Exception{
-// if(!displayName.startsWith("Sim Data")) {
-// return;
-// }
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- // TODO Auto-generated method stub
- ij.ui().show(displayName,thingToDisplay);
- //Find display and set zoom, resize window
- List knownImageDisplays = ij.imageDisplay().getImageDisplays();
- boolean bvisible = false;
- while (!bvisible) {
- for (ImageDisplay imageDisplay : knownImageDisplays) {
- if (imageDisplay.getName().equals(displayName)) {
- if (imageDisplay.isVisible(imageDisplay.getActiveView())) {
- bvisible = true;
- break;
- }
- }
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-// int vw = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportWidth();
-// int vh = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportHeight();
-// System.out.println(" -----byname="+ij.display().getDisplay(displayName));
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- try {
- ij.imageDisplay().getActiveImageDisplay().getCanvas().setZoom(zoomFactor);
- if(ij.display().getDisplay(displayName) != null && ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)) instanceof JFrame) {
- double vw = ij.imageDisplay().getActiveImageDisplay().dimension(ij.imageDisplay().getActiveImageDisplay().dimensionIndex(Axes.X))*zoomFactor;
- double vh = ij.imageDisplay().getActiveImageDisplay().dimension(ij.imageDisplay().getActiveImageDisplay().dimensionIndex(Axes.Y))*zoomFactor;
- ((JFrame)ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getWindow()).setSize(new Dimension((int)vw+50, (int)vh+150));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
-
-// ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getPanel().redoLayout();
-// List> displays = ij.display().getDisplays();
-// for (Display> display : displays) {
-// System.out.println(display+" -----byname="+ij.display().getDisplay(displayName));
-// }
-
- }
- }).start();
-
- }
-
- def IJGeom createGeometry(ImgPlus nonZProjectedSegmentedGeom,int xIndex,int yIndex,int assumedZIndex,int xsize,int ysize,int zsize,HashMap segmentedGeomValuesMapSubvolumeName) throws Exception{
- //Create byte array that defines vcell subvolumes ids (handles)
- byte[] vcellSubvolumeHandles = new byte[(int)Intervals.numElements(nonZProjectedSegmentedGeom)];
- Cursor nonZProjectedSegmentedGeomCursor = nonZProjectedSegmentedGeom.localizingCursor();
- while(nonZProjectedSegmentedGeomCursor.hasNext()){
- UnsignedByteType segmentedGeomValue = (UnsignedByteType) nonZProjectedSegmentedGeomCursor.next();
- int currentZ = (assumedZIndex==-1?0:nonZProjectedSegmentedGeomCursor.getIntPosition(assumedZIndex));
- int currXYPixelIndex = nonZProjectedSegmentedGeomCursor.getIntPosition(yIndex)*xsize + nonZProjectedSegmentedGeomCursor.getIntPosition(xIndex);
- int currXYZPixelIndex = currXYPixelIndex + (assumedZIndex==-1?0:currentZ*(xsize*ysize));
- vcellSubvolumeHandles[currXYZPixelIndex] = (byte)segmentedGeomValue.get();
- }
- //Define new Geometry with domain equal to xyz pixel size for ease of use
- String[] subvolumeNames = segmentedGeomValuesMapSubvolumeName.values().toArray(new String[0]);
- Integer[] subvolumePixelValues = segmentedGeomValuesMapSubvolumeName.keySet().toArray(new Integer[0]);
- double[] origin = [0,0,0] as double[];
- double[] extent = [xsize,ysize,zsize] as double[];
- IJGeom ijGeom = new IJGeom(subvolumeNames, subvolumePixelValues, xsize, ysize, zsize, origin, extent, vcellSubvolumeHandles);
- return ijGeom;
- }
-
diff --git a/vcell-imagej-helper/example.groovy b/vcell-imagej-helper/example.groovy
deleted file mode 100644
index 2c72fb9906..0000000000
--- a/vcell-imagej-helper/example.groovy
+++ /dev/null
@@ -1,37 +0,0 @@
-#@VCellHelper vh
-
-import java.net.URL;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearch
-import org.vcell.imagej.helper.VCellHelper.ModelType
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults
-
-println(vh)
-
-vcServerPort = vh.findVCellApiServerPort()
-println(vcServerPort)
-xmlStr = vh.getApiInfo()
-//println(xmlStr)
-infoUrl = new URL("http://localhost:"+vcServerPort+"/getinfo?type=quick&open=true")
-info = vh.getRawContent(infoUrl)
-println(infoUrl.toString())
-println(info)
-vcms = new VCellModelSearch(ModelType.quick,null,null,null,null,null,null)
-vcmsr = vh.getSearchedModelSimCacheKey(true,vcms,null)
-theCacheKey = vcmsr.get(0).getCacheKey();
-println(theCacheKey)
-varUrl = new URL("http://localhost:"+vcServerPort+"/getdata?cachekey="+theCacheKey)
-varInfoRaw = vh.getRawContent(varUrl)
-println(varUrl.toString())
-println(varInfoRaw)
-varInfo = vh.getSimulationInfo(theCacheKey)
-println("# vars:")
-println(varInfo.getIjVarInfo().size())
-dataUrl = new URL("http://localhost:"+vcServerPort+"/getdata?cachekey="+theCacheKey+"&varname=C_cyt&timeindex=1")
-doc = vh.getDocument(dataUrl)
-println(dataUrl.toString())
-println(vh.documentToString(doc))
-tpIndexes = [1] as int[]
-tpd = vh.getTimePointData(theCacheKey,"C_cyt",tpIndexes,0)
-double[] data = tpd.getTimePointData()
-println("data length:")
-println(data.length)
\ No newline at end of file
diff --git a/vcell-imagej-helper/example2.groovy b/vcell-imagej-helper/example2.groovy
deleted file mode 100644
index fd1efdb4a1..0000000000
--- a/vcell-imagej-helper/example2.groovy
+++ /dev/null
@@ -1,17 +0,0 @@
-#@VCellHelper vh
-
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.display.imagej.ImageJFunctions;
-
-cachekey=1
-lastVCellApiPort = vh.findVCellApiServerPort()
- doc = vh.getDocument(new URL("http://localhost:"+lastVCellApiPort+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+"C_cyt"+"&"+"timepoint"+"=0.5"));//get data
- basicStackDimensions = vh.getVCStackDims(doc);
- double[] data = vh.getData(doc);
- System.out.println(basicStackDimensions.getTotalSize());
- System.out.println(data.length);
-
- dims = new long[basicStackDimensions.numDimensions()];
- basicStackDimensions.dimensions(dims);
- img = ArrayImgs.doubles(data, dims);
- ImageJFunctions.show( img );
diff --git a/vcell-imagej-helper/frap_example.ijm.groovy b/vcell-imagej-helper/frap_example.ijm.groovy
deleted file mode 100644
index 1d0855c47a..0000000000
--- a/vcell-imagej-helper/frap_example.ijm.groovy
+++ /dev/null
@@ -1,128 +0,0 @@
-//@VCellHelper vh
-//@ImageJ ij
-
-import org.vcell.imagej.helper.CR;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.jfree.data.xy.DefaultXYDataset;
-import javax.swing.JFrame;
-import ij.WindowManager;
-import java.awt.Window;
-import javax.swing.JRootPane;
-import org.jfree.data.xy.XYDataset;
-import javax.swing.SwingUtilities;
-import net.imagej.display.DefaultDatasetView;
-import net.imagej.display.DefaultImageDisplay;
-
-final String CHART_TITLE = "FRAP results";
-
-
-//disps = ij.display().getDisplays();
-//for(DefaultImageDisplay ddsv:disps){
-//println(ddsv.getActiveView().getData().getDepth());
-//}
-//
-//owins = ij.window().getOpenWindows();
-//println(owins);
-//noimg =WindowManager.getNonImageTitles();
-//println(noimg);
-//Window mywin = WindowManager.getWindow(CHART_TITLE);
-////WindowManager.removeWindow(mywin);
-////if(true){return}
-//mywin.setVisible(true);
-//JFreeChart mychart = ((ChartPanel)(((JRootPane)mywin.getComponents()[0]).getContentPane().getComponents()[0])).getChart();
-//XYDataset mydataset = mychart.getXYPlot().getDataset();
-////double[][] newdata = [[0.95,1.0],[0.194,0.195]] as double[][]
-////SwingUtilities.invokeLater(new Runnable() {
-//// @Override
-//// public void run() {
-//// mydataset.addSeries("moredata2",newdata);
-////// mychart.fireChartChanged();
-//// }
-////});
-//println(mydataset.getSeriesCount());
-//if(true){return}
-
-File exampleDir = new File("C:/Users/frm/VCellTrunkGitWorkspace2/vcell/vcell-imagej-helper");
-println(exampleDir);
-//double[] diffRates = [
-// 1.25,
-// 1.3,
-// 1.4,
-// 1.45,
-// 1.5,
-// 1.55,
-// 1.6,
-// 1.65
-//] as double[];
-
-double[] diffRates = [
- 0.00001,
- 0.5,
- 1.0,
- 1.5,
- 2.0,
- 2.5,
- 3.0,
- 3.5,
- 4.0
-] as double[];
-
-//double[] diffRates = [
-// 1.40,
-// 1.41,
-// 1.42,
-// 1.43,
-// 1.44,
-// 1.45,
-// 1.46,
-// 1.47,
-// 1.48
-//] as double[];
-
-double[] mse = CR.testSolver2(diffRates,exampleDir,vh,ij);
-double minResult = Double.POSITIVE_INFINITY;
-double maxResult = Double.NEGATIVE_INFINITY;
-for(int i =0;i attrDescrList = getStringsFromAttribute(file_id,"dataSourceDescr");
- String subTitle = attrDescrList.get(0);
-
- H5G_info_t info = H5.H5Gget_info(file_id);
- println("links="+info.nlinks);
- ArrayList dataSets = new ArrayList();
- ArrayList> attrNamesLists = new ArrayList>();
- ArrayList> attrParamNamesLists = new ArrayList>();
- ArrayList> attrParamValuesLists = new ArrayList>();
- String dataType = "";
- for(int i=0;i attrTypesList = getStringsFromAttribute(dataset_id,"_type");
- dataType = attrTypesList.get(0);
- println("DataType= "+dataType);
-
- ArrayList attrNamesList = getStringsFromAttribute(dataset_id,"dataSetNames");
- attrNamesLists.add(attrNamesList);
-
- ArrayList attrParamNamesList = getStringsFromAttribute(dataset_id,"paramNames");
- if(attrParamNamesList != null){
- attrParamNamesLists.add(attrParamNamesList);
- }
- ArrayList attrParamValuesList = getStringsFromAttribute(dataset_id,"paramValues");
- if(attrParamValuesList != null){
- attrParamValuesLists.add(attrParamValuesList);
- }
-
-
- double[][] data = getDataValues(dataset_id);
- dataSets.add(data);
-
- // Close the dataset.
- status = H5.H5Dclose (dataset_id);
-
- //if(i==2){
- // createChart(data,attrNamesList,attrDescrList.get(0));
- //}
- }
-
- // Close the file.
- status = H5.H5Fclose (file_id);
-
-if(dataType.equals("ODE Data Export")){// ODE non-stochastic with or without param scan
- createODEChart(dataSets,attrNamesLists,attrParamNamesLists,attrParamValuesLists,subTitle);
-}else{// ODE stochastic, without param scan
- createStochChart();
-}
-
-public void createStochChart(ArrayList dataSets,ArrayList> attrNamesLists,String subTitle){
- String title = "Stoch ODE"+" "+subTitle
- String xAxisLabel = "No. of Particles"
- String yAxisLabel = "Probability Distribution"
-
-}
-
-public void createODEChart(ArrayList dataSets,ArrayList> attrNamesLists,ArrayList> attrParamNamesLists,ArrayList> attrParamValuesLists,String subTitle){
- String title = "ODE"+" "+subTitle
- String xAxisLabel = "time"
- String yAxisLabel = "value"
-
- xyDataset = new DefaultXYDataset()
- for(int i=0;i varNames = attrNamesLists.get(i);
- for(int j=0;j getStringsFromAttribute(int dataset_id,String attrName){
- if(!H5.H5Aexists(dataset_id,attrName)){
- return null;
- }
- H5A_info_t attrInfo = H5.H5Aget_info_by_name(dataset_id, ".", attrName, HDF5Constants.H5P_DEFAULT);
- int attrid = H5.H5Aopen(dataset_id,attrName,HDF5Constants.H5P_DEFAULT);
- int atypeid = H5.H5Aget_type(attrid);
- int sizeOfEach = H5.H5Tget_size(atypeid);
- long attrTotalSize = H5.H5Aget_storage_size(attrid);
- int attrCount = (attrTotalSize/sizeOfEach);
- if((attrTotalSize%sizeOfEach) != 0){
- throw new Exception("Unexpected attrTotalSize not multiple of sizeOfEach");
- }
- println("attr="+attrName+" attrTotalSize="+attrTotalSize+" attrSizeOfEach="+sizeOfEach+" attrCount="+attrCount);
- byte[] attrValue = new byte[attrTotalSize];
- H5.H5Aread(attrid, atypeid, attrValue);
- String s = new String(attrValue);
- byte[] attr = new byte[sizeOfEach];
- ArrayList attrNamesList = new ArrayList();
- for(int j=0;j mapAppVarToSum = new TreeMap();
- breakhere:
- for(int j=0;j mapObsTpData = new TreeMap<>();
-// double[] times = null;
-// BioModelInfo[] bioModelInfos = VCellClientTest.getVCellClient().getRequestManager().getDocumentManager().getBioModelInfos();
-// for (int i = 0; i < bioModelInfos.length; i++) {
-// if(bioModelInfos[i].getVersion().getName().equals("EGFR Full_Model_Compart_v3")) {
-// System.out.println(bioModelInfos[i]);
-// BioModel bioModel = VCellClientTest.getVCellClient().getRequestManager().getDocumentManager().getBioModel(bioModelInfos[i]);
-// SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
-// for (int j = 0; j < simulationContexts.length; j++) {
-// if(simulationContexts[j].getName().toLowerCase().contains("nfsim")) {
-// TreeMap mapObsTpData = new TreeMap<>();
-// SimulationContext simulationContext = simulationContexts[j];
-// Simulation[] sims = simulationContext.getSimulations();
-// for (int k = 0; k < sims.length; k++) {
-// VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(sims[k].getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
-// ODESimData odeSimData = VCellClientTest.getVCellClient().getClientServerManager().getVCDataManager().getODEData(vcSimulationDataIdentifier);
-// for (int l = 0; l < odeSimData.getRowCount(); l++) {
-// ColumnDescription columnDescription = odeSimData.getColumnDescriptions(l);
-//// System.out.println(columnDescription.getName()+"\n-----");
-// double[] rowData = odeSimData.extractColumn(l);
-// if(times == null && columnDescription.getName().toLowerCase().equals("t")) {
-// times = rowData;
-// System.out.print("'Model:App:Variable'");
-// for (int m = 0;m < times.length; m++) {
-// System.out.print((m!= 0?",":"")+(times[m]));
-// }
-// System.out.println();
-// }
-// String keyName = simulationContexts[j].getName()+":"+columnDescription.getName();
-// double[] accumData = mapObsTpData.get(keyName);
-// if(accumData == null) {
-// accumData = rowData;
-// mapObsTpData.put(keyName, accumData);
-// }
-// if(accumData.length != rowData.length) {
-// throw new Exception("Rows are different lengths");
-// }
-// for (int m = 0; m < rowData.length; m++) {
-// accumData[m]+= rowData[m];
-// }
-//// System.out.println();
-// }
-//// DataIdentifier[] dataIdentifiers = VCellClientTest.getVCellClient().getClientServerManager().getVCDataManager().getDataIdentifiers(null, vcSimulationDataIdentifier);
-//// for (int l = 0; l < dataIdentifiers.length; l++) {
-//// if(dataIdentifiers[l].getName().toLowerCase().endsWith("_count")){
-//// VCellClientTest.getVCellClient().getClientServerManager().getVCDataManager().getODEData(dataIdentifiers[l]);
-//// }
-//// }
-// }
-// for(String s:mapObsTpData.keySet()) {
-// System.out.print("'"+/*bioModelInfos[i].getVersion().getName()+":"+simulationContexts[j].getName()+":"+*/s+"'");
-// double[] accumVals = mapObsTpData.get(s);
-// for (int k = 0; k < accumVals.length; k++) {
-// System.out.print((k!= 0?",":"")+(accumVals[k]/sims.length));
-// }
-// System.out.println();
-// }
-// System.out.println();
-// }
-// }
-// }
-// }
-//// VCellClientTest.getVCellClient().getClientServerManager().getVCDataManager().
-// }
-// } catch (Exception e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
diff --git a/vcell-imagej-helper/open2D.groovy b/vcell-imagej-helper/open2D.groovy
deleted file mode 100644
index 6d88b9b6f7..0000000000
--- a/vcell-imagej-helper/open2D.groovy
+++ /dev/null
@@ -1,35 +0,0 @@
-#@VCellHelper vh
-#@ImageJ ij
-import org.vcell.imagej.helper.VCellHelper
-import org.vcell.imagej.helper.VCellHelper.IJDataList
-import org.vcell.imagej.helper.VCellHelper.IJData
-import net.imglib2.img.array.ArrayImgs
-
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearch
-import org.vcell.imagej.helper.VCellHelper.ModelType
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults
-//import org.vcell.imagej.helper.VCellHelper.TimePointData
-
-vcms = new VCellModelSearch(ModelType.bm,"mblinov","Monkeyflower_pigmentation","Pattern_formation","Wildtype",null,null)
-//format is "username","BioModelName","ApplicationName","SimulationName",null,null). The BioModel must be open in VCell.
-vcmsr = vh.getSearchedModelSimCacheKey(false,vcms,null)
-//false enables operating with model not currently open
-theCacheKey = vcmsr.get(0).getCacheKey();
-println(theCacheKey)
-
-var = "A"
-//enter varialble name (from simulation results)
-time= [500]
-//enter timeindex (for fixed timestep timeindex will be time*saved_timesteps
-
-IJDataList tpd = vh.getTimePointData(theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time as int[],0)
-
-data = tpd.ijData[0].getDoubleData()
-//println (data);
-//if (true) {return}
-bsd = tpd.ijData[0].stackInfo
-println(bsd.xsize+" "+bsd.ysize)
-testimg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize )
-ij.ui().show(var+"_"+time[0],testimg)
-//can change var+"_"+time[0] to make custom name for the image.
\ No newline at end of file
diff --git a/vcell-imagej-helper/photoactivation.groovy b/vcell-imagej-helper/photoactivation.groovy
deleted file mode 100644
index 21fcb5558b..0000000000
--- a/vcell-imagej-helper/photoactivation.groovy
+++ /dev/null
@@ -1,342 +0,0 @@
-//@VCellHelper vh
-
-#@ File (label="Project File", value="NewProject.txt") projFile
-
-#@ File (label="TimeSeries Data Source",value="/home/vcell/Desktop/Frank_for_ImageJ_VCell/Dicty Actin Cortex/TS.nd2") tsDataFile
-#@ String (label="TS Data Channel",value="2") tsDataChanNumStr
-#@ String (label="TS Cell ROI [x,y,width,height]",value="[129, 48, 96, 88]") tsCellRoi
-#@ String (label="TS BG ROI [x,y,width,height]",value="[20, 30, 50, 50]") tsBGRoi
-
-#@ File (label="Geom/FieldData Source",value="/home/vcell/Desktop/Frank_for_ImageJ_VCell/Dicty Actin Cortex/ZS.nd2") zsDataFile
-#@ String (label="Geom/FieldData Channel",value="1") zsDataChanNumStr
-// String (label="Geom/FieldData ROI",value="[x,y,width,height]") zsCellRoi
-
-#@ Float (label="Geom smooth factor", value=2.0) geomGuassSigma
-#@ String (label="Geom threshold", value="[76,65535]") geomThreshold
-
-#@ File (label="User Fill RoiSet", value="/home/vcell/Desktop/Frank_for_ImageJ_VCell/Dicty Actin Cortex/fillRoiSet.zip") fillSet
-#@ File (label="User Clear RoiSet", value="/home/vcell/Desktop/Frank_for_ImageJ_VCell/Dicty Actin Cortex/clearRoiSet.zip") clearSet
-#@ File (label="User Nuc RoiSet", value="/home/vcell/Desktop/Frank_for_ImageJ_VCell/Dicty Actin Cortex/nucRoiSet.zip") nucSet
-
-
-
-import org.vcell.imagej.helper.VCellHelper.IJGeom
-import org.vcell.imagej.helper.VCellHelper
-import org.vcell.imagej.helper.VCellHelper.IJFieldData
-import net.imglib2.Cursor;
-import java.text.SimpleDateFormat;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import net.imagej.ImgPlus
-import net.imglib2.type.numeric.integer.UnsignedByteType
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import net.imglib2.img.ImagePlusAdapter
-import net.imglib2.util.Intervals;
-import ij.plugin.frame.RoiManager
-
-ij.IJ.setForegroundColor(255,255,255);
-ij.IJ.run("Set Measurements...", "mean min redirect=None decimal=3");
-
-//Get Actin and ABP timeseries images, subtract background , crop to cell ROI
-ij.IJ.run("Bio-Formats", "open=["+tsDataFile.getAbsolutePath()+"] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
-tsChannelCount = ij.IJ.getImage().getNChannels()
-String TS_NAME = "TS"
-ij.IJ.getImage().setTitle(TS_NAME)
-ij.IJ.run("Split Channels");
-
-//Remove Unwanted channels
-tsDataChanNum = Integer.valueOf(tsDataChanNumStr)
-removeUnwantedChannels(tsDataChanNum,tsChannelCount,TS_NAME)
-
-//BG subtract, crop abp and actin
-abp_actin_cellROI = parseArrROI(tsCellRoi)//[129, 48, 96, 88] as int[]
-abp_actin_bgROI = parseArrROI(tsBGRoi) //[20, 30, 50, 50] as int[]
-//enhanceAndStats("C2-TS.nd2", "actin",abp_actin_cellROI,abp_actin_bgROI)
-enhanceAndStats("C"+tsDataChanNum+"-"+TS_NAME, "abp",abp_actin_cellROI,abp_actin_bgROI)
-
-/*
-//Create FieldData from time 0.0 (slice 1) of 'abp'
-ij.IJ.selectWindow("abp");
-abpImage = ij.IJ.getImage()
-fdImage = ij.IJ.createImage("fieldData", "16-bit", abpImage.getWidth(), abpImage.getHeight(), 1)
-//fdImage.getStack().deleteSlice(1)
-ip = abpImage.getStack().getProcessor(1)
-fip = fdImage.getStack().getProcessor(1)
-for (x=0;x geomImgPlus = ImagePlusAdapter.wrapImgPlus(ij.IJ.getImage())
-int xIndex = geomImgPlus.dimensionIndex(Axes.X);
-int xsize = (int)geomImgPlus.dimension(xIndex);
-int yIndex = geomImgPlus.dimensionIndex(Axes.Y);
-int ysize = (int)geomImgPlus.dimension(yIndex);
-int assumedZIndex = -1;
-for (int i = 0; i < geomImgPlus.numDimensions(); i++) {
- if(geomImgPlus.dimensionIndex(Axes.X)!=i && geomImgPlus.dimensionIndex(Axes.Y)!=i) {
- assumedZIndex = i;
- break;
- }
-}
-int zsize = (assumedZIndex == -1?1:(int)geomImgPlus.dimension(assumedZIndex));
-HashMap segmentedGeomValuesMapSubvolumeName = new HashMap();
-segmentedGeomValuesMapSubvolumeName.put(0, "ec");
-segmentedGeomValuesMapSubvolumeName.put(255, "cyt");
-segmentedGeomValuesMapSubvolumeName.put(128, "Nuc");
-IJGeom overrideGeom = createGeometry(geomImgPlus, xIndex, yIndex, assumedZIndex, xsize, ysize, zsize, segmentedGeomValuesMapSubvolumeName);
-println(overrideGeom)
-
-//Create FieldData
-ij.IJ.selectWindow("FieldData")
-times = [0.0] as double[]
-vars = ["BS"] as String[]
-xsize = ij.IJ.getImage().getWidth()
-ysize = ij.IJ.getImage().getHeight()
-zsize = ij.IJ.getImage().getNSlices()
-fdData = new short[times.length][vars.length][xsize*ysize*zsize]
-fdStackArr = ij.IJ.getImage().getStack().getImageArray()
-println(xsize+" "+ysize+" "+zsize+" "+fdStackArr.length)
-for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- //This search should only find 1
- if(vcellModelSearchResults.size() != 1) {
- ij.IJ.showMessage("Expecting 1 search result for "+search.getModelName()+" but got "+vcellModelSearchResults.size()+", make sure model is open in VCell client");
- throw new Exception("Expecting only 1 model from search results");
- }
-
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-// try{
-// //make sure original sim result is open
-// VCellHelper.IJDataList ijDataList = vh.getTimePointData(cacheKey, null, null, 0);
-// }catch(Exception e){
-// ij.IJ.showMessage("Make sure Application '"+search.getApplicationName()+"' -> Simulation '"+search.getSimulationName()+"' results viewer is open");
-// throw e
-// }
-
- return cacheKey;
-
-}
-
-def IJGeom createGeometry(ImgPlus nonZProjectedSegmentedGeom,int xIndex,int yIndex,int assumedZIndex,int xsize,int ysize,int zsize,HashMap segmentedGeomValuesMapSubvolumeName) throws Exception{
- //Create byte array that defines vcell subvolumes ids (handles)
- byte[] vcellSubvolumeHandles = new byte[(int)Intervals.numElements(nonZProjectedSegmentedGeom)];
- Cursor nonZProjectedSegmentedGeomCursor = nonZProjectedSegmentedGeom.localizingCursor();
- while(nonZProjectedSegmentedGeomCursor.hasNext()){
- UnsignedByteType segmentedGeomValue = (UnsignedByteType) nonZProjectedSegmentedGeomCursor.next();
- int currentZ = (assumedZIndex==-1?0:nonZProjectedSegmentedGeomCursor.getIntPosition(assumedZIndex));
- int currXYPixelIndex = nonZProjectedSegmentedGeomCursor.getIntPosition(yIndex)*xsize + nonZProjectedSegmentedGeomCursor.getIntPosition(xIndex);
- int currXYZPixelIndex = currXYPixelIndex + (assumedZIndex==-1?0:currentZ*(xsize*ysize));
- vcellSubvolumeHandles[currXYZPixelIndex] = (byte)segmentedGeomValue.get();
- }
- //Define new Geometry with domain equal to xyz pixel size for ease of use
- String[] subvolumeNames = segmentedGeomValuesMapSubvolumeName.values().toArray(new String[0]);
- Integer[] subvolumePixelValues = segmentedGeomValuesMapSubvolumeName.keySet().toArray(new Integer[0]);
- double[] origin = [0,0,0] as double[];
- double[] extent = [xsize,ysize,zsize] as double[];
- IJGeom ijGeom = new IJGeom(subvolumeNames, subvolumePixelValues, xsize, ysize, zsize, origin, extent, vcellSubvolumeHandles);
- return ijGeom;
-}
-*/
-
-def clearROI(int slice,int x,int y,boolean bFill){
- ij.IJ.setSlice(slice);
- if(x==-1 || y == -1){
- ij.IJ.run("Select All");
- }else{
- ij.IJ.doWand(x, y);
- }
- if(bFill){
- ij.IJ.run("Fill", "slice");
- }else{
- ij.IJ.run("Clear", "slice");
- }
-}
-
-def void zoomEnhance(){
-ij.IJ.run("In [+]");
-ij.IJ.run("In [+]");
-ij.IJ.run("In [+]");
-ij.IJ.run("Enhance Contrast", "saturated=0.35");
-}
-
-def void enhanceAndStats(String imageWindowTitle,String newTitle, int[] cellROI,int[] bgROI) {
-ij.IJ.selectWindow(imageWindowTitle);
-ij.IJ.getImage().setTitle(newTitle)
-
-textPanel = ij.IJ.getTextPanel()
-
-ij.IJ.makeRectangle(bgROI[0],bgROI[1],bgROI[2],bgROI[3]); //Background
-ij.IJ.run("Clear Results");
-ij.IJ.run("Statistics");
-meanBGArr = textPanel.getResultsTable().getColumnAsVariables("Mean")
-
-ij.IJ.makeRectangle(cellROI[0],cellROI[1],cellROI[2],cellROI[3]); //Cell
-//ij.IJ.run("Clear Results");
-//ij.IJ.run("Statistics");
-
-ij.IJ.run("Crop");
-zoomEnhance()
-//minArr = textPanel.getResultsTable().getColumnAsVariables("Min")
-//maxArr = textPanel.getResultsTable().getColumnAsVariables("Max")
-//println(newTitle+" "+minArr[0]+" "+maxArr[0]+" bgMean="+meanBGArr[0])
-
-ij.IJ.run("Subtract...", "value="+meanBGArr[0]+" stack");
-}
diff --git a/vcell-imagej-helper/photoactivation_analyze.groovy b/vcell-imagej-helper/photoactivation_analyze.groovy
deleted file mode 100644
index a8e685a153..0000000000
--- a/vcell-imagej-helper/photoactivation_analyze.groovy
+++ /dev/null
@@ -1,421 +0,0 @@
-//@VCellHelper vh
-//@ImageJ netij
-
-import org.vcell.imagej.helper.VCellHelper
-import java.text.SimpleDateFormat;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import org.vcell.imagej.helper.VCellHelper.IJSimStatusJobs
-import org.vcell.imagej.helper.VCellHelper.IJDataList
-import org.vcell.imagej.helper.VCellHelper.IJData
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos
-import org.vcell.imagej.helper.VCellHelper.IJVarInfo
-//import io.scif.img.SCIFIOImgPlus;
-import ij.process.ImageProcessor
-import ij.ImagePlus
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.FloatArray;
-import net.imglib2.type.numeric.real.FloatType;
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import org.jfree.chart.ChartFactory
-import org.jfree.chart.JFreeChart
-import org.jfree.chart.ChartPanel
-import org.jfree.data.category.CategoryDataset
-import org.jfree.data.xy.XYSeriesCollection
-import org.jfree.data.xy.XYSeries
-import javax.swing.JFrame
-import java.awt.BasicStroke
-import ij.WindowManager
-import net.imglib2.img.ImagePlusAdapter
-
-//public IJDataList getTimePointData(String simulationDataCacheKey,String variableName,int[] timePointIndexes,int simulationJobIndex) throws Exception{
-
-//simID = 171890707
-stroke = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10,[5] as float[], 0)
-//jobIndex = 0
-int t0Sim = 0;//15;
-int t0Exp = 2;//2
-int tCount = 27
-int ANALYZE_END_TIMEINDEX = 2;
-simVar = "fluor"
-simVarDataType = VCellHelper.VARTYPE_POSTPROC.PostProcessDataPDEDataContext;// null for SimulationData, "DataProcessingOutputInfo" for postprocessStats
-expDataVar = "abp" //Expected to be open ImageJ dataset window
-//roix = 30
-//roiy = 55
-//roixs = 2;
-//roiys = 2
-BOX_X = 0
-BOX_Y = 1
-BOX_XS = 2
-BOX_YS = 3
-//boxes = [[73,33,4,5]/*,[55,26,8,8]*/,[25,33,8,8]] as int[][]
-boxes = [[0,0,51,88]/*,[55,26,8,8]*/,[51,0,45,88]] as int[][]
-//if(false){waitForSolverGetCacheForData(simID,jobIndex);}
-
-simulationDataCacheKey = getSimulationCacheKey(vh)
-//IJDataList bpflDataList = vh.getTimePointData(simulationDataCacheKey, "BP_fl", null, [activateTimeIndex] as int[], simID);
-//bpflData = fluorDomainIJDataList.ijData[0].getDoubleData()
-/*
-cnt = 0
-for(int i=0;i annotatedZProjectedSimPostBleachData =
-// zProjectNormalizeSimData(vh, "Kr_bind .01 ", simulationDataCacheKey, "BP_fl", 0, 0, ANALYZE_BEGIN_TIMEINDEX, ANALYZE_END_TIMEINDEX);
-
-IJVarInfos ijVarInfos = vh.getSimulationInfo(simulationDataCacheKey)
-//Get Exp Data - 'TS.nd2, channel 2'
-//expData = ij.IJ.getImage().getStack().getPixels(t0+t0Exp)
-ij.IJ.selectWindow(expDataVar)
-expImage = ij.IJ.getImage()
-ImagePlus[] simImage = new ImagePlus[ijVarInfos.scancount]
-exp_xsize = ij.IJ.getImage().getWidth()
-exp_ysize = ij.IJ.getImage().getHeight()
-exp_frames = ij.IJ.getImage().getNFrames()
-//fdStackArr = ij.IJ.getImage().getStack().getImageArray()
-//SOMETIMES fdStackArr.length != exp_frames, use exp_frames
-println("xsize="+exp_xsize+" ysize="+exp_ysize+" frames="+exp_frames+" scancount="+ijVarInfos.scancount)
-double[] Kr_Bind_OverrideIndexes = new double[ijVarInfos.scancount]
-//new float[tCount*exp_xsize*exp_ysize],
- SIM_WIN_NAME = "Sim fluor"
- for(int job=0;job fluorImage = null
- netij.ui().show(SIM_WIN_NAME+"_"+i,fluorImage)
- simImage[i] = ij.IJ.getImage()
- ij.IJ.run("In [+]");
- ij.IJ.run("In [+]");
- ij.IJ.run("In [+]");
- }
- */
-double[][][] diffSqrTimeAndJob = new double[tCount][Kr_Bind_OverrideIndexes.length][boxes.length]
-double[][] jobSum = new double[Kr_Bind_OverrideIndexes.length][boxes.length]
-ROI_EXP_INDEX = 0
-ROI_SIM_INDEX = 1
-double[][][][] roiMean = new double[tCount][Kr_Bind_OverrideIndexes.length][boxes.length][2]
-//Init diffSqr Graph
-DIFFSQR_SERIES_PREFIX = "Sim "
-XYSeriesCollection diffSqrDataset = new XYSeriesCollection();
-for(int i=0;i simTimePointData = ArrayImgs.floats(fluorData, [simStackInfo.xsize,simStackInfo.ysize,1] as long[])
-*/
-
- // if(t == 0 && job == 0){
- //ArrayImg simAllTimes = ArrayImgs.doubles(fluorData, [simStackInfo.xsize,simStackInfo.ysize,tCount] as long[]);
- //fluorImage = new SCIFIOImgPlus<>(simTimePointData,"Sim fluor",[Axes.X,Axes.Y] as AxisType[]);
- //netij.ui().show("Sim fluor",simTimePointData)
- //simImage = ij.IJ.getImage()
- //simImage.setRoi(roix,roiy,roixs,roiys)
- //ij.IJ.run("In [+]");
- //ij.IJ.run("In [+]");
- //ij.IJ.run("In [+]");
- // }else
- //if(job == 1){
- //ij.IJ.selectWindow(SIM_WIN_NAME)
- //println(ij.IJ.getImage().getProcessor().getPixels())
- //if(true){return}
- //ImageProcessor ip = ij.IJ.getImage().getStack().getProcessor(t+1)
- //float[] tempf = simTimePointData.update(null).getCurrentStorageArray()
- //println(simTimePointData.update(null).getCurrentStorageArray())
- //ij.IJ.getImage().setSlice(t+1)
-/*
- println("Copy Sim double to float...")
- simImage[job].setSlice(t+1)
- float[] srcFloats = simImage[job].getProcessor().getPixels()
- cnt = 0
- for(int y= 0;y vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- //This search should only find 1
- if(vcellModelSearchResults.size() != 1) {
- ij.IJ.showMessage("Expecting 1 search result for "+search.getModelName()+" but got "+vcellModelSearchResults.size()+", make sure model is open in VCell client");
- throw new Exception("Expecting only 1 model from search results");
- }
-
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-/*
- try{
- //make sure original sim result is open
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(cacheKey, null, null, 0);
- }catch(Exception e){
- ij.IJ.showMessage("Make sure Application '"+search.getApplicationName()+"' -> Simulation '"+search.getSimulationName()+"' results viewer is open");
- throw e
- }
-*/
- return cacheKey;
-
-}
-/*
- def SCIFIOImgPlus zProjectNormalizeSimData(VCellHelper vh,
- String newImgPlusName,String simulationDataCachekey,String varToAnalyze,int preBleachTimeIndex,int solverStatus_jobIndex,int ANALYZE_BEGIN_TIMEINDEX,int ANALYZE_END_TIMEINDEX) throws Exception{
-
- int ANALYZE_COUNT = ANALYZE_END_TIMEINDEX - ANALYZE_BEGIN_TIMEINDEX+1;
- // Get the SIMULATION pre-bleach timepoint data for normalizing
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(simulationDataCachekey, varToAnalyze, [preBleachTimeIndex] as int[], solverStatus_jobIndex);
- int xysize = ijDataList.ijData[0].stackInfo.xsize*ijDataList.ijData[0].stackInfo.ysize;
- double[] bleachedTimeStack = new double[ANALYZE_COUNT*xysize];
-// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-// URL dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)(0)+"&"+"jobid="+ijSolverStatus.getJobIndex());
- double[] zProjectedSimNormalizer = getNormalizedZProjected(ijDataList,null);
-//showAndZoom(ij, "Sim Data PreBleach", ArrayImgs.doubles(simNormalizer, xsize,ysize), 4);
-
- // Get the SIMULATION post-bleach data to analyze
- for(int timeIndex = ANALYZE_BEGIN_TIMEINDEX;timeIndex<=ANALYZE_END_TIMEINDEX;timeIndex++){
- ijDataList = vh.getTimePointData(simulationDataCachekey, varToAnalyze, [timeIndex] as int[], solverStatus_jobIndex);
-// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-// dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)timeIndex+"&"+"jobid="+ijSolverStatus.getJobIndex());
- double[] data = getNormalizedZProjected(ijDataList,zProjectedSimNormalizer);
- System.arraycopy(data, 0, bleachedTimeStack, (timeIndex-ANALYZE_BEGIN_TIMEINDEX)*xysize, data.length);
- }
-
- //Turn VCell data into iterableinterval
-// FinalInterval zProjectedSimDataSize = FinalInterval.createMinSize(new long[] {0,0,0, xsize,ysize,ANALYZE_COUNT});//xyzt:origin and xyzt:size
- ArrayImg simImgs = ArrayImgs.doubles(bleachedTimeStack, [ijDataList.ijData[0].stackInfo.xsize,ijDataList.ijData[0].stackInfo.ysize,ANALYZE_COUNT] as long[]);
- SCIFIOImgPlus annotatedZProjectedSimPostBleachData = new SCIFIOImgPlus<>(simImgs,newImgPlusName,[Axes.X,Axes.Y,Axes.TIME] as AxisType[]);
-// RandomAccessibleInterval simExtracted = ij.op().transform().crop(annotatedSimData, simExtractInterval);
-//showAndZoom(ij, "Sim Data "+diffusionRate, annotatedZProjectedSimPostBleachData, 4);
- return annotatedZProjectedSimPostBleachData;
- }
-*/
- def double[] getNormalizedZProjected(VCellHelper.IJDataList ijDataList,double[] normalizer) throws Exception{
- VCellHelper.BasicStackDimensions basicStackDimensions = ijDataList.ijData[0].stackInfo;//VCellHelper.getDimensions(nodes.item(0));
- //Sum pixel values in Z direction to match experimental data (open pinhole confocal, essentially brightfield)
- int xysize = basicStackDimensions.xsize*basicStackDimensions.ysize;
- double[] normalizedData = new double[xysize];
- for (int i = 0; i < ijDataList.ijData[0].getDoubleData().length; i++) {
- normalizedData[(i%xysize)]+= ijDataList.ijData[0].getDoubleData()[i];
- }
- if(normalizer != null) {
- for (int i = 0; i < normalizedData.length; i++) {
- if(normalizedData[i] != 0) {
- normalizedData[i] = (normalizedData[i]+Double.MIN_VALUE)/(normalizer[i]+Double.MIN_VALUE);
- }
- }
- }
- return normalizedData;
- }
diff --git a/vcell-imagej-helper/photoactivation_load.groovy b/vcell-imagej-helper/photoactivation_load.groovy
deleted file mode 100644
index ba7219ee2a..0000000000
--- a/vcell-imagej-helper/photoactivation_load.groovy
+++ /dev/null
@@ -1,169 +0,0 @@
-//@VCellHelper vh
-//@ImageJ netij
-
-import org.vcell.imagej.helper.VCellHelper
-import java.text.SimpleDateFormat;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults
-import org.vcell.imagej.helper.VCellHelper.IJSimStatusJobs
-import org.vcell.imagej.helper.VCellHelper.IJDataList
-import org.vcell.imagej.helper.VCellHelper.IJData
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos
-import org.vcell.imagej.helper.VCellHelper.IJVarInfo
-//import io.scif.img.SCIFIOImgPlus;
-import ij.process.ImageProcessor
-import ij.ImagePlus
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.FloatArray;
-import net.imglib2.type.numeric.real.FloatType;
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import org.jfree.chart.ChartFactory
-import org.jfree.chart.JFreeChart
-import org.jfree.chart.ChartPanel
-import org.jfree.data.category.CategoryDataset
-import org.jfree.data.xy.XYSeriesCollection
-import org.jfree.data.xy.XYSeries
-import javax.swing.JFrame
-import java.awt.BasicStroke
-
-//simID = 109812874
-int t0Sim = 16;
-int tCount = 27
-simVar = "fluor"
-simVarDataType = VCellHelper.VARTYPE_POSTPROC.PostProcessDataPDEDataContext;// null for SimulationData, "DataProcessingOutputInfo" for postprocessStats
-
-simulationDataCacheKeyStr = getSimulationCacheKey(vh)
-println("simulationDataCacheKeyStr="+simulationDataCacheKeyStr)
-
-simTimes = new int[tCount]
-for(int i=0;i fluorImage = null
- netij.ui().show(SIM_WIN_NAME+"_"+i,fluorImage)
- simImage[i] = ij.IJ.getImage()
-// simImage.setRoi(roix,roiy,roixs,roiys)
- ij.IJ.run("In [+]");
- ij.IJ.run("In [+]");
- ij.IJ.run("In [+]");
- }
-double[][][] diffSqrTimeAndJob = new double[tCount][Kr_Bind_OverrideIndexes.length][boxes.length]
-double[][] jobSum = new double[Kr_Bind_OverrideIndexes.length][boxes.length]
-ROI_EXP_INDEX = 0
-ROI_SIM_INDEX = 1
-double[][][][] roiMean = new double[tCount][Kr_Bind_OverrideIndexes.length][boxes.length][2]
-//Init diffSqr Graph
-DIFFSQR_SERIES_PREFIX = "Sim "
-XYSeriesCollection diffSqrDataset = new XYSeriesCollection();
-for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- //This search should only find 1
- if(vcellModelSearchResults.size() != 1) {
- ij.IJ.showMessage("Expecting 1 search result for "+search.getModelName()+" but got "+vcellModelSearchResults.size()+", make sure model is open in VCell client");
- throw new Exception("Expecting only 1 model from search results");
- }
-
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-/*
- try{
- //make sure original sim result is open
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(cacheKey, null, null, 0);
- }catch(Exception e){
- ij.IJ.showMessage("Make sure Application '"+search.getApplicationName()+"' -> Simulation '"+search.getSimulationName()+"' results viewer is open");
- throw e
- }
-*/
- return cacheKey;
-
-}
\ No newline at end of file
diff --git a/vcell-imagej-helper/photoactivation_run.groovy b/vcell-imagej-helper/photoactivation_run.groovy
deleted file mode 100644
index b637b1b95c..0000000000
--- a/vcell-imagej-helper/photoactivation_run.groovy
+++ /dev/null
@@ -1,146 +0,0 @@
-//@VCellHelper vh
-
-import org.vcell.imagej.helper.VCellHelper
-import org.vcell.imagej.helper.VCellHelper.IJFieldData
-import java.text.SimpleDateFormat;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-import net.imagej.ImgPlus
-import net.imglib2.type.numeric.integer.UnsignedByteType
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import net.imglib2.img.ImagePlusAdapter
-import net.imglib2.util.Intervals;
-import org.vcell.imagej.helper.VCellHelper.IJGeom
-import net.imglib2.Cursor;
-
-fieldDataName = "ijFDTest"
-fieldDataVarName = "BS"
-fieldDataTime = 0.0
-HashMap simulationParameterOverrides = new HashMap<>();
-simulationParameterOverrides.put("Kr_bind", ".01,.1,1.0,10"); //See 'Simulation List Table'->'Edit Simulation'->'Parameters tab'->'Parameter name'
-HashMap speciesContextInitialConditionsOverrides = new HashMap<>();
-speciesContextInitialConditionsOverrides.put("BS", "(0.56 * vcField('"+fieldDataName+"', '"+fieldDataVarName+"', "+fieldDataTime+", 'Volume'))"); //See Application->Specifications->Species
-newEndTime = 180.0
-
-//Create IJGeom
-ij.IJ.selectWindow("Geom")
-ImgPlus geomImgPlus = ImagePlusAdapter.wrapImgPlus(ij.IJ.getImage())
-int xIndex = geomImgPlus.dimensionIndex(Axes.X);
-int xsize = (int)geomImgPlus.dimension(xIndex);
-int yIndex = geomImgPlus.dimensionIndex(Axes.Y);
-int ysize = (int)geomImgPlus.dimension(yIndex);
-int assumedZIndex = -1;
-for (int i = 0; i < geomImgPlus.numDimensions(); i++) {
- if(geomImgPlus.dimensionIndex(Axes.X)!=i && geomImgPlus.dimensionIndex(Axes.Y)!=i) {
- assumedZIndex = i;
- break;
- }
-}
-int zsize = (assumedZIndex == -1?1:(int)geomImgPlus.dimension(assumedZIndex));
-HashMap segmentedGeomValuesMapSubvolumeName = new HashMap();
-segmentedGeomValuesMapSubvolumeName.put(0, "EC");
-segmentedGeomValuesMapSubvolumeName.put(255, "cell");
-segmentedGeomValuesMapSubvolumeName.put(128, "nuc");
-IJGeom overrideGeom = createGeometry(geomImgPlus, xIndex, yIndex, assumedZIndex, xsize, ysize, zsize, 26.445,25.625,16.5,segmentedGeomValuesMapSubvolumeName);
-println(overrideGeom)
-
-//Create FieldData
-ij.IJ.selectWindow("FieldData")
-times = [fieldDataTime] as double[]
-vars = [fieldDataVarName] as String[]
-xsize = ij.IJ.getImage().getWidth()
-ysize = ij.IJ.getImage().getHeight()
-zsize = ij.IJ.getImage().getNSlices()
-fdData = new short[times.length][vars.length][xsize*ysize*zsize]
-fdStackArr = ij.IJ.getImage().getStack().getImageArray()
-println(xsize+" "+ysize+" "+zsize+" "+fdStackArr.length)
-for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- //This search should only find 1
- if(vcellModelSearchResults.size() != 1) {
- ij.IJ.showMessage("Expecting 1 search result for "+search.getModelName()+" but got "+vcellModelSearchResults.size()+", make sure model is open in VCell client");
- throw new Exception("Expecting only 1 model from search results");
- }
-
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-/*
- try{
- //make sure original sim result is open
- VCellHelper.IJDataList ijDataList = vh.getTimePointData(cacheKey, null, null, 0);
- }catch(Exception e){
- ij.IJ.showMessage("Make sure Application '"+search.getApplicationName()+"' -> Simulation '"+search.getSimulationName()+"' results viewer is open");
- throw e
- }
-*/
- return cacheKey;
-
-}
-
-def IJGeom createGeometry(ImgPlus nonZProjectedSegmentedGeom,int xIndex,int yIndex,int assumedZIndex,int xsize,int ysize,int zsize,double xext,double yext,double zext,HashMap segmentedGeomValuesMapSubvolumeName) throws Exception{
- //Create byte array that defines vcell subvolumes ids (handles)
- byte[] vcellSubvolumeHandles = new byte[(int)Intervals.numElements(nonZProjectedSegmentedGeom)];
- Cursor nonZProjectedSegmentedGeomCursor = nonZProjectedSegmentedGeom.localizingCursor();
- while(nonZProjectedSegmentedGeomCursor.hasNext()){
- UnsignedByteType segmentedGeomValue = (UnsignedByteType) nonZProjectedSegmentedGeomCursor.next();
- int currentZ = (assumedZIndex==-1?0:nonZProjectedSegmentedGeomCursor.getIntPosition(assumedZIndex));
- int currXYPixelIndex = nonZProjectedSegmentedGeomCursor.getIntPosition(yIndex)*xsize + nonZProjectedSegmentedGeomCursor.getIntPosition(xIndex);
- int currXYZPixelIndex = currXYPixelIndex + (assumedZIndex==-1?0:currentZ*(xsize*ysize));
- vcellSubvolumeHandles[currXYZPixelIndex] = (byte)segmentedGeomValue.get();
- }
- //Define new Geometry with domain equal to xyz pixel size for ease of use
- String[] subvolumeNames = segmentedGeomValuesMapSubvolumeName.values().toArray(new String[0]);
- Integer[] subvolumePixelValues = segmentedGeomValuesMapSubvolumeName.keySet().toArray(new Integer[0]);
- double[] origin = [0,0,0] as double[];
- double[] extent = [xext,yext,zext] as double[];
- IJGeom ijGeom = new IJGeom(subvolumeNames, subvolumePixelValues, xsize, ysize, zsize, origin, extent, vcellSubvolumeHandles);
- return ijGeom;
-}
diff --git a/vcell-imagej-helper/pom.xml b/vcell-imagej-helper/pom.xml
deleted file mode 100644
index 55c115824d..0000000000
--- a/vcell-imagej-helper/pom.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-
-
- 4.0.0
-
- org.vcell
- vcell-pom
- 0.0.1-SNAPSHOT
-
-
-
-
- org.vcell
- vcell-imagej-helper
- 0.0.1-SNAPSHOT
- vcell-imagej-helper
-
-
-
-
-
- The Virtual Cell client and server
- http://maven.apache.org
- 1997
-
- VCell
- http://vcell.org
-
-
-
- MIT
- https://opensource.org/licenses/MIT
-
-
-
-
-
- frm
- Frank Morgan
-
- founder
- lead
- developer
- debugger
- reviewer
- support
- maintainer
-
-
-
-
-
- John Wagner
-
-
-
-
-
- VCell Open Discussion Forum
- https://groups.google.com/group/vcell-discuss
- https://groups.google.com/group/vcell-discuss
- vcell-discuss@googlegroups.com
- https://groups.google.com/group/vcell-discuss
-
-
-
-
- scm:git:git://github.com/virtualcell/vcell
- scm:git:git@github.com:virtualcell/vcell
- HEAD
- https://github.com/virtualcell/vcell
-
-
- Bugzilla
- http://code3.cam.uchc.edu/bugzilla/
-
-
- None
-
-
-
- MIT
- UConn Health
-
-
-
-
- imagej.public
- https://maven.imagej.net/content/groups/public
-
-
-
-
-
- io.scif
- scifio-bf-compat
- ${scifio-bf-compat.version}
-
-
- ome
- bio-formats_plugins
- ${bio-formats_plugins.version}
-
-
- net.imagej
- imagej
- ${imagej.version}
-
-
-
- org.apache.httpcomponents
- httpclient
- 4.5.13
-
-
- javax.xml.bind
- jaxb-api
- 2.3.0
-
-
- com.sun.xml.bind
- jaxb-core
- 2.3.0
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.3.0
-
-
-
- org.jfree
- jfreechart
- ${jfreechart.version}
-
-
-
-
-
diff --git a/vcell-imagej-helper/solverData.groovy b/vcell-imagej-helper/solverData.groovy
deleted file mode 100644
index e63660c219..0000000000
--- a/vcell-imagej-helper/solverData.groovy
+++ /dev/null
@@ -1,238 +0,0 @@
-#@VCellHelper vh
-#@OpService op //This is a net.imagej.ops.OpEnvironment
-#@ImageJ ij
-
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.IJGeom;
-import org.vcell.imagej.helper.VCellHelper.IJSolverStatus;
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import net.imglib2.type.numeric.real.DoubleType;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.display.imagej.ImageJFunctions;
-import net.imagej.ops.OpInfo
-import net.imagej.ops.OpMatchingService
-import net.imagej.ops.OpRef
-import net.imagej.ops.OpCandidate
-import net.imglib2.algorithm.neighborhood.HyperSphereShape;
-import net.imglib2.type.numeric.integer.UnsignedByteType;
-import net.imglib2.type.logic.BitType;
-import net.imglib2.FinalInterval;
-import net.imglib2.util.Intervals;
-
-
-//Collection opInfos = op.infos();
-//for(OpInfo opInfo:opInfos){
-// println(opInfo.getName());
-//}
-//OpMatchingService matcher = op.matcher();
-//ArrayImg img0;
-//Double d = new Double("100.5");
-//List opCandidates = matcher.findCandidates(op,OpRef.create("stats.mean"));
-//for(OpCandidate opCandidate:opCandidates){
-// println(opCandidate);
-//}
-//something = op.image();
-//if(true){return}
-//test
-
-
-//println(test2_Tmany_Zone.getClass().getName())
-//String id = "/path/to/myFile.ext";
-//ImagePlus[] imps = BF.openImagePlus(id);
-//if(true){return}
-
-
-//Load image
-test2_Tmany_Zone = ij.io().open("C:/temp/ImportImageExamples/test2_Tmany_Zone.lsm")
-
-//Define slice location of pre-bleach image (--------------------User has to determine location)
-finterval = FinalInterval.createMinSize(132,146, 0,4, 244,165, 1,1);//xyzt:origin and xyzt:size
-int xsize = finterval.dimension(0);
-int ysize = finterval.dimension(1);
-int zsize = finterval.dimension(2);
-println(xsize+" "+ysize+" "+zsize);
-//Extract pre-bleach image
-slice = ij.op().transform().crop(test2_Tmany_Zone, finterval)
-
-//Smooth slice to aid in creating threshold geometry
-median = ij.op().run("create.img", slice)
-neighborhood = new HyperSphereShape(4)
-ij.op().run("filter.median", median, slice, neighborhood)
-
-//Create threshold image as a BitType image array (--------------------User has to determine threshold)
-bits = op.threshold().apply(/*bits,*/median,new UnsignedByteType(15))
-
-//Create bitmap to send to VCell as geometry subvolume definition
-byte[] geomBits = new byte[Intervals.numElements(finterval)];
-mycursor = bits.localizingCursor();
-int currIndex = 0;
-while(mycursor.hasNext()){
- BitType nextbit = mycursor.next();
- geomBits[currIndex++] = nextbit.getInteger();
-// sb.append(nextbit.toString());
-// if(mycursor.getIntPosition(0)+finterval.min(0) == finterval.max(0)){
-// println()
-// }
-}
-
-//Define relevent simulation parameters
-Double diffOverride = null;//new Double(".00001");
-Double forwardBinding = null;
-Double reverseBinding = null;
-
-//Define new Geometry
-subvolumeNames = ["cyt","Nuc"] as String[]
-subvolumePixelValues = [0,1] as int[]
-origin = [0,0,0] as double[];
-extent = [xsize,ysize,zsize] as double[];
-//public IJGeom(String[] subvolumeNames, int[] subvolumePixelValue, int xsize, int ysize, int zsize,double[] originXYZ, double[] extentXYZ, byte[] geom) throws Exception{
-IJGeom ijGeom = new IJGeom(subvolumeNames /*["cyt","Nuc"]*/, subvolumePixelValues/*[0,1]*/, xsize, ysize, zsize, origin /*new double[] {0,0,0}*/, extent /*new double[] {22,22,10}*/, geomBits);
-
-//Define Laser area of exposure
-laserArea = "((x >= 180) && (x <= 190) && (y >= 85) && (y <= 90))";
-//laserArea = "((x >= - 7.4) && (x <= -3.96) && (y >= - 4.4) && (y <= -3.96))";
-
-//Define new Simulation endtime
-newEndTime = new Double(10.0);
-
-//Start Frap simulation
-//public IJSolverStatus startFrap(Double rDiffusionOverride,Double kForwardBindingOverride,Double kReversBindingOverride,IJGeom ijGeom,String laserCoverageAnalyticExpression) throws Exception{
-IJSolverStatus ijSolverStatus = vh.startFrap(diffOverride,forwardBinding,reverseBinding,ijGeom,laserArea,newEndTime);
-
-
-// ijSolverStatus = new IJSolverStatus();
-// ijSolverStatus.simJobId = "SimID_0123456789_0";
-
-// IJSolverStatus ijSolverStatus = vh.startFrap(diffOverride,null,null);
- println(ijSolverStatus.toString());
- String simulationJobId = ijSolverStatus.simJobId;
- while(true) {
- Thread.sleep(5000);
- ijSolverStatus = vh.getSolverStatus(simulationJobId);
- println(ijSolverStatus.toString());
- String statusName = ijSolverStatus.statusName.toLowerCase();
- if(statusName.equals("finished") || statusName.equals("stopped") || statusName.equals("aborted")) {
- break;
- }
- }
-
- URL url = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getinfo"+"?"+"type"+"="+"quick");
- Document doc = VCellHelper.getDocument(url);
- println(VCellHelper.documentToString(doc));
- NodeList nodes = doc.getElementsByTagName("simInfo");
- String cachekey = null;
- for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,vcellModelVersionTimeRange);
-// if(vcellModelSearchResults.size() != 1) {
-// throw new Exception("Expecting only 1 model from search results");
-// }
-// // Get cacheKey to reference the found simulation
-// String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
-//
-// // As simple example define new simulation endTime and 'rf_diffusionRate' parameter override (refer to FRAP script for more advanced example)
-// final double newDiffusionRate = 1.5;
-// HashMap simulationParameterOverrides = new HashMap<>();
-// simulationParameterOverrides.put("rf_diffusionRate", ""+newDiffusionRate);
-// double newEndTime = 5.0;
-// // Start running the solver LOCALLY (solver will run on users local machine, equivalent to 'quickrun')
-// System.out.println("Starting solver...");
-// IJSolverStatus ijSolverStatus = vh.startVCellSolver(Long.parseLong(cacheKey), null/*keep default geom*/, simulationParameterOverrides, null/*keep default initConditions*/,newEndTime);
-// System.out.println(ijSolverStatus.toString());
-// String simulationJobId = ijSolverStatus.simJobId;
-// // Wait for simulation to finish
-// while(true) {
-// Thread.sleep(5000);
-// ijSolverStatus = vh.getSolverStatus(simulationJobId);
-// System.out.println(ijSolverStatus.toString());
-// String statusName = ijSolverStatus.statusName.toLowerCase();
-// if(statusName.equals("finished") || statusName.equals("stopped") || statusName.equals("aborted")) {
-// break;
-// }
-// }
-// //Get reference to simulation data
-// String simulationDataCacheKey = vh.getSimulationDataCacheKey(ijSolverStatus.simJobId);
-// // Get data for variable 'rf' at timeIndex 5
-// VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationDataCacheKey, "rf", new int[] {5}, ijSolverStatus.getJobIndex());
-// BasicStackDimensions bsd = timePointData.getBasicStackDimensions();
-// System.out.print("xsize="+bsd.xsize+" ysize="+bsd.ysize+" zsize="+bsd.zsize+" csize="+bsd.csize+" tsize="+bsd.tsize);
- }
- public static void pdeDataTest(VCellHelper vh,ImageJ ij) throws ParseException, Exception {
-// // Set the ModelName, ApplicationName and SimulationName for models we are interested in
-// VCellHelper.VCellModelSearch search = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.mm, null/*Any user*/, "Calcium sparks_simple", null/*MathModels have no Applications*/, "seed=18",3,null);
-// // Use VCellHelper to contact VCell client and return preliminary info
-// ArrayList vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,null/*Any date*/);
-// System.out.println("Model name='"+vcellModelSearchResults.get(0).getModelName()+"'");
-// System.out.println("Application name='"+vcellModelSearchResults.get(0).getApplicationName()+"'");
-// System.out.println("Simulation name='"+vcellModelSearchResults.get(0).getSimulationName()+"'"+" geomDims="+vcellModelSearchResults.get(0).getGeometryDimension()+" mathType="+vcellModelSearchResults.get(0).getMathType());
-// // Get the cacheKey that identifies the particular simulation result we are interested in
-// String simulationInfoCacheKey = vcellModelSearchResults.get(0).getCacheKey();
-// // Get more specific information about our simulation using the cacheKey (times, parameter scan count, variable names,...)
-// // (the cacheKey was stored in the running VCell client during the previous search and is used to quickly lookup information)
-// VCellHelper.IJVarInfos ijVarInfos = vh.getSimulationInfo(simulationInfoCacheKey);
-// final int THE_TIME_INDEX = 2;
-// for (IJVarInfo ijVarInfo : ijVarInfos.getIjVarInfo()) {
-// if(ijVarInfo.getName().equals("Ca")) {
-// // Get the actual data (our simulation is non-spatial ODE)
-// System.out.println("getting data for timepoint="+ijVarInfos.getTimes()[THE_TIME_INDEX]);
-// VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationInfoCacheKey, ijVarInfo.getName(), new int[] {THE_TIME_INDEX},0);
-// BasicStackDimensions bsd = timePointData.getBasicStackDimensions();
-// if(bsd.csize != 1 || bsd.tsize != 1) {
-// throw new Exception("Expecting csize and tsize to be 1");
-// }
-// ArrayImg data3dAtSingleTimePoint = ArrayImgs.doubles(timePointData.getTimePointData(), bsd.xsize,bsd.ysize,bsd.zsize,bsd.csize,bsd.tsize);
-// ImgPlus scifoImg = SCIFIOImgPlus.wrap(data3dAtSingleTimePoint);
-// DoubleType max= ij.op().stats().max(scifoImg);
-// DoubleType min= ij.op().stats().min(scifoImg);
-// System.out.println("name='"+ijVarInfo.getName()+"' type="+ijVarInfo.getVariableType()+" min="+min.get()+" max="+max.get());
-// }
-// }
-//
- }
- public static void odeDataTest(VCellHelper vh) throws ParseException, Exception {
-// //
-// // SEARCH for a public simulation (in a BioModel), get information about the simulation and download a portion of the data
-// //
-// // Set the date range for models we are interested in
-// VCellHelper.VCellModelVersionTimeRange vcellModelVersionTimeRange = new VCellHelper.VCellModelVersionTimeRange(EASY_DATE.parse("2016-01-01 00:00:00"), EASY_DATE.parse("2017-01-01 00:00:00"));
-// // Set the ModelName, ApplicationName and SimulationName for models we are interested in
-// VCellHelper.VCellModelSearch search = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm, "tutorial60", "Rule-based_egfr_tutorial", "*stoch", "Simulation1",null,null);
-// // Use VCellHelper to contact VCell client and return preliminary info
-// ArrayList vcellModelSearchResults = vh.getSearchedModelSimCacheKey(false, search,vcellModelVersionTimeRange);
-// // Our search was constructed such that only 1 simulation should be in the search results
-// if(vcellModelSearchResults.size() != 1) {
-// throw new Exception("Expecting exactly 1 model from search results but got "+vcellModelSearchResults.size());
-// }
-// System.out.println("Model name='"+vcellModelSearchResults.get(0).getModelName()+"'");
-// System.out.println("Application name='"+vcellModelSearchResults.get(0).getApplicationName()+"'");
-// System.out.println("Simulation name='"+vcellModelSearchResults.get(0).getSimulationName()+"'"+" geomDims="+vcellModelSearchResults.get(0).getGeometryDimension()+" mathType="+vcellModelSearchResults.get(0).getMathType());
-// // Get the cacheKey that identifies the particular simulation result we are interested in
-// String simulationInfoCacheKey = vcellModelSearchResults.get(0).getCacheKey();
-//
-// // Get more specific information about our simulation using the cacheKey (times, parameter scan count, variable names,...)
-// // (the cacheKey was stored in the running VCell client during the previous search and is used to quickly lookup information)
-// VCellHelper.IJVarInfos ijVarInfos = vh.getSimulationInfo(simulationInfoCacheKey);
-// for (IJVarInfo ijVarInfo : ijVarInfos.getIjVarInfo()) {
-// if(ijVarInfo.getName().startsWith("Dimer")) {
-// // Get the actual data (our simulation is non-spatial ODE)
-// VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationInfoCacheKey, ijVarInfo.getName(), null,0);
-// // Check the length of the data == length of timepoints (should be true for non-spatial data)
-// if(timePointData.getTimePointData().length != ijVarInfos.getTimes().length) {
-// throw new Exception("Expecting datalength for variable "+timePointData.getTimePointData().length+" to match number of timepoints "+ijVarInfos.getTimes().length);
-// }
-// System.out.println("name='"+ijVarInfo.getName()+"' type="+ijVarInfo.getVariableType());
-// }
-// }
- }
-
-}
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/SmallCR.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/SmallCR.java
deleted file mode 100644
index 4656aac5ab..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/SmallCR.java
+++ /dev/null
@@ -1,392 +0,0 @@
-package org.vcell.imagej.helper;
-
-import java.awt.Dimension;
-import java.io.File;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.vcell.imagej.helper.VCellHelper.IJGeom;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import io.scif.img.SCIFIOImgPlus;
-import net.imagej.DefaultDataset;
-import net.imagej.ImageJ;
-import net.imagej.ImgPlus;
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import net.imagej.display.ImageDisplay;
-import net.imglib2.Cursor;
-import net.imglib2.FinalInterval;
-import net.imglib2.RandomAccessibleInterval;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.type.numeric.RealType;
-import net.imglib2.type.numeric.integer.UnsignedByteType;
-import net.imglib2.type.numeric.real.DoubleType;
-import net.imglib2.util.Intervals;
-import net.imglib2.view.IterableRandomAccessibleInterval;
-
-public class SmallCR {
-
-// public static void main(String[] args) {
-// try {
-// VCellHelper vh = new VCellHelper();
-// ImageJ ij = new ImageJ();
-// ij.ui().showUI();
-//
-// ExampleDatasets exampleDatasets = openExample(ij, new File("C:\\Users\\frm\\VCellTrunkGitWorkspace2\\vcell\\vcell-imagej-helper")/*new File(System.getProperty("user.dir", "."))*/);
-// int ANALYZE_BEGIN_TIMEINDEX = 3;
-// int ANALYZE_END_TIMEINDEX = 8;
-// int ANALYZE_COUNT = ANALYZE_END_TIMEINDEX - ANALYZE_BEGIN_TIMEINDEX +1;
-// int xIndex = exampleDatasets.experimentalData.dimensionIndex(Axes.X);
-// int xsize = (int)exampleDatasets.experimentalData.dimension(xIndex);
-// int yIndex = exampleDatasets.experimentalData.dimensionIndex(Axes.Y);
-// int ysize = (int)exampleDatasets.experimentalData.dimension(yIndex);
-// FinalInterval analyzeOrigInterval = FinalInterval.createMinSize(new long[] {0,0,ANALYZE_BEGIN_TIMEINDEX, xsize,ysize,ANALYZE_COUNT});//xyzt:origin and xyzt:size
-// int assumedZIndex = -1;
-// for (int i = 0; i < exampleDatasets.segmentedGeom.numDimensions(); i++) {
-// if(exampleDatasets.segmentedGeom.dimensionIndex(Axes.X)!=i && exampleDatasets.segmentedGeom.dimensionIndex(Axes.Y)!=i) {
-// assumedZIndex = i;
-// break;
-// }
-// }
-// int zsize = (assumedZIndex == -1?1:(int)exampleDatasets.segmentedGeom.dimension(assumedZIndex));
-// HashMap segmentedGeomValuesMapSubvolumeName = new HashMap();
-// segmentedGeomValuesMapSubvolumeName.put(0, "cyt");
-// segmentedGeomValuesMapSubvolumeName.put(255, "Nuc");
-// VCellHelper.IJGeom overrideGeom = createGeometry(exampleDatasets.segmentedGeom, xIndex, yIndex, assumedZIndex, xsize, ysize, zsize, segmentedGeomValuesMapSubvolumeName);
-// double[] diffRates = new double[] {
-// 1.25,
-// 1.3,
-// 1.4,
-// 1.45,
-// 1.5,
-// 1.55,
-// 1.6
-// };
-// double[] mse = new double[diffRates.length];
-// for (int i = 0; i < diffRates.length; i++) {
-// String simulationCacheKey = getSimulationCacheKey(vh);
-// IJSolverStatus ijSolverStatus = runFrapSolver(vh, diffRates[i],simulationCacheKey,overrideGeom);
-// String simulationDataCacheKey = waitForSolverGetCacheForData(vh, ijSolverStatus);
-// SCIFIOImgPlus annotatedZProjectedSimPostBleachData = zProjectNormalizeSimData(vh, "Sim Data "+diffRates[i], simulationDataCacheKey, "rf", 0, ijSolverStatus.getJobIndex(), ANALYZE_BEGIN_TIMEINDEX, ANALYZE_END_TIMEINDEX);
-// showAndZoom(ij, "Sim Data "+diffRates[i], annotatedZProjectedSimPostBleachData, 4);
-// mse[i] = calcMSE(ij, annotatedZProjectedSimPostBleachData,exampleDatasets,analyzeOrigInterval);
-// }
-// for(int i=0;i vcellModelSearchResults = vh.getSearchedModelSimCacheKey(true, search,vcellModelVersionTimeRange);
- if(vcellModelSearchResults.size() != 1) {
- throw new Exception("Expecting only 1 model from search results");
- }
- String cacheKey = vcellModelSearchResults.get(0).getCacheKey();
- return cacheKey;
-
- }
-// public static IJSolverStatus runFrapSolver(VCellHelper vh,double diffusionRate,String cacheKey,VCellHelper.IJGeom overrideGeom) throws Exception{
-// //Override Model/Simulation parameter values (user must have knowledge of chosen model to know what parameter names to override)
-// HashMap simulationParameterOverrides = new HashMap<>();
-// simulationParameterOverrides.put("rf_diffusionRate", ""+diffusionRate);
-// HashMap speciesContextInitialConditionsOverrides = new HashMap<>();
-// String laserArea = "((x >= "+43+") && (x <= "+47+") && (y >= "+22+") && (y <= "+26+"))";
-// speciesContextInitialConditionsOverrides.put("Laser", laserArea);
-// double newEndTime = 10.0;
-// //Start Frap simulation
-// IJSolverStatus ijSolverStatus = vh.startVCellSolver(Long.parseLong(cacheKey), overrideGeom, simulationParameterOverrides, speciesContextInitialConditionsOverrides,newEndTime);
-// return ijSolverStatus;
-// }
-// public static String waitForSolverGetCacheForData(VCellHelper vh,IJSolverStatus ijSolverStatus) throws Exception{
-// //Wait for solver to finish
-// System.out.println(ijSolverStatus.toString());
-// String simulationJobId = ijSolverStatus.simJobId;
-// while(true) {
-// Thread.sleep(5000);
-// ijSolverStatus = vh.getSolverStatus(simulationJobId);
-// System.out.println(ijSolverStatus.toString());
-// String statusName = ijSolverStatus.statusName.toLowerCase();
-// if(statusName.equals("finished") || statusName.equals("stopped") || statusName.equals("aborted")) {
-// break;
-// }
-// }
-// return vh.getSimulationDataCacheKey(ijSolverStatus.simJobId);
-// }
-// public static SCIFIOImgPlus zProjectNormalizeSimData(VCellHelper vh,
-// String newImgPlusName,String simulationDataCachekey,String varToAnalyze,int preBleachTimeIndex,int solverStatus_jobIndex,int ANALYZE_BEGIN_TIMEINDEX,int ANALYZE_END_TIMEINDEX) throws Exception{
-//
-// int ANALYZE_COUNT = ANALYZE_END_TIMEINDEX - ANALYZE_BEGIN_TIMEINDEX+1;
-// // Get the SIMULATION pre-bleach timepoint data for normalizing
-// VCellHelper.TimePointData timePointData = vh.getTimePointData(simulationDataCachekey, varToAnalyze, new int[] {preBleachTimeIndex}, solverStatus_jobIndex);
-// int xysize = timePointData.getBasicStackDimensions().xsize*timePointData.getBasicStackDimensions().ysize;
-// double[] bleachedTimeStack = new double[ANALYZE_COUNT*xysize];
-//// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-//// URL dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)(0)+"&"+"jobid="+ijSolverStatus.getJobIndex());
-// double[] zProjectedSimNormalizer = getNormalizedZProjected(timePointData,null);
-////showAndZoom(ij, "Sim Data PreBleach", ArrayImgs.doubles(simNormalizer, xsize,ysize), 4);
-//
-// // Get the SIMULATION post-bleach data to analyze
-// for(int timeIndex = ANALYZE_BEGIN_TIMEINDEX;timeIndex<=ANALYZE_END_TIMEINDEX;timeIndex++){
-// timePointData = vh.getTimePointData(simulationDataCachekey, varToAnalyze, new int[] {timeIndex}, solverStatus_jobIndex);
-//// checkSizes(timePointData.getBasicStackDimensions(), xsize, xysize, zsize);
-//// dataUrl = new URL("http://localhost:"+vh.findVCellApiServerPort()+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+varToAnalyze+"&"+"timeindex"+"="+(int)timeIndex+"&"+"jobid="+ijSolverStatus.getJobIndex());
-// double[] data = getNormalizedZProjected(timePointData,zProjectedSimNormalizer);
-// System.arraycopy(data, 0, bleachedTimeStack, (timeIndex-ANALYZE_BEGIN_TIMEINDEX)*xysize, data.length);
-// }
-//
-// //Turn VCell data into iterableinterval
-//// FinalInterval zProjectedSimDataSize = FinalInterval.createMinSize(new long[] {0,0,0, xsize,ysize,ANALYZE_COUNT});//xyzt:origin and xyzt:size
-// ArrayImg simImgs = ArrayImgs.doubles(bleachedTimeStack, new long[] {timePointData.getBasicStackDimensions().xsize,timePointData.getBasicStackDimensions().ysize,ANALYZE_COUNT});
-// SCIFIOImgPlus annotatedZProjectedSimPostBleachData = new SCIFIOImgPlus<>(simImgs,newImgPlusName /*"Sim Data "+diffusionRate*/,new AxisType[] {Axes.X,Axes.Y,Axes.TIME});
-//// RandomAccessibleInterval simExtracted = ij.op().transform().crop(annotatedSimData, simExtractInterval);
-////showAndZoom(ij, "Sim Data "+diffusionRate, annotatedZProjectedSimPostBleachData, 4);
-// return annotatedZProjectedSimPostBleachData;
-// }
-// public static double[] getNormalizedZProjected(VCellHelper.TimePointData timePointData,double[] normalizer) throws Exception{
-// BasicStackDimensions basicStackDimensions = timePointData.getBasicStackDimensions();//VCellHelper.getDimensions(nodes.item(0));
-// //Sum pixel values in Z direction to match experimental data (open pinhole confocal, essentially brightfield)
-// int xysize = basicStackDimensions.xsize*basicStackDimensions.ysize;
-// double[] normalizedData = new double[xysize];
-// for (int i = 0; i < timePointData.getTimePointData().length; i++) {
-// normalizedData[(i%xysize)]+= timePointData.getTimePointData()[i];
-// }
-// if(normalizer != null) {
-// for (int i = 0; i < normalizedData.length; i++) {
-// if(normalizedData[i] != 0) {
-// normalizedData[i] = (normalizedData[i]+Double.MIN_VALUE)/(normalizer[i]+Double.MIN_VALUE);
-// }
-// }
-// }
-// return normalizedData;
-// }
-// public static void checkSizes(BasicStackDimensions basicStackDimensions,int xsize,int ysize,int zsize) throws Exception{
-// if(basicStackDimensions.xsize != xsize || basicStackDimensions.ysize != ysize || basicStackDimensions.zsize != zsize) {
-// throw new Exception("One or more sim data xyz dimensions="+basicStackDimensions.xsize+","+basicStackDimensions.ysize+","+basicStackDimensions.zsize+" does not match expected xyz sizes="+xsize+","+ysize+","+zsize);
-// }
-// }
-
- public static double calcMSE(ImageJ ij,SCIFIOImgPlus annotatedZProjectedSimPostBleachData,ExampleDatasets exampleDatasets,FinalInterval analyzeOrigInterval) throws Exception{
- //Calculate mean-squared-error as example, normalize experimental data by dividing by a prebleach image
- RandomAccessibleInterval extends RealType>> zProjectedExperimentalPostBleach = ij.op().transform().crop(exampleDatasets.experimentalData, analyzeOrigInterval);
- Cursor zProjectedSimPostBleachDataCursor = IterableRandomAccessibleInterval.create(annotatedZProjectedSimPostBleachData).localizingCursor();
- Cursor extends RealType>> zProjectedExpPostBleachDataCursor = IterableRandomAccessibleInterval.create(zProjectedExperimentalPostBleach).localizingCursor();
- IterableRandomAccessibleInterval extends RealType>> zProjectedPreBleachInterval = IterableRandomAccessibleInterval.create(exampleDatasets.preBleachImage);
- BigDecimal sumSquaredDiff = new BigDecimal(0);
- int[] analysisPosition = new int[exampleDatasets.analysisROI.numDimensions()];
- int[] preBleachPosition = new int[zProjectedPreBleachInterval.numDimensions()];
- int[] experimentalPosition = new int[zProjectedExperimentalPostBleach.numDimensions()];
- int[] simulationPosition = new int[annotatedZProjectedSimPostBleachData.numDimensions()];
- int numValsInMask = 0;
- while(zProjectedSimPostBleachDataCursor.hasNext()){
- Cursor analysisCursor = exampleDatasets.analysisROI.localizingCursor();
- Cursor extends RealType>> preBleachNormalizingCursor = zProjectedPreBleachInterval.localizingCursor();
- while(analysisCursor.hasNext()){
- boolean maskBit = !(analysisCursor.next().get() == 0);
- DoubleType simPostBleachVal = zProjectedSimPostBleachDataCursor.next();
- RealType> expPostBleachVal = zProjectedExpPostBleachDataCursor.next();
- RealType> preBleachNormalizingVal = preBleachNormalizingCursor.next();
- if(!maskBit) {//skip areas where analysis mask is 0
- continue;
- }
- //Get the position of all the cursors and check they are in sync
- analysisCursor.localize(analysisPosition);
- preBleachNormalizingCursor.localize(preBleachPosition);
- zProjectedExpPostBleachDataCursor.localize(experimentalPosition);
- zProjectedSimPostBleachDataCursor.localize(simulationPosition);
-// System.out.println("analysis="+Arrays.toString(analysisPosition)+" prebleach="+Arrays.toString(preBleachPosition)+" exp="+Arrays.toString(experimentalPosition)+" sim="+Arrays.toString(simulationPosition));
- if(!Arrays.equals(analysisPosition, preBleachPosition) || !Arrays.equals(experimentalPosition, simulationPosition)){
- throw new Exception("Cursor positions not equal");
- }
- if(analysisPosition[0] != experimentalPosition[0] || analysisPosition[1] != experimentalPosition[1]) {//check xy are same
- throw new Exception("XY Cursor position not equal for analysisROI mask and experimental data");
- }
- double normalizedExpDataVal = 0;
- if(expPostBleachVal.getRealDouble() != 0) {
- normalizedExpDataVal = (expPostBleachVal.getRealDouble())/(preBleachNormalizingVal.getRealDouble()+Double.MIN_VALUE);
- }
- double diff = simPostBleachVal.get()-(normalizedExpDataVal);
- sumSquaredDiff = sumSquaredDiff.add(new BigDecimal(Math.pow(diff,2.0)));
- numValsInMask++;
- }
- }
- return sumSquaredDiff.divide(new BigDecimal(numValsInMask),8, RoundingMode.HALF_UP).doubleValue();
-
- }
- public static class ExampleDatasets{
- public ImgPlus extends RealType>> experimentalData;
- public ImgPlus extends RealType>> preBleachImage;
- public ImgPlus segmentedGeom;
- public ImgPlus analysisROI;
- public ExampleDatasets(ImgPlus extends RealType>> experimentalData,
- ImgPlus extends RealType>> preBleachImage, ImgPlus segmentedGeom,
- ImgPlus analysisROI) {
- super();
- this.experimentalData = experimentalData;
- this.preBleachImage = preBleachImage;
- this.segmentedGeom = segmentedGeom;
- this.analysisROI = analysisROI;
- }
- }
- public static ExampleDatasets openExample(ImageJ ij,File exampleDataDir) throws Exception{
- final String[] exampleFiles = new String[] {"Experimental.zip","Seg Geom_3d.zip","PreBleach.zip","Analysis ROI.zip"};
-// final String[] exampleFiles = new String[] {"testDiff_1_2.zip","Seg Geom_3d.zip","testPreBleach.zip","Analysis ROI.zip"};// for test
-
-
-// List> displays0 = ij.display().getDisplays();
-// for (Display> display : displays0) {
-// System.out.println("----------disp "+display.getName()+" "+display.getIdentifier());
-// }
- List knownImageDisplays = ij.imageDisplay().getImageDisplays();
-// for (ImageDisplay imageDisplay : imageDisplays0) {
-// System.out.println("----------imgdisp "+imageDisplay.getName()+" "+imageDisplay.getIdentifier());
-// }
-
- ImgPlus extends RealType>> experimentalData = null;// 2D
- ImgPlus segmentedGeom = null;// 2D or 3D (if 3D will be z-project for analysis withg 2D experimental data)
- ImgPlus extends RealType>> preBleachImage = null;// 2D
- ImgPlus analysisROI = null; // 2D
-
- // Open example images if they are not already open
- for (int exampleFilesIndex = 0; exampleFilesIndex < exampleFiles.length; exampleFilesIndex++) {
- DefaultDataset exampleFileDataset = null;
-
- for (ImageDisplay imageDisplay : knownImageDisplays) {
- if(imageDisplay.getName().equals(exampleFiles[exampleFilesIndex])) {
- exampleFileDataset = (DefaultDataset) imageDisplay.getActiveView().getData();
- break;
- }
- }
- if(exampleFileDataset == null) {
- exampleFileDataset = (DefaultDataset)ij.io().open(new File(exampleDataDir,exampleFiles[exampleFilesIndex]).getAbsolutePath());
-// ij.ui().show(exampleFileDataset);
- showAndZoom(ij, exampleFiles[exampleFilesIndex], exampleFileDataset, 4);
- }
- // Print names of axes (x,y,z,time,channel,unknown,...)
- System.out.print(exampleFileDataset.getName()+": ");
- for (int dimensionIndex = 0; dimensionIndex < exampleFileDataset.numDimensions(); dimensionIndex++) {
- System.out.print((exampleFileDataset.axis(dimensionIndex)!=null?exampleFileDataset.axis(dimensionIndex).type().toString()+" ":"null "));
- }
- System.out.println();
-
- // Assign variables (defaultDataset corresponds to open 'exampleFiles' element
- switch (exampleFilesIndex) {
- case 0:
- experimentalData = exampleFileDataset.getImgPlus();
- break;
- case 1:
- segmentedGeom = (ImgPlus) exampleFileDataset.getImgPlus();
- break;
- case 2:
- preBleachImage = exampleFileDataset.getImgPlus();
- break;
- case 3:
- analysisROI = (ImgPlus) exampleFileDataset.getImgPlus();
- break;
- }
- }
- return new ExampleDatasets(experimentalData, preBleachImage, segmentedGeom, analysisROI);
- }
- public static void showAndZoom(ImageJ ij,String displayName,Object thingToDisplay,double zoomFactor) throws Exception{
-// if(!displayName.startsWith("Sim Data")) {
-// return;
-// }
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- // TODO Auto-generated method stub
- ij.ui().show(displayName,thingToDisplay);
- //Find display and set zoom, resize window
- List knownImageDisplays = ij.imageDisplay().getImageDisplays();
- boolean bvisible = false;
- while (!bvisible) {
- for (ImageDisplay imageDisplay : knownImageDisplays) {
- if (imageDisplay.getName().equals(displayName)) {
- if (imageDisplay.isVisible(imageDisplay.getActiveView())) {
- bvisible = true;
- break;
- }
- }
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-// int vw = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportWidth();
-// int vh = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportHeight();
-// System.out.println(" -----byname="+ij.display().getDisplay(displayName));
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- try {
- ij.imageDisplay().getActiveImageDisplay().getCanvas().setZoom(zoomFactor);
- if(ij.display().getDisplay(displayName) != null && ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)) instanceof JFrame) {
- double vw = ij.imageDisplay().getActiveImageDisplay().dimension(ij.imageDisplay().getActiveImageDisplay().dimensionIndex(Axes.X))*zoomFactor;
- double vh = ij.imageDisplay().getActiveImageDisplay().dimension(ij.imageDisplay().getActiveImageDisplay().dimensionIndex(Axes.Y))*zoomFactor;
- ((JFrame)ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getWindow()).setSize(new Dimension((int)vw+50, (int)vh+150));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
-
-// ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getPanel().redoLayout();
-// List> displays = ij.display().getDisplays();
-// for (Display> display : displays) {
-// System.out.println(display+" -----byname="+ij.display().getDisplay(displayName));
-// }
-
- }
- }).start();
-
- }
-
- public static IJGeom createGeometry(ImgPlus nonZProjectedSegmentedGeom,int xIndex,int yIndex,int assumedZIndex,int xsize,int ysize,int zsize,HashMap segmentedGeomValuesMapSubvolumeName) throws Exception{
- //Create byte array that defines vcell subvolumes ids (handles)
- byte[] vcellSubvolumeHandles = new byte[(int)Intervals.numElements(nonZProjectedSegmentedGeom)];
- Cursor nonZProjectedSegmentedGeomCursor = nonZProjectedSegmentedGeom.localizingCursor();
- while(nonZProjectedSegmentedGeomCursor.hasNext()){
- UnsignedByteType segmentedGeomValue = (UnsignedByteType) nonZProjectedSegmentedGeomCursor.next();
- int currentZ = (assumedZIndex==-1?0:nonZProjectedSegmentedGeomCursor.getIntPosition(assumedZIndex));
- int currXYPixelIndex = nonZProjectedSegmentedGeomCursor.getIntPosition(yIndex)*xsize + nonZProjectedSegmentedGeomCursor.getIntPosition(xIndex);
- int currXYZPixelIndex = currXYPixelIndex + (assumedZIndex==-1?0:currentZ*(xsize*ysize));
- vcellSubvolumeHandles[currXYZPixelIndex] = (byte)segmentedGeomValue.get();
- }
- //Define new Geometry with domain equal to xyz pixel size for ease of use
- String[] subvolumeNames = segmentedGeomValuesMapSubvolumeName.values().toArray(new String[0]);
- Integer[] subvolumePixelValues = segmentedGeomValuesMapSubvolumeName.keySet().toArray(new Integer[0]);
- double[] origin = new double[] {0,0,0};
- double[] extent = new double[] {xsize,ysize,zsize};
- IJGeom ijGeom = new IJGeom(subvolumeNames, subvolumePixelValues, xsize, ysize, zsize, origin, extent, vcellSubvolumeHandles);
- return ijGeom;
- }
-}
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/VCellHelper.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/VCellHelper.java
deleted file mode 100644
index 59fc70d65f..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/helper/VCellHelper.java
+++ /dev/null
@@ -1,1532 +0,0 @@
-package org.vcell.imagej.helper;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.nio.ByteBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.regex.Pattern;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlInlineBinaryData;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.scijava.plugin.Plugin;
-import org.scijava.service.AbstractService;
-import org.scijava.service.Service;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import net.imagej.ImageJService;
-import net.imagej.lut.LUTService;
-import net.imglib2.Dimensions;
-import net.imglib2.display.ColorTable;
-
-@Plugin(type = Service.class)
-public class VCellHelper extends AbstractService implements ImageJService
-{
- private int lastVCellApiPort = -1;
- JAXBContext jaxbContext;
-
- public VCellHelper() {
- try {
- jaxbContext = JAXBContext.newInstance(new Class[] {IJSimStatusJobs.class,IJFDid.class,IJSimStatus.class,IJTimeSeriesJobResults.class,IJTimeSeriesJobSpec.class,IJFieldData.class,IJGeom.class,IJVarInfo.class,IJVarInfos.class,IJData.class,IJDataList.class,BasicStackDimensions.class});
- } catch (JAXBException e) {
- e.printStackTrace();
- }
- }
-
- public static String documentToString(Document doc) throws Exception {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- transformer.transform(new DOMSource(doc),new StreamResult(new OutputStreamWriter(baos, "UTF-8")));
- return baos.toString();
- }
-
- public int findVCellApiServerPort() throws Exception{
- final int start = 50000;
- final int end = 50100;
- int tryCount = end-start+1;
- for(int i = lastVCellApiPort;i<=end;i++) {
- if(i == -1) {
- i= start;
- }
- try (Socket socket = new Socket();){
- socket.connect(new InetSocketAddress("localhost", i), 100);
- socket.close();
- String response = getRawContent(new URL("http://localhost:"+i+"/hello"));
- if(response.startsWith("VCellApi")) {
- lastVCellApiPort = i;
- break;
- }
- } catch (IOException e) {
- //ignore, continue scanning
- }
- if(i == end) {
- i = start-1;
- }
- if(--tryCount == 0) {
- throw new Exception("Couldn't find VCellApi Server between ports "+start+" and "+end);
- }
- }
- return lastVCellApiPort;
-
- }
-// public String getApiInfo() throws Exception{
-// findVCellApiServerPort();
-// URL url = new URL("http://localhost:"+lastVCellApiPort+"/");
-// // URL url = new URL("http://localhost:8080/list");
-// HttpURLConnection con = (HttpURLConnection)url.openConnection();
-// int responseCode = con.getResponseCode();
-// if(responseCode == HttpURLConnection.HTTP_OK) {
-// BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
-// int currChar;
-// StringBuffer sb = new StringBuffer();
-// while ((currChar = bis.read()) != -1) {
-// sb.append((char)currChar);
-// }
-// return sb.toString();
-// }else {
-// throw new Exception("Expecting OK but got "+responseCode+" "+con.getResponseMessage());
-// }
-//
-//// InputStream in = con.getInputStream();
-//// String encoding = con.getContentEncoding();
-//// encoding = encoding == null ? "UTF-8" : encoding;
-//// String body = IOUtils.toString(in, encoding);
-//// System.out.println(body);
-//
-// }
-
- public static Document getDocument(URL url) throws Exception{
- HttpURLConnection con = (HttpURLConnection)url.openConnection();
- int responseCode = con.getResponseCode();
- if(responseCode == HttpURLConnection.HTTP_OK) {
- return getDocument(con.getInputStream());
- }else {
-// throw new Exception("Expecting OK but got "+responseCode+" "+con.getResponseMessage());
- throw new Exception("Expecting OK but got "+responseCode+" "+streamToStringWithClose(con.getErrorStream()));
- }
- }
- public static Document getDocument(InputStream is) throws Exception{
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document doc = docBuilder.parse(is);
- return doc;
- }
- public static Document getDocument(String str) throws Exception{
- InputStream is = new ByteArrayInputStream(StandardCharsets.UTF_16.encode(str).array());
- return getDocument(is);
- }
- public static class BasicStackDimensions implements Dimensions{
- @XmlAttribute
- public int xsize;
- @XmlAttribute
- public int ysize;
- @XmlAttribute
- public int zsize;
- @XmlAttribute
- public int csize;
- @XmlAttribute
- public int tsize;
- public BasicStackDimensions(){
-
- }
- public BasicStackDimensions(int xsize, int ysize, int zsize, int csize, int tsize) {
- this.xsize = xsize;
- this.ysize = ysize;
- this.zsize = zsize;
- this.csize = csize;
- this.tsize = tsize;
- }
- public int getTotalSize(){
- return xsize*ysize*zsize*csize*tsize;
- }
- @Override
- public int numDimensions() {
- int numdims = (xsize>1?1:0)+(ysize>1?1:0)+(zsize>1?1:0)+(csize>1?1:0)+(tsize>1?1:0);
- return (numdims==0?1:numdims);
- }
- @Override
- public void dimensions(long[] dimensions) {
- for(int i=0;i>>>>> mapModelToContext = new HashMap<>();
-// private HashMap mapDataToDimension = new HashMap<>();
-// public String[] getModelNames() {
-// return mapModelToContext.keySet().toArray(new String[0]);
-// }
-// public String[] getContextNames(String modelName) {
-// return mapModelToContext.get(modelName).keySet().toArray(new String[0]);
-// }
-// public String[] getSimulationNames(String modelName,String contextName) {
-// return mapModelToContext.get(modelName).get(contextName).keySet().toArray(new String[0]);
-// }
-// public String[] getVariableNames(String modelName,String contextName,String simulationName) {
-// return mapModelToContext.get(modelName).get(contextName).get(simulationName).keySet().toArray(new String[0]);
-// }
-// public Double[] getTimePoints(String modelName,String contextName,String simulationName,String variableName) {
-// return mapModelToContext.get(modelName).get(contextName).get(simulationName).get(variableName).keySet().toArray(new Double[0]);
-// }
-// public Integer[] getJobIndexes(String modelName,String contextName,String simulationName,String variableName,double timePoint) {
-// return mapModelToContext.get(modelName).get(contextName).get(simulationName).get(variableName).get(timePoint).keySet().toArray(new Integer[0]);
-// }
-// public double[] getData(String modelName,String contextName,String simulationName,String variableName,double timePoint,int jobIndex) {
-// return mapModelToContext.get(modelName).get(contextName).get(simulationName).get(variableName).get(timePoint).get(jobIndex);
-// }
-// public long[] getXYZDimensions(double[] data) {
-// return mapDataToDimension.get(data);
-// }
-// public Set getDatas(){
-// return mapDataToDimension.keySet();
-// }
-// public void put(String modelName,String contextName,String simName,String varName,double[] data,long[] xyzDim,double timePoint,int jobIndex) throws Exception{
-// while(true){
-// if(mapModelToContext.containsKey(modelName)) {
-// HashMap>>>> mapContextToSim = mapModelToContext.get(modelName);
-// if(mapContextToSim.containsKey(contextName)) {
-// HashMap>>> mapSimToVar = mapContextToSim.get(contextName);
-// if(mapSimToVar.containsKey(simName)) {
-// HashMap>> mapVarToTime = mapSimToVar.get(simName);
-// if(mapVarToTime.containsKey(varName)) {
-// HashMap> mapTimeToJob = mapVarToTime.get(varName);
-// if(mapTimeToJob.containsKey(timePoint)) {
-// HashMap mapJobToData = mapTimeToJob.get(timePoint);
-// if(mapJobToData.containsKey(jobIndex)) {
-// throw new Exception("Data already exists for "+modelName+":"+contextName+":"+simName+":"+varName);
-// }else {
-// mapJobToData.put(jobIndex, data);
-// mapDataToDimension.put(data, xyzDim);
-// return;
-// }
-// }else {
-// mapTimeToJob.put(timePoint, new HashMap());
-// }
-// }else {
-// mapVarToTime.put(varName, new HashMap>());
-// }
-// }else {
-// mapSimToVar.put(simName, new HashMap>>());
-// }
-// }else {
-// mapContextToSim.put(contextName, new HashMap>>>());
-// }
-// }else {
-// mapModelToContext.put(modelName, new HashMap>>>>());
-// }
-// }
-// }
-// }
-
-// public static class IJDataSearchPart {
-// public String varNameSearch;
-// public int[] timeIndexes;
-// public int jobIndex;
-// public IJDataSearchPart(String varNameSearch, int[] timeIndexes, int jobIndex) {
-// super();
-// this.varNameSearch = varNameSearch;
-// this.timeIndexes = timeIndexes;
-// this.jobIndex = jobIndex;
-// }
-// }
- public static class VCellModelVersionTimeRange{
- private Date earliest;
- private Date latest;
- public VCellModelVersionTimeRange(Date earliest, Date latest) {
- super();
- this.earliest = earliest;
- this.latest = latest;
- }
- public Date getEarliest() {
- return earliest;
- }
- public Date getLatest() {
- return latest;
- }
-
- }
- public static class VCellModelSearch {
- private ModelType modelType;
- private String userId;
- private String modelName;
- private String applicationName;
- private String simulationName;
- private Integer geometryDimension;
- private String mathType;
- public VCellModelSearch(ModelType modelType, String userId, String modelName, String applicationName,
- String simulationName, Integer geometryDimension, String mathType) {
- super();
- if(modelType==ModelType.mm && applicationName != null) {
- throw new IllegalArgumentException("MathModel types should have 'null' applicationName");
- }
- this.modelType = modelType;
- this.userId = userId;
- this.modelName = modelName;
- this.applicationName = applicationName;
- this.simulationName = simulationName;
- this.geometryDimension = geometryDimension;
- this.mathType = mathType;
- }
- public ModelType getModelType() {
- return modelType;
- }
- public String getUserId() {
- return userId;
- }
- public String getModelName() {
- return modelName;
- }
- public String getApplicationName() {
- return applicationName;
- }
- public String getSimulationName() {
- return simulationName;
- }
- public Integer getGeometryDimension() {
- return geometryDimension;
- }
- public String getMathType() {
- return mathType;
- }
-
- }
- public static class VCellModelSearchResults extends VCellModelSearch{
- private Long date;
- private String cacheKey;
- public VCellModelSearchResults(int geometryDiimension,String mathType,ModelType modelType, String userId, String modelName, String applicationName,String simulationname, Long date, String cacheKey) {
- super(modelType, userId, modelName, applicationName, simulationname,geometryDiimension,mathType);
- this.date = date;
- this.cacheKey = cacheKey;
- }
- public Long getDate() {
- return date;
- }
- public String getCacheKey() {
- return cacheKey;
- }
- }
- public static enum ModelType {bm,mm,quick};
- public ArrayList getSearchedModelSimCacheKey(Boolean bOpenOnly,VCellModelSearch vcCellModelSearch,VCellModelVersionTimeRange vcellModelVersionTimeRange) throws Exception{
- ArrayList modelSimCacheKeys = new ArrayList<>();
- URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/"+"getinfo/"+"?"+(bOpenOnly == null?"":"open="+bOpenOnly+"&")+"type"+"="+vcCellModelSearch.getModelType().name());
- Pattern regexModelNameSearch = (vcCellModelSearch.getModelName()==null?null:Pattern.compile(("\\Q" + vcCellModelSearch.getModelName() + "\\E").replace("*", "\\E.*\\Q")));
- Pattern regexContextNameSearch = (vcCellModelSearch.getApplicationName()==null?null:Pattern.compile(("\\Q" + vcCellModelSearch.getApplicationName() + "\\E").replace("*", "\\E.*\\Q")));
- Pattern regexSimNameSearch = (vcCellModelSearch.getSimulationName()==null?null:Pattern.compile(("\\Q" + vcCellModelSearch.getSimulationName() + "\\E").replace("*", "\\E.*\\Q")));
- Document doc = getDocument(url);
-//System.out.println(VCellHelper.documentToString(doc));
- NodeList si = (NodeList)doc.getElementsByTagName("modelInfo");
- for(int i=0;i vcellModelVersionTimeRange.getLatest().getTime())) {
- continue;
- }
- ModelType modelType = (node.getAttributes().getNamedItem("type")==null?null:ModelType.valueOf(node.getAttributes().getNamedItem("type").getNodeValue()));
- boolean bModelMatch = vcCellModelSearch.getModelName() == null || regexModelNameSearch.matcher(currentModel).matches();
- if(bUserMatch && bModelMatch){
- NodeList modelChildren = node.getChildNodes();
- for(int j=0;j getIjVarInfo() {
- return ijVarInfo;
- }
- }
- public static class IJVarInfo{
- @XmlAttribute
- private String name;
- @XmlAttribute
- private String displayName;
- @XmlAttribute
- private String variableType;
- @XmlAttribute
- private String domain;
- @XmlAttribute
- private Boolean bFunction;
- public IJVarInfo() {
-
- }
- public IJVarInfo(String name, String displayName, String variableType, String domain, Boolean bFunction) {
- this.name = name;
- this.displayName = displayName;
- this.variableType = variableType;
- this.domain = domain;
- this.bFunction = bFunction;
- }
- public String getName() {
- return name;
- }
- public String getDisplayName() {
- return displayName;
- }
- public String getVariableType() {
- return variableType;
- }
- public String getDomain() {
- return domain;
- }
- public Boolean getbFunction() {
- return bFunction;
- }
- }
-
- public IJVarInfos getSimulationInfo(String cacheKey) throws Exception{
- URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/"+"getdata/"+"?"+"cachekey"+"="+cacheKey);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- return (IJVarInfos)unmarshallResponseFromConnection(con, jaxbContext);
-
-// Document varDoc = getDocument(new URL("http://localhost:"+findVCellApiServerPort()+"/"+"getdata/"+"?"+"cachekey"+"="+cacheKey));//get variable names
-// return getTimesFromVarInfos(varDoc);
- }
- private static double[] getTimesFromVarInfos(String timeList) {
- //reads times from human readable 'times' xml tag: 0='0.0',1='0.2',...
- StringTokenizer st = new StringTokenizer(timeList, ",");
- double[] doubles = new double[st.countTokens()];
- while(st.hasMoreTokens()) {
- StringTokenizer st2 = new StringTokenizer(st.nextToken(), "='");
- int index = Integer.valueOf(st2.nextToken());
- doubles[index] = Double.valueOf(st2.nextToken());
- }
- return doubles;
- }
- public static String[] getVarNamesFromVarInfos(Document doc) {
- ArrayList varNamesList = new ArrayList<>();
- NodeList varNodes = doc.getElementsByTagName("ijVarInfo");
- for(int j=0;j jaxbMap = new TreeMap<>();
-// private static String createXML(Object theClass) throws Exception{
-//// vcListXML.setCommandInfo(result);
-// JAXBContext context = jaxbMap.get(theClass.getClass().getName());
-// if(context == null) {
-// context = JAXBContext.newInstance(theClass.getClass());
-// jaxbMap.put(theClass.getClass().getName(), context);
-// System.out.println("jaxbMap entry count = "+jaxbMap.size());
-// }
-
-// private static JAXBContext getJaxbContext(Class> theClass,TreeMap jaxbMap) throws Exception{
-// JAXBContext jaxbContext = jaxbMap.get(theClass.getName());
-// if(jaxbContext == null) {
-// jaxbContext = JAXBContext.newInstance(theClass.getClass());
-// jaxbMap.put(theClass.getClass().getName(), jaxbContext);
-// System.out.println("jaxbMap entry count = "+jaxbMap.size());
-// }
-// return jaxbContext;
-// }
- private String createXML(Object theObject) throws Exception{
-// vcListXML.setCommandInfo(result);
- Marshaller m = jaxbContext.createMarshaller();
- // for pretty-print XML in JAXB
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- StringWriter writer = new StringWriter();
- // Write to list to a writer
- m.marshal(theObject, writer);
- String str = writer.toString();
-// System.out.println(str);
- // write the content to a physical file
-// new FileWriter("jaxbTest.xml").write(result);
- return str;
- }
-
- @XmlRootElement
- public static class IJTimeSeriesJobSpec{
- @XmlElement
- private String[] variableNames;
- @XmlElement
- private int[] indices;
- @XmlAttribute
- private double startTime;
- @XmlAttribute
- private int step;
- @XmlAttribute
- private double endTime;
- @XmlAttribute
- private boolean calcSpaceStats = false;//Calc stats over space for each timepoint
- @XmlAttribute
- private boolean calcTimeStats = false;
- @XmlAttribute
- private int jobid;
- @XmlAttribute
- private int cachekey;
- public IJTimeSeriesJobSpec() {
-
- }
- public IJTimeSeriesJobSpec(String[] variableNames, int[] indices, double startTime, int step, double endTime,
- boolean calcSpaceStats, boolean calcTimeStats, int jobid, int cachekey) {
- super();
- this.variableNames = variableNames;
- this.indices = indices;
- this.startTime = startTime;
- this.step = step;
- this.endTime = endTime;
- this.calcSpaceStats = calcSpaceStats;
- this.calcTimeStats = calcTimeStats;
- this.jobid = jobid;
- this.cachekey = cachekey;
- }
-
- }
-
-
- @XmlRootElement
- public static class IJTimeSeriesJobResults{
- @XmlElement
- public String[] variableNames;
- @XmlElement
- public int[] indices;//all variable share same indices
- @XmlElement
- public double[] times;//all vars share times
- @XmlElement
- public double[][][] data;//[varname][indices][times];
- @XmlElement
- public double[][] min;
- @XmlElement
- public double[][] max;
- @XmlElement
- public double[][] unweightedMean;
- @XmlElement
- public double[][] weightedMean = null;
- @XmlElement
- public double[] totalSpace = null;
- @XmlElement
- public double[][] unweightedSum;
- @XmlElement
- public double[][] weightedSum;
- public IJTimeSeriesJobResults() {
-
- }
- }
-
- @XmlRootElement()
- public static class IJFDid{
- @XmlElement()
- public String fdid;
- public IJFDid() {
- }
- public IJFDid(String fdid) {
- super();
- this.fdid = fdid;
- }
- }
-
- @XmlRootElement
- public static class IJFieldData {
- @XmlAttribute
- public String fdName;
- @XmlAttribute
- public String[] varNames;
- @XmlAttribute
- public int xsize;
- @XmlAttribute
- public int ysize;
- @XmlAttribute
- public int zsize;
- @XmlElement
- short[][][] data;
- @XmlElement
- double[] times;
- @XmlAttribute
- public double xExtent;
- @XmlAttribute
- public double yExtent;
- @XmlAttribute
- public double zExtent;
- @XmlAttribute
- public double xOrigin;
- @XmlAttribute
- public double yOrigin;
- @XmlAttribute
- public double zOrigin;
-
- public IJFieldData() {
- }
-
- public IJFieldData(String fdName, String[] varNames, int xsize, int ysize, int zsize, short[][][] data, double[] times,
- double xExtent, double yExtent, double zExtent, double xOrigin, double yOrigin, double zOrigin) {
- super();
- if(data.length != times.length) {
- throw new IllegalArgumentException("data length "+data.length+" not equal times length "+times.length);
- }
- for (int i = 0; i < data.length; i++) {
- if(data[i].length != varNames.length){
- throw new IllegalArgumentException("data length ["+i+"] "+data[i].length+" not equal varNames length "+varNames.length);
- }
- for (int j = 0; j < data[i].length; j++) {
- if(data[i][j].length != xsize*ysize*zsize){
- throw new IllegalArgumentException("data length ["+i+"]["+j+"] "+data[i][j].length+" not equal xyz length "+xsize*ysize*zsize);
- }
- }
- }
- this.fdName = fdName;
- this.varNames = varNames;
- this.xsize = xsize;
- this.ysize = ysize;
- this.zsize = zsize;
- this.data = data;
- this.times = times;
- this.xExtent = xExtent;
- this.yExtent = yExtent;
- this.zExtent = zExtent;
- this.xOrigin = xOrigin;
- this.yOrigin = yOrigin;
- this.zOrigin = zOrigin;
- }
- }
-
- @XmlRootElement
- public static class IJGeom {
- @XmlElement
- String[] subvolumeNames;
- @XmlElement
- Integer[] subvolumePixelValue;
- @XmlAttribute
- public int xsize;
- @XmlAttribute
- public int ysize;
- @XmlAttribute
- public int zsize;
- @XmlElement
- double[] originXYZ;
- @XmlElement
- double[] extentXYZ;
- @XmlElement
- byte[] geom;
- public IJGeom() {
-
- }
- public IJGeom(String[] subvolumeNames, Integer[] subvolumePixelValue, int xsize, int ysize, int zsize,double[] originXYZ, double[] extentXYZ, byte[] geom) throws Exception{
- super();
- if(originXYZ == null || extentXYZ == null || originXYZ.length != 3 || extentXYZ.length != 3) {
- throw new Exception("origin and extent array size must be 3");
- }
- if(subvolumeNames == null || subvolumePixelValue == null || (subvolumeNames.length != subvolumePixelValue.length)) {
- throw new Exception("subvolNames and pixelvalues arrays must be non-null and same length");
- }
- if(geom == null || geom.length != (xsize*ysize*zsize)) {
- throw new Exception("x*y*z="+(xsize*ysize*zsize)+" not the same as geom length="+geom.length);
- }
-
- this.subvolumeNames = subvolumeNames;
- this.subvolumePixelValue = subvolumePixelValue;
- this.xsize = xsize;
- this.ysize = ysize;
- this.zsize = zsize;
- this.originXYZ = originXYZ;
- this.extentXYZ = extentXYZ;
- this.geom = geom;
- }
- }
-
- public IJFDid sendFieldData(IJFieldData ijFieldData) throws Exception{
- URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/solver/fielddata");
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- con.setDoOutput(true); // indicates POST method
- con.setDoInput(true);
- con.setRequestMethod("POST");
- con.setRequestProperty("Content-Type", "text/xml");
- jaxbContext.createMarshaller().marshal(ijFieldData, con.getOutputStream());
- con.getOutputStream().close();
- return (IJFDid)unmarshallResponseFromConnection(con, jaxbContext);
- }
-
- public IJSimStatus startVCellSolver(long cachekey,IJGeom ijGeom,HashMap simulationParameterOverrides,HashMap speciesContextInitialConditionsOverrides,Double endTime,boolean bSaveOnly) throws Exception{
- StringBuffer overridesQueryParameters = new StringBuffer();
- overridesQueryParameters.append("cachekey="+cachekey);
- if(simulationParameterOverrides != null) {
- for(String simParameterdName:simulationParameterOverrides.keySet()) {
- overridesQueryParameters.append((overridesQueryParameters.length()>0?"&":"")+simParameterdName+"="+URLEncoder.encode(simulationParameterOverrides.get(simParameterdName)));
- }
- }
- if(speciesContextInitialConditionsOverrides != null) {
- for(String speciesContextName:speciesContextInitialConditionsOverrides.keySet()) {
- overridesQueryParameters.append((overridesQueryParameters.length()>0?"&":"")+speciesContextName+"="+URLEncoder.encode(speciesContextInitialConditionsOverrides.get(speciesContextName)));
- }
- }
- if(endTime != null) {
- overridesQueryParameters.append((overridesQueryParameters.length()>0?"&":"")+"newSimEndTime"+"="+endTime);
- }
- if(bSaveOnly) {
- overridesQueryParameters.append((overridesQueryParameters.length()>0?"&":"")+"bSaveOnly"+"="+true);
- }
- URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/solver/bycachekey/"+(overridesQueryParameters.length()>0?"?"+overridesQueryParameters.toString():""));
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- if(ijGeom != null) {
- con.setDoOutput(true); // indicates POST method
- con.setDoInput(true);
- con.setRequestMethod("POST");
- con.setRequestProperty("Content-Type", "text/xml");
- jaxbContext.createMarshaller().marshal(ijGeom, con.getOutputStream());
- con.getOutputStream().close();
- }
- return (IJSimStatus)unmarshallResponseFromConnection(con, jaxbContext);
-
- }
-// public IJSolverStatus startFrap(Double lasA,Double rDiffusionOverride,Double kForwardBindingOverride,Double kReversBindingOverride,IJGeom ijGeom,String laserCoverageAnalyticExpression,Double newEndTime) throws Exception{
-// StringBuffer sb = new StringBuffer();
-// sb.append((sb.length()>0?"&":"")+(laserCoverageAnalyticExpression==null?"":"laserCoverage="+URLEncoder.encode(laserCoverageAnalyticExpression)));
-// sb.append((sb.length()>0?"&":"")+(newEndTime==null?"": "endTime="+newEndTime.doubleValue()));
-// sb.append((sb.length()>0?"&":"")+(rDiffusionOverride==null?"": "Dex_diffusionRate="+rDiffusionOverride.doubleValue()+"&rf_diffusionRate="+rDiffusionOverride.doubleValue()));
-// sb.append((sb.length()>0?"&":"")+(lasA==null?"": "lasA="+lasA.doubleValue()));
-// sb.append((sb.length()>0?"&":"")+(kForwardBindingOverride==null?"": "Kf_RAN_FITC_binding="+kForwardBindingOverride.doubleValue()+"&Kf_RAN_binding="+kForwardBindingOverride.doubleValue()));
-// sb.append((sb.length()>0?"&":"")+(kReversBindingOverride==null?"": "Kr_RAN_FITC_binding="+kReversBindingOverride.doubleValue()+"&Kr_RAN_binding="+kReversBindingOverride.doubleValue()));
-// URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/solver/frap/"+(sb.length()>0?"?"+sb.toString():""));
-// HttpURLConnection con = (HttpURLConnection) url.openConnection();
-// if(ijGeom != null) {
-// con.setDoOutput(true); // indicates POST method
-// con.setDoInput(true);
-// con.setRequestMethod("POST");
-// con.setRequestProperty("Content-Type", "text/xml");
-//// jaxbContext.createMarshaller().marshal(ijFieldData, con.getOutputStream());
-// jaxbContext.createMarshaller().marshal(ijGeom, con.getOutputStream());
-// con.getOutputStream().close();
-// }
-// return (IJSolverStatus)unmarshallResponseFromConnection(con, jaxbContext);
-// }
-
- private static Object unmarshallResponseFromConnection(HttpURLConnection con,JAXBContext jaxbContext) throws Exception{
- int responseCode = con.getResponseCode();
-// System.out.println("Response Code : " + responseCode);
- if(responseCode == HttpURLConnection.HTTP_OK) {
- Object obj = jaxbContext.createUnmarshaller().unmarshal(con.getInputStream());
- con.getInputStream().close();
- return obj;
- }
- throw new Exception(streamToStringWithClose(con.getErrorStream()));
- }
-
- @XmlRootElement
- public static class IJSimStatus {
- @XmlAttribute
- int simulationStatusCode;
- @XmlAttribute
- String simulationStatusName;
- @XmlAttribute
- String statusID;
- public IJSimStatus() {
-
- }
- public IJSimStatus(int simulationStatusCode, String simulationStatusName,String statusID) {
- super();
- this.simulationStatusCode = simulationStatusCode;
- this.simulationStatusName = simulationStatusName;
- this.statusID = statusID;
- }
- }
-
- @XmlRootElement
- public static class IJSimStatusJobs{
- @XmlElement
- public IJSimStatus[] results;
- public IJSimStatusJobs() {
-
- }
- public IJSimStatusJobs(IJSimStatus[] results) {
- super();
- this.results = results;
- }
- }
-
-// @XmlRootElement
-// public static class IJSolverStatus {
-// @XmlAttribute
-// public String simJobId;
-// @XmlAttribute
-// public int statusCode;
-// @XmlAttribute
-// public String statusName;
-// @XmlAttribute
-// public String statusDetail;
-// @XmlAttribute
-// public String statusMessage;
-// public IJSolverStatus() {
-// }
-// //SimulationJobStatus vs. SolverStatus
-// @Override
-// public String toString() {
-// return simJobId+" "+statusCode+" "+statusName+" "+statusDetail+" "+statusMessage;
-// }
-// public int getJobIndex() {
-// //Assumes simJobId = SimID_simkey_jobindex
-// StringTokenizer st = new StringTokenizer(simJobId, "_");
-// st.nextToken();
-// st.nextToken();
-// return Integer.parseInt(st.nextToken());
-// }
-// }
-
-
- public IJSimStatusJobs getSolverStatus(String simulationJobId) throws Exception{
- URL url = new URL("http://localhost:"+findVCellApiServerPort()+"/solver/status/?vcSimId="+URLEncoder.encode(simulationJobId, Charset.forName("UTF-8").name()));
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- return (IJSimStatusJobs)unmarshallResponseFromConnection(con, jaxbContext);
- }
-
- public IJTimeSeriesJobResults getTimeSeries(String[] variableNames, int[] indices, double startTime, int step, double endTime,
- boolean calcSpaceStats, boolean calcTimeStats, int jobid, int cachekey) throws Exception{
- IJTimeSeriesJobSpec ijTimeSeriesJobSpec = new IJTimeSeriesJobSpec(variableNames, indices, startTime, step, endTime, calcSpaceStats, calcTimeStats, jobid, cachekey);
- URL url = new URL("http://localhost:"+lastVCellApiPort+"/gettimeseries/");
-
-// MultipartUtility multipart = new MultipartUtility(url.toString(), "UTF-8");
-// InputStream stream = new ByteArrayInputStream(createXML(ijTimeSeriesJobSpec).getBytes(StandardCharsets.UTF_8));
-// multipart.addStreamPart("testfield", stream);
-// System.out.println(multipart.finish());
-
-
-
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
-// String boundary = "---" + System.currentTimeMillis() + "---";
- con.setUseCaches(false);
- con.setDoOutput(true); // indicates POST method
- con.setDoInput(true);
- con.setRequestProperty("Content-Type","text/xml");
-// con.setRequestProperty("Content-Type","multipart/form-data; boundary=" + boundary);
-
-
- con.setRequestMethod("POST");
-// con.setRequestProperty("User-Agent", USER_AGENT);
- con.setRequestProperty("Accept-Language", "UTF-8");
-
- OutputStreamWriter outputStreamWriter = new OutputStreamWriter(con.getOutputStream());
- String s = createXML(ijTimeSeriesJobSpec);
- outputStreamWriter.write(s);
- outputStreamWriter.flush();
- outputStreamWriter.close();
-
- return (IJTimeSeriesJobResults)unmarshallResponseFromConnection(con, jaxbContext);
-// int responseCode = con.getResponseCode();
-// System.out.println("Response Code : " + responseCode);
-//
-// BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
-// String inputLine;
-// StringBuffer response = new StringBuffer();
-//
-// while ((inputLine = in.readLine()) != null) {
-// response.append(inputLine);
-// }
-// in.close();
-//
-//// System.out.println(response.toString());
-//
-// JAXBContext jaxbContext = JAXBContext.newInstance(IJTimeSeriesJobResults.class);
-// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-// IJTimeSeriesJobResults ijTimeSeriesJobResults = (IJTimeSeriesJobResults) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(response.toString().getBytes()));
-
-
-
-
-
-
-// MultipartUtility multipart = new MultipartUtility("http://localhost:8000/", "UTF-8");
-// multipart.addStreamPart("testfield", new StringInputStream("blah"));
-// System.out.println(multipart.finish());
-
-// // In your case you are not adding form data so ignore this
-// /* This is to add parameter values */
-// for (int i = 0; i < myFormDataArray.size(); i++) {
-// multipart.addFormField(myFormDataArray.get(i).getParamName(), myFormDataArray.get(i).getParamValue());
-// }
-
-// // add your file here.
-// /* This is to add file content */
-// for (int i = 0; i < myFileArray.size(); i++) {
-// multipart.addFilePart(myFileArray.getParamName(), new File(myFileArray.getFileName()));
-// }
-//
-// List response = multipart.finish();
-// for (String line : response) {
-// // get your server response here.
-// System.out.println(line);
-// }
-
-
-// URL url = new URL("http://example.net/new-message.php");
-// Map params = new LinkedHashMap<>();
-// params.put("name", "Freddie the Fish");
-// params.put("email", "fishie@seamail.example.com");
-// params.put("reply_to_thread", 10394);
-// params.put("message", "Shark attacks in Botany Bay have gotten out of control. We need more defensive dolphins to protect the schools here, but Mayor Porpoise is too busy stuffing his snout with lobsters. He's so shellfish.");
-//
-// StringBuilder postData = new StringBuilder();
-// for (Map.Entry param : params.entrySet()) {
-// if (postData.length() != 0) postData.append('&');
-// postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
-// postData.append('=');
-// postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
-// }
-// byte[] postDataBytes = postData.toString().getBytes("UTF-8");
-//
-// HttpURLConnection conn = (HttpURLConnection)url.openConnection();
-// conn.setRequestMethod("POST");
-// conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-// conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
-// conn.setDoOutput(true);
-// conn.getOutputStream().write(postDataBytes);
-//
-// Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
-//
-// StringBuilder sb = new StringBuilder();
-// for (int c; (c = in.read()) >= 0;) {
-// sb.append((char)c);
-// }
-// String response = sb.toString();
-// return ijTimeSeriesJobResults;
- }
-
- public static class MultipartUtility {
- private final String boundary;
- private static final String LINE_FEED = "\r\n";
- private HttpURLConnection httpConn;
- private String charset;
- private OutputStream outputStream;
- private PrintWriter writer;
-
- public MultipartUtility(String requestURL, String charset)
- throws IOException {
- this.charset = charset;
-
- // creates a unique boundary based on time stamp
- boundary = "---" + System.currentTimeMillis() + "---";
- URL url = new URL(requestURL);
- httpConn = (HttpURLConnection) url.openConnection();
- httpConn.setUseCaches(false);
- httpConn.setDoOutput(true); // indicates POST method
- httpConn.setDoInput(true);
- httpConn.setRequestMethod( "POST" );
- httpConn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
-
-// httpConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
- outputStream = httpConn.getOutputStream();
- writer = new PrintWriter(new OutputStreamWriter(outputStream, charset),
- true);
- }
-
- public void addFormField(String name, String value) {
- writer.append("--" + boundary).append(LINE_FEED);
- writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
- .append(LINE_FEED);
- writer.append("Content-Type: text/plain; charset=" + charset).append(
- LINE_FEED);
- writer.append(LINE_FEED);
- writer.append(value).append(LINE_FEED);
- writer.flush();
- }
-
- public void addStreamPart(String fieldName, InputStream inputStream) throws IOException {
-//// String fileName = uploadFile.getName();
-// writer.append("--" + boundary).append(LINE_FEED);
-// writer.append("Content-Disposition: form-data; name=\"" + fieldName/* + "\"; filename=\"" + fileName + "\""*/)
-// .append(LINE_FEED);
-// writer.append("Content-Type: " + "text/xml").append(LINE_FEED);
-// writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
-// writer.append(LINE_FEED);
-// writer.flush();
-//
-//// FileInputStream inputStream = new FileInputStream(uploadFile);
- byte[] buffer = new byte[4096];
- int bytesRead = -1;
- while ((bytesRead = inputStream.read(buffer)) != -1) {
- outputStream.write(buffer, 0, bytesRead);
- }
- outputStream.flush();
- inputStream.close();
-// writer.append(LINE_FEED);
- writer.flush();
- }
-
- public void addHeaderField(String name, String value) {
- writer.append(name + ": " + value).append(LINE_FEED);
- writer.flush();
- }
-
- public List finish() throws IOException {
- List response = new ArrayList();
-// writer.append(LINE_FEED).flush();
-// writer.append("--" + boundary + "--").append(LINE_FEED);
- writer.close();
-
- // checks server's status code first
- int status = httpConn.getResponseCode();
- if (status == HttpURLConnection.HTTP_OK) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- httpConn.getInputStream()));
- String line = null;
- while ((line = reader.readLine()) != null) {
- response.add(line);
- }
- reader.close();
- httpConn.disconnect();
- } else {
- throw new IOException("Server returned non-OK status: " + status);
- }
- return response;
- }
- }
-// public static String getApiInfo() throws Exception{
-// String responseBody = null;
-// try (CloseableHttpClient httpclient = HttpClients.createDefault()){
-// HttpGet httpget = new HttpGet("http://localhost:8080/");
-//
-// System.out.println("Executing request " + httpget.getRequestLine());
-//
-// // Create a custom response handler
-// ResponseHandler responseHandler = new ResponseHandler() {
-//
-// @Override
-// public String handleResponse(
-// final HttpResponse response) throws ClientProtocolException, IOException {
-// int status = response.getStatusLine().getStatusCode();
-// if (status >= 200 && status < 300) {
-// HttpEntity entity = response.getEntity();
-// return entity != null ? EntityUtils.toString(entity) : null;
-// } else {
-// throw new ClientProtocolException("Unexpected response status: " + status);
-// }
-// }
-//
-// };
-// responseBody = httpclient.execute(httpget, responseHandler);
-//// System.out.println("----------------------------------------");
-//// System.out.println(responseBody);
-// return responseBody;
-// }
-// }
-
-// import java.io.StringReader;
-// import java.io.StringWriter;
-//
-// import javax.xml.parsers.DocumentBuilder;
-// import javax.xml.parsers.DocumentBuilderFactory;
-// import javax.xml.transform.OutputKeys;
-// import javax.xml.transform.Transformer;
-// import javax.xml.transform.TransformerException;
-// import javax.xml.transform.TransformerFactory;
-// import javax.xml.transform.dom.DOMSource;
-// import javax.xml.transform.stream.StreamResult;
-//
-// import org.w3c.dom.Document;
-// import org.xml.sax.InputSource;
-//
-// public class StringToDocumentToString {
-//
-// public static void main(String[] args) {
-// final String xmlStr = "\n"+
-// "Pankaj25\n"+
-// "DeveloperMale";
-// Document doc = convertStringToDocument(xmlStr);
-//
-// String str = convertDocumentToString(doc);
-// System.out.println(str);
-// }
-//
-// private static String convertDocumentToString(Document doc) {
-// TransformerFactory tf = TransformerFactory.newInstance();
-// Transformer transformer;
-// try {
-// transformer = tf.newTransformer();
-// // below code to remove XML declaration
-// // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-// StringWriter writer = new StringWriter();
-// transformer.transform(new DOMSource(doc), new StreamResult(writer));
-// String output = writer.getBuffer().toString();
-// return output;
-// } catch (TransformerException e) {
-// e.printStackTrace();
-// }
-//
-// return null;
-// }
-//
-// private static Document convertStringToDocument(String xmlStr) {
-// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-// DocumentBuilder builder;
-// try
-// {
-// builder = factory.newDocumentBuilder();
-// Document doc = builder.parse( new InputSource( new StringReader( xmlStr ) ) );
-// return doc;
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// return null;
-// }
-//
-// }
-
-// public static void exerciseService() {
-// try {
-//// HttpClient httpClient = new HttpClient();
-//// HostConfiguration hostConfiguration = new HostConfiguration();
-//// hostConfiguration.setHost("localhost",8080);
-//// HttpMethod method = new GetMethod("/list?type=biom");
-//// int var = httpClient.executeMethod(hostConfiguration, method);
-//// System.out.println("result="+var);
-////
-//// method = new GetMethod("/");
-//// var = httpClient.executeMethod(hostConfiguration, method);
-//// System.out.println("result="+var);
-//
-// int lastVCellApiPort = VCellHelper.findVCellApiServerPort();//search for port that vcell is providing IJ related services on
-// int cachekey = 1;
-// System.out.println(VCellHelper.getApiInfo());//get rest api
-//// System.out.println(VCellHelper.getRawContent(new URL("http://localhost:"+lastVCellApiPort+"/"+"getinfo"+"?"/*+"open=true"+"&"*/+"type"+"="+"quick")));//generate cachekeys user can reference to get data
-// System.out.println(VCellHelper.getRawContent(new URL("http://localhost:"+lastVCellApiPort+"/"+"getdata"+"?"/*+"open=true"+"&"*/+"cachekey"+"="+cachekey)));//get variable names
-// Document doc = VCellHelper.getDocument(new URL("http://localhost:"+lastVCellApiPort+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+"C_cyt"+"&"+"timepoint"+"=0.5"));//get data
-// BasicStackDimensions basicStackDimensions = VCellHelper.getVCStackDims(doc);
-// double[] data = VCellHelper.getData(doc);
-// System.out.println(basicStackDimensions.getTotalSize());
-// System.out.println(data.length);
-//
-// long[] dims = new long[basicStackDimensions.numDimensions()];
-// basicStackDimensions.dimensions(dims);
-// ArrayImg img = ArrayImgs.doubles(data, dims);
-//// ArrayImg img = (ArrayImg)new ArrayImgFactory< DoubleType >().create( basicStackDimensions, new DoubleType() );
-//// ArrayCursor cursor = img.cursor();
-//// while(cursor.hasNext()) {
-//// cursor.next().set
-//// }
-//
-//
-//// Img< UnsignedByteType > img = new ArrayImgFactory< UnsignedByteType >().create( new long[] { 400, 320 }, new UnsignedByteType() );
-// ImageJFunctions.show( img );
-// DialogUtils.showInfoDialog(JOptionPane.getRootFrame(), "blah");
-//
-//// JAXBContext jaxbContext = JAXBContext.newInstance(IJData.class);
-//// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-//// IJData ijData = (IJData) jaxbUnmarshaller.unmarshal(new URL("http://localhost:8080/"+ApiEnum.getdata.name()+"?"/*+"open=true"+"&"*/+IJGetDataParams.cachekey.name()+"=0"));
-//// System.out.println(ijData);
-//
-//// URLConnection con = url.openConnection();
-//// InputStream in = con.getInputStream();
-//// String encoding = con.getContentEncoding();
-//// encoding = encoding == null ? "UTF-8" : encoding;
-//// String body = IOUtils.toString(in, encoding);
-//// System.out.println(body);
-// } catch (Exception e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//}
-
-}
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/LinePlot.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/LinePlot.java
deleted file mode 100644
index f14fb3a548..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/LinePlot.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.vcell.imagej.plugin;
-
-import java.util.ArrayList;
-
-import javax.swing.JFrame;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.data.Range;
-import org.jfree.data.xy.DefaultXYDataset;
-import org.scijava.command.ContextCommand;
-import org.scijava.plugin.Parameter;
-import org.scijava.plugin.Plugin;
-import org.scijava.ui.DialogPrompt.MessageType;
-import org.scijava.ui.UIService;
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.IJDataList;
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos;
-import org.vcell.imagej.helper.VCellHelper.VARTYPE_POSTPROC;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import net.imagej.ImageJ;
-
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>LinePlot")
-public class LinePlot extends ContextCommand{
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
- @Parameter (choices={"bm", "mm"}, style="listBox")
- private String modelType;
-
- @Parameter
- private String vCellUser = "colreeze";
-
- @Parameter
- private String vCellModel = "Monkeyflower_pigmentation_v2";
-
- @Parameter
- private String application = "Pattern_formation";
-
- @Parameter
- private String simulation = "WT";
-
- //String[] require more complicated programming
- //For now use just 1 string
- @Parameter
- private String variable = "A";
-
- @Parameter
- private int timePoint = 500;
-
- @Parameter
- private int startIndex = 1279;
-
- @Parameter
- private int endIndex = 1321;
-
- @Parameter
- private String imageName = "test";
-
- public static void main(String[] args) {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
- @Override
- public void run() {
-
- try {
- //Find the port that a separately running VCell client is listening on
- System.out.println("vcell service port="+vcellHelper.findVCellApiServerPort());
- } catch (Exception e) {
- uiService.showDialog("Activate VCell client ImageJ service\nTools->'Start Fiji (ImageJ) service'\n"+e.getMessage(), "Couldn't contact VCell client", MessageType.ERROR_MESSAGE);
- return;
- }
- String theCacheKey = null;
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.valueOf(modelType),vCellUser,vCellModel,application,simulation,null,null);
- try {
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- theCacheKey = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+theCacheKey);
- } catch (Exception e) {
- uiService.showDialog(modelType+", "+vCellUser+", "+vCellModel+", "+application+", "+simulation+", null, null\n"+e.getMessage(), "Search failed", MessageType.ERROR_MESSAGE);
- return;
- }
-
- IJDataList timePointData = null;
- int[] timePointIndexes = new int[1]; // there is 1 timePoint
- int theTimePointIndex = 0;
- timePointIndexes[theTimePointIndex] = timePoint;
- try {
- timePointData = vcellHelper.getTimePointData(theCacheKey, variable, VARTYPE_POSTPROC.NotPostProcess, timePointIndexes, 0);
- } catch (Exception e) {
- uiService.showDialog(modelType+", "+vCellUser+", "+vCellModel+", "+application+", "+simulation+", "+variable+", "+timePoint+"\n"+e.getMessage(), "Get Data failed", MessageType.ERROR_MESSAGE);
- return;
- }
- double[] theTimePointData = timePointData.ijData[theTimePointIndex].getDoubleData();
- Range xAxisRange = null;
- int[] dataIndexes = new int[endIndex-startIndex+1];
- double[] dataIndexesDouble = new double[dataIndexes.length];// This is just for JFreeChart
- for(int i=startIndex;i<=endIndex;i++) {
- dataIndexes[i-startIndex] = i;
- dataIndexesDouble[i-startIndex] = i;
- xAxisRange = Range.expandToInclude(xAxisRange, dataIndexesDouble[i-startIndex]);
- }
-
- Range yAxisRange = null;
- double[] chartTheseDataPoints = new double[dataIndexes.length];
- for(int i=0;i
- * You should replace the parameter fields with your own inputs and outputs,
- * and replace the {@link run} method implementation with your own logic.
- *
- *
- * To add VCellHelper to this project,
- * rt-click on topmost tree element
- * "imagej-plugin2"->Properties->Libraries tab->Add External Jars...->
- * File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT.jar.
- *
- *
- * Once vcell-imagej-helper-0.0.1-SNAPSHOT.jar has been added to the Libraries tab open
- * the small arrow to the left and select "Source Attachment"->Add/Edit->External Location->
- * External File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT-sources.jar.
- *
- */
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>Load VCell Model")
-public class ModelLoad extends ContextCommand {
- //
- // Feel free to add more parameters here...
- //
-
- //"colreeze\",\"Monkeyflower_pigmentation_v2\",\"Pattern_formation\",\"WT\",null,null\n"+e.getMessage(), "Search failed", MessageType.ERROR_MESSAGE);
- //displayProgressBar(false, null, null);
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
-
- @Parameter
- private String vCellUser = "colreeze";
-
- @Parameter
- private String vCellModel = "Monkeyflower_pigmentation_v2";
-
- @Parameter
- private String application = "Pattern_formation";
-
- @Parameter
- private String simulation = "WT";
-
- @Parameter
- private String variable = "A";
-
- @Parameter
- private int timePoint = 500;
-
- /* @Parameter
- private String imageName; */
-
- /* @Parameter */
- /*private String size; */
-
- /**
- * This main function serves for development purposes.
- * It allows you to run the plugin immediately out of
- * your integrated development environment (IDE).
- *
- * @param args whatever, it's ignored
- * @throws Exception
- */
- public static void main(final String... args) throws Exception {
- // create the ImageJ application context with all available services
-
-
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
-
- private JDialog progressDialog = null;
- private final Dimension dim = new Dimension(200,25);
- private final JProgressBar jProgressBar = new JProgressBar(0,100) {
- @Override
- public Dimension getPreferredSize() {
- // TODO Auto-generated method stub
- return dim;
- }
- @Override
- public Dimension getSize(Dimension rv) {
- // TODO Auto-generated method stub
- return dim;
- }
- };
- private void displayProgressBar(boolean bShow,String message,String title) {
- if(progressDialog == null) {
- JFrame applicationFrame = (JFrame)uiService.getDefaultUI().getApplicationFrame();
- progressDialog = new JDialog(applicationFrame,"Checking for VCell Client",false);
- progressDialog.getContentPane().add(jProgressBar);
- jProgressBar.setStringPainted(true);
- progressDialog.pack();
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(!bShow) {
- progressDialog.setVisible(false);
- return;
- }
- jProgressBar.setValue(0);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- progressDialog.setVisible(true);
- }
- });
- }
-
- private Hashtable threadHash = new Hashtable();
- private void startJProgressThread0(String lastName,String newName) {
- if(lastName != null && threadHash.get(lastName) != null) {
- threadHash.get(lastName).interrupt();
- while(threadHash.get(lastName) != null) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- break;
- }
- }
- }
- if(newName == null) {
- return;
- }
- final Thread progressThread = new Thread(new Runnable(){
- @Override
- public void run() {
- final int[] progress = new int[] {1};
- while(progressDialog.isVisible()) {
- if(Thread.currentThread().isInterrupted()) {
- break;
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- jProgressBar.setValue(progress[0]);
- }});
- progress[0]++;
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- break;
- }
- }
- threadHash.remove(Thread.currentThread().getName());
- }});
- threadHash.put(newName, progressThread);
- progressThread.setName(newName);
- progressThread.setDaemon(true);//So not block JVM exit
- progressThread.start();
- }
-
- @Override
- public void run() {
-
- displayProgressBar(true, "Checking listening ports...", "Checking for VCell Client");
- startJProgressThread0(null,"Check");
-
- try {
- //Find the port that a separately running VCell client is listening on
- //
- System.out.println("vcell service port="+vcellHelper.findVCellApiServerPort());
- //uiService.getDisplayViewer(textDisplay).dispose();
- displayProgressBar(false, null, null);
- } catch (Exception e) {
- //e.printStackTrace();
- displayProgressBar(false, null, null);
- //uiService.getDisplayViewer(textDisplay).dispose();
- uiService.showDialog("Activate VCell client ImageJ service\nTools->'Start Fiji (ImageJ) service'\n"+e.getMessage(), "Couldn't contact VCell client", MessageType.ERROR_MESSAGE);
- return;
- }
-
-
- displayProgressBar(true, "Searching...", "Searching VCell Models");
- startJProgressThread0("Check","Search");
-
- String theCacheKey = null;
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm,vCellUser,vCellModel,application,simulation,null,null);
- try {
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- theCacheKey = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+theCacheKey);
- displayProgressBar(false, null, null);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- uiService.showDialog("VCellHelper.ModelType.bm,vCellUser,vCellModel,application,simulation,null,null\n"+e.getMessage(), "Search failed", MessageType.ERROR_MESSAGE);
- displayProgressBar(false, null, null);
- }
-
- displayProgressBar(true, "Loading Data...", "Loading Data");
- startJProgressThread0("Search","getTimePointData");
-
- try {
- String var = variable;
- int[] time = new int[] {timePoint};
- IJDataList tpd = vcellHelper.getTimePointData(theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0);
- double[] data = tpd.ijData[0].getDoubleData();
- BasicStackDimensions bsd = tpd.ijData[0].stackInfo;
- System.out.println(bsd.xsize+" "+bsd.ysize);
- ArrayImg testimg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize);
- uiService.show(testimg);
-
- displayProgressBar(false, null, null);
- } catch (Exception e) {
- // TODO Auto-generated catch block
-// e.printStackTrace();
- uiService.showDialog("theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0\n"+e.getMessage(), "getTimePoint(...) failed", MessageType.ERROR_MESSAGE);
- displayProgressBar(false, null, null);
-
- }
- startJProgressThread0("getTimePointData",null);
- }
-}
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/ModelSearch.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/ModelSearch.java
deleted file mode 100644
index 20447dc502..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/ModelSearch.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*
- * To the extent possible under law, the ImageJ developers have waived
- * all copyright and related or neighboring rights to this tutorial code.
- *
- * See the CC0 1.0 Universal license for details:
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-package org.vcell.imagej.plugin;
-
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.GridLayout;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.SwingUtilities;
-import javax.swing.plaf.basic.BasicComboBoxUI;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.ComboPopup;
-
-import org.scijava.command.ContextCommand;
-import org.scijava.module.Module;
-import org.scijava.module.ModuleItem;
-import org.scijava.module.process.AbstractPreprocessorPlugin;
-import org.scijava.module.process.PreprocessorPlugin;
-import org.scijava.plugin.Parameter;
-import org.scijava.plugin.Plugin;
-import org.scijava.ui.DialogPrompt.MessageType;
-import org.scijava.ui.UIService;
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.vcell.imagej.helper.VCellHelper.IJDataList;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import net.imagej.ImageJ;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.type.numeric.real.DoubleType;
-
-
-/**
- * This example illustrates how to create an ImageJ {@link ContextCommand} plugin that uses VCellHelper.
- *
- * You should replace the parameter fields with your own inputs and outputs,
- * and replace the {@link run} method implementation with your own logic.
- *
- *
- * To add VCellHelper to this project,
- * rt-click on topmost tree element
- * "imagej-plugin2"->Properties->Libraries tab->Add External Jars...->
- * File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT.jar.
- *
- *
- * Once vcell-imagej-helper-0.0.1-SNAPSHOT.jar has been added to the Libraries tab open
- * the small arrow to the left and select "Source Attachment"->Add/Edit->External Location->
- * External File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT-sources.jar.
- *
- *
- * When editing the original VCellHelper in another running Eclipse,
- * to make the changes show up in this project choose thisEclipse->Project->Clean...->clean.
- *
- */
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>VCellPluginSearch")
-public class ModelSearch extends ContextCommand {
-
-
-
- public static class StyledComboBoxUI extends BasicComboBoxUI {
- protected ComboPopup createPopup() {
- BasicComboPopup popup = new BasicComboPopup(comboBox) {
- @Override
- protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
- return super.computePopupBounds(
- px,py,Math.max(comboBox.getPreferredSize().width,pw),ph
- );
- }
- };
- popup.getAccessibleContext().setAccessibleParent(comboBox);
- return popup;
- }
- }
-
- public static class StyledComboBox extends JComboBox {
- public StyledComboBox() {
- setUI(new StyledComboBoxUI());
- }
- public StyledComboBox(E[] items) {
- setUI(new StyledComboBoxUI());
- setModel(new DefaultComboBoxModel(items));
- }
- }
-
- public static class VCellSelection {
- public String theCacheKey;
- public String userid;
- public String modelName;
- public String appName;
- public String simname;
- public String varName;
- public int timePointIndex;
- public Exception exception;
- public VCellSelection(String theCacheKey, String userid,String modelName, String appName, String simname,String varName,int timePointIndex) {
- super();
- this.theCacheKey = theCacheKey;
- this.userid=userid;
- this.modelName = modelName;
- this.appName = appName;
- this.simname = simname;
- this.varName = varName;
- this.timePointIndex = timePointIndex;
- }
- public VCellSelection(Exception exception) {
- this.exception = exception;
- }
- }
-
- @Plugin(type = PreprocessorPlugin.class)
- public static class MyPreProcessor extends AbstractPreprocessorPlugin {
-
- public static final String CANCELLED = "cancelled";
-
- @Parameter
- private UIService uiService;
-
- @Parameter(required = true)
- private VCellHelper vcellHelper;
-
-
- @Override
- public void process(Module module) {
- final ModuleItem vcellModelsInput = getvcellModelsInput(module);
- if (vcellModelsInput == null) {
- return;
- }
- Comparator comp = new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- return o1.toLowerCase().compareTo(o2.toLowerCase());
- }};
- TreeSet useridSet = new TreeSet(comp);
- Hashtable> mapUseridToModelNameTime = new Hashtable>();
- Hashtable mapModelNameTimeToActualModelname = new Hashtable();
- Hashtable> mapModelToApps = new Hashtable>();
- Hashtable> mapAppsToSims = new Hashtable>();
-// VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm,"tutorial","Tutorial_MultiApp","3D pde","Simulation4",null,null);
- displayProgressBar(true, "Searching Database...", "VCell Model Loader", 25,uiService);
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm,null,null,null,null,null,null);
- displayProgressBar(true, "Creating GUI...", "VCell Model Loader", 100,uiService);
- try {
- final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- final Iterator iterator = vcmsr.iterator();
- while(iterator.hasNext()) {
- final VCellModelSearchResults next = iterator.next();
- String userid = next.getUserId();
- useridSet.add(userid);
- final String modelName = next.getModelName();
- final String modelNameTime = modelName+" - "+(next.getDate()==null?"unsaved":dateTimeInstance.format(new Date(next.getDate())));
- TreeSet modelsForUserid = mapUseridToModelNameTime.get(userid);
- if(modelsForUserid == null) {
- modelsForUserid = new TreeSet();
- mapUseridToModelNameTime.put(userid, modelsForUserid);
- }
- modelsForUserid.add(modelNameTime);
- mapModelNameTimeToActualModelname.put(modelNameTime, modelName);
- //System.out.println(modelName+" "+next.getApplicationName()+" "+next.getSimulationName());
- TreeSet appsForModel = mapModelToApps.get(modelNameTime);
- if(appsForModel == null) {
- appsForModel = new TreeSet();
- mapModelToApps.put(modelNameTime, appsForModel);
- }
- appsForModel.add(next.getApplicationName());
- String modelNameTimeApp = modelNameTime+" "+next.getApplicationName();
- TreeSet simsForApp = mapAppsToSims.get(modelNameTimeApp);
- if(simsForApp == null) {
- simsForApp = new TreeSet();
- mapAppsToSims.put(modelNameTimeApp, simsForApp);
- }
- simsForApp.add(next.getSimulationName());
- }
- } catch (Exception e) {
- //e.printStackTrace();
- displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
- vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
- module.resolveInput(vcellModelsInput.getName());
- return;
- }finally {
- displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
- }
-
- JFrame applicationFrame = (JFrame)uiService.getDefaultUI().getApplicationFrame();
- final Dimension dim = new Dimension(300,120);
- JPanel jp = new JPanel() {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- };
- jp.setLayout(new GridLayout(7,2));
-
- jp.add(new JLabel("VCell Userid"));
- JComboBox jcbUserid = new StyledComboBox(useridSet.toArray(new String[0]));
- jp.add(jcbUserid);
-
- jp.add(new JLabel("Model Name"));
- JComboBox jcbModelNames = new StyledComboBox(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0]));
- jcbUserid.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbModelNames.removeAllItems();
- if(jcbUserid.getSelectedItem() != null && mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()) != null) {
- jcbModelNames.setModel(new DefaultComboBoxModel(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0])));
- jcbModelNames.setSelectedIndex(0);
- }
- }});
- jp.add(jcbModelNames);
-
-
- jp.add(new JLabel("App Name"));
- JComboBox jcbAppNames = new StyledComboBox(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0]));
- jcbModelNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbAppNames.removeAllItems();
- if(jcbModelNames.getSelectedItem() != null && mapModelToApps.get(jcbModelNames.getSelectedItem()) != null) {
- jcbAppNames.setModel(new DefaultComboBoxModel(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0])));
- jcbAppNames.setSelectedIndex(0);
- }
- }});
- jp.add(jcbAppNames);
-
- final JComboBox jcbVars = new StyledComboBox();
- jcbVars.setEnabled(false);
-
- final JComboBox jcbTimes = new StyledComboBox();
- jcbTimes.setEnabled(false);
-
- jp.add(new JLabel("Sim Name"));
- JComboBox jcbSimNames = new StyledComboBox(mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()).toArray(new String[0]));
- jcbAppNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbVars.removeAllItems();
- jcbTimes.removeAllItems();
- jcbSimNames.removeAllItems();
- if(jcbAppNames.getSelectedItem() != null && mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()) != null) {
- jcbSimNames.setModel(new DefaultComboBoxModel(mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()).toArray(new String[0])));
- jcbSimNames.setSelectedIndex(0);
- }
- }});
- jp.add(jcbSimNames);
-
- jp.add(new JLabel("Variables"));
- jp.add(jcbVars);
- jp.add(new JLabel("Times"));
- jp.add(jcbTimes);
-
- final String[] cacheKeyHolder = new String[1];
- final IJVarInfos[] ijVarInfosHolder = new IJVarInfos[1];
-
- jp.add(new JLabel("Load Vars and Times"));
- JButton loadVarsAndTimesBtn = new JButton("Load...");
- loadVarsAndTimesBtn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- displayProgressBar(true, "Getting Vars and Times...", "VCell Model Loader", 25,uiService);
- String userid = jcbUserid.getSelectedItem().toString();
- String modelName = (jcbModelNames.getSelectedItem()==null?null:mapModelNameTimeToActualModelname.get(jcbModelNames.getSelectedItem()).toString());
- String appName = (jcbModelNames.getSelectedItem()==null?null:jcbAppNames.getSelectedItem().toString());
- String simName = (jcbModelNames.getSelectedItem()==null?null:jcbSimNames.getSelectedItem().toString());
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.bm,userid,modelName,appName,simName,null,null);
- try {
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- cacheKeyHolder[0] = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+cacheKeyHolder[0]);
-
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- try {
- displayProgressBar(true, "Setting Var Times GUI...", "VCell Model Loader", 100,uiService);
- jcbVars.setEnabled(true);
- ijVarInfosHolder[0] = vcellHelper.getVarInfos(cacheKeyHolder[0]);
- for(int i=0;i vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
-// if(vcmsr.size() == 0) {
-// throw new Exception("No Results for search found");
-// }
-// theCacheKey = vcmsr.get(0).getCacheKey();
-// System.out.println("theCacheKey="+theCacheKey);
-//
-// jcbTimes.setEnabled(true);
-// IJVarInfos ijVarInfos = vcellHelper.getVarInfos(theCacheKey);
-// for(int i=0;i inputs = module.getInputs();
-// for(String key:inputs.keySet()) {
-// System.out.println(" "+key+" "+inputs.get(key));
-// }
- }
-
- private ModuleItem getvcellModelsInput(final Module module) {
- ModuleItem result = null;
- for (final ModuleItem> input : module.getInfo().inputs()) {
- if (module.isInputResolved(input.getName())) continue;
- final Class> type = input.getType();
- if (!VCellSelection.class.isAssignableFrom(type)) {
- // not a VCellSelection parameter; abort
- return null;
- }
- if (result != null) {
- // second VCellSelection parameter; abort
- return null;
- }
- @SuppressWarnings("unchecked")
- final ModuleItem vcellSelect = (ModuleItem) input;
- result = vcellSelect;
- }
- return result;
- }
-
- private JPanel getLabeledJComboBox(String labelName,String[] items) {
- JPanel jp = new JPanel(new FlowLayout());
- jp.add(new JLabel(labelName));
- JComboBox jcbModelNames = new JComboBox(items);
- jp.add(jcbModelNames);
- return jp;
- }
-
- }
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
- @Parameter
- private VCellSelection vcellSelection = new VCellSelection("-1", "colreeze","Monkeyflower_pigmentation_v2", "Pattern_formation", "WT","A",50);
- //private VCellSelection vcellSelection;
-
-
- /**
- * This main function serves for development purposes.
- * It allows you to run the plugin immediately out of
- * your integrated development environment (IDE).
- *
- * @param args whatever, it's ignored
- * @throws Exception
- */
- public static void main(final String... args) throws Exception {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
- private static JDialog progressDialog = null;
- private static final Dimension dim = new Dimension(200,30);
- private static final JProgressBar jProgressBar = new JProgressBar(0,100) {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- @Override
- public Dimension getSize(Dimension rv) {
- return dim;
- }
- };
- private static void displayProgressBar(boolean bShow,String message,String title,int progress,UIService uiService) {
- if(progressDialog == null) {
- JFrame applicationFrame = (JFrame)uiService.getDefaultUI().getApplicationFrame();
- progressDialog = new JDialog(applicationFrame,"Checking for VCell Client",false);
- progressDialog.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- super.windowClosing(e);
- progressDialog.dispose();
- progressDialog = null;
- }});
- progressDialog.getContentPane().add(jProgressBar);
- jProgressBar.setStringPainted(true);
- jProgressBar.setString("setting up...");
- progressDialog.pack();
-
- }
-
- if(SwingUtilities.isEventDispatchThread()) {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
-
- }else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
- }
- });
- }
- }
-
-// private Hashtable threadHash = new Hashtable();
-// private void startJProgressThread0(String lastName,String newName) {
-// if(lastName != null && threadHash.get(lastName) != null) {
-// threadHash.get(lastName).interrupt();
-// while(threadHash.get(lastName) != null) {
-// try {
-// Thread.sleep(50);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// break;
-// }
-// }
-// }
-// if(newName == null) {
-// return;
-// }
-// final Thread progressThread = new Thread(new Runnable(){
-// @Override
-// public void run() {
-// final int[] progress = new int[] {1};
-// while(progressDialog.isVisible()) {
-// if(Thread.currentThread().isInterrupted()) {
-// break;
-// }
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// jProgressBar.setValue(progress[0]);
-// }});
-// progress[0]++;
-// try {
-// Thread.sleep(500);
-// } catch (InterruptedException e) {
-// break;
-// }
-// }
-// threadHash.remove(Thread.currentThread().getName());
-// }});
-// threadHash.put(newName, progressThread);
-// progressThread.setName(newName);
-// progressThread.setDaemon(true);//So not block JVM exit
-// progressThread.start();
-// }
-
- @Override
- public void run() {
- try {
- if(vcellSelection != null && vcellSelection.exception != null) {
- if(!vcellSelection.exception.getMessage().equals(MyPreProcessor.CANCELLED)) {
- uiService.showDialog("Model search failed\n"+vcellSelection.exception.getClass().getName()+"\n"+vcellSelection.exception.getMessage(), MessageType.ERROR_MESSAGE);
- }
- return;
- }
- if(vcellSelection == null || vcellSelection.theCacheKey==null) {
- return;
- }
- String var = vcellSelection.varName;
- int[] time = new int[] {vcellSelection.timePointIndex};
- displayProgressBar(true, "loading Image...", "VCell Model Loader", 50,uiService);
- IJDataList tpd = vcellHelper.getTimePointData(vcellSelection.theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0);
- displayProgressBar(true, "displaying Image...", "VCell Model Loader", 100,uiService);
- double[] data = tpd.ijData[0].getDoubleData();
- BasicStackDimensions bsd = tpd.ijData[0].stackInfo;
- System.out.println(bsd.xsize+" "+bsd.ysize);
- ArrayImg testimg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize,bsd.zsize);
- uiService.show(testimg);
- } catch (Exception e) {
- displayProgressBar(false, "displaying Image...", "VCell Model Loader", 100,uiService);
- uiService.showDialog("theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0\n"+e.getMessage(), "getTimePoint(...) failed", MessageType.ERROR_MESSAGE);
- }finally {
- displayProgressBar(false, "displaying Image...", "VCell Model Loader", 100,uiService);
- }
- }
-}
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/NikitaTest.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/NikitaTest.java
deleted file mode 100644
index fa3aea0f7d..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/NikitaTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.vcell.imagej.plugin;
-
-import java.util.ArrayList;
-
-import javax.swing.JFrame;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.data.Range;
-import org.jfree.data.xy.DefaultXYDataset;
-import org.scijava.command.ContextCommand;
-import org.scijava.plugin.Parameter;
-import org.scijava.plugin.Plugin;
-import org.scijava.ui.DialogPrompt.MessageType;
-import org.scijava.ui.UIService;
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.IJDataList;
-import org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos;
-import org.vcell.imagej.helper.VCellHelper.VARTYPE_POSTPROC;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import net.imagej.ImageJ;
-
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>NikitaTest")
-public class NikitaTest extends ContextCommand{
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
- @Parameter (choices={"bm", "mm"}, style="listBox")
- private String modelType;
-
- @Parameter
- private String vCellUser = "colreeze";
-
- @Parameter
- private String vCellModel = "Monkeyflower_pigmentation_v2";
-
- @Parameter
- private String application = "Pattern_formation";
-
- @Parameter
- private String simulation = "WT";
-
- //String[] require more complicated programming
- //For now use just 1 string
- @Parameter
- private String variable = "A";
-
- @Parameter
- private int timePoint = 500;
-
- @Parameter
- private int startIndex = 1279;
-
- @Parameter
- private int endIndex = 1321;
-
- @Parameter
- private String imageName = "test";
-
- public static void main(String[] args) {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
- @Override
- public void run() {
-
- try {
- //Find the port that a separately running VCell client is listening on
- System.out.println("vcell service port="+vcellHelper.findVCellApiServerPort());
- } catch (Exception e) {
- uiService.showDialog("Activate VCell client ImageJ service\nTools->'Start Fiji (ImageJ) service'\n"+e.getMessage(), "Couldn't contact VCell client", MessageType.ERROR_MESSAGE);
- return;
- }
- String theCacheKey = null;
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(VCellHelper.ModelType.valueOf(modelType),vCellUser,vCellModel,application,simulation,null,null);
- try {
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- theCacheKey = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+theCacheKey);
- } catch (Exception e) {
- uiService.showDialog(modelType+", "+vCellUser+", "+vCellModel+", "+application+", "+simulation+", null, null\n"+e.getMessage(), "Search failed", MessageType.ERROR_MESSAGE);
- return;
- }
-
- IJDataList timePointData = null;
- int[] timePointIndexes = new int[1]; // there is 1 timePoint
- int theTimePointIndex = 0;
- timePointIndexes[theTimePointIndex] = timePoint;
- try {
- timePointData = vcellHelper.getTimePointData(theCacheKey, variable, VARTYPE_POSTPROC.NotPostProcess, timePointIndexes, 0);
- } catch (Exception e) {
- uiService.showDialog(modelType+", "+vCellUser+", "+vCellModel+", "+application+", "+simulation+", "+variable+", "+timePoint+"\n"+e.getMessage(), "Get Data failed", MessageType.ERROR_MESSAGE);
- return;
- }
- double[] theTimePointData = timePointData.ijData[theTimePointIndex].getDoubleData();
- Range xAxisRange = null;
- int[] dataIndexes = new int[endIndex-startIndex+1];
- double[] dataIndexesDouble = new double[dataIndexes.length];// This is just for JFreeChart
- for(int i=startIndex;i<=endIndex;i++) {
- dataIndexes[i-startIndex] = i;
- dataIndexesDouble[i-startIndex] = i;
- xAxisRange = Range.expandToInclude(xAxisRange, dataIndexesDouble[i-startIndex]);
- }
-
- Range yAxisRange = null;
- double[] chartTheseDataPoints = new double[dataIndexes.length];
- for(int i=0;i
- * You should replace the parameter fields with your own inputs and outputs,
- * and replace the {@link run} method implementation with your own logic.
- *
- *
- * To add VCellHelper to this project,
- * rt-click on topmost tree element
- * "imagej-plugin2"->Properties->Libraries tab->Add External Jars...->
- * File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT.jar.
- *
- *
- * Once vcell-imagej-helper-0.0.1-SNAPSHOT.jar has been added to the Libraries tab open
- * the small arrow to the left and select "Source Attachment"->Add/Edit->External Location->
- * External File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT-sources.jar.
- *
- *
- * When editing the original VCellHelper in another running Eclipse,
- * to make the changes show up in this project choose thisEclipse->Project->Clean...->clean.
- *
- */
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>VCellPlugin")
-public class VCellPlugin extends ContextCommand {
-
-// final UIService service = getContext().getService(UIService.class);
-// System.out.println(service.getDefaultUI().getApplicationFrame().getClass().getName()+" "+(service.getDefaultUI().getApplicationFrame() instanceof Frame));
-
- private static Frame mainApplicationFrame;
-
- public static class StyledComboBoxUI extends BasicComboBoxUI {
- protected ComboPopup createPopup() {
- @SuppressWarnings("serial")
- BasicComboPopup popup = new BasicComboPopup(comboBox) {
- @Override
- protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
- return super.computePopupBounds(
- px,py,Math.max(comboBox.getPreferredSize().width,pw),ph
- );
- }
- };
- popup.getAccessibleContext().setAccessibleParent(comboBox);
- return popup;
- }
- }
-
- @SuppressWarnings("serial")
- public static class StyledComboBox extends JComboBox {
- public StyledComboBox() {
- setUI(new StyledComboBoxUI());
- }
- public StyledComboBox(String[] items) {
- setUI(new StyledComboBoxUI());
- setModel(new DefaultComboBoxModel(items));
- }
- }
-
- public static class VCellSelection {
- public String theCacheKey;
- public VCellHelper.ModelType modelType;
- public String userid;
- public String modelName;
- public String appName;
- public String simname;
- public String[] varName;
- public int[] timePointIndexes;
- public Exception exception;
- public VCellSelection(String theCacheKey, VCellHelper.ModelType modelType,String userid,String modelName, String appName, String simname,String[] varName,int[] timePointIndexes) {
- super();
- this.theCacheKey = theCacheKey;
- this.modelType = modelType;
- this.userid=userid;
- this.modelName = modelName;
- this.appName = appName;
- this.simname = simname;
- this.varName = varName;
- this.timePointIndexes = timePointIndexes;
- }
- public VCellSelection(Exception exception) {
- this.exception = exception;
- }
- }
-
-
-
- @Plugin(type = PreprocessorPlugin.class)
- public static class MyPreProcessor extends AbstractPreprocessorPlugin {
-
- public static final String CANCELLED = "cancelled";
-
- @Parameter
- private UIService uiService;
-
- @Parameter(required = true)
- private VCellHelper vcellHelper;
-
- private JComboBox jcbModelType = new StyledComboBox(new String[] {ModelType.bm.name(),ModelType.mm.name(),ModelType.quick.name()});
- private JComboBox jcbUserid = new StyledComboBox();
- private JComboBox jcbModelNames = new StyledComboBox();
- private JComboBox jcbAppNames = new StyledComboBox();
- private JComboBox jcbSimNames = new StyledComboBox();
-
-
- private Comparator comp = new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- return o1.toLowerCase().compareTo(o2.toLowerCase());
- }
- };
- private TreeSet useridSet = new TreeSet(comp);
- private Hashtable> mapUseridToModelNameTime = new Hashtable>();
- private Hashtable mapModelNameTimeToActualModelname = new Hashtable();
- private Hashtable> mapModelToApps = new Hashtable>();
- private Hashtable> mapAppsToSims = new Hashtable>();
-
- public MyPreProcessor() {
-// jcbModelType.addActionListener(new ActionListener() {
-// @Override
-// public void actionPerformed(ActionEvent e) {
-// try {
-// searchVCell();
-// } catch (Exception e1) {
-//// // TODO Auto-generated catch block
-//// e1.printStackTrace();
-// }
-// }});
-// jcbModelType.setSelectedIndex(0);
-
- }
-
- private String createMapAppToSimsKeyName(String modelName,String appName) {
- //return jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem();
- return modelName+" "+(appName==null?modelName:appName);
- }
- private void searchVCell() throws Exception{
- final UIService service = getContext().getService(UIService.class);
- Object obj = service.getDefaultUI().getApplicationFrame();
- if(obj instanceof UIComponent && ((UIComponent)obj).getComponent() instanceof Frame) {
- mainApplicationFrame = (Frame)((UIComponent)obj).getComponent();
- }else if(obj instanceof Frame) {
- mainApplicationFrame = (Frame)obj;
- }
- //System.out.println(service.getDefaultUI().getApplicationFrame().getClass().getName()+" "+(service.getDefaultUI().getApplicationFrame() instanceof Frame));
-
- displayProgressBar(true, "Searching Database...", "VCell Model Loader", 25,uiService);
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),null,null,null,null,null,null);
- displayProgressBar(true, "Creating GUI...", "VCell Model Loader", 100,uiService);
- try {
- final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- useridSet = new TreeSet(comp);
- mapUseridToModelNameTime = new Hashtable>();
- mapModelNameTimeToActualModelname = new Hashtable();
- mapModelToApps = new Hashtable>();
- mapAppsToSims = new Hashtable>();
-
- final Iterator iterator = vcmsr.iterator();
- while(iterator.hasNext()) {
- final VCellModelSearchResults next = iterator.next();
- String userid = next.getUserId();
- useridSet.add(userid);
- final String modelName = next.getModelName();
- final String modelNameTime = modelName+" ("+next.getModelType().name()+")"+" - "+(next.getDate()==null?"unsaved":dateTimeInstance.format(new Date(next.getDate())));
- TreeSet modelsForUserid = mapUseridToModelNameTime.get(userid);
- if(modelsForUserid == null) {
- modelsForUserid = new TreeSet();
- mapUseridToModelNameTime.put(userid, modelsForUserid);
- }
- modelsForUserid.add(modelNameTime);
- mapModelNameTimeToActualModelname.put(modelNameTime, modelName);
- //System.out.println(modelName+" "+next.getApplicationName()+" "+next.getSimulationName());
- TreeSet appsForModel = mapModelToApps.get(modelNameTime);
- if(appsForModel == null) {
- appsForModel = new TreeSet();
- mapModelToApps.put(modelNameTime, appsForModel);
- }
- appsForModel.add((next.getModelType()==ModelType.mm?modelNameTime:next.getApplicationName()));
- String modelNameTimeApp = createMapAppToSimsKeyName(modelNameTime,(next.getModelType()==ModelType.mm?null:next.getApplicationName()));//modelNameTime+(next.getModelType()==ModelType.mm?"":" "+next.getApplicationName());
- TreeSet simsForApp = mapAppsToSims.get(modelNameTimeApp);
- if(simsForApp == null) {
- simsForApp = new TreeSet();
- mapAppsToSims.put(modelNameTimeApp, simsForApp);
- }
- simsForApp.add(next.getSimulationName());
- }
-// DefaultComboBoxModel a= null;
-// ((DefaultComboBoxModel)jcbUserid.getModel()).
- } catch (Exception e) {
- throw e;
-// //e.printStackTrace();
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
- }finally {
- displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
- }
-
- }
- @Override
- public void process(Module module) {
- final ModuleItem vcellModelsInput = getvcellModelsInput(module);
- if (vcellModelsInput == null) {
- return;
- }
-// try {
-// searchVCell();
-// } catch (Exception e) {
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
-// }
-
-// displayProgressBar(true, "Searching Database...", "VCell Model Loader", 25,uiService);
-// VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),null,null,null,null,null,null);
-// displayProgressBar(true, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// try {
-// final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
-// ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
-// final Iterator iterator = vcmsr.iterator();
-// while(iterator.hasNext()) {
-// final VCellModelSearchResults next = iterator.next();
-// String userid = next.getUserId();
-// useridSet.add(userid);
-// final String modelName = next.getModelName();
-// final String modelNameTime = modelName+" ("+next.getModelType().name()+")"+" - "+(next.getDate()==null?"unsaved":dateTimeInstance.format(new Date(next.getDate())));
-// TreeSet modelsForUserid = mapUseridToModelNameTime.get(userid);
-// if(modelsForUserid == null) {
-// modelsForUserid = new TreeSet();
-// mapUseridToModelNameTime.put(userid, modelsForUserid);
-// }
-// modelsForUserid.add(modelNameTime);
-// mapModelNameTimeToActualModelname.put(modelNameTime, modelName);
-// //System.out.println(modelName+" "+next.getApplicationName()+" "+next.getSimulationName());
-// TreeSet appsForModel = mapModelToApps.get(modelNameTime);
-// if(appsForModel == null) {
-// appsForModel = new TreeSet();
-// mapModelToApps.put(modelNameTime, appsForModel);
-// }
-// appsForModel.add(next.getApplicationName());
-// String modelNameTimeApp = modelNameTime+" "+next.getApplicationName();
-// TreeSet simsForApp = mapAppsToSims.get(modelNameTimeApp);
-// if(simsForApp == null) {
-// simsForApp = new TreeSet();
-// mapAppsToSims.put(modelNameTimeApp, simsForApp);
-// }
-// simsForApp.add(next.getSimulationName());
-// }
-// } catch (Exception e) {
-// //e.printStackTrace();
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
-// }finally {
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// }
-
- //ApplicationFrame applicationFrame = uiService.getDefaultUI().getApplicationFrame();
- final Dimension dim = new Dimension(300,120);
- @SuppressWarnings("serial")
- final JPanel jp = new JPanel() {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- };
- jp.setLayout(new GridLayout(8,2));
-
- final boolean[] bUseVCellSelectionHolder = new boolean[] {false};
-
- //jcbModelType
- jp.add(new JLabel("Model Type"));
- jp.add(jcbModelType);
-
-
- jp.add(new JLabel("VCell Userid"));
-// JComboBox jcbUserid = new StyledComboBox(useridSet.toArray(new String[0]));
- jcbModelType.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- searchVCell();
- } catch (Exception e1) {
- uiService.showDialog("Error in searchVCell()\n"+e1.getClass().getName()+"\n"+e1.getMessage());
-// JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(jp);
-// topFrame.dispose();
- return;
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(vcellModelsInput.getDefaultValue() != null && vcellModelsInput.getDefaultValue().modelType.name().equals(jcbModelType.getSelectedItem().toString())) {
- bUseVCellSelectionHolder[0] = true;
- }
- jcbUserid.removeAllItems();
- jcbUserid.setModel(new DefaultComboBoxModel(useridSet.toArray(new String[0])));
- if(jcbUserid.getItemCount()==0) {
- jcbUserid.addItem("Nothing Found");
- }else if(bUseVCellSelectionHolder[0]) {
- jcbUserid.setSelectedItem(vcellModelsInput.getDefaultValue().userid);
- }else {
- jcbUserid.setSelectedIndex(0);
- }
- bUseVCellSelectionHolder[0] = false;
- }});
- }}).start();
- }});
- jp.add(jcbUserid);
-
- jp.add(new JLabel("Model Name"));
-// JComboBox jcbModelNames = new StyledComboBox(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0]));
- jcbUserid.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbModelNames.removeAllItems();
- if(jcbUserid.getSelectedItem() != null && mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()) != null) {
- jcbModelNames.setModel(new DefaultComboBoxModel(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- for(int i=0;i jcbAppNames = new StyledComboBox(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0]));
- jcbModelNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbAppNames.removeAllItems();
- if(jcbModelNames.getSelectedItem() != null && mapModelToApps.get(jcbModelNames.getSelectedItem()) != null) {
- jcbAppNames.setModel(new DefaultComboBoxModel(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- jcbAppNames.setSelectedItem(vcellModelsInput.getDefaultValue().appName);
- }else {
- jcbAppNames.setSelectedIndex(0);
- }
- }
- }});
- jp.add(jcbAppNames);
-
- //final JComboBox jcbVars = new StyledComboBox();
- //jcbVars.setEnabled(false);
-
- // JComboBox jcbTimes = new StyledComboBox();
- //jcbTimes.setEnabled(false);
-
- jp.add(new JLabel("Sim Name"));
- jcbAppNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
-// jcbVars.removeAllItems();
-// jcbTimes.removeAllItems();
- jcbSimNames.removeAllItems();
- if(jcbAppNames.getSelectedItem() != null && mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()) != null) {
- jcbSimNames.setModel(new DefaultComboBoxModel(mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- jcbSimNames.setSelectedItem(vcellModelsInput.getDefaultValue().simname);
- }else {
- jcbSimNames.setSelectedIndex(0);
- }
- }
- }});
- jp.add(jcbSimNames);
-
-// if(vcellModelsInput.getDefaultValue() != null) {//If user provided an inital value for VCellSelection var in VCellPlugin
-// final VCellSelection defaultValue = vcellModelsInput.getDefaultValue();
-// jcbUserid.setSelectedItem(defaultValue.userid);
-// System.out.println(jcbUserid.getSelectedItem());
-// for(int i=0;i maxTimeJSlider1.getValue()){
- maxTimeJSlider1.setValue(minTimeJSlider1.getValue());
- return;
- }else if(ce.getSource()==maxTimeJSlider1 && maxTimeJSlider1.getValue() < minTimeJSlider1.getValue()){
- minTimeJSlider1.setValue(maxTimeJSlider1.getValue());
- return;
- }
- minTimeJLabel.setText(MINTIMESTR+ijVarInfosHolder[0].getTimes()[minTimeJSlider1.getValue()]);
- maxTimeJLabel.setText(MAXTIMESTR+ijVarInfosHolder[0].getTimes()[maxTimeJSlider1.getValue()]);
- }};
-
- minTimeJSlider1.setName("minTime");
- minTimeJSlider1.setPaintTicks(true);
- minTimeJSlider1.setMajorTickSpacing(10);
- minTimeJSlider1.setSnapToTicks(true);
- minTimeJSlider1.setMinorTickSpacing(1);
- minTimeJSlider1.setMaximum(ijVarInfosHolder[0].getTimes().length - 1);
- minTimeJSlider1.setValue(0);
- minTimeJSlider1.addChangeListener(changeListener);
-
- maxTimeJSlider1.setName("maxTime");
- maxTimeJSlider1.setPaintTicks(true);
- maxTimeJSlider1.setMajorTickSpacing(10);
- maxTimeJSlider1.setSnapToTicks(true);
- maxTimeJSlider1.setMinorTickSpacing(1);
- maxTimeJSlider1.setMaximum(ijVarInfosHolder[0].getTimes().length - 1);
- maxTimeJSlider1.setValue(ijVarInfosHolder[0].getTimes().length - 1);
- maxTimeJSlider1.addChangeListener(changeListener);
-
-// Object[][] dataVars = new Object[jcbVars.getModel().getSize()][1];
-// for(int i=0;i compList = new ArrayList();
- compList.add(SwingUtilities.getAncestorOfClass(Window.class, selectMultipleVarsAndTimesBtn));
- while(compList.size() > 0) {
- Container container = compList.remove(0);
- for(int i=0;i vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
-// if(vcmsr.size() == 0) {
-// throw new Exception("No Results for search found");
-// }
-// theCacheKey = vcmsr.get(0).getCacheKey();
-// System.out.println("theCacheKey="+theCacheKey);
-//
-// jcbTimes.setEnabled(true);
-// IJVarInfos ijVarInfos = vcellHelper.getVarInfos(theCacheKey);
-// for(int i=0;i inputs = module.getInputs();
-// for(String key:inputs.keySet()) {
-// System.out.println(" "+key+" "+inputs.get(key));
-// }
- }
-
- private void populateVarAndTimes(final String[] cacheKeyHolder,IJVarInfos[] ijVarInfosHolder
- /*
- * final VCellSelection vcellSelection, final JComboBox jcbVars,
- * final JComboBox jcbTimes, final String[] cacheKeyHolder, final
- * IJVarInfos[] ijVarInfosHolder
- */){
- displayProgressBar(true, "Getting Vars and Times...", "VCell Model Loader", 25,uiService);
- String userid = jcbUserid.getSelectedItem().toString();
- String modelName = (jcbModelNames.getSelectedItem()==null?null:mapModelNameTimeToActualModelname.get(jcbModelNames.getSelectedItem()).toString());
- String appName = (jcbModelNames.getSelectedItem()==null?null:jcbAppNames.getSelectedItem().toString());
- String simName = (jcbModelNames.getSelectedItem()==null?null:jcbSimNames.getSelectedItem().toString());
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),userid,modelName,appName,simName,null,null);
- try {
-// jcbVars.removeAllItems();
-// jcbTimes.removeAllItems();
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- cacheKeyHolder[0] = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+cacheKeyHolder[0]);
- ijVarInfosHolder[0] = vcellHelper.getVarInfos(cacheKeyHolder[0]);
-
- ijVarInfosHolder[0].getIjVarInfo().sort(new Comparator() {
- @Override
- public int compare(IJVarInfo o1, IJVarInfo o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }});
-
-// SwingUtilities.invokeAndWait(new Runnable() {
-// @Override
-// public void run() {
-// try {
-// displayProgressBar(true, "Getting Var Times GUI...", "VCell Model Loader", 100,uiService);
-// jcbVars.setEnabled(true);
-// ijVarInfosHolder[0] = vcellHelper.getVarInfos(cacheKeyHolder[0]);
-// for(int i=0;i getvcellModelsInput(final Module module) {
- ModuleItem result = null;
- for (final ModuleItem> input : module.getInfo().inputs()) {
- if (module.isInputResolved(input.getName())) continue;
- final Class> type = input.getType();
- if (!VCellSelection.class.isAssignableFrom(type)) {
- // not a VCellSelection parameter; abort
- return null;
- }
- if (result != null) {
- // second VCellSelection parameter; abort
- return null;
- }
- @SuppressWarnings("unchecked")
- final ModuleItem vcellSelect = (ModuleItem) input;
- result = vcellSelect;
- }
- return result;
- }
-
-// private JPanel getLabeledJComboBox(String labelName,String[] items) {
-// JPanel jp = new JPanel(new FlowLayout());
-// jp.add(new JLabel(labelName));
-// JComboBox jcbModelNames = new JComboBox(items);
-// jp.add(jcbModelNames);
-// return jp;
-// }
-
- }
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private DisplayService displayService;
-
- @Parameter
- EventService eventService;
-
- @Parameter
- ZoomService zoomService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
- @Parameter
- private VCellSelection vcellSelection = new VCellSelection("-1",ModelType.bm, "tutorial","Tutorial_MultiApp", "3D pde", "Simulation4",new String[] {"C_cyt"},new int[] {50});
- //private VCellSelection vcellSelection;
-
-
- /**
- * This main function serves for development purposes.
- * It allows you to run the plugin immediately out of
- * your integrated development environment (IDE).
- *
- * @param args whatever, it's ignored
- * @throws Exception
- */
- public static void main(final String... args) throws Exception {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
- private static JDialog progressDialog = null;
- private static final Dimension dim = new Dimension(200,30);
- @SuppressWarnings("serial")
- private static final JProgressBar jProgressBar = new JProgressBar(0,100) {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- @Override
- public Dimension getSize(Dimension rv) {
- return dim;
- }
- };
-
- private static void displayProgressBar(boolean bShow,String message,String title,int progress,UIService uiService) {
- if(progressDialog == null) {
- //Frame applicationFrame = VCellPlugin.mainApplicationFrame;//IJ.getInstance();//(Frame)uiService.getDefaultUI().getApplicationFrame();
- progressDialog = new JDialog(VCellPlugin.mainApplicationFrame,"Checking for VCell Client",false);
- progressDialog.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- super.windowClosing(e);
- progressDialog.dispose();
- progressDialog = null;
- }});
- progressDialog.getContentPane().add(jProgressBar);
- jProgressBar.setStringPainted(true);
- jProgressBar.setString("setting up...");
- progressDialog.pack();
-
- }
-
- if(SwingUtilities.isEventDispatchThread()) {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
-
- }else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
- }
- });
- }
- }
-
-// private Hashtable threadHash = new Hashtable();
-// private void startJProgressThread0(String lastName,String newName) {
-// if(lastName != null && threadHash.get(lastName) != null) {
-// threadHash.get(lastName).interrupt();
-// while(threadHash.get(lastName) != null) {
-// try {
-// Thread.sleep(50);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// break;
-// }
-// }
-// }
-// if(newName == null) {
-// return;
-// }
-// final Thread progressThread = new Thread(new Runnable(){
-// @Override
-// public void run() {
-// final int[] progress = new int[] {1};
-// while(progressDialog.isVisible()) {
-// if(Thread.currentThread().isInterrupted()) {
-// break;
-// }
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// jProgressBar.setValue(progress[0]);
-// }});
-// progress[0]++;
-// try {
-// Thread.sleep(500);
-// } catch (InterruptedException e) {
-// break;
-// }
-// }
-// threadHash.remove(Thread.currentThread().getName());
-// }});
-// threadHash.put(newName, progressThread);
-// progressThread.setName(newName);
-// progressThread.setDaemon(true);//So not block JVM exit
-// progressThread.start();
-// }
-
-// public void showAndZoom(String displayName,Object thingToDisplay,double zoomFactor) throws Exception{
-// final ImageDisplayService ids = getContext().getService(ImageDisplayService.class);
-// final DisplayService ds = getContext().getService(DisplayService.class);
-// new Thread(new Runnable() {
-//
-// @Override
-// public void run() {
-// // TODO Auto-generated method stub
-// uiService.show(displayName,thingToDisplay);
-// //Find display and set zoom, resize window
-// List knownImageDisplays = ids.getImageDisplays();
-// boolean bvisible = false;
-// while (!bvisible) {
-// for (ImageDisplay imageDisplay : knownImageDisplays) {
-// if (imageDisplay.getName().equals(displayName)) {
-// if (imageDisplay.isVisible(imageDisplay.getActiveView())) {
-// bvisible = true;
-// break;
-// }
-// }
-// }
-// try {
-// Thread.sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
-// }
-//// int vw = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportWidth();
-//// int vh = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportHeight();
-//// System.out.println(" -----byname="+ij.display().getDisplay(displayName));
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// try {
-// ids.getActiveImageDisplay().getCanvas().setZoom(zoomFactor);
-// if(ds.getDisplay(displayName) != null && uiService.getDisplayViewer(ds.getDisplay(displayName)) instanceof JFrame) {
-// double vw = ids.getActiveImageDisplay().dimension(ids.getActiveImageDisplay().dimensionIndex(Axes.X))*zoomFactor;
-// double vh = ids.getActiveImageDisplay().dimension(ids.getActiveImageDisplay().dimensionIndex(Axes.Y))*zoomFactor;
-// ((JFrame)uiService.getDisplayViewer(ds.getDisplay(displayName)).getWindow()).setSize(new Dimension((int)vw+50, (int)vh+150));
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-// });
-//
-//// ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getPanel().redoLayout();
-//// List> displays = ij.display().getDisplays();
-//// for (Display> display : displays) {
-//// System.out.println(display+" -----byname="+ij.display().getDisplay(displayName));
-//// }
-//
-// }
-// }).start();
-//
-// }
-
- @Override
- public void run() {
- try {
- if(vcellSelection != null && vcellSelection.exception != null) {
- if(!vcellSelection.exception.getMessage().equals(MyPreProcessor.CANCELLED)) {
- uiService.showDialog("Model search failed\n"+vcellSelection.exception.getClass().getName()+"\n"+vcellSelection.exception.getMessage(), MessageType.ERROR_MESSAGE);
- }
- return;
- }
- if(vcellSelection == null || vcellSelection.theCacheKey==null) {
- return;
- }
- //Create ImageJ datasets and display separate hyperstack for each variable
- for(int varIndex=0;varIndex testimg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize,bsd.zsize,tpd.ijData.length);
- for(int i=0;i imgPlus = new ImgPlus(testimg);
- imgPlus.setChannelMinimum(0, min);
- imgPlus.setChannelMaximum(0, max);
- imgPlus.setAxis(new DefaultLinearAxis(Axes.Z), 2);
- imgPlus.setAxis(new DefaultLinearAxis(Axes.TIME), 3);
-
- uiService.show(vcellSelection.varName[varIndex],imgPlus);
- DefaultImageDisplay createDisplayQuietly = (DefaultImageDisplay)displayService/* getContext().getService(DisplayService.class) */.getDisplay(vcellSelection.varName[varIndex]);
- while(displayService.getActiveDisplay() == null) {
- Thread.sleep(100);
- }
- WindowManager.getActiveWindow().setSize(400, 400);
- IJ.run("Scale to Fit", "");
- WindowManager.getActiveWindow().setSize(400, 400);//refresh the sliders
-
- //final ZoomService zoomService = getContext().getService(ZoomService.class);
-// zoomService.zoomSet(createDisplayQuietly, 300, 0, 0);
-// eventService.publish(new PanZoomEvent(createDisplayQuietly.getCanvas()));
-
-// IJ.run("Set... ", "zoom=300 x="+(bsd.xsize/2)+" y="+(bsd.ysize/2));
-// IJ.run("Set... ", "zoom=300");
-// IJ.run("In");
-// IJ.run("In");
-// IJ.run("In");
-
-// RunService runService = getContext().getService(RunService.class);
-// runService.run("In", (Map)null);
-// final Iterator> iterator = opService.getPlugins().iterator();
-// while(iterator.hasNext()) {
-// System.out.println(iterator.next());
-// }
-// opService.run("In", "");
-// final ZoomService zoomService = getContext().getService(ZoomService.class);
-// zoomService.zoomSet(createDisplayQuietly, 300, 0, 0);
-// createDisplayQuietly.update();
-
- //final Display> createDisplayQuietly = getContext().getService(DisplayService.class).createDisplayQuietly(testimg);
- final DefaultDatasetView defaultDatasetView = (DefaultDatasetView)((DefaultImageDisplay)createDisplayQuietly).getActiveView();
-// defaultDatasetView.getData().setAxis(createDisplayQuietly.axis(2), 2);
-// defaultDatasetView.getData().setAxis(createDisplayQuietly.axis(3), 3);
-// defaultDatasetView.update();
- System.out.println(min+" "+max);
-// displayService.setActiveDisplay(createDisplayQuietly);
-// IJ.setMinAndMax(min, max);
-// defaultDatasetView.getData().setChannelMinimum(0, min);
-// defaultDatasetView.getData().setChannelMaximum(0, max);
-
-// defaultDatasetView.setChannelRanges(min,max);
-
- //IJ.getImage().updateAndDraw();
-// while(displayService.getActiveDisplay() == null) {
-// Thread.sleep(100);
-// }
-// IJ.setMinAndMax(min, max);
- //WindowManager.getCurrentImage().setDisplayRange(min, max)
-
- //WindowManager.getCurrentImage().setDisplayRange(min,max);
- //ImageStack.create(varIndex, varIndex, varIndex, varIndex)
- //ImagePlus ip = new ImagePlus();
-
- //uiService.showUI();
-// EventService es = null;
- //getContext().getService(EventService.class).publish(new DisplayUpdatedEvent(createDisplayQuietly,DisplayUpdatedEvent.DisplayUpdateLevel.UPDATE));
- //uiService.get
-// uiService.show(createDisplayQuietly);
-// getContext().getService(DisplayService.class).
-// showAndZoom(vcellSelection.varName[varIndex],createDisplayQuietly, 3);
- }
- } catch (Exception e) {
- displayProgressBar(false, "Error", "VCell Model Loader", 100,uiService);
- uiService.showDialog("theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0\n"+e.getMessage(), "getTimePoint(...) failed", MessageType.ERROR_MESSAGE);
- }finally {
- displayProgressBar(false, "displaying Image...", "VCell Model Loader", 100,uiService);
- }
- }
-}
-
-//final long timePointSize = tpd.ijData[0].stackInfo.getTotalSize();
-//final long totalSize = tpd.ijData.length*timePointSize;
-//class MyAI extends AbstractImg {
-//
-// class MyCursor extends AbstractCursor {
-//
-// private long position = 0;
-//
-// RandomAccess myRandomAccess = new RandomAccess() {
-//
-// @Override
-// public long getLongPosition(int d) {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public int numDimensions() {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public void fwd(int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void bck(int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(int distance, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(long distance, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(Localizable distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(int[] distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(long[] distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(Localizable position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(int[] position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(long[] position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(int position, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(long position, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public DoubleType get() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Sampler copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public RandomAccess copyRandomAccess() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// };
-// final DoubleType myDoubleType = new DoubleType() {
-//
-// @Override
-// public double get() {
-// // TODO Auto-generated method stub
-// return tpd.ijData[(int) (position/timePointSize)].getDoubleData()[(int) (position%timePointSize)];
-// }
-//
-// };
-//
-// public MyCursor(int n) {
-// super(n);
-// // TODO Auto-generated constructor stub
-// }
-//
-// @Override
-// public DoubleType get() {
-// // TODO Auto-generated method stub
-// return myDoubleType;
-// }
-//
-// @Override
-// public void fwd() {
-// // TODO Auto-generated method stub
-// position++;
-// }
-//
-// @Override
-// public void reset() {
-// // TODO Auto-generated method stub
-// position = 0;
-// }
-//
-// @Override
-// public boolean hasNext() {
-// // TODO Auto-generated method stub
-// return position < (totalSize-1);
-// }
-//
-// @Override
-// public long getLongPosition(int d) {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public AbstractCursor copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public AbstractCursor copyCursor() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// };
-//
-// Cursor myCursor;
-// public MyAI(long[] size) {
-// super(size);
-// myCursor = new MyCursor(size.length);
-// }
-//
-// @Override
-// public ImgFactory factory() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Img copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public RandomAccess randomAccess() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Cursor cursor() {
-// // TODO Auto-generated method stub
-// return myCursor;
-// }
-//
-// @Override
-// public Cursor localizingCursor() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Object iterationOrder() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-//};
-//
-//uiService.show(new MyAI(new long[] {tpd.ijData[0].stackInfo.xsize,tpd.ijData[0].stackInfo.ysize,tpd.ijData[0].stackInfo.zsize,tpd.ijData.length}));
-
diff --git a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/VCellPlugin_Minimal.java b/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/VCellPlugin_Minimal.java
deleted file mode 100644
index 53ae4cb0f5..0000000000
--- a/vcell-imagej-helper/src/main/java/org/vcell/imagej/plugin/VCellPlugin_Minimal.java
+++ /dev/null
@@ -1,1422 +0,0 @@
-/*
- * To the extent possible under law, the ImageJ developers have waived
- * all copyright and related or neighboring rights to this tutorial code.
- *
- * See the CC0 1.0 Universal license for details:
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-package org.vcell.imagej.plugin;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.GridLayout;
-import java.awt.Rectangle;
-import java.awt.Window;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.TreeSet;
-
-import javax.swing.BoxLayout;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.JScrollPane;
-import javax.swing.JSlider;
-import javax.swing.JTable;
-import javax.swing.SwingUtilities;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.plaf.basic.BasicComboBoxUI;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.ComboPopup;
-import javax.swing.table.DefaultTableModel;
-
-import org.scijava.command.ContextCommand;
-import org.scijava.display.Display;
-import org.scijava.display.DisplayService;
-import org.scijava.display.event.DisplayUpdatedEvent;
-import org.scijava.event.EventService;
-import org.scijava.module.Module;
-import org.scijava.module.ModuleItem;
-import org.scijava.module.process.AbstractPreprocessorPlugin;
-import org.scijava.module.process.PreprocessorPlugin;
-import org.scijava.plugin.Parameter;
-import org.scijava.plugin.Plugin;
-import org.scijava.plugin.PluginInfo;
-import org.scijava.run.RunService;
-import org.scijava.ui.DialogPrompt.MessageType;
-import org.scijava.ui.UIService;
-import org.scijava.widget.UIComponent;
-import org.vcell.imagej.helper.VCellHelper;
-import org.vcell.imagej.helper.VCellHelper.BasicStackDimensions;
-import org.vcell.imagej.helper.VCellHelper.IJDataList;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfo;
-import org.vcell.imagej.helper.VCellHelper.IJVarInfos;
-import org.vcell.imagej.helper.VCellHelper.ModelType;
-import org.vcell.imagej.helper.VCellHelper.VCellModelSearchResults;
-
-import ij.IJ;
-import ij.ImagePlus;
-import ij.ImageStack;
-import ij.WindowManager;
-import ij.gui.NewImage;
-import net.imagej.ImageJ;
-import net.imagej.ImgPlus;
-import net.imagej.axis.Axes;
-import net.imagej.axis.AxisType;
-import net.imagej.axis.CalibratedAxis;
-import net.imagej.axis.DefaultAxisType;
-import net.imagej.axis.DefaultLinearAxis;
-import net.imagej.display.DefaultDatasetView;
-import net.imagej.display.DefaultImageDisplay;
-import net.imagej.display.ImageDisplay;
-import net.imagej.display.ImageDisplayService;
-import net.imagej.display.WindowService;
-import net.imagej.display.ZoomService;
-import net.imagej.display.event.PanZoomEvent;
-import net.imagej.ops.Op;
-import net.imagej.ops.OpService;
-import net.imagej.ops.Ops.Map;
-import net.imglib2.img.array.ArrayImg;
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.basictypeaccess.array.DoubleArray;
-import net.imglib2.type.numeric.real.DoubleType;
-import net.imglib2.util.Pair;
-
-
-/**
- * This example illustrates how to create an ImageJ {@link ContextCommand} plugin that uses VCellHelper.
- *
- * You should replace the parameter fields with your own inputs and outputs,
- * and replace the {@link run} method implementation with your own logic.
- *
- *
- * To add VCellHelper to this project,
- * rt-click on topmost tree element
- * "imagej-plugin2"->Properties->Libraries tab->Add External Jars...->
- * File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT.jar.
- *
- *
- * Once vcell-imagej-helper-0.0.1-SNAPSHOT.jar has been added to the Libraries tab open
- * the small arrow to the left and select "Source Attachment"->Add/Edit->External Location->
- * External File Dialog->{EclipseVCellWorkspaceRootDir}/vcell/vcell-imagej-helper/target/vcell-imagej-helper-0.0.1-SNAPSHOT-sources.jar.
- *
- *
- * When editing the original VCellHelper in another running Eclipse,
- * to make the changes show up in this project choose thisEclipse->Project->Clean...->clean.
- *
- */
-@Plugin(type = ContextCommand.class, menuPath = "Plugins>VCellPlugin_Minimal")
-public class VCellPlugin_Minimal extends ContextCommand {
-
-// final UIService service = getContext().getService(UIService.class);
-// System.out.println(service.getDefaultUI().getApplicationFrame().getClass().getName()+" "+(service.getDefaultUI().getApplicationFrame() instanceof Frame));
-
- private static Frame mainApplicationFrame;
-
- public static class StyledComboBoxUI extends BasicComboBoxUI {
- protected ComboPopup createPopup() {
- @SuppressWarnings("serial")
- BasicComboPopup popup = new BasicComboPopup(comboBox) {
- @Override
- protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
- return super.computePopupBounds(
- px,py,Math.max(comboBox.getPreferredSize().width,pw),ph
- );
- }
- };
- popup.getAccessibleContext().setAccessibleParent(comboBox);
- return popup;
- }
- }
-
- @SuppressWarnings("serial")
- public static class StyledComboBox extends JComboBox {
- public StyledComboBox() {
- setUI(new StyledComboBoxUI());
- }
- public StyledComboBox(String[] items) {
- setUI(new StyledComboBoxUI());
- setModel(new DefaultComboBoxModel(items));
- }
- }
-
- public static class VCellSelection {
- public String theCacheKey;
- public VCellHelper.ModelType modelType;
- public String userid;
- public String modelName;
- public String appName;
- public String simname;
- public String[] varName;
- public int[] timePointIndexes;
- public Exception exception;
- public VCellSelection(String theCacheKey, VCellHelper.ModelType modelType,String userid,String modelName, String appName, String simname,String[] varName,int[] timePointIndexes) {
- super();
- this.theCacheKey = theCacheKey;
- this.modelType = modelType;
- this.userid=userid;
- this.modelName = modelName;
- this.appName = appName;
- this.simname = simname;
- this.varName = varName;
- this.timePointIndexes = timePointIndexes;
- }
- public VCellSelection(Exception exception) {
- this.exception = exception;
- }
- }
-
-
-
- @Plugin(type = PreprocessorPlugin.class)
- public static class MyPreProcessor extends AbstractPreprocessorPlugin {
-
- public static final String CANCELLED = "cancelled";
-
- @Parameter
- private UIService uiService;
-
- @Parameter(required = true)
- private VCellHelper vcellHelper;
-
- private JComboBox jcbModelType = new StyledComboBox(new String[] {ModelType.bm.name(),ModelType.mm.name(),ModelType.quick.name()});
- private JComboBox jcbUserid = new StyledComboBox();
- private JComboBox jcbModelNames = new StyledComboBox();
- private JComboBox jcbAppNames = new StyledComboBox();
- private JComboBox jcbSimNames = new StyledComboBox();
-
-
- private Comparator comp = new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- return o1.toLowerCase().compareTo(o2.toLowerCase());
- }
- };
- private TreeSet useridSet = new TreeSet(comp);
- private Hashtable> mapUseridToModelNameTime = new Hashtable>();
- private Hashtable mapModelNameTimeToActualModelname = new Hashtable();
- private Hashtable> mapModelToApps = new Hashtable>();
- private Hashtable> mapAppsToSims = new Hashtable>();
-
-
-
- public MyPreProcessor() {
-// jcbModelType.addActionListener(new ActionListener() {
-// @Override
-// public void actionPerformed(ActionEvent e) {
-// try {
-// searchVCell();
-// } catch (Exception e1) {
-//// // TODO Auto-generated catch block
-//// e1.printStackTrace();
-// }
-// }});
-// jcbModelType.setSelectedIndex(0);
-
- }
-
- private String createMapAppToSimsKeyName(String modelName,String appName) {
- //return jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem();
- return modelName+" "+(appName==null?modelName:appName);
- }
- private void searchVCell() throws Exception{
- final UIService service = getContext().getService(UIService.class);
- Object obj = service.getDefaultUI().getApplicationFrame();
- if(obj instanceof UIComponent && ((UIComponent)obj).getComponent() instanceof Frame) {
- mainApplicationFrame = (Frame)((UIComponent)obj).getComponent();
- }else if(obj instanceof Frame) {
- mainApplicationFrame = (Frame)obj;
- }
- //System.out.println(service.getDefaultUI().getApplicationFrame().getClass().getName()+" "+(service.getDefaultUI().getApplicationFrame() instanceof Frame));
-
- displayProgressBar(true, "Searching Database...", "VCell Model Loader", 25,uiService);
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),null,null,null,null,null,null);
- displayProgressBar(true, "Creating GUI...", "VCell Model Loader", 100,uiService);
- try {
- final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- useridSet = new TreeSet(comp);
- mapUseridToModelNameTime = new Hashtable>();
- mapModelNameTimeToActualModelname = new Hashtable();
- mapModelToApps = new Hashtable>();
- mapAppsToSims = new Hashtable>();
-
- final Iterator iterator = vcmsr.iterator();
- while(iterator.hasNext()) {
- final VCellModelSearchResults next = iterator.next();
- String userid = next.getUserId();
- useridSet.add(userid);
- final String modelName = next.getModelName();
- final String modelNameTime = modelName+" ("+next.getModelType().name()+")"+" - "+(next.getDate()==null?"unsaved":dateTimeInstance.format(new Date(next.getDate())));
- TreeSet modelsForUserid = mapUseridToModelNameTime.get(userid);
- if(modelsForUserid == null) {
- modelsForUserid = new TreeSet();
- mapUseridToModelNameTime.put(userid, modelsForUserid);
- }
- modelsForUserid.add(modelNameTime);
- mapModelNameTimeToActualModelname.put(modelNameTime, modelName);
- //System.out.println(modelName+" "+next.getApplicationName()+" "+next.getSimulationName());
- TreeSet appsForModel = mapModelToApps.get(modelNameTime);
- if(appsForModel == null) {
- appsForModel = new TreeSet();
- mapModelToApps.put(modelNameTime, appsForModel);
- }
- appsForModel.add((next.getModelType()==ModelType.mm?modelNameTime:next.getApplicationName()));
- String modelNameTimeApp = createMapAppToSimsKeyName(modelNameTime,(next.getModelType()==ModelType.mm?null:next.getApplicationName()));//modelNameTime+(next.getModelType()==ModelType.mm?"":" "+next.getApplicationName());
- TreeSet simsForApp = mapAppsToSims.get(modelNameTimeApp);
- if(simsForApp == null) {
- simsForApp = new TreeSet();
- mapAppsToSims.put(modelNameTimeApp, simsForApp);
- }
- simsForApp.add(next.getSimulationName());
- }
-// DefaultComboBoxModel a= null;
-// ((DefaultComboBoxModel)jcbUserid.getModel()).
- } catch (Exception e) {
- throw e;
-// //e.printStackTrace();
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
- }finally {
- displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
- }
-
- }
- @Override
- public void process(Module module) {
- final ModuleItem vcellModelsInput = getvcellModelsInput(module);
- if (vcellModelsInput == null) {
- return;
- }
-// try {
-// searchVCell();
-// } catch (Exception e) {
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
-// }
-
-// displayProgressBar(true, "Searching Database...", "VCell Model Loader", 25,uiService);
-// VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),null,null,null,null,null,null);
-// displayProgressBar(true, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// try {
-// final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
-// ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
-// final Iterator iterator = vcmsr.iterator();
-// while(iterator.hasNext()) {
-// final VCellModelSearchResults next = iterator.next();
-// String userid = next.getUserId();
-// useridSet.add(userid);
-// final String modelName = next.getModelName();
-// final String modelNameTime = modelName+" ("+next.getModelType().name()+")"+" - "+(next.getDate()==null?"unsaved":dateTimeInstance.format(new Date(next.getDate())));
-// TreeSet modelsForUserid = mapUseridToModelNameTime.get(userid);
-// if(modelsForUserid == null) {
-// modelsForUserid = new TreeSet();
-// mapUseridToModelNameTime.put(userid, modelsForUserid);
-// }
-// modelsForUserid.add(modelNameTime);
-// mapModelNameTimeToActualModelname.put(modelNameTime, modelName);
-// //System.out.println(modelName+" "+next.getApplicationName()+" "+next.getSimulationName());
-// TreeSet appsForModel = mapModelToApps.get(modelNameTime);
-// if(appsForModel == null) {
-// appsForModel = new TreeSet();
-// mapModelToApps.put(modelNameTime, appsForModel);
-// }
-// appsForModel.add(next.getApplicationName());
-// String modelNameTimeApp = modelNameTime+" "+next.getApplicationName();
-// TreeSet simsForApp = mapAppsToSims.get(modelNameTimeApp);
-// if(simsForApp == null) {
-// simsForApp = new TreeSet();
-// mapAppsToSims.put(modelNameTimeApp, simsForApp);
-// }
-// simsForApp.add(next.getSimulationName());
-// }
-// } catch (Exception e) {
-// //e.printStackTrace();
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// vcellModelsInput.setValue(module, new VCellSelection(e));//return empty VCellSelection
-// module.resolveInput(vcellModelsInput.getName());
-// return;
-// }finally {
-// displayProgressBar(false, "Creating GUI...", "VCell Model Loader", 100,uiService);
-// }
-
- //ApplicationFrame applicationFrame = uiService.getDefaultUI().getApplicationFrame();
- final Dimension dim = new Dimension(300,120);
- @SuppressWarnings("serial")
- final JPanel jp = new JPanel() {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- };
- jp.setLayout(new GridLayout(8,2));
-
- JButton site = new JButton("VCell Website");
- site.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
-
- try {
-
- String myurl = "https://vcell.org/";
-
- java.awt.Desktop.getDesktop().browse(java.net.URI.create(myurl));
-
- } catch (Exception e2) {
- // TODO: handle exception
- e2.printStackTrace();
- }
- }
- });
-
- final boolean[] bUseVCellSelectionHolder = new boolean[] {false};
-
- //jcbModelType
- jp.add(new JLabel("Model Type"));
- jp.add(jcbModelType);
-
-
- jp.add(new JLabel("VCell Userid"));
- JComboBox jcbUserid = new StyledComboBox(useridSet.toArray(new String[0]));
- jcbModelType.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- searchVCell();
- } catch (Exception e1) {
- uiService.showDialog("Error in searchVCell()\n"+e1.getClass().getName()+"\n"+e1.getMessage());
- JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(jp);
- topFrame.dispose();
- return;
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(vcellModelsInput.getDefaultValue() != null && vcellModelsInput.getDefaultValue().modelType.name().equals(jcbModelType.getSelectedItem().toString())) {
- bUseVCellSelectionHolder[0] = true;
- }
- jcbUserid.removeAllItems();
- jcbUserid.setModel(new DefaultComboBoxModel(useridSet.toArray(new String[0])));
- if(jcbUserid.getItemCount()==0) {
- jcbUserid.addItem("Nothing Found");
- }else if(bUseVCellSelectionHolder[0]) {
- jcbUserid.setSelectedItem(vcellModelsInput.getDefaultValue().userid);
- }else {
- jcbUserid.setSelectedIndex(0);
- }
- bUseVCellSelectionHolder[0] = false;
- }});
- }}).start();
- }});
- jp.add(jcbUserid);
-
- jp.add(new JLabel("Model Name"));
- JComboBox jcbModelNames = new StyledComboBox(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0]));
- jcbUserid.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbModelNames.removeAllItems();
- if(jcbUserid.getSelectedItem() != null && mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()) != null) {
- jcbModelNames.setModel(new DefaultComboBoxModel(mapUseridToModelNameTime.get(jcbUserid.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- for(int i=0;i jcbAppNames = new StyledComboBox(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0]));
- jcbModelNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- jcbAppNames.removeAllItems();
- if(jcbModelNames.getSelectedItem() != null && mapModelToApps.get(jcbModelNames.getSelectedItem()) != null) {
- jcbAppNames.setModel(new DefaultComboBoxModel(mapModelToApps.get(jcbModelNames.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- jcbAppNames.setSelectedItem(vcellModelsInput.getDefaultValue().appName);
- }else {
- jcbAppNames.setSelectedIndex(0);
- }
- }
- }});
- jp.add(jcbAppNames);
-
- final JComboBox jcbVars = new StyledComboBox();
- jcbVars.setEnabled(false);
-
- final JComboBox jcbTimes = new StyledComboBox();
- jcbTimes.setEnabled(false);
-
- jp.add(new JLabel("Sim Name"));
- jcbAppNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
-// jcbVars.removeAllItems();
-// jcbTimes.removeAllItems();
- jcbSimNames.removeAllItems();
- if(jcbAppNames.getSelectedItem() != null && mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()) != null) {
- jcbSimNames.setModel(new DefaultComboBoxModel(mapAppsToSims.get(jcbModelNames.getSelectedItem()+" "+jcbAppNames.getSelectedItem()).toArray(new String[0])));
- if(bUseVCellSelectionHolder[0]) {
- jcbSimNames.setSelectedItem(vcellModelsInput.getDefaultValue().simname);
- }else {
- jcbSimNames.setSelectedIndex(0);
- }
- }
- }});
- jp.add(jcbSimNames);
-
-// if(vcellModelsInput.getDefaultValue() != null) {//If user provided an inital value for VCellSelection var in VCellPlugin
-// final VCellSelection defaultValue = vcellModelsInput.getDefaultValue();
-// jcbUserid.setSelectedItem(defaultValue.userid);
-// System.out.println(jcbUserid.getSelectedItem());
-// for(int i=0;i maxTimeJSlider1.getValue()){
- maxTimeJSlider1.setValue(minTimeJSlider1.getValue());
- return;
- }else if(ce.getSource()==maxTimeJSlider1 && maxTimeJSlider1.getValue() < minTimeJSlider1.getValue()){
- minTimeJSlider1.setValue(maxTimeJSlider1.getValue());
- return;
- }
- minTimeJLabel.setText(MINTIMESTR+ijVarInfosHolder[0].getTimes()[minTimeJSlider1.getValue()]);
- maxTimeJLabel.setText(MAXTIMESTR+ijVarInfosHolder[0].getTimes()[maxTimeJSlider1.getValue()]);
- }};
-
- minTimeJSlider1.setName("minTime");
- minTimeJSlider1.setPaintTicks(true);
- minTimeJSlider1.setMajorTickSpacing(10);
- minTimeJSlider1.setSnapToTicks(true);
- minTimeJSlider1.setMinorTickSpacing(1);
- minTimeJSlider1.setMaximum(ijVarInfosHolder[0].getTimes().length - 1);
- minTimeJSlider1.setValue(0);
- minTimeJSlider1.addChangeListener(changeListener);
-
- maxTimeJSlider1.setName("maxTime");
- maxTimeJSlider1.setPaintTicks(true);
- maxTimeJSlider1.setMajorTickSpacing(10);
- maxTimeJSlider1.setSnapToTicks(true);
- maxTimeJSlider1.setMinorTickSpacing(1);
- maxTimeJSlider1.setMaximum(ijVarInfosHolder[0].getTimes().length - 1);
- maxTimeJSlider1.setValue(ijVarInfosHolder[0].getTimes().length - 1);
- maxTimeJSlider1.addChangeListener(changeListener);
-
-// Object[][] dataVars = new Object[jcbVars.getModel().getSize()][1];
-// for(int i=0;i compList = new ArrayList();
- compList.add(SwingUtilities.getAncestorOfClass(Window.class, selectMultipleVarsAndTimesBtn));
- while(compList.size() > 0) {
- Container container = compList.remove(0);
- for(int i=0;i vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
-// if(vcmsr.size() == 0) {
-// throw new Exception("No Results for search found");
-// }
-// theCacheKey = vcmsr.get(0).getCacheKey();
-// System.out.println("theCacheKey="+theCacheKey);
-//
-// jcbTimes.setEnabled(true);
-// IJVarInfos ijVarInfos = vcellHelper.getVarInfos(theCacheKey);
-// for(int i=0;i inputs = module.getInputs();
-// for(String key:inputs.keySet()) {
-// System.out.println(" "+key+" "+inputs.get(key));
-// }
- }
-
- private void populateVarAndTimes(final String[] cacheKeyHolder,IJVarInfos[] ijVarInfosHolder
- /*
- * final VCellSelection vcellSelection, final JComboBox jcbVars,
- * final JComboBox jcbTimes, final String[] cacheKeyHolder, final
- * IJVarInfos[] ijVarInfosHolder
- */){
- displayProgressBar(true, "Getting Vars and Times...", "VCell Model Loader", 25,uiService);
- String userid = jcbUserid.getSelectedItem().toString();
- String modelName = (jcbModelNames.getSelectedItem()==null?null:mapModelNameTimeToActualModelname.get(jcbModelNames.getSelectedItem()).toString());
- String appName = (jcbModelNames.getSelectedItem()==null?null:jcbAppNames.getSelectedItem().toString());
- String simName = (jcbModelNames.getSelectedItem()==null?null:jcbSimNames.getSelectedItem().toString());
- VCellHelper.VCellModelSearch vcms = new VCellHelper.VCellModelSearch(ModelType.valueOf(jcbModelType.getSelectedItem().toString()),userid,modelName,appName,simName,null,null);
- try {
-// jcbVars.removeAllItems();
-// jcbTimes.removeAllItems();
- ArrayList vcmsr = vcellHelper.getSearchedModelSimCacheKey(false,vcms,null);
- if(vcmsr.size() == 0) {
- throw new Exception("No Results for search found");
- }
- cacheKeyHolder[0] = vcmsr.get(0).getCacheKey();
- System.out.println("theCacheKey="+cacheKeyHolder[0]);
- ijVarInfosHolder[0] = vcellHelper.getVarInfos(cacheKeyHolder[0]);
-
- ijVarInfosHolder[0].getIjVarInfo().sort(new Comparator() {
- @Override
- public int compare(IJVarInfo o1, IJVarInfo o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }});
-
-// SwingUtilities.invokeAndWait(new Runnable() {
-// @Override
-// public void run() {
-// try {
-// displayProgressBar(true, "Getting Var Times GUI...", "VCell Model Loader", 100,uiService);
-// jcbVars.setEnabled(true);
-// ijVarInfosHolder[0] = vcellHelper.getVarInfos(cacheKeyHolder[0]);
-// for(int i=0;i getvcellModelsInput(final Module module) {
- ModuleItem result = null;
- for (final ModuleItem> input : module.getInfo().inputs()) {
- if (module.isInputResolved(input.getName())) continue;
- final Class> type = input.getType();
- if (!VCellSelection.class.isAssignableFrom(type)) {
- // not a VCellSelection parameter; abort
- return null;
- }
- if (result != null) {
- // second VCellSelection parameter; abort
- return null;
- }
- @SuppressWarnings("unchecked")
- final ModuleItem vcellSelect = (ModuleItem) input;
- result = vcellSelect;
- }
- return result;
- }
-
- private JPanel getLabeledJComboBox(String labelName,String[] items) {
- JPanel jp = new JPanel(new FlowLayout());
- jp.add(new JLabel(labelName));
- JComboBox jcbModelNames = new JComboBox(items);
- jp.add(jcbModelNames);
- return jp;
- }
-
- }
-
- @Parameter
- private UIService uiService;
-
- @Parameter
- private DisplayService displayService;
-
- @Parameter
- EventService eventService;
-
- @Parameter
- ZoomService zoomService;
-
- @Parameter
- private VCellHelper vcellHelper;
-
- @Parameter
- private VCellSelection vcellSelection = new VCellSelection("-1",ModelType.bm, "tutorial","Tutorial_MultiApp", "3D pde", "Simulation4",new String[] {"C_cyt"},new int[] {50});
- //private VCellSelection vcellSelection;
-
-
- /**
- * This main function serves for development purposes.
- * It allows you to run the plugin immediately out of
- * your integrated development environment (IDE).
- *
- * @param args whatever, it's ignored
- * @throws Exception
- */
- public static void main(final String... args) throws Exception {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.ui().showUI();
- }
-
- private static JDialog progressDialog = null;
- private static final Dimension dim = new Dimension(200,30);
- @SuppressWarnings("serial")
- private static final JProgressBar jProgressBar = new JProgressBar(0,100) {
- @Override
- public Dimension getPreferredSize() {
- return dim;
- }
- @Override
- public Dimension getSize(Dimension rv) {
- return dim;
- }
- };
-
- private static void displayProgressBar(boolean bShow,String message,String title,int progress,UIService uiService) {
- if(progressDialog == null) {
- //Frame applicationFrame = VCellPlugin.mainApplicationFrame;//IJ.getInstance();//(Frame)uiService.getDefaultUI().getApplicationFrame();
- progressDialog = new JDialog(VCellPlugin_Minimal.mainApplicationFrame,"Checking for VCell Client",false);
- progressDialog.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- super.windowClosing(e);
- progressDialog.dispose();
- progressDialog = null;
- }});
- progressDialog.getContentPane().add(jProgressBar);
- jProgressBar.setStringPainted(true);
- jProgressBar.setString("setting up...");
- progressDialog.pack();
-
- }
-
- if(SwingUtilities.isEventDispatchThread()) {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
-
- }else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if(progressDialog ==null) {
- return;
- }
- if(!bShow) {
- progressDialog.dispose();
- progressDialog = null;
- return;
- }
- progressDialog.setVisible(true);
- jProgressBar.setValue(progress);
- progressDialog.setTitle(title);
- jProgressBar.setString(message);
- jProgressBar.invalidate();
- progressDialog.revalidate();
- }
- });
- }
- }
-
-// private Hashtable threadHash = new Hashtable();
-// private void startJProgressThread0(String lastName,String newName) {
-// if(lastName != null && threadHash.get(lastName) != null) {
-// threadHash.get(lastName).interrupt();
-// while(threadHash.get(lastName) != null) {
-// try {
-// Thread.sleep(50);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// break;
-// }
-// }
-// }
-// if(newName == null) {
-// return;
-// }
-// final Thread progressThread = new Thread(new Runnable(){
-// @Override
-// public void run() {
-// final int[] progress = new int[] {1};
-// while(progressDialog.isVisible()) {
-// if(Thread.currentThread().isInterrupted()) {
-// break;
-// }
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// jProgressBar.setValue(progress[0]);
-// }});
-// progress[0]++;
-// try {
-// Thread.sleep(500);
-// } catch (InterruptedException e) {
-// break;
-// }
-// }
-// threadHash.remove(Thread.currentThread().getName());
-// }});
-// threadHash.put(newName, progressThread);
-// progressThread.setName(newName);
-// progressThread.setDaemon(true);//So not block JVM exit
-// progressThread.start();
-// }
-
-// public void showAndZoom(String displayName,Object thingToDisplay,double zoomFactor) throws Exception{
-// final ImageDisplayService ids = getContext().getService(ImageDisplayService.class);
-// final DisplayService ds = getContext().getService(DisplayService.class);
-// new Thread(new Runnable() {
-//
-// @Override
-// public void run() {
-// // TODO Auto-generated method stub
-// uiService.show(displayName,thingToDisplay);
-// //Find display and set zoom, resize window
-// List knownImageDisplays = ids.getImageDisplays();
-// boolean bvisible = false;
-// while (!bvisible) {
-// for (ImageDisplay imageDisplay : knownImageDisplays) {
-// if (imageDisplay.getName().equals(displayName)) {
-// if (imageDisplay.isVisible(imageDisplay.getActiveView())) {
-// bvisible = true;
-// break;
-// }
-// }
-// }
-// try {
-// Thread.sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
-// }
-//// int vw = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportWidth();
-//// int vh = ij.imageDisplay().getActiveImageDisplay().getCanvas().getViewportHeight();
-//// System.out.println(" -----byname="+ij.display().getDisplay(displayName));
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// try {
-// ids.getActiveImageDisplay().getCanvas().setZoom(zoomFactor);
-// if(ds.getDisplay(displayName) != null && uiService.getDisplayViewer(ds.getDisplay(displayName)) instanceof JFrame) {
-// double vw = ids.getActiveImageDisplay().dimension(ids.getActiveImageDisplay().dimensionIndex(Axes.X))*zoomFactor;
-// double vh = ids.getActiveImageDisplay().dimension(ids.getActiveImageDisplay().dimensionIndex(Axes.Y))*zoomFactor;
-// ((JFrame)uiService.getDisplayViewer(ds.getDisplay(displayName)).getWindow()).setSize(new Dimension((int)vw+50, (int)vh+150));
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-// });
-//
-//// ij.ui().getDisplayViewer(ij.display().getDisplay(displayName)).getPanel().redoLayout();
-//// List> displays = ij.display().getDisplays();
-//// for (Display> display : displays) {
-//// System.out.println(display+" -----byname="+ij.display().getDisplay(displayName));
-//// }
-//
-// }
-// }).start();
-//
-// }
-
- @Override
- public void run() {
- try {
- if(vcellSelection != null && vcellSelection.exception != null) {
- if(!vcellSelection.exception.getMessage().equals(MyPreProcessor.CANCELLED)) {
- uiService.showDialog("Model search failed\n"+vcellSelection.exception.getClass().getName()+"\n"+vcellSelection.exception.getMessage(), MessageType.ERROR_MESSAGE);
- }
- return;
- }
- if(vcellSelection == null || vcellSelection.theCacheKey==null) {
- return;
- }
- //Create ImageJ datasets and display separate hyperstack for each variable
- for(int varIndex=0;varIndex testimg = ArrayImgs.doubles( data, bsd.xsize,bsd.ysize,bsd.zsize,tpd.ijData.length);
- for(int i=0;i imgPlus = new ImgPlus(testimg);
- imgPlus.setChannelMinimum(0, min);
- imgPlus.setChannelMaximum(0, max);
- imgPlus.setAxis(new DefaultLinearAxis(Axes.Z), 2);
- imgPlus.setAxis(new DefaultLinearAxis(Axes.TIME), 3);
-
- uiService.show(vcellSelection.varName[varIndex],imgPlus);
- DefaultImageDisplay createDisplayQuietly = (DefaultImageDisplay)displayService/* getContext().getService(DisplayService.class) */.getDisplay(vcellSelection.varName[varIndex]);
- while(displayService.getActiveDisplay() == null) {
- Thread.sleep(100);
- }
- WindowManager.getActiveWindow().setSize(400, 400);
- IJ.run("Scale to Fit", "");
- WindowManager.getActiveWindow().setSize(400, 400);//refresh the sliders
-
- //final ZoomService zoomService = getContext().getService(ZoomService.class);
-// zoomService.zoomSet(createDisplayQuietly, 300, 0, 0);
-// eventService.publish(new PanZoomEvent(createDisplayQuietly.getCanvas()));
-
-// IJ.run("Set... ", "zoom=300 x="+(bsd.xsize/2)+" y="+(bsd.ysize/2));
-// IJ.run("Set... ", "zoom=300");
-// IJ.run("In");
-// IJ.run("In");
-// IJ.run("In");
-
-// RunService runService = getContext().getService(RunService.class);
-// runService.run("In", (Map)null);
-// final Iterator> iterator = opService.getPlugins().iterator();
-// while(iterator.hasNext()) {
-// System.out.println(iterator.next());
-// }
-// opService.run("In", "");
-// final ZoomService zoomService = getContext().getService(ZoomService.class);
-// zoomService.zoomSet(createDisplayQuietly, 300, 0, 0);
-// createDisplayQuietly.update();
-
- //final Display> createDisplayQuietly = getContext().getService(DisplayService.class).createDisplayQuietly(testimg);
- final DefaultDatasetView defaultDatasetView = (DefaultDatasetView)((DefaultImageDisplay)createDisplayQuietly).getActiveView();
-// defaultDatasetView.getData().setAxis(createDisplayQuietly.axis(2), 2);
-// defaultDatasetView.getData().setAxis(createDisplayQuietly.axis(3), 3);
-// defaultDatasetView.update();
- System.out.println(min+" "+max);
-// displayService.setActiveDisplay(createDisplayQuietly);
-// IJ.setMinAndMax(min, max);
-// defaultDatasetView.getData().setChannelMinimum(0, min);
-// defaultDatasetView.getData().setChannelMaximum(0, max);
-
-// defaultDatasetView.setChannelRanges(min,max);
-
- //IJ.getImage().updateAndDraw();
-// while(displayService.getActiveDisplay() == null) {
-// Thread.sleep(100);
-// }
-// IJ.setMinAndMax(min, max);
- //WindowManager.getCurrentImage().setDisplayRange(min, max)
-
- //WindowManager.getCurrentImage().setDisplayRange(min,max);
- //ImageStack.create(varIndex, varIndex, varIndex, varIndex)
- //ImagePlus ip = new ImagePlus();
-
- //uiService.showUI();
-// EventService es = null;
- //getContext().getService(EventService.class).publish(new DisplayUpdatedEvent(createDisplayQuietly,DisplayUpdatedEvent.DisplayUpdateLevel.UPDATE));
- //uiService.get
-// uiService.show(createDisplayQuietly);
-// getContext().getService(DisplayService.class).
-// showAndZoom(vcellSelection.varName[varIndex],createDisplayQuietly, 3);
- }
- } catch (Exception e) {
- displayProgressBar(false, "Error", "VCell Model Loader", 100,uiService);
- uiService.showDialog("theCacheKey,var,VCellHelper.VARTYPE_POSTPROC.NotPostProcess,time,0\n"+e.getMessage(), "getTimePoint(...) failed", MessageType.ERROR_MESSAGE);
- }finally {
- displayProgressBar(false, "displaying Image...", "VCell Model Loader", 100,uiService);
- }
- }
-}
-
-//final long timePointSize = tpd.ijData[0].stackInfo.getTotalSize();
-//final long totalSize = tpd.ijData.length*timePointSize;
-//class MyAI extends AbstractImg {
-//
-// class MyCursor extends AbstractCursor {
-//
-// private long position = 0;
-//
-// RandomAccess myRandomAccess = new RandomAccess() {
-//
-// @Override
-// public long getLongPosition(int d) {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public int numDimensions() {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public void fwd(int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void bck(int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(int distance, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(long distance, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(Localizable distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(int[] distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void move(long[] distance) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(Localizable position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(int[] position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(long[] position) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(int position, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public void setPosition(long position, int d) {
-// // TODO Auto-generated method stub
-//
-// }
-//
-// @Override
-// public DoubleType get() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Sampler copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public RandomAccess copyRandomAccess() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// };
-// final DoubleType myDoubleType = new DoubleType() {
-//
-// @Override
-// public double get() {
-// // TODO Auto-generated method stub
-// return tpd.ijData[(int) (position/timePointSize)].getDoubleData()[(int) (position%timePointSize)];
-// }
-//
-// };
-//
-// public MyCursor(int n) {
-// super(n);
-// // TODO Auto-generated constructor stub
-// }
-//
-// @Override
-// public DoubleType get() {
-// // TODO Auto-generated method stub
-// return myDoubleType;
-// }
-//
-// @Override
-// public void fwd() {
-// // TODO Auto-generated method stub
-// position++;
-// }
-//
-// @Override
-// public void reset() {
-// // TODO Auto-generated method stub
-// position = 0;
-// }
-//
-// @Override
-// public boolean hasNext() {
-// // TODO Auto-generated method stub
-// return position < (totalSize-1);
-// }
-//
-// @Override
-// public long getLongPosition(int d) {
-// // TODO Auto-generated method stub
-// return 0;
-// }
-//
-// @Override
-// public AbstractCursor copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public AbstractCursor copyCursor() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// };
-//
-// Cursor myCursor;
-// public MyAI(long[] size) {
-// super(size);
-// myCursor = new MyCursor(size.length);
-// }
-//
-// @Override
-// public ImgFactory factory() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Img copy() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public RandomAccess randomAccess() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Cursor cursor() {
-// // TODO Auto-generated method stub
-// return myCursor;
-// }
-//
-// @Override
-// public Cursor localizingCursor() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public Object iterationOrder() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-//};
-//
-//uiService.show(new MyAI(new long[] {tpd.ijData[0].stackInfo.xsize,tpd.ijData[0].stackInfo.ysize,tpd.ijData[0].stackInfo.zsize,tpd.ijData.length}));
diff --git a/vcell-imagej-helper/test_remove.groovy b/vcell-imagej-helper/test_remove.groovy
deleted file mode 100644
index 2fc9963c3c..0000000000
--- a/vcell-imagej-helper/test_remove.groovy
+++ /dev/null
@@ -1,17 +0,0 @@
-#@VCellHelper vh
-
-import net.imglib2.img.array.ArrayImgs;
-import net.imglib2.img.display.imagej.ImageJFunctions;
-
-cachekey=1
-lastVCellApiPort = vh.findVCellApiServerPort()
- doc = vh.getDocument(new URL("http://localhost:"+lastVCellApiPort+"/"+"getdata"+"?"+"cachekey"+"="+cachekey+"&"+"varname"+"="+"C_cyt"+"&"+"timepoint"+"=0.5"));//get data
- basicStackDimensions = vh.getVCStackDims(doc);
- double[] data = vh.getData(doc);
- System.out.println(basicStackDimensions.getTotalSize());
- System.out.println(data.length);
-
- dims = new long[basicStackDimensions.numDimensions()];
- basicStackDimensions.dimensions(dims);
- img = ArrayImgs.doubles(data, dims);
- ImageJFunctions.show( img );
diff --git a/vcell-imagej/.idea/.name b/vcell-imagej/.idea/.name
deleted file mode 100644
index 9d287aa646..0000000000
--- a/vcell-imagej/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-GaussFiltering
\ No newline at end of file
diff --git a/vcell-imagej/.idea/compiler.xml b/vcell-imagej/.idea/compiler.xml
deleted file mode 100644
index 6097754212..0000000000
--- a/vcell-imagej/.idea/compiler.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-