Search in sources :

Example 36 with VCImageUncompressed

use of cbit.image.VCImageUncompressed 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 37 with VCImageUncompressed

use of cbit.image.VCImageUncompressed 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

VCImageUncompressed (cbit.image.VCImageUncompressed)37 Extent (org.vcell.util.Extent)23 RegionImage (cbit.vcell.geometry.RegionImage)21 ISize (org.vcell.util.ISize)21 VCImage (cbit.image.VCImage)20 CartesianMesh (cbit.vcell.solvers.CartesianMesh)18 Origin (org.vcell.util.Origin)17 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)12 Geometry (cbit.vcell.geometry.Geometry)11 Expression (cbit.vcell.parser.Expression)11 ImageException (cbit.image.ImageException)10 ArrayList (java.util.ArrayList)10 SubVolume (cbit.vcell.geometry.SubVolume)9 UserCancelException (org.vcell.util.UserCancelException)9 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)8 BioModel (cbit.vcell.biomodel.BioModel)7 SimulationContext (cbit.vcell.mapping.SimulationContext)7 SurfaceClass (cbit.vcell.geometry.SurfaceClass)6 FeatureMapping (cbit.vcell.mapping.FeatureMapping)6 VariableType (cbit.vcell.math.VariableType)6