Search in sources :

Example 46 with ISize

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

the class FRAPStudy method getROIDataGenerator.

public ROIDataGenerator getROIDataGenerator(LocalWorkspace localWorkspace) {
    // create ROI image
    short[] roiFieldData = null;
    ROI[] rois = getFrapData().getRois();
    if (rois.length > 0) {
        Extent extent = rois[0].getRoiImages()[0].getExtent();
        ISize isize = rois[0].getISize();
        int numROIX = rois[0].getISize().getX();
        int numROIY = rois[0].getISize().getY();
        roiFieldData = new short[numROIX * numROIY];
        short regionCounter = 1;
        for (int roiIdx = FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.ordinal(); roiIdx < rois.length; roiIdx++) {
            short[] roiImg = rois[roiIdx].getPixelsXYZ();
            for (int pixelIdx = 0; pixelIdx < (numROIX * numROIY); pixelIdx++) {
                if (roiImg[pixelIdx] > 0) {
                    roiFieldData[pixelIdx] = regionCounter;
                }
            }
            regionCounter++;
        }
        // create field data
        int NumTimePoints = 1;
        // 8 rois integrated into 1 image
        int NumChannels = 1;
        short[][][] pixData = new short[NumTimePoints][NumChannels][];
        pixData[0][0] = roiFieldData;
        // get extental data id
        ExternalDataIdentifier newROIExtDataID = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_SUMDATA_NAME).getExternalDataIdentifier();
        CartesianMesh cartesianMesh;
        try {
            cartesianMesh = getCartesianMesh();
            Origin origin = new Origin(0, 0, 0);
            FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
            fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
            fdos.cartesianMesh = cartesianMesh;
            fdos.shortSpecData = pixData;
            fdos.specEDI = newROIExtDataID;
            fdos.varNames = new String[] { "roiSumDataVar" };
            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);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return new ROIDataGenerator(ROI_EXTDATA_NAME, /*name*/
        new int[] { 0 }, /* volumePoints*/
        new int[0], /* membranePoints*/
        regionCounter, /*numRegions*/
        0, /*zSlice*/
        newROIExtDataID.getKey(), /* fieldDataKey, sample image*/
        new FieldFunctionArguments(FRAPStudy.ROI_SUMDATA_NAME, "roiSumDataVar", new Expression(0), VariableType.VOLUME), /*FieldFunctionArguments, sample image*/
        false);
    }
    return null;
}
Also used : Origin(org.vcell.util.Origin) Extent(org.vcell.util.Extent) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) ISize(org.vcell.util.ISize) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) ROI(cbit.vcell.VirtualMicroscopy.ROI) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Expression(cbit.vcell.parser.Expression) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier)

Example 47 with ISize

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

the class MeshSpecification method getVCML.

/**
 * This method was created by a SmartGuide.
 * @return java.lang.String
 */
public String getVCML() {
    StringBuffer buffer = new StringBuffer();
    buffer.append(VCML.MeshSpecification + " {\n");
    ISize size = getSamplingSize();
    buffer.append("\t" + VCML.Size + " " + size.getX() + " " + size.getY() + " " + size.getZ() + "\n");
    buffer.append("}\n");
    return buffer.toString();
}
Also used : ISize(org.vcell.util.ISize)

Example 48 with ISize

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

the class XmlReader method getMeshSpecification.

/**
 * This method returns a MeshSpecification object from a XML Element.
 * Creation date: (5/22/2001 12:05:21 PM)
 * @return cbit.vcell.mesh.MeshSpecification
 * @param param org.jdom.Element
 */
