Search in sources :

Example 11 with ImageDataset

use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.

the class BioformatsImageDatasetReader method getImageDataset.

private ImageDataset getImageDataset(org.vcell.imagedataset.ImageDataset t_imageDataset) throws ImageException {
    List<org.vcell.imagedataset.UShortImage> t_images = t_imageDataset.getImages();
    UShortImage[] images = new UShortImage[t_images.size()];
    for (int i = 0; i < t_images.size(); i++) {
        org.vcell.imagedataset.UShortImage t_image = t_images.get(i);
        short[] pixels = new short[t_image.getPixels().size()];
        for (int p = 0; p < t_image.getPixelsSize(); p++) {
            pixels[p] = t_image.getPixels().get(p);
        }
        Origin origin = new Origin(t_image.getOrigin().x, t_image.getOrigin().y, t_image.getOrigin().z);
        Extent extent = new Extent(t_image.getExtent().x, t_image.getExtent().y, t_image.getExtent().z);
        int numX = t_image.getSize().x;
        int numY = t_image.getSize().y;
        int numZ = t_image.getSize().z;
        UShortImage image = new UShortImage(pixels, origin, extent, numX, numY, numZ);
        images[i] = image;
    }
    ;
    List<Double> t_imageTimeStamps = t_imageDataset.getImageTimeStamps();
    double[] timestamps = new double[t_imageTimeStamps.size()];
    for (int t = 0; t < t_imageTimeStamps.size(); t++) {
        timestamps[t] = t_imageTimeStamps.get(t);
    }
    ImageDataset imageDataset = new ImageDataset(images, timestamps, t_imageDataset.numZ);
    return imageDataset;
}
Also used : Origin(org.vcell.util.Origin) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Extent(org.vcell.util.Extent) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Example 12 with ImageDataset

use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.

the class BioformatsImageDatasetReader method readImageDatasetChannels.

@Override
public ImageDataset[] readImageDatasetChannels(String imageID, ClientTaskStatusSupport status, boolean bMergeChannels, Integer timeIndex, ISize resize) throws Exception {
    try (TTransport transport = new TSocket("localhost", port)) {
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        ImageDatasetService.Client client = new ImageDatasetService.Client(protocol);
        String fileName = imageID;
        org.vcell.imagedataset.ISize t_resize = null;
        if (resize != null) {
            t_resize = new org.vcell.imagedataset.ISize(resize.getX(), resize.getY(), resize.getZ());
        }
        List<org.vcell.imagedataset.ImageDataset> t_imageDatasetList = client.readImageDatasetChannels(fileName, bMergeChannels, timeIndex, t_resize);
        ImageDataset[] imageDatasets = new ImageDataset[t_imageDatasetList.size()];
        for (int i = 0; i < t_imageDatasetList.size(); i++) {
            imageDatasets[i] = getImageDataset(t_imageDatasetList.get(i));
        }
        return imageDatasets;
    }
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) ImageDatasetService(org.vcell.imagedataset.ImageDatasetService) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 13 with ImageDataset

use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.

the class BioformatsImageDatasetReader method readImageDataset.

@Override
public ImageDataset readImageDataset(String imageID, ClientTaskStatusSupport status) throws Exception {
    try (TTransport transport = new TSocket("localhost", port)) {
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        ImageDatasetService.Client client = new ImageDatasetService.Client(protocol);
        String fileName = imageID;
        org.vcell.imagedataset.ImageDataset t_imageDataset = client.readImageDataset(fileName);
        ImageDataset imageDataset = getImageDataset(t_imageDataset);
        return imageDataset;
    }
}
Also used : ImageDatasetService(org.vcell.imagedataset.ImageDatasetService) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 14 with ImageDataset

use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.

the class MicroscopyXmlReader method getImageDataset.

/**
 * This method returns a Biomodel object from a XML Element.
 * Creation date: (3/13/2001 12:35:00 PM)
 * @param param org.jdom.Element
 * @return cbit.vcell.biomodel.BioModel
 * @throws XmlParseException
 */
