Search in sources :

Example 1 with ConvolutionDataGeneratorKernel

use of cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel in project vcell by virtualcell.

the class XmlReader method getConvolutionDataGenerator.

private ConvolutionDataGenerator getConvolutionDataGenerator(Element element) {
    String name = unMangle(element.getAttributeValue(XMLTags.NameAttrTag));
    Expression volumeFunction = null;
    Element volumeFunctionElement = element.getChild(XMLTags.FunctionTag, vcNamespace);
    if (volumeFunctionElement == null) {
        volumeFunctionElement = element.getChild(XMLTags.VolumeFunctionTag, vcNamespace);
    }
    if (volumeFunctionElement != null) {
        String s = volumeFunctionElement.getText();
        volumeFunction = unMangleExpression(s);
    }
    Expression membraneFunction = null;
    Element membraneFunctionElement = element.getChild(XMLTags.MembraneFunctionTag, vcNamespace);
    if (membraneFunctionElement != null) {
        String s = membraneFunctionElement.getText();
        membraneFunction = unMangleExpression(s);
    }
    ConvolutionDataGeneratorKernel kernel = null;
    Element kernelElement = element.getChild(XMLTags.Kernel, vcNamespace);
    String kernelType = kernelElement.getAttributeValue(XMLTags.TypeAttrTag);
    if (kernelType.equals(XMLTags.KernelType_Gaussian)) {
        Element e0 = kernelElement.getChild(XMLTags.KernelGaussianSigmaXY, vcNamespace);
        String s = e0.getText();
        Expression sigmaXY = unMangleExpression(s);
        e0 = kernelElement.getChild(XMLTags.KernelGaussianSigmaZ, vcNamespace);
        s = e0.getText();
        Expression sigmaZ = unMangleExpression(s);
        kernel = new GaussianConvolutionDataGeneratorKernel(sigmaXY, sigmaZ);
    }
    ConvolutionDataGenerator cdg = new ConvolutionDataGenerator(name, kernel, volumeFunction, membraneFunction);
    return cdg;
}
Also used : Expression(cbit.vcell.parser.Expression) Element(org.jdom.Element) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) ConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel)

Example 2 with ConvolutionDataGeneratorKernel

use of cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel in project vcell by virtualcell.

the class Xmlproducer method getXML.

private Element getXML(ConvolutionDataGenerator convolutionDataGenerator) {
    Element element = new Element(XMLTags.ConvolutionDataGenerator);
    element.setAttribute(XMLTags.NameAttrTag, mangle(convolutionDataGenerator.getName()));
    Element kernelElement = new Element(XMLTags.Kernel);
    ConvolutionDataGeneratorKernel kernel = convolutionDataGenerator.getKernel();
    if (kernel instanceof GaussianConvolutionDataGeneratorKernel) {
        kernelElement.setAttribute(XMLTags.TypeAttrTag, XMLTags.KernelType_Gaussian);
        GaussianConvolutionDataGeneratorKernel gck = (GaussianConvolutionDataGeneratorKernel) kernel;
        Element e = new Element(XMLTags.KernelGaussianSigmaXY);
        e.addContent(mangleExpression(gck.getSigmaXY_um()));
        kernelElement.addContent(e);
        e = new Element(XMLTags.KernelGaussianSigmaZ);
        e.addContent(mangleExpression(gck.getSigmaZ_um()));
        kernelElement.addContent(e);
    }
    element.addContent(kernelElement);
    if (convolutionDataGenerator.getVolFunction() != null) {
        Element e = new Element(XMLTags.VolumeFunctionTag);
        e.addContent(mangleExpression(convolutionDataGenerator.getVolFunction()));
        element.addContent(e);
    }
    if (convolutionDataGenerator.getMemFunction() != null) {
        Element e = new Element(XMLTags.MembraneFunctionTag);
        e.addContent(mangleExpression(convolutionDataGenerator.getMemFunction()));
        element.addContent(e);
    }
    return element;
}
Also used : Element(org.jdom.Element) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) ConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel)

Example 3 with ConvolutionDataGeneratorKernel

use of cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel in project vcell by virtualcell.

the class FiniteVolumeFileWriter method writePostProcessingBlock.

