Search in sources :

Example 16 with Origin

use of org.vcell.util.Origin in project vcell by virtualcell.

the class RunRefSimulationFastOp method saveROIsAsExternalData.

private void saveROIsAsExternalData(ROI[] rois, LocalWorkspace localWorkspace, ExternalDataIdentifier newROIExtDataID) throws ObjectNotFoundException, ImageException, IOException {
    ISize isize = rois[0].getISize();
    Origin origin = rois[0].getRoiImages()[0].getOrigin();
    Extent extent = rois[0].getRoiImages()[0].getExtent();
    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 cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
    int NumTimePoints = 1;
    int NumChannels = rois.length;
    // dimensions: time points, channels, whole image ordered by z slices.
    double[][][] pixData = new double[NumTimePoints][NumChannels][];
    int index = 0;
    for (ROI roi : rois) {
        pixData[0][index++] = createDoubleArray(roi.getBinaryPixelsXYZ(1));
    }
    // Origin origin = new Origin(0,0,0);
    FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
    fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
    fdos.cartesianMesh = cartesianMesh;
    fdos.doubleSpecData = pixData;
    fdos.specEDI = newROIExtDataID;
    ArrayList<String> varNames = new ArrayList<String>();
    ArrayList<VariableType> varTypes = new ArrayList<VariableType>();
    for (ROI roi : rois) {
        varNames.add(ROI_MASK_NAME_PREFIX + roi.getROIName());
        varTypes.add(VariableType.VOLUME);
    }
    fdos.varNames = varNames.toArray(new String[0]);
    fdos.owner = LocalWorkspace.getDefaultOwner();
    fdos.times = new double[] { 0.0 };
    fdos.variableTypes = varTypes.toArray(new VariableType[0]);
    fdos.origin = origin;
    fdos.extent = extent;
    fdos.isize = isize;
    localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
Also used : Origin(org.vcell.util.Origin) VariableType(cbit.vcell.math.VariableType) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) ArrayList(java.util.ArrayList) VCImage(cbit.image.VCImage) VCImageUncompressed(cbit.image.VCImageUncompressed) ROI(cbit.vcell.VirtualMicroscopy.ROI) CartesianMesh(cbit.vcell.solvers.CartesianMesh) RegionImage(cbit.vcell.geometry.RegionImage)

Example 17 with Origin

use of org.vcell.util.Origin in project vcell by virtualcell.

the class RunRefSimulationFastOp method savePsfAsExternalData.

private void savePsfAsExternalData(UShortImage psf, String varName, ExternalDataIdentifier newPsfExtDataID, LocalWorkspace localWorkspace) throws IOException, ImageException, ObjectNotFoundException {
    Origin origin = new Origin(0, 0, 0);
    Extent ext = new Extent(1, 1, 1);
    ISize isize = new ISize(3, 3, 1);
    VCImageUncompressed vcImage = new VCImageUncompressed(null, new byte[isize.getXYZ()], ext, isize.getX(), isize.getY(), isize.getZ());
    RegionImage regionImage = new RegionImage(vcImage, 0, null, null, RegionImage.NO_SMOOTHING);
    CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, ext, isize, regionImage);
    int NumTimePoints = 1;
    // 8 rois integrated into 1 image
    int NumChannels = 1;
    short[][][] pixData = new short[NumTimePoints][NumChannels][1];
    pixData[0][0] = psf.getPixels();
    FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
    fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
    fdos.cartesianMesh = cartesianMesh;
    fdos.shortSpecData = pixData;
    fdos.specEDI = newPsfExtDataID;
    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 = ext;
    fdos.isize = isize;
    localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
Also used : Origin(org.vcell.util.Origin) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) RegionImage(cbit.vcell.geometry.RegionImage) VCImageUncompressed(cbit.image.VCImageUncompressed)

Example 18 with Origin

use of org.vcell.util.Origin in project vcell by virtualcell.

the class RunSimulation2DOp method runRefSimulation.

