Search in sources :

Example 1 with ImageDatasetReader

use of org.vcell.vcellij.ImageDatasetReader in project vcell by virtualcell.

the class ClientRequestManager method createFDOSFromImageFile.

// public void prepareDocumentToLoad(VCDocument doc) throws Exception {
// Simulation[] simulations = null;
// if (doc instanceof MathModel) {
// Geometry geometry = ((MathModel)doc).getMathDescription().getGeometry();
// geometry.precomputeAll();
// simulations = ((MathModel)doc).getSimulations();
// } else if (doc instanceof Geometry) {
// ((Geometry)doc).precomputeAll();
// } else if (doc instanceof BioModel) {
// BioModel bioModel = (BioModel)doc;
// SimulationContext[] simContexts = bioModel.getSimulationContexts();
// for (SimulationContext simContext : simContexts) {
// simContext.getGeometry().precomputeAll();
// }
// simulations = ((BioModel)doc).getSimulations();
// }
// if (simulations != null) {
// // preload simulation status
// VCSimulationIdentifier simIDs[] = new VCSimulationIdentifier[simulations.length];
// for (int i = 0; i < simulations.length; i++){
// simIDs[i] = simulations[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
// }
// getDocumentManager().preloadSimulationStatus(simIDs);
// }
// }
public static FieldDataFileOperationSpec createFDOSFromImageFile(File imageFile, boolean bCropOutBlack, Integer saveOnlyThisTimePointIndex) throws DataFormatException, ImageException {
    try {
        ImageDatasetReader imageDatasetReader = ImageDatasetReaderService.getInstance().getImageDatasetReader();
        ImageDataset[] imagedataSets = imageDatasetReader.readImageDatasetChannels(imageFile.getAbsolutePath(), null, false, saveOnlyThisTimePointIndex, null);
        if (imagedataSets != null && bCropOutBlack) {
            for (int i = 0; i < imagedataSets.length; i++) {
                Rectangle nonZeroRect = imagedataSets[i].getNonzeroBoundingRectangle();
                if (nonZeroRect != null) {
                    imagedataSets[i] = imagedataSets[i].crop(nonZeroRect);
                }
            }
        }
        return createFDOSWithChannels(imagedataSets, null);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw new DataFormatException(e.getMessage());
    }
}
Also used : DataFormatException(java.util.zip.DataFormatException) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Rectangle(java.awt.Rectangle) ImageDatasetReader(org.vcell.vcellij.ImageDatasetReader) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException)

Example 2 with ImageDatasetReader

use of org.vcell.vcellij.ImageDatasetReader in project vcell by virtualcell.

the class NonGUIFRAPTest method readExternalDataContents.

public static ExternalDataFileContents readExternalDataContents(String imageDataPathName, String cellROIPathName, String bleachROIPathName, String backgroundROIPathName) throws Exception {
    ExternalDataFileContents extDataFilecontents = new ExternalDataFileContents();
    ImageDatasetReader imageDatasetReader = ImageDatasetReaderService.getInstance().getImageDatasetReader();
    extDataFilecontents.imageData = imageDatasetReader.readImageDataset(imageDataPathName, null);
    extDataFilecontents.cellROIData = imageDatasetReader.readImageDataset(cellROIPathName, null);
    extDataFilecontents.bleachROIData = imageDatasetReader.readImageDataset(bleachROIPathName, null);
    extDataFilecontents.backgroundROIData = imageDatasetReader.readImageDataset(backgroundROIPathName, null);
    return extDataFilecontents;
}
Also used : ImageDatasetReader(org.vcell.vcellij.ImageDatasetReader)

Aggregations

ImageDatasetReader (org.vcell.vcellij.ImageDatasetReader)2 ImageException (cbit.image.ImageException)1 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)1 GeometryException (cbit.vcell.geometry.GeometryException)1 Rectangle (java.awt.Rectangle)1 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 DataFormatException (java.util.zip.DataFormatException)1 DataAccessException (org.vcell.util.DataAccessException)1 ProgrammingException (org.vcell.util.ProgrammingException)1 UserCancelException (org.vcell.util.UserCancelException)1 UtilCancelException (org.vcell.util.UtilCancelException)1