private MeshSpecification getMeshSpecification(Element param, Geometry geometry) throws XmlParseException {
    // *** create new MeshSpecification ***
    MeshSpecification meshSpec = new MeshSpecification(geometry);
    // get ISize
    Element size = param.getChild(XMLTags.SizeTag, vcNamespace);
    int x = Integer.parseInt(size.getAttributeValue(XMLTags.XAttrTag));
    int y = Integer.parseInt(size.getAttributeValue(XMLTags.YAttrTag));
    int z = Integer.parseInt(size.getAttributeValue(XMLTags.ZAttrTag));
    ISize newsize = new ISize(x, y, z);
    // set ISize
    try {
        meshSpec.setSamplingSize(newsize);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("A PropertyVetoException was fired when setting the ISize object to a new MeshSpecification", e);
    }
    return meshSpec;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ISize(org.vcell.util.ISize) Element(org.jdom.Element) MeshSpecification(cbit.vcell.solver.MeshSpecification)

Example 49 with ISize

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

the class Xmlproducer method getXML.

private Element getXML(GeometrySurfaceDescription param) throws XmlParseException {
    Element gsd = new Element(XMLTags.SurfaceDescriptionTag);
    // add attributes
    ISize isize = param.getVolumeSampleSize();
    if (isize == null) {
        throw new XmlParseException("Unable to retrieve dimensions for surface descriptions for Geometry: " + param.getGeometry().getName());
    }
    gsd.setAttribute(XMLTags.NumSamplesXAttrTag, String.valueOf(isize.getX()));
    gsd.setAttribute(XMLTags.NumSamplesYAttrTag, String.valueOf(isize.getY()));
    gsd.setAttribute(XMLTags.NumSamplesZAttrTag, String.valueOf(isize.getZ()));
    Double coFrequency = param.getFilterCutoffFrequency();
    if (coFrequency == null) {
        throw new XmlParseException("Unable to retrieve cutoff frequency for surface descriptions for Geometry: " + param.getGeometry().getName());
    }
    double cutoffFrequency = coFrequency.doubleValue();
    gsd.setAttribute(XMLTags.CutoffFrequencyAttrTag, String.valueOf(cutoffFrequency));
    // add subelements
    GeometricRegion[] geomRegions = param.getGeometricRegions();
    if (geomRegions != null) {
        for (int i = 0; i < geomRegions.length; i++) {
            if (geomRegions[i] instanceof SurfaceGeometricRegion) {
                SurfaceGeometricRegion sgr = (SurfaceGeometricRegion) geomRegions[i];
                Element membraneRegion = new Element(XMLTags.MembraneRegionTag);
                membraneRegion.setAttribute(XMLTags.NameAttrTag, sgr.getName());
                GeometricRegion[] adjacents = sgr.getAdjacentGeometricRegions();
                if (adjacents == null || adjacents.length != 2) {
                    throw new XmlParseException("Wrong number of adjacent regions for surface descriptions for location: " + sgr.getName() + " in Geometry: " + param.getGeometry().getName());
                }
                membraneRegion.setAttribute(XMLTags.VolumeRegion_1AttrTag, adjacents[0].getName());
                membraneRegion.setAttribute(XMLTags.VolumeRegion_2AttrTag, adjacents[1].getName());
                double size = sgr.getSize();
                if (size != -1) {
                    membraneRegion.setAttribute(XMLTags.SizeAttrTag, String.valueOf(size));
                    VCUnitDefinition unit = sgr.getSizeUnit();
                    if (unit != null) {
                        membraneRegion.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
                    }
                }
                gsd.addContent(membraneRegion);
            } else if (geomRegions[i] instanceof VolumeGeometricRegion) {
                VolumeGeometricRegion vgr = (VolumeGeometricRegion) geomRegions[i];
                Element volumeRegion = new Element(XMLTags.VolumeRegionTag);
                volumeRegion.setAttribute(XMLTags.NameAttrTag, vgr.getName());
                volumeRegion.setAttribute(XMLTags.RegionIDAttrTag, String.valueOf(vgr.getRegionID()));
                volumeRegion.setAttribute(XMLTags.SubVolumeAttrTag, vgr.getSubVolume().getName());
                double size = vgr.getSize();
                if (size != -1) {
                    volumeRegion.setAttribute(XMLTags.SizeAttrTag, String.valueOf(size));
                    VCUnitDefinition unit = vgr.getSizeUnit();
                    if (unit != null) {
                        volumeRegion.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
                    }
                }
                gsd.addContent(volumeRegion);
            }
        }
    }
    return gsd;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) ISize(org.vcell.util.ISize) Element(org.jdom.Element) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 50 with ISize

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

the class Xmlproducer method getXML.

/**
 * Insert the method's description here.
 * Creation date: (3/3/2001 12:24:59 AM)
 * @return Element
 * @param param cbit.vcell.mesh.MeshSpecification
 */
private Element getXML(MeshSpecification param) {
    Element meshspec = new Element(XMLTags.MeshSpecTag);
    Element size = new Element(XMLTags.SizeTag);
    // Add extent attributes
    ISize sampling = param.getSamplingSize();
    size.setAttribute(XMLTags.XAttrTag, String.valueOf(sampling.getX()));
    size.setAttribute(XMLTags.YAttrTag, String.valueOf(sampling.getY()));
    size.setAttribute(XMLTags.ZAttrTag, String.valueOf(sampling.getZ()));
    meshspec.addContent(size);
    return meshspec;
}
Also used : ISize(org.vcell.util.ISize) Element(org.jdom.Element)

Aggregations

ISize (org.vcell.util.ISize)139 Extent (org.vcell.util.Extent)53 Origin (org.vcell.util.Origin)46 CartesianMesh (cbit.vcell.solvers.CartesianMesh)27 IOException (java.io.IOException)22 VCImage (cbit.image.VCImage)21 VCImageUncompressed (cbit.image.VCImageUncompressed)21 Geometry (cbit.vcell.geometry.Geometry)21 ExpressionException (cbit.vcell.parser.ExpressionException)21 DataAccessException (org.vcell.util.DataAccessException)21 RegionImage (cbit.vcell.geometry.RegionImage)20 ImageException (cbit.image.ImageException)19 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)19 File (java.io.File)18 MathException (cbit.vcell.math.MathException)17 ArrayList (java.util.ArrayList)16 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)14 Expression (cbit.vcell.parser.Expression)14 PropertyVetoException (java.beans.PropertyVetoException)14 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)13