private ImageDataset getImageDataset(Element param, ClientTaskStatusSupport progressListener) throws XmlParseException {
    List<Element> ushortImageElementList = param.getChildren(MicroscopyXMLTags.UShortImageTag);
    Iterator<Element> imageElementIter = ushortImageElementList.iterator();
    UShortImage[] images = new UShortImage[ushortImageElementList.size()];
    // added in Feb 2008, for counting loading progress
    int imageSize = ushortImageElementList.size();
    int imageCount = 0;
    while (imageElementIter.hasNext()) {
        images[imageCount++] = getUShortImage(imageElementIter.next());
        if (progressListener != null) {
            progressListener.setProgress((int) ((imageCount * 100.0) / imageSize));
        }
    }
    Element timeStampListElement = param.getChild(MicroscopyXMLTags.TimeStampListTag);
    double[] timestamps = null;
    if (timeStampListElement != null) {
        String timeStampListText = timeStampListElement.getTextTrim();
        StringTokenizer tokens = new StringTokenizer(timeStampListText, ",\n\r\t ", false);
        ArrayList<Double> times = new ArrayList<Double>();
        while (tokens.hasMoreTokens()) {
            String token = tokens.nextToken();
            times.add(Double.parseDouble(token));
        }
        timestamps = new double[times.size()];
        for (int i = 0; i < timestamps.length; i++) {
            timestamps[i] = times.get(i);
        }
    }
    int numTimeSteps = (timestamps != null) ? (timestamps.length) : (1);
    int numZ = images.length / numTimeSteps;
    ImageDataset imageDataset = new ImageDataset(images, timestamps, numZ);
    return imageDataset;
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Element(org.jdom.Element) ArrayList(java.util.ArrayList) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) StringTokenizer(java.util.StringTokenizer)

Example 15 with ImageDataset

use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.

the class MicroscopyXmlReader method getAnnotatedImageDataset.

public AnnotatedImageDataset getAnnotatedImageDataset(Element param, /*root, frapstudy element*/
ClientTaskStatusSupport progressListener) throws XmlParseException {
    // get frapData element
    Element frapDataElement = param.getChild(MicroscopyXMLTags.FRAPDataTag);
    Element imageDatasetElement = frapDataElement.getChild(MicroscopyXMLTags.ImageDatasetTag);
    ImageDataset imageDataset = null;
    if (imageDatasetElement != null) {
        imageDataset = getImageDataset(imageDatasetElement, progressListener);
    }
    Namespace ns = param.getNamespace();
    List<Element> roiList = frapDataElement.getChildren(MicroscopyXMLTags.ROITag);
    ROI[] rois = new ROI[0];
    int numROIs = roiList.size();
    if (numROIs > 0) {
        rois = new ROI[numROIs];
        Iterator<Element> roiIter = roiList.iterator();
        int index = 0;
        while (roiIter.hasNext()) {
            Element roiElement = roiIter.next();
            rois[index++] = getROI(roiElement);
        }
    }
    // reorder ROIs according to the order of FRAPData.VFRAP_ROI_ENUM
    ROI[] reorderedROIs = AnnotatedImageDataset.reorderROIs(rois);
    AnnotatedImageDataset annotatedImages = new AnnotatedImageDataset(imageDataset, reorderedROIs);
    // After loading all the ROI rings, the progress should set to 100.
    if (progressListener != null) {
        progressListener.setProgress(100);
    }
    return annotatedImages;
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Element(org.jdom.Element) ROI(cbit.vcell.VirtualMicroscopy.ROI) Namespace(org.jdom.Namespace)

Aggregations

ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)42 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)20 ROI (cbit.vcell.VirtualMicroscopy.ROI)9 Extent (org.vcell.util.Extent)9 File (java.io.File)8 Element (org.jdom.Element)8 ISize (org.vcell.util.ISize)8 Origin (org.vcell.util.Origin)7 CartesianMesh (cbit.vcell.solvers.CartesianMesh)6 UserCancelException (org.vcell.util.UserCancelException)6 ImageException (cbit.image.ImageException)5 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)5 Hashtable (java.util.Hashtable)5 Component (java.awt.Component)4 ArrayList (java.util.ArrayList)4 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)4 VCImageUncompressed (cbit.image.VCImageUncompressed)3 AnnotatedImageDataset (cbit.vcell.VirtualMicroscopy.importer.AnnotatedImageDataset)3 MicroscopyXmlReader (cbit.vcell.VirtualMicroscopy.importer.MicroscopyXmlReader)3