use of org.vcell.util.Origin in project vcell by virtualcell.
the class RunRefSimulationFastOp method saveExternalData.
private void saveExternalData(Image image, String varName, ExternalDataIdentifier newROIExtDataID, LocalWorkspace localWorkspace) throws ObjectNotFoundException, ImageException, IOException {
Extent extent = image.getExtent();
Origin origin = image.getOrigin();
ISize isize = image.getISize();
VCImage vcImage = new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ());
RegionImage regionImage = new RegionImage(vcImage, 0, null, null, RegionImage.NO_SMOOTHING);
CartesianMesh simpleCartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
int NumTimePoints = 1;
int NumChannels = 1;
// dimensions: time points, channels, whole image ordered by z slices.
double[][][] pixData = new double[NumTimePoints][NumChannels][];
pixData[0][0] = image.getDoublePixels();
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = simpleCartesianMesh;
fdos.doubleSpecData = pixData;
fdos.specEDI = newROIExtDataID;
fdos.varNames = new String[] { varName };
fdos.owner = LocalWorkspace.getDefaultOwner();
fdos.times = new double[] { 0.0 };
fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
fdos.origin = origin;
fdos.extent = extent;
fdos.isize = isize;
localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
use of org.vcell.util.Origin in project vcell by virtualcell.
the class FluorescenceNoiseTest method testImageTimeSeries.
private void testImageTimeSeries(boolean bNoise, boolean bConvolve) throws ImageException, IOException {
Origin origin = new Origin(0, 0, 0);
Extent extent = new Extent(10, 10, 1);
int numX = 30;
int numY = 30;
// typically 10000 or 100000;
int numParticles = 40000;
double diffusionRate = 1;
double bleachRadius = 5 * 5;
double psfVar = 0.6 * 0.6;
ImageTimeSeries<UShortImage> rawTimeSeries = generateTestData(origin, extent, numX, numY, numParticles, diffusionRate, psfVar, bleachRadius, bNoise, bConvolve);
new DisplayTimeSeriesOp().displayImageTimeSeries(rawTimeSeries, "time series", null);
}
use of org.vcell.util.Origin in project vcell by virtualcell.
the class FluorescenceNoiseTest method doit.
private void doit() throws ImageException {
int[] sizes = new int[] { 1, 2, 4, 8, 16, 32, 64, 128, 256 };
for (int imageSize : sizes) {
ISize size = new ISize(imageSize, imageSize, 1);
Extent extent = new Extent(1, 1, 1);
Origin origin = new Origin(0, 0, 0);
// NormalizedSampleFunction sampleFunction = NormalizedSampleFunction.createUniform("uniformROI", origin, extent, size);
NormalizedSampleFunction sampleFunction = NormalizedSampleFunction.fromGaussian("testGaussian", origin, extent, size, 0.5, 0.2, 0.1);
SampleStatistics[] samples = new SampleStatistics[NUM_TRIALS];
for (int i = 0; i < NUM_TRIALS; i++) {
UShortImage rawImage = getUniformFluorescenceImage(size, extent, origin, MEAN_INTENSITY);
samples[i] = sampleFunction.sample(rawImage);
}
Mean mean = new Mean();
Variance var = new Variance();
double[] weightedMeans = getWeightedMeans(samples);
double[] weightedVariances = getWeightedVariances(samples);
double weightedMeansVariance = var.evaluate(weightedMeans);
double weightedMeansMean = mean.evaluate(weightedMeans);
double weightedVarVariance = var.evaluate(weightedVariances);
double weightedVarMean = mean.evaluate(weightedVariances);
double V1 = samples[0].sumOfWeights;
double V2 = samples[0].sumOfWeightsSquared;
System.out.println("image is " + imageSize + "x" + imageSize + ", V1=" + V1 + ", V2=" + V2 + ", numTrials=" + NUM_TRIALS + ", sample means (mu=" + weightedMeansMean + ",s=" + weightedMeansVariance + "), sample variances (mu=" + weightedVarMean + ",s=" + weightedVarVariance);
}
}
use of org.vcell.util.Origin in project vcell by virtualcell.
the class DisplayTimeSeries method displayImageTimeSeries.
public static void displayImageTimeSeries(final ImageTimeSeries<Image> imageTimeSeries, String title, WindowListener windowListener) throws ImageException, IOException {
ISize size = imageTimeSeries.getISize();
int dimension = (size.getZ() > 0) ? (3) : (2);
Extent extent = imageTimeSeries.getExtent();
Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
// don't care ... no surfaces
double filterCutoffFrequency = 0.5;
VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
final DataSetController dataSetController = new DataSetController() {
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
double timePoint = time;
double[] timePoints = getDataSetTimes(vcdataID);
int index = -1;
for (int i = 0; i < timePoints.length; i++) {
if (timePoint == timePoints[i]) {
index = i;
break;
}
}
double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
VariableType varType = VariableType.VOLUME;
return new SimDataBlock(pdeDataInfo, data, varType);
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return mesh;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return new AnnotatedFunction[0];
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return imageTimeSeries.getImageTimeStamps();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return new DataIdentifier[] { dataIdentifier };
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return dataSetController;
}
};
VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {
public User getOwner() {
return new User("nouser", null);
}
public KeyValue getDataKey() {
return null;
}
public String getID() {
return "mydata";
}
};
PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
PDEDataViewer pdeDataViewer = new PDEDataViewer();
JFrame jframe = new JFrame();
jframe.setTitle(title);
jframe.getContentPane().add(pdeDataViewer);
jframe.setSize(1000, 600);
jframe.setVisible(true);
if (windowListener != null) {
jframe.addWindowListener(windowListener);
}
pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
use of org.vcell.util.Origin in project vcell by virtualcell.
the class FitTimeSeries method main.
public static void main(String[] args) {
try {
int numX = 100;
int numY = 100;
double center_i = 52.44;
double center_j = 51.39;
double K = 30;
double high = 0.9;
double sigma2 = 4;
float[] pixels = new float[numX * numY];
Origin origin = new Origin(0, 0, 0);
Extent extent = new Extent(1, 1, 1);
FloatImage image = new FloatImage(pixels, origin, extent, numX, numY, 1);
int index = 0;
for (int j = 0; j < numY; j++) {
for (int i = 0; i < numX; i++) {
double radius = ((i - center_i) * (i - center_i) + (j - center_j) * (j - center_j));
pixels[index++] = (float) (high - FastMath.exp(-K * FastMath.exp(-radius / sigma2)));
}
}
double init_center_i = 50;
double init_center_j = 50;
double init_sigma2 = 2;
GaussianFitResults fitResults = fitToGaussian(init_center_i, init_center_j, init_sigma2, image);
System.out.println(fitResults);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations