Search in sources :

Example 16 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec 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 FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec 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 FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class RunRefSimulationFastOp method saveExternalData.

private 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)

Example 19 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class ClientRequestManager method createFDOSFromSurfaceFile.

public static FieldDataFileOperationSpec createFDOSFromSurfaceFile(File surfaceFile) throws Exception {
    SurfaceCollection surfaceCollection = createSurfaceCollectionFromSurfaceFile(surfaceFile);
    if (surfaceCollection != null) {
        Geometry geometry = RayCaster.createGeometryFromSTL(new GeometryThumbnailImageFactoryAWT(), surfaceCollection, 1000000);
        FieldDataFileOperationSpec fdfos = new FieldDataFileOperationSpec();
        fdfos.origin = geometry.getOrigin();
        fdfos.extent = geometry.getExtent();
        VCImage image = geometry.getGeometrySpec().getImage();
        if (image.getNumPixelClasses() == 1) {
            throw new Exception("STL import failed during processing, pixelclass count=1");
        }
        fdfos.isize = new ISize(image.getNumX(), image.getNumY(), image.getNumZ());
        byte[] pixels = image.getPixels();
        short[] dataToSegment = new short[image.getNumXYZ()];
        for (int i = 0; i < pixels.length; i++) {
            dataToSegment[i] = pixels[i];
        }
        fdfos.shortSpecData = new short[][][] { { dataToSegment } };
        return fdfos;
    }
    return null;
}
Also used : SurfaceCollection(cbit.vcell.geometry.surface.SurfaceCollection) Geometry(cbit.vcell.geometry.Geometry) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) ISize(org.vcell.util.ISize) VCImage(cbit.image.VCImage) ProgrammingException(org.vcell.util.ProgrammingException) MatrixException(cbit.vcell.matrix.MatrixException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) ModelException(cbit.vcell.model.ModelException) DataFormatException(java.util.zip.DataFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) UserCancelException(org.vcell.util.UserCancelException)

Example 20 with FieldDataFileOperationSpec

use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.

the class ClientRequestManager method getResizeImageTask.

public static AsynchClientTask getResizeImageTask(final VCDocument.DocumentCreationInfo documentCreationInfo) {
    AsynchClientTask resizeImageTask = new AsynchClientTask("Resizing Image...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ImageSizeInfo newImageSizeInfo = (ImageSizeInfo) hashTable.get(NEW_IMAGE_SIZE_INFO);
            FieldDataFileOperationSpec fdfos = (FieldDataFileOperationSpec) hashTable.get(FDFOS);
            if (newImageSizeInfo != null && fdfos != null && !fdfos.isize.compareEqual(newImageSizeInfo.getiSize())) {
                // resizeImage((FieldDataFileOperationSpec) hashTable.get(FDFOS), newImageSizeInfo.getiSize(),
                // documentCreationInfo.getOption());
                resize0(hashTable);
            }
        }
    };
    return resizeImageTask;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) ImageSizeInfo(cbit.image.ImageSizeInfo)

Aggregations

FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)29 ISize (org.vcell.util.ISize)19 Origin (org.vcell.util.Origin)18 CartesianMesh (cbit.vcell.solvers.CartesianMesh)16 Extent (org.vcell.util.Extent)16 RegionImage (cbit.vcell.geometry.RegionImage)14 UserCancelException (org.vcell.util.UserCancelException)13 VCImageUncompressed (cbit.image.VCImageUncompressed)12 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)10 VCImage (cbit.image.VCImage)9 ImageException (cbit.image.ImageException)8 Hashtable (java.util.Hashtable)8 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)7 VariableType (cbit.vcell.math.VariableType)6 DataFormatException (java.util.zip.DataFormatException)6 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)5 File (java.io.File)5 ClientRequestManager (cbit.vcell.client.ClientRequestManager)4 RequestManager (cbit.vcell.client.RequestManager)4 SimDataBlock (cbit.vcell.simdata.SimDataBlock)4