use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class FRAPStudy method getROIDataGenerator.
public ROIDataGenerator getROIDataGenerator(LocalWorkspace localWorkspace) {
// create ROI image
short[] roiFieldData = null;
ROI[] rois = getFrapData().getRois();
if (rois.length > 0) {
Extent extent = rois[0].getRoiImages()[0].getExtent();
ISize isize = rois[0].getISize();
int numROIX = rois[0].getISize().getX();
int numROIY = rois[0].getISize().getY();
roiFieldData = new short[numROIX * numROIY];
short regionCounter = 1;
for (int roiIdx = FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.ordinal(); roiIdx < rois.length; roiIdx++) {
short[] roiImg = rois[roiIdx].getPixelsXYZ();
for (int pixelIdx = 0; pixelIdx < (numROIX * numROIY); pixelIdx++) {
if (roiImg[pixelIdx] > 0) {
roiFieldData[pixelIdx] = regionCounter;
}
}
regionCounter++;
}
// create field data
int NumTimePoints = 1;
// 8 rois integrated into 1 image
int NumChannels = 1;
short[][][] pixData = new short[NumTimePoints][NumChannels][];
pixData[0][0] = roiFieldData;
// get extental data id
ExternalDataIdentifier newROIExtDataID = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_SUMDATA_NAME).getExternalDataIdentifier();
CartesianMesh cartesianMesh;
try {
cartesianMesh = getCartesianMesh();
Origin origin = new Origin(0, 0, 0);
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = cartesianMesh;
fdos.shortSpecData = pixData;
fdos.specEDI = newROIExtDataID;
fdos.varNames = new String[] { "roiSumDataVar" };
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);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new ROIDataGenerator(ROI_EXTDATA_NAME, /*name*/
new int[] { 0 }, /* volumePoints*/
new int[0], /* membranePoints*/
regionCounter, /*numRegions*/
0, /*zSlice*/
newROIExtDataID.getKey(), /* fieldDataKey, sample image*/
new FieldFunctionArguments(FRAPStudy.ROI_SUMDATA_NAME, "roiSumDataVar", new Expression(0), VariableType.VOLUME), /*FieldFunctionArguments, sample image*/
false);
}
return null;
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class NonGUIFRAPTest method checkExternalDataSameAsOriginal.
private static void checkExternalDataSameAsOriginal(FRAPStudy frapStudy, String testDirectoryPath) throws Exception {
ImageDataset imageDataset = frapStudy.getFrapData().getImageDataset();
ROI cellROI = frapStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name());
ROI bleachROI = frapStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name());
ROI backgroundROI = frapStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name());
// FileInputStream fis = new FileInputStream(getCanonicalFilename(testDirectoryPath, null));
// BufferedInputStream bis = new BufferedInputStream(fis);
// ZipInputStream zis = new ZipInputStream(bis);
// ZipEntry zipEntry = null;
// int timeIndex = 0;
// while((zipEntry =zis.getNextEntry()) != null){
// byte[] timePointData = new byte[(int)zipEntry.getSize()];
// int offset = 0;
// while((offset+= zis.read(timePointData,offset,timePointData.length-offset)) != timePointData.length){}
// short[] shortPixels = imageDataset.getImage(0, 0, timeIndex).getPixels();
// checkPixels(shortPixels, timePointData);
// timeIndex++;
// }
// zis.close();
ExternalDataFileContents extDataFileContents = readExternalDataContents(getCanonicalFilename(testDirectoryPath, null).getAbsolutePath(), getCanonicalFilename(testDirectoryPath, FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).getAbsolutePath(), getCanonicalFilename(testDirectoryPath, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).getAbsolutePath(), getCanonicalFilename(testDirectoryPath, FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name()).getAbsolutePath());
ImageDataset imageData = extDataFileContents.imageData;
UShortImage[] allIDiskmages = imageData.getAllImages();
UShortImage[] allIFrapmages = imageDataset.getAllImages();
if (allIDiskmages.length != allIFrapmages.length) {
throw new Exception("different number of times");
}
for (int i = 0; i < allIDiskmages.length; i++) {
short[] allDiskPixels = allIDiskmages[i].getPixels();
short[] allFrapPixels = allIFrapmages[i].getPixels();
checkPixels(allDiskPixels, allFrapPixels);
}
checkPixels(extDataFileContents.cellROIData.getPixelsZ(0, 0), cellROI.getPixelsXYZ());
checkPixels(extDataFileContents.bleachROIData.getPixelsZ(0, 0), bleachROI.getPixelsXYZ());
checkPixels(extDataFileContents.backgroundROIData.getPixelsZ(0, 0), backgroundROI.getPixelsXYZ());
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class AnnotatedImageDataset method setCurrentlyDisplayedROI.
public void setCurrentlyDisplayedROI(ROI argCurrentlyDisplayedROI, boolean bSave) {
ROI oldDisplayedROI = this.currentlyDisplayedROI;
this.currentlyDisplayedROI = argCurrentlyDisplayedROI;
if (bSave) {
propertyChangeSupport.firePropertyChange(FRAPSingleWorkspace.PROPERTY_CHANGE_CURRENTLY_DISPLAYED_ROI_WITH_SAVE, oldDisplayedROI, currentlyDisplayedROI);
} else {
propertyChangeSupport.firePropertyChange(FRAPSingleWorkspace.PROPERTY_CHANGE_CURRENTLY_DISPLAYED_ROI_WITHOUT_SAVE, oldDisplayedROI, currentlyDisplayedROI);
}
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class FRAPData method refreshDependentROIs.
protected void refreshDependentROIs() {
UShortImage cellROI_2D = null;
UShortImage bleachedROI_2D = null;
UShortImage dilatedROI_2D_1 = null;
UShortImage dilatedROI_2D_2 = null;
UShortImage dilatedROI_2D_3 = null;
UShortImage dilatedROI_2D_4 = null;
UShortImage dilatedROI_2D_5 = null;
UShortImage erodedROI_2D_0 = null;
UShortImage erodedROI_2D_1 = null;
UShortImage erodedROI_2D_2 = null;
try {
cellROI_2D = convertToUShortImage(binarize(getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).getRoiImages()[0]), getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).getRoiImages()[0].getOrigin(), getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()).getRoiImages()[0].getExtent());
bleachedROI_2D = convertToUShortImage(AndDescriptor.create(binarize(getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).getRoiImages()[0]), binarize(cellROI_2D), null).createInstance(), getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).getRoiImages()[0].getOrigin(), getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name()).getRoiImages()[0].getExtent());
// writeUShortFile(cellROI_2D, new File("D:\\developer\\eclipse\\workspace\\cellROI_2D.bmp"));
// writeUShortFile(bleachedROI_2D, new File("D:\\developer\\eclipse\\workspace\\bleachedROI_2D.bmp"));
dilatedROI_2D_1 = fastDilate(bleachedROI_2D, 4, cellROI_2D);
// erodeDilate(bleachedROI_2D, createCircularBinaryKernel(8), cellROI_2D,false);
dilatedROI_2D_2 = fastDilate(bleachedROI_2D, 10, cellROI_2D);
// erodeDilate(bleachedROI_2D, createCircularBinaryKernel(16), cellROI_2D,false);
dilatedROI_2D_3 = fastDilate(bleachedROI_2D, 18, cellROI_2D);
// erodeDilate(bleachedROI_2D, createCircularBinaryKernel(24), cellROI_2D,false);
dilatedROI_2D_4 = fastDilate(bleachedROI_2D, 28, cellROI_2D);
// erodeDilate(bleachedROI_2D, createCircularBinaryKernel(32), cellROI_2D,false);
dilatedROI_2D_5 = fastDilate(bleachedROI_2D, 40, cellROI_2D);
// erodeDilate(bleachedROI_2D, createCircularBinaryKernel(40), cellROI_2D,false);
erodedROI_2D_0 = new UShortImage(bleachedROI_2D);
// The erode always causes problems if eroding without checking the bleached length and hight.
// we have to check the min length of the bleahed area to make sure erode within the length.
Rectangle bleachRect = bleachedROI_2D.getNonzeroBoundingBox();
int minLen = Math.min(bleachRect.height, bleachRect.width);
if ((minLen / 2.0) < 5) {
erodedROI_2D_1 = erodeDilate(bleachedROI_2D, createCircularBinaryKernel(1), bleachedROI_2D, true);
erodedROI_2D_2 = erodeDilate(bleachedROI_2D, createCircularBinaryKernel(2), bleachedROI_2D, true);
} else {
erodedROI_2D_1 = erodeDilate(bleachedROI_2D, createCircularBinaryKernel(2), bleachedROI_2D, true);
erodedROI_2D_2 = erodeDilate(bleachedROI_2D, createCircularBinaryKernel(5), bleachedROI_2D, true);
}
UShortImage reverseErodeROI_2D_1 = new UShortImage(erodedROI_2D_1);
reverseErodeROI_2D_1.reverse();
erodedROI_2D_0.and(reverseErodeROI_2D_1);
UShortImage reverseErodeROI_2D_2 = new UShortImage(erodedROI_2D_2);
reverseErodeROI_2D_2.reverse();
erodedROI_2D_1.and(reverseErodeROI_2D_2);
UShortImage reverseDilateROI_2D_4 = new UShortImage(dilatedROI_2D_4);
reverseDilateROI_2D_4.reverse();
dilatedROI_2D_5.and(reverseDilateROI_2D_4);
UShortImage reverseDilateROI_2D_3 = new UShortImage(dilatedROI_2D_3);
// writeUShortFile(dilatedROI_2D_3, new File("D:\\developer\\eclipse\\workspace\\dilatedROI_2D_3.bmp"));
reverseDilateROI_2D_3.reverse();
// writeUShortFile(reverseDilateROI_2D_3, new File("D:\\developer\\eclipse\\workspace\\dilatedROI_2D_3_reverse.bmp"));
// writeUShortFile(dilatedROI_2D_4, new File("D:\\developer\\eclipse\\workspace\\dilatedROI_2D_4.bmp"));
dilatedROI_2D_4.and(reverseDilateROI_2D_3);
// writeUShortFile(dilatedROI_2D_4, new File("D:\\developer\\eclipse\\workspace\\dilatedROI_2D_4_anded.bmp"));
UShortImage reverseDilateROI_2D_2 = new UShortImage(dilatedROI_2D_2);
reverseDilateROI_2D_2.reverse();
dilatedROI_2D_3.and(reverseDilateROI_2D_2);
UShortImage reverseDilateROI_2D_1 = new UShortImage(dilatedROI_2D_1);
reverseDilateROI_2D_1.reverse();
dilatedROI_2D_2.and(reverseDilateROI_2D_1);
UShortImage reverseBleach_2D = new UShortImage(bleachedROI_2D);
reverseBleach_2D.reverse();
dilatedROI_2D_1.and(reverseBleach_2D);
} catch (ImageException e) {
e.printStackTrace(System.out);
}
ROI roiBleachedRing1_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name());
if (roiBleachedRing1_2D == null) {
roiBleachedRing1_2D = new ROI(erodedROI_2D_2, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name());
addReplaceRoi(roiBleachedRing1_2D);
} else {
System.arraycopy(erodedROI_2D_2.getPixels(), 0, roiBleachedRing1_2D.getRoiImages()[0].getPixels(), 0, erodedROI_2D_2.getPixels().length);
}
ROI roiBleachedRing2_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name());
if (roiBleachedRing2_2D == null) {
roiBleachedRing2_2D = new ROI(erodedROI_2D_1, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name());
addReplaceRoi(roiBleachedRing2_2D);
} else {
System.arraycopy(erodedROI_2D_1.getPixels(), 0, roiBleachedRing2_2D.getRoiImages()[0].getPixels(), 0, erodedROI_2D_1.getPixels().length);
}
ROI roiBleachedRing3_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name());
if (roiBleachedRing3_2D == null) {
roiBleachedRing3_2D = new ROI(erodedROI_2D_0, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name());
addReplaceRoi(roiBleachedRing3_2D);
} else {
System.arraycopy(erodedROI_2D_0.getPixels(), 0, roiBleachedRing3_2D.getRoiImages()[0].getPixels(), 0, erodedROI_2D_0.getPixels().length);
}
ROI roiBleachedRing4_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name());
if (roiBleachedRing4_2D == null) {
roiBleachedRing4_2D = new ROI(dilatedROI_2D_1, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name());
addReplaceRoi(roiBleachedRing4_2D);
} else {
System.arraycopy(dilatedROI_2D_1.getPixels(), 0, roiBleachedRing4_2D.getRoiImages()[0].getPixels(), 0, dilatedROI_2D_1.getPixels().length);
}
ROI roiBleachedRing5_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name());
if (roiBleachedRing5_2D == null) {
roiBleachedRing5_2D = new ROI(dilatedROI_2D_2, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name());
addReplaceRoi(roiBleachedRing5_2D);
} else {
System.arraycopy(dilatedROI_2D_2.getPixels(), 0, roiBleachedRing5_2D.getRoiImages()[0].getPixels(), 0, dilatedROI_2D_2.getPixels().length);
}
ROI roiBleachedRing6_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name());
if (roiBleachedRing6_2D == null) {
roiBleachedRing6_2D = new ROI(dilatedROI_2D_3, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name());
addReplaceRoi(roiBleachedRing6_2D);
} else {
System.arraycopy(dilatedROI_2D_3.getPixels(), 0, roiBleachedRing6_2D.getRoiImages()[0].getPixels(), 0, dilatedROI_2D_3.getPixels().length);
}
ROI roiBleachedRing7_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name());
if (roiBleachedRing7_2D == null) {
roiBleachedRing7_2D = new ROI(dilatedROI_2D_4, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name());
addReplaceRoi(roiBleachedRing7_2D);
} else {
System.arraycopy(dilatedROI_2D_4.getPixels(), 0, roiBleachedRing7_2D.getRoiImages()[0].getPixels(), 0, dilatedROI_2D_4.getPixels().length);
}
ROI roiBleachedRing8_2D = getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name());
if (roiBleachedRing8_2D == null) {
roiBleachedRing8_2D = new ROI(dilatedROI_2D_5, FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name());
addReplaceRoi(roiBleachedRing8_2D);
} else {
System.arraycopy(dilatedROI_2D_5.getPixels(), 0, roiBleachedRing8_2D.getRoiImages()[0].getPixels(), 0, dilatedROI_2D_5.getPixels().length);
}
}
use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.
the class DefineROI_RoiForErrorPanel method refreshROIImage.
public void refreshROIImage() {
FRAPData frapData = frapWorkspace.getWorkingFrapStudy().getFrapData();
ROI[] allROIs = getAllROIs();
Color[] allColors = getAllROIColors();
ArrayList<ROI> plottedROIs = new ArrayList<ROI>();
ArrayList<Color> plottedColors = new ArrayList<Color>();
ArrayList<String> tempSelectedROIs = new ArrayList<String>();
if (roi_bleachedCheckBox.isEnabled() && roi_bleachedCheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED]);
plottedColors.add(allColors[IDX_ROI_BLEACHED]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name());
}
if (roi_bleached_ring1CheckBox.isEnabled() && roi_bleached_ring1CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING1]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING1]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name());
}
if (roi_bleached_ring2CheckBox.isEnabled() && roi_bleached_ring2CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING2]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING2]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name());
}
if (roi_bleached_ring3CheckBox.isEnabled() && roi_bleached_ring3CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING3]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING3]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name());
}
if (roi_bleached_ring4CheckBox.isEnabled() && roi_bleached_ring4CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING4]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING4]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name());
}
if (roi_bleached_ring5CheckBox.isEnabled() && roi_bleached_ring5CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING5]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING5]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name());
}
if (roi_bleached_ring6CheckBox.isEnabled() && roi_bleached_ring6CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING6]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING6]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name());
}
if (roi_bleached_ring7CheckBox.isEnabled() && roi_bleached_ring7CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING7]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING7]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name());
}
if (roi_bleached_ring8CheckBox.isEnabled() && roi_bleached_ring8CheckBox.isSelected()) {
plottedROIs.add(allROIs[IDX_ROI_BLEACHED_RING8]);
plottedColors.add(allColors[IDX_ROI_BLEACHED_RING8]);
tempSelectedROIs.add(FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name());
}
// save selected ROI names
refreshSelectedROIs(tempSelectedROIs);
// show ROI image
ROI[] plottedROIArray = new ROI[plottedROIs.size()];
plottedROIArray = plottedROIs.toArray(plottedROIArray);
Color[] plottedColorArray = new Color[plottedColors.size()];
plottedColorArray = plottedColors.toArray(plottedColorArray);
roiImagePanel.refreshROIImage(plottedROIArray, plottedColorArray, frapData.getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()), Color.white);
}
Aggregations