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;
}
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;
}
}
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;
}
}
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;
}
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;
}
Aggregations