use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.
the class FRAPOptimizationUtils method refreshNormalizedMeasurementError.
/*
* Calculate Measurement error for data that is normalized
* and averaged at each ROI ring.
* The first dimension is ROI rings(according to the Enum in FRAPData)
* The second dimension is time points (from starting index to the end)
*/
public static double[][] refreshNormalizedMeasurementError(FRAPStudy frapStudy) throws Exception {
FRAPData fData = frapStudy.getFrapData();
ImageDataset imgDataset = fData.getImageDataset();
double[] timeStamp = imgDataset.getImageTimeStamps();
int startIndexRecovery = frapStudy.getStartingIndexForRecovery();
int roiLen = FRAPData.VFRAP_ROI_ENUM.values().length;
double[][] sigma = new double[roiLen][timeStamp.length - startIndexRecovery];
double[] prebleachAvg = FrapDataUtils.calculatePreBleachAverageXYZ(fData, startIndexRecovery);
for (int roiIdx = 0; roiIdx < roiLen; roiIdx++) {
ROI roi = fData.getRoi((FRAPData.VFRAP_ROI_ENUM.values()[roiIdx]).name());
if (roi != null) {
short[] roiData = roi.getPixelsXYZ();
for (int timeIdx = startIndexRecovery; timeIdx < timeStamp.length; timeIdx++) {
short[] rawTimeData = AnnotatedImageDataset.collectAllZAtOneTimepointIntoOneArray(imgDataset, timeIdx);
if (roiData.length != rawTimeData.length || roiData.length != prebleachAvg.length || rawTimeData.length != prebleachAvg.length) {
throw new Exception("ROI data and image data are not in the same length.");
} else {
// loop through ROI
int roiPixelCounter = 0;
double sigmaVal = 0;
for (int i = 0; i < roiData.length; i++) {
if (roiData[i] != 0) {
sigmaVal = sigmaVal + ((rawTimeData[i] & 0x0000FFFF)) / (prebleachAvg[i] * prebleachAvg[i]);
roiPixelCounter++;
}
}
if (roiPixelCounter == 0) {
sigmaVal = 0;
} else {
sigmaVal = Math.sqrt(sigmaVal) / roiPixelCounter;
}
sigma[roiIdx][timeIdx - startIndexRecovery] = sigmaVal;
}
}
}
}
// }
return sigma;
}
use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.
the class FRAPStudy method getCartesianMesh.
public CartesianMesh getCartesianMesh() throws Exception {
CartesianMesh cartesianMesh = null;
ImageDataset imgDataSet = getFrapData().getImageDataset();
Extent extent = imgDataSet.getExtent();
ISize isize = imgDataSet.getISize();
Origin origin = new Origin(0, 0, 0);
if (getBioModel() == null) {
cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
} else {
RegionImage regionImage = getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().getRegionImage();
if (regionImage == null) {
getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().updateAll();
regionImage = getBioModel().getSimulationContexts()[0].getGeometry().getGeometrySurfaceDescription().getRegionImage();
}
cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
}
return cartesianMesh;
}
use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.
the class FRAPWorkspace method loadFRAPDataFromMultipleFiles.
public static FRAPStudy loadFRAPDataFromMultipleFiles(File[] inputFiles, ClientTaskStatusSupport clientTaskStatusSupport, boolean isTimeSeries, double timeInterval) throws Exception {
FRAPStudy newFrapStudy = new FRAPStudy();
FRAPData newFrapData = null;
newFrapStudy.setXmlFilename(null);
ImageDataset imageDataset;
imageDataset = ImageDatasetReaderService.getInstance().getImageDatasetReader().readImageDatasetFromMultiFiles(inputFiles, clientTaskStatusSupport, isTimeSeries, timeInterval);
newFrapData = new FRAPData(imageDataset, new String[] { FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name(), FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name(), FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name() });
newFrapStudy.setFrapData(newFrapData);
return newFrapStudy;
}
use of cbit.vcell.VirtualMicroscopy.ImageDataset in project vcell by virtualcell.
the class MicroscopyXmlReader method getFrapData.
/**
* 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 FRAPData getFrapData(Element param, ClientTaskStatusSupport progressListener) throws XmlParseException {
Element imageDatasetElement = param.getChild(MicroscopyXMLTags.ImageDatasetTag);
ImageDataset imageDataset = null;
if (imageDatasetElement != null) {
imageDataset = getImageDataset(imageDatasetElement, progressListener);
}
@SuppressWarnings("unchecked") List<Element> roiList = param.getChildren(MicroscopyXMLTags.ROITag);
ROI[] rois = null;
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);
FRAPData frapData = new FRAPData(imageDataset, reorderedROIs);
// After loading all the ROI rings, the progress should set to 100.
if (progressListener != null) {
progressListener.setProgress(100);
}
return frapData;
}
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 {
@SuppressWarnings("unchecked") 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