private void writePostProcessingBlock() throws Exception {
    // SolverException, ExpressionException and exceptions from roiDataGenerator.getROIDataGeneratorDescription()
    PostProcessingBlock postProcessingBlock = simTask.getSimulation().getMathDescription().getPostProcessingBlock();
    if (postProcessingBlock.getNumDataGenerators() == 0) {
        // to make c++ code write default var statisitcs, without the token it won't write anything
        printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_BEGIN);
        printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_END);
        printWriter.println();
        return;
    }
    if (bChomboSolver && postProcessingBlock.getDataGeneratorList().size() > 0) {
        throw new Exception("Data generators are not supported by " + simTask.getSimulation().getSolverTaskDescription().getSolverDescription().getDisplayLabel());
    }
    printWriter.println(" # Post Processing Block");
    printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_BEGIN);
    for (DataGenerator dataGenerator : postProcessingBlock.getDataGeneratorList()) {
        String varName = dataGenerator.getName();
        Domain domain = dataGenerator.getDomain();
        String domainName = domain == null ? null : domain.getName();
        if (dataGenerator instanceof ProjectionDataGenerator) {
            ProjectionDataGenerator pdg = (ProjectionDataGenerator) dataGenerator;
            Expression function = subsituteExpression(pdg.getFunction(), VariableDomain.VARIABLEDOMAIN_VOLUME);
            printWriter.println(FVInputFileKeyword.PROJECTION_DATA_GENERATOR + " " + varName + " " + domainName + " " + pdg.getAxis() + " " + pdg.getOperation() + " " + function.infix() + ";");
        } else if (dataGenerator instanceof ConvolutionDataGenerator) {
            ConvolutionDataGenerator convolutionDataGenerator = (ConvolutionDataGenerator) dataGenerator;
            ConvolutionDataGeneratorKernel kernel = convolutionDataGenerator.getKernel();
            if (kernel instanceof GaussianConvolutionDataGeneratorKernel) {
                GaussianConvolutionDataGeneratorKernel gck = (GaussianConvolutionDataGeneratorKernel) kernel;
                Expression volFunction = subsituteExpression(convolutionDataGenerator.getVolFunction(), VariableDomain.VARIABLEDOMAIN_VOLUME);
                Expression memFunction = subsituteExpression(convolutionDataGenerator.getMemFunction(), VariableDomain.VARIABLEDOMAIN_MEMBRANE);
                Expression sigmaXY = subsituteExpression(gck.getSigmaXY_um(), VariableDomain.VARIABLEDOMAIN_VOLUME);
                Expression sigmaZ = subsituteExpression(gck.getSigmaZ_um(), VariableDomain.VARIABLEDOMAIN_VOLUME);
                String volFuncStr = volFunction.infix();
                String memFuncStr = memFunction.infix();
                printWriter.println(FVInputFileKeyword.GAUSSIAN_CONVOLUTION_DATA_GENERATOR + " " + varName + " " + domainName + " " + sigmaXY.infix() + " " + sigmaZ.infix() + " " + FVInputFileKeyword.GAUSSIAN_CONVOLUTION_VOL_FUNCTION + " " + volFuncStr + "; " + FVInputFileKeyword.GAUSSIAN_CONVOLUTION_MEM_FUNCTION + " " + memFuncStr + ";");
            }
        } else if (dataGenerator instanceof cbit.vcell.microscopy.ROIDataGenerator) {
            /*
			ROI_DATA_GENERATOR_BEGIN roidata
			VolumePoints 20
			2667 2676 2679 2771 2969 2877 3067 3277 3185 3283 3473 3580 3690 3687 3878 4086 3990 4182 4193 1077 (all points in one line)
			SampleImage 9 0 1341426862190 vcField('sumROIData','roiSumDataVar',0.0,'Volume')
			StoreEnabled false

			SampleImageFile roiSumDataVar 0.0 C:\Users\abcde\VirtualMicroscopy\SimulationData\SimID_1341426862125_0_sumROIData_roiSumDataVar_0_0_Volume.fdat
			DATA_PROCESSOR_END
			*/
            cbit.vcell.microscopy.ROIDataGenerator roiDataGenerator = (cbit.vcell.microscopy.ROIDataGenerator) dataGenerator;
            printWriter.println(roiDataGenerator.getROIDataGeneratorDescription(workingDirectory, simTask.getSimulationJob()));
        } else if (dataGenerator instanceof org.vcell.vmicro.workflow.data.ROIDataGenerator) {
            /*
			ROI_DATA_GENERATOR_BEGIN roidata
			VolumePoints 20
			2667 2676 2679 2771 2969 2877 3067 3277 3185 3283 3473 3580 3690 3687 3878 4086 3990 4182 4193 1077 (all points in one line)
			SampleImage 9 0 1341426862190 vcField('sumROIData','roiSumDataVar',0.0,'Volume')
			StoreEnabled false

			SampleImageFile roiSumDataVar 0.0 C:\Users\abcde\VirtualMicroscopy\SimulationData\SimID_1341426862125_0_sumROIData_roiSumDataVar_0_0_Volume.fdat
			DATA_PROCESSOR_END
			*/
            org.vcell.vmicro.workflow.data.ROIDataGenerator roiDataGenerator = (org.vcell.vmicro.workflow.data.ROIDataGenerator) dataGenerator;
            printWriter.println(roiDataGenerator.getROIDataGeneratorDescription(workingDirectory, simTask.getSimulationJob()));
        } else {
            throw new SolverException(dataGenerator.getClass() + " : data generator not supported yet.");
        }
    }
    printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_END);
    printWriter.println();
}
Also used : ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) ImageException(cbit.image.ImageException) FileNotFoundException(java.io.FileNotFoundException) SolverException(cbit.vcell.solver.SolverException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) ConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel) PostProcessingBlock(cbit.vcell.math.PostProcessingBlock) Expression(cbit.vcell.parser.Expression) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) DataGenerator(cbit.vcell.math.DataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) SolverException(cbit.vcell.solver.SolverException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) SubDomain(cbit.vcell.math.SubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain)

Aggregations

ConvolutionDataGeneratorKernel (cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel)3 GaussianConvolutionDataGeneratorKernel (cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel)3 ConvolutionDataGenerator (cbit.vcell.math.ConvolutionDataGenerator)2 Expression (cbit.vcell.parser.Expression)2 Element (org.jdom.Element)2 ImageException (cbit.image.ImageException)1 GeometryException (cbit.vcell.geometry.GeometryException)1 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)1 DataGenerator (cbit.vcell.math.DataGenerator)1 MathException (cbit.vcell.math.MathException)1 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)1 PostProcessingBlock (cbit.vcell.math.PostProcessingBlock)1 ProjectionDataGenerator (cbit.vcell.math.ProjectionDataGenerator)1 SubDomain (cbit.vcell.math.SubDomain)1 Domain (cbit.vcell.math.Variable.Domain)1 VariableDomain (cbit.vcell.math.VariableType.VariableDomain)1 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 SolverException (cbit.vcell.solver.SolverException)1 PropertyVetoException (java.beans.PropertyVetoException)1