public ImageTimeSeries<FloatImage> runRefSimulation(LocalWorkspace localWorkspace, Simulation simulation, String varName, ClientTaskStatusSupport progressListener) throws Exception {
    User owner = LocalWorkspace.getDefaultOwner();
    KeyValue simKey = LocalWorkspace.createNewKeyValue();
    runFVSolverStandalone(new File(localWorkspace.getDefaultSimDataDirectory()), simulation, progressListener);
    Extent extent = simulation.getMathDescription().getGeometry().getExtent();
    Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
    VCDataIdentifier vcDataIdentifier = new VCSimulationDataIdentifier(new VCSimulationIdentifier(simKey, owner), 0);
    CartesianMesh mesh = localWorkspace.getDataSetControllerImpl().getMesh(vcDataIdentifier);
    ISize isize = new ISize(mesh.getSizeX(), mesh.getSizeY(), mesh.getSizeZ());
    double[] dataTimes = localWorkspace.getDataSetControllerImpl().getDataSetTimes(vcDataIdentifier);
    FloatImage[] solutionImages = new FloatImage[dataTimes.length];
    for (int i = 0; i < dataTimes.length; i++) {
        SimDataBlock simDataBlock = localWorkspace.getDataSetControllerImpl().getSimDataBlock(null, vcDataIdentifier, varName, dataTimes[i]);
        double[] doubleData = simDataBlock.getData();
        float[] floatPixels = new float[doubleData.length];
        for (int j = 0; j < doubleData.length; j++) {
            floatPixels[j] = (float) doubleData[j];
        }
        solutionImages[i] = new FloatImage(floatPixels, origin, extent, isize.getX(), isize.getY(), isize.getZ());
    }
    ImageTimeSeries<FloatImage> solution = new ImageTimeSeries<FloatImage>(FloatImage.class, solutionImages, dataTimes, 1);
    return solution;
}
Also used : Origin(org.vcell.util.Origin) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) CartesianMesh(cbit.vcell.solvers.CartesianMesh) SimDataBlock(cbit.vcell.simdata.SimDataBlock) File(java.io.File) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 19 with Origin

use of org.vcell.util.Origin in project vcell by virtualcell.

the class FluorescenceNoiseTest method testBrownianDynamics.

private void testBrownianDynamics() throws ImageException {
    Origin origin = new Origin(0, 0, 0);
    Extent extent = new Extent(10, 10, 1);
    double psfVar = 0.25 * 0.25;
    // typically 10000 or 100000;
    int numParticles = 10000;
    double diffusionRate = 1;
    double bleachRadius = 0.25;
    final double bleachAmplitude = 0.5;
    final double bleachRadius2 = bleachRadius * bleachRadius;
    double endTime = 10;
    int numTimes = 1000;
    final BrownianDynamics2DSolver solver = new BrownianDynamics2DSolver(origin, extent, numParticles);
    boolean initiallyFluorescent = true;
    solver.initializeUniform(initiallyFluorescent);
    double totalBleachTime = 0.00001;
    int numBleachSteps = 1;
    double bleachCenterX = origin.getX() + 0.5 * extent.getX();
    double bleachCenterY = origin.getY() + 0.5 * extent.getY();
    double bleachPsfVariance = psfVar;
    double bleachFactor_K = 1000000;
    solver.bleachGuassian(diffusionRate, totalBleachTime, numBleachSteps, bleachCenterX, bleachCenterY, bleachPsfVariance, bleachFactor_K);
    // ParticleVisitor bleachGaussian = new ParticleVisitor() {
    // UniformRealDistribution uniform = new UniformRealDistribution();
    // 
    // @Override
    // public void visit(double x, double y, boolean bFluorescent, int index) {
    // // TODO Auto-generated method stub
    // double radius2 = x*x + y*y;
    // double bleachProb = bleachAmplitude * FastMath.exp(-radius2/bleachRadius2);
    // if (uniform.sample() < bleachProb){
    // solver.setFluorescence(index,false);
    // }else{
    // solver.setFluorescence(index,true);
    // }
    // }
    // };
    // solver.visit(bleachGaussian);
    double totalSampleTime = 0.1;
    int numSampleSteps = 1;
    double samplePsfVariance = psfVar;
    double detectorGainAndQuantumYeild = 100;
    boolean bNoise = true;
    boolean bConvolve = true;
    UShortImage sampledImage = solver.sampleImage(100, 100, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, samplePsfVariance, detectorGainAndQuantumYeild, bConvolve, bNoise);
    new DisplayImageOp().displayImage(sampledImage, "initialBleach", null);
}
Also used : Origin(org.vcell.util.Origin) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) Extent(org.vcell.util.Extent) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BrownianDynamics2DSolver(org.vcell.vmicro.op.BrownianDynamics2DSolver)

Example 20 with Origin

use of org.vcell.util.Origin in project vcell by virtualcell.

the class RunRefSimulationOp method saveExternalData.

private static 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);
}
Also used : Origin(org.vcell.util.Origin) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) RegionImage(cbit.vcell.geometry.RegionImage) VCImage(cbit.image.VCImage) VCImageUncompressed(cbit.image.VCImageUncompressed)

Aggregations

Origin (org.vcell.util.Origin)64 Extent (org.vcell.util.Extent)58 ISize (org.vcell.util.ISize)45 CartesianMesh (cbit.vcell.solvers.CartesianMesh)18 VCImageUncompressed (cbit.image.VCImageUncompressed)17 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)17 ImageException (cbit.image.ImageException)14 RegionImage (cbit.vcell.geometry.RegionImage)14 VCImage (cbit.image.VCImage)13 ArrayList (java.util.ArrayList)13 Expression (cbit.vcell.parser.Expression)12 IOException (java.io.IOException)12 SubVolume (cbit.vcell.geometry.SubVolume)11 File (java.io.File)11 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)10 Geometry (cbit.vcell.geometry.Geometry)9 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)8 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)7 BioModel (cbit.vcell.biomodel.BioModel)7 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)7