Search in sources :

Example 36 with RegionImage

use of cbit.vcell.geometry.RegionImage in project vcell by virtualcell.

the class FRAPStudy method getCartesianMesh.

public CartesianMesh getCartesianMesh() throws Exception {
    CartesianMesh cartesianMesh = null;
    ImageDataset imgDataSet = getFrapData().getImageDataset();
    Extent extent = imgDataSet.getExtent();
    ISize isize = imgDataSet.getISize();
    Origin origin = new Origin(0, 0, 0);
    if (getBioModel() == null) {
        cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
    } else {
        RegionImage regionImage = getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().getRegionImage();
        if (regionImage == null) {
            getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().updateAll();
            regionImage = getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().getRegionImage();
        }
        cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
    }
    return cartesianMesh;
}
Also used : Origin(org.vcell.util.Origin) CartesianMesh(cbit.vcell.solvers.CartesianMesh) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) RegionImage(cbit.vcell.geometry.RegionImage) VCImageUncompressed(cbit.image.VCImageUncompressed)

Example 37 with RegionImage

use of cbit.vcell.geometry.RegionImage in project vcell by virtualcell.

the class FRAPStudy method getPSFFieldData.

public static FieldDataIdentifierSpec getPSFFieldData(LocalWorkspace localWorkspace) {
    // create ROI image
    short[] psfFieldData = null;
    psfFieldData = new short[9];
    psfFieldData[4] = (short) 1;
    // create field data
    int NumTimePoints = 1;
    // 8 rois integrated into 1 image
    int NumChannels = 1;
    short[][][] pixData = new short[NumTimePoints][NumChannels][1];
    pixData[0][0] = psfFieldData;
    // get extental data id
    ExternalDataIdentifier newPsfExtDataID = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.PSF_DATA_NAME).getExternalDataIdentifier();
    CartesianMesh cartesianMesh;
    try {
        Origin origin = new Origin(0, 0, 0);
        Extent ext = new Extent(1, 1, 1);
        ISize isize = new ISize(3, 3, 1);
        cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, ext, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], ext, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
        FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
        fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
        fdos.cartesianMesh = cartesianMesh;
        fdos.shortSpecData = pixData;
        fdos.specEDI = newPsfExtDataID;
        fdos.varNames = new String[] { "psfVar" };
        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);
        FieldFunctionArguments psfFieldFunc = new FieldFunctionArguments(PSF_DATA_NAME, "psfVar", new Expression(0.0), VariableType.VOLUME);
        FieldDataIdentifierSpec fdis = new FieldDataIdentifierSpec(psfFieldFunc, newPsfExtDataID);
        return fdis;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        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) VCImageUncompressed(cbit.image.VCImageUncompressed) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Expression(cbit.vcell.parser.Expression) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) RegionImage(cbit.vcell.geometry.RegionImage)

Example 38 with RegionImage

use of cbit.vcell.geometry.RegionImage in project vcell by virtualcell.

the class TopLevelWindowManager method addWorkspaceGeomSizeSelection.

private void addWorkspaceGeomSizeSelection(final Hashtable<String, Object> hash, Geometry sourceGeom) throws Exception {
    if (TopLevelWindowManager.this instanceof DocumentWindowManager) {
        Simulation[] simulations = null;
        SimulationContext[] simContexts = null;
        SimulationContext selectedSC = null;
        ArrayList<Object[]> allRows = new ArrayList<Object[]>();
        ArrayList<ISize> iSizes = new ArrayList<ISize>();
        if (this instanceof BioModelWindowManager) {
            BioModelWindowManager bmwm = ((BioModelWindowManager) this);
            // System.out.println(bmwm);
            if (bmwm.getDocumentEditor() instanceof cbit.vcell.client.desktop.biomodel.BioModelEditor) {
                cbit.vcell.client.desktop.biomodel.BioModelEditor bme = (cbit.vcell.client.desktop.biomodel.BioModelEditor) bmwm.getDocumentEditor();
                // System.out.println(bme);
                selectedSC = bme.getSelectedSimulationContext();
            // System.out.println(selectedSC);
            }
        }
        if (((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument() instanceof BioModel) {
            simContexts = ((BioModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getSimulationContexts();
        } else if (((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument() instanceof MathModel) {
            simulations = ((MathModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getSimulations();
        }
        String[] simColumnNames = null;
        if (simContexts != null) {
            simColumnNames = new String[] { "x", "y", "z", "appName", "simName" };
        } else {
            simColumnNames = new String[] { "x", "y", "z", "simName" };
        }
        ArrayList<Object[]> simRows = new ArrayList<Object[]>();
        ArrayList<CartesianMesh> meshes = new ArrayList<CartesianMesh>();
        for (int j = 0; j < (simContexts == null ? 1 : simContexts.length); j++) {
            Geometry geom = null;
            if (simContexts != null) {
                if (simContexts[j] != selectedSC) {
                    continue;
                }
                simulations = simContexts[j].getSimulations();
                geom = simContexts[j].getGeometry();
            } else {
                geom = ((MathModel) ((DocumentWindowManager) TopLevelWindowManager.this).getVCDocument()).getGeometry();
            }
            // ISize defaultSamplesize = geom.getGeometrySpec().getDefaultSampledImageSize();
            if (simulations != null && simulations.length > 0) {
                for (int i = 0; i < simulations.length; i++) {
                    Object[] row = new Object[simColumnNames.length];
                    // }
                    if (simulations[i].getMeshSpecification() != null && simulations[i].getMeshSpecification() != null) {
                        row = new Object[simColumnNames.length];
                        ISize samplingSize = simulations[i].getMeshSpecification().getSamplingSize();
                        row[0] = samplingSize.getX();
                        row[1] = samplingSize.getY();
                        row[2] = samplingSize.getZ();
                        row[3] = (simContexts != null ? simContexts[j].getName() : simulations[i].getName());
                        if (simContexts != null) {
                            row[4] = simulations[i].getName();
                        }
                        simRows.add(row);
                        VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[samplingSize.getXYZ()], geom.getExtent(), samplingSize.getX(), samplingSize.getY(), samplingSize.getZ());
                        CartesianMesh simpleMesh = CartesianMesh.createSimpleCartesianMesh(geom.getOrigin(), geom.getExtent(), samplingSize, new RegionImage(vcImageUnc, geom.getDimension(), geom.getExtent(), geom.getOrigin(), RegionImage.NO_SMOOTHING));
                        meshes.add(simpleMesh);
                    }
                }
            }
        }
        for (int i = 0; i < simRows.size(); i++) {
            ISize iSize = meshes.get(i).getISize();
            iSizes.add(iSize);
            allRows.add(new Object[] { iSize.getX(), iSize.getY(), iSize.getZ(), "Simulation=" + (simColumnNames.length == 4 ? simRows.get(i)[3] : simRows.get(i)[3] + ":" + simRows.get(i)[4]) });
        }
        // if(allRows.size() > 0) {
        if (simRows.size() > 0) {
            Object[][] rowData = simRows.toArray(new Object[0][]);
            int[] selections = DialogUtils.showComponentOKCancelTableList(TopLevelWindowManager.this.getComponent(), "Select Simulation for Geom Size", simColumnNames, rowData, ListSelectionModel.SINGLE_SELECTION);
            if (selections != null && selections.length == 1) {
                // ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal",meshes.get(selections[0]).getISize(),1,new double[] {0},0);
                ImageSizeInfo imagesizeInfo = new ImageSizeInfo("internal", iSizes.get(selections[0]), 1, new double[] { 0 }, 0);
                hash.put(ClientRequestManager.NEW_IMAGE_SIZE_INFO, imagesizeInfo);
                VCImage image = null;
                if (sourceGeom.getGeometrySpec().getImage() == null) {
                    image = sourceGeom.getGeometrySpec().createSampledImage(iSizes.get(selections[0]));
                } else {
                    image = sourceGeom.getGeometrySpec().getImage();
                }
                // 
                ISize samplingSize = new ISize(image.getNumX(), image.getNumY(), image.getNumZ());
                VCImageUncompressed vcImageUnc = new VCImageUncompressed(null, new byte[samplingSize.getXYZ()], sourceGeom.getExtent(), samplingSize.getX(), samplingSize.getY(), samplingSize.getZ());
                CartesianMesh sourceMesh = CartesianMesh.createSimpleCartesianMesh(sourceGeom.getOrigin(), sourceGeom.getExtent(), samplingSize, new RegionImage(vcImageUnc, sourceGeom.getDimension(), sourceGeom.getExtent(), sourceGeom.getOrigin(), RegionImage.NO_SMOOTHING));
                hash.put("newMesh", meshes.get(selections[0]));
                hash.put("sourceMesh", sourceMesh);
            }
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) ISize(org.vcell.util.ISize) ArrayList(java.util.ArrayList) VCImage(cbit.image.VCImage) VCImageUncompressed(cbit.image.VCImageUncompressed) SimulationContext(cbit.vcell.mapping.SimulationContext) ImageSizeInfo(cbit.image.ImageSizeInfo) Geometry(cbit.vcell.geometry.Geometry) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) RegionImage(cbit.vcell.geometry.RegionImage)

Aggregations

RegionImage (cbit.vcell.geometry.RegionImage)38 VCImageUncompressed (cbit.image.VCImageUncompressed)21 ISize (org.vcell.util.ISize)20 CartesianMesh (cbit.vcell.solvers.CartesianMesh)19 Extent (org.vcell.util.Extent)17 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)14 Origin (org.vcell.util.Origin)14 VCImage (cbit.image.VCImage)13 UserCancelException (org.vcell.util.UserCancelException)8 Point (java.awt.Point)7 ImageException (cbit.image.ImageException)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)6 VariableType (cbit.vcell.math.VariableType)6 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)6 SimDataBlock (cbit.vcell.simdata.SimDataBlock)5 ArrayList (java.util.ArrayList)5 RegionInfo (cbit.vcell.geometry.RegionImage.RegionInfo)4 BufferedImage (java.awt.image.BufferedImage)4 Hashtable (java.util.Hashtable)4 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)3