Search in sources :

Example 16 with UShortImage

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

the class ROIAssistPanel method resolveCurrentROI.

private void resolveCurrentROI() {
    final String CELL_ROI = "CELL_ROI";
    AsynchClientTask keepRegionsTask = new AsynchClientTask("Pick Region", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // TODO Auto-generated method stub
            RegionInfo[] keepRegionInfos = pickKeepRegionInfoFromCurrentROI();
            if (keepRegionInfos == null) {
                throw UserCancelException.CANCEL_GENERIC;
            }
            // dataToThreshold.getCurrentlyDisplayedROI().getPixelsXYZ();
            short[] keepPixels = new short[dataToThreshold.getCurrentlyDisplayedROI().getISize().getXYZ()];
            for (int i = 0; i < keepPixels.length; i++) {
                for (int j = 0; j < keepRegionInfos.length; j++) {
                    if (keepRegionInfos[j].isIndexInRegion(i)) {
                        keepPixels[i] = 1;
                    }
                }
            }
            UShortImage ushortImage = new UShortImage(keepPixels, originalROI.getRoiImages()[0].getOrigin(), originalROI.getRoiImages()[0].getExtent(), originalROI.getISize().getX(), originalROI.getISize().getY(), originalROI.getISize().getZ());
            ROI newCellROI = new ROI(ushortImage, originalROI.getROIName());
            hashTable.put(CELL_ROI, newCellROI);
        }
    };
    AsynchClientTask updateDisplayTask = new AsynchClientTask("Updating display", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            dataToThreshold.addReplaceRoi((ROI) hashTable.get(CELL_ROI));
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { keepRegionsTask, updateDisplayTask }, false, false, null, true);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) RegionInfo(cbit.vcell.geometry.RegionImage.RegionInfo) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 17 with UShortImage

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

the class ROIMultiPaintManager method initImageDataSet.

private void initImageDataSet(short[][] dataToSegmentChannels, ISize uncroppedISize) throws Exception {
    initImageDataSetChannels = new ImageDataset[(dataToSegmentChannels != null ? dataToSegmentChannels.length : 1)];
    for (int c = 0; c < initImageDataSetChannels.length; c++) {
        UShortImage[] zImageSet = new UShortImage[uncroppedISize.getZ()];
        for (int i = 0; i < zImageSet.length; i++) {
            short[] shortData = new short[uncroppedISize.getX() * uncroppedISize.getY()];
            if (dataToSegmentChannels != null) {
                System.arraycopy(dataToSegmentChannels[c], shortData.length * i, shortData, 0, shortData.length);
            }
            zImageSet[i] = new UShortImage(shortData, DEFAULT_ORIGIN, DEFAULT_EXTENT, uncroppedISize.getX(), uncroppedISize.getY(), 1);
        }
        initImageDataSetChannels[c] = new ImageDataset(zImageSet, new double[] { 0.0 }, uncroppedISize.getZ());
    }
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 18 with UShortImage

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

the class ROIMultiPaintManager method calculateAllPixelValuesRangeChannels0.

private static OverlayEditorPanelJAI.AllPixelValuesRange[] calculateAllPixelValuesRangeChannels0(ImageDataset[] sourceImageDatasetChannels) {
    OverlayEditorPanelJAI.AllPixelValuesRange[] pixelValuesRangeChannels = new OverlayEditorPanelJAI.AllPixelValuesRange[sourceImageDatasetChannels.length];
    for (int c = 0; c < sourceImageDatasetChannels.length; c++) {
        UShortImage[] allImages = sourceImageDatasetChannels[c].getAllImages();
        double min = 0;
        double max = min;
        for (int i = 0; i < allImages.length; i++) {
            ImageStatistics imageStats = allImages[i].getImageStatistics();
            if (i == 0 || imageStats.minValue < min) {
                min = imageStats.minValue;
            }
            if (i == 0 || imageStats.maxValue > max) {
                max = imageStats.maxValue;
            }
        }
        pixelValuesRangeChannels[c] = new OverlayEditorPanelJAI.AllPixelValuesRange((int) min, (int) max);
    }
    return pixelValuesRangeChannels;
}
Also used : ImageStatistics(cbit.vcell.VirtualMicroscopy.Image.ImageStatistics) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 19 with UShortImage

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

the class FluorescenceNoiseTest method testBrownianDynamics.

private void testBrownianDynamics() throws ImageException {
    Origin origin = new Origin(0, 0, 0);
    Extent extent = new Extent(10, 10, 1);
    double psfVar = 0.25 * 0.25;
    // typically 10000 or 100000;
    int numParticles = 10000;
    double diffusionRate = 1;
    double bleachRadius = 0.25;
    final double bleachAmplitude = 0.5;
    final double bleachRadius2 = bleachRadius * bleachRadius;
    double endTime = 10;
    int numTimes = 1000;
    final BrownianDynamics2DSolver solver = new BrownianDynamics2DSolver(origin, extent, numParticles);
    boolean initiallyFluorescent = true;
    solver.initializeUniform(initiallyFluorescent);
    double totalBleachTime = 0.00001;
    int numBleachSteps = 1;
    double bleachCenterX = origin.getX() + 0.5 * extent.getX();
    double bleachCenterY = origin.getY() + 0.5 * extent.getY();
    double bleachPsfVariance = psfVar;
    double bleachFactor_K = 1000000;
    solver.bleachGuassian(diffusionRate, totalBleachTime, numBleachSteps, bleachCenterX, bleachCenterY, bleachPsfVariance, bleachFactor_K);
    // ParticleVisitor bleachGaussian = new ParticleVisitor() {
    // UniformRealDistribution uniform = new UniformRealDistribution();
    // 
    // @Override
    // public void visit(double x, double y, boolean bFluorescent, int index) {
    // // TODO Auto-generated method stub
    // double radius2 = x*x + y*y;
    // double bleachProb = bleachAmplitude * FastMath.exp(-radius2/bleachRadius2);
    // if (uniform.sample() < bleachProb){
    // solver.setFluorescence(index,false);
    // }else{
    // solver.setFluorescence(index,true);
    // }
    // }
    // };
    // solver.visit(bleachGaussian);
    double totalSampleTime = 0.1;
    int numSampleSteps = 1;
    double samplePsfVariance = psfVar;
    double detectorGainAndQuantumYeild = 100;
    boolean bNoise = true;
    boolean bConvolve = true;
    UShortImage sampledImage = solver.sampleImage(100, 100, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, samplePsfVariance, detectorGainAndQuantumYeild, bConvolve, bNoise);
    new DisplayImageOp().displayImage(sampledImage, "initialBleach", null);
}
Also used : Origin(org.vcell.util.Origin) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) Extent(org.vcell.util.Extent) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BrownianDynamics2DSolver(org.vcell.vmicro.op.BrownianDynamics2DSolver)

Example 20 with UShortImage

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

the class VFrapProcess method main.

public static void main(String[] args) {
    try {
        File baseDir = new File(".");
        // File baseDir = new File("/Users/schaff/Documents/workspace/VCell_5.4");
        // initialize computing environment
        // 
        File workingDirectory = new File(baseDir, "workingDir");
        LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
        // 
        // import raw image time series data from VFRAP file format (can have noise, background, etc ... can be actual microscopy data)
        // 
        ClientTaskStatusSupport progressListener = new ClientTaskStatusSupport() {

            String message = "";

            int progress = 0;

            @Override
            public void setProgress(int progress) {
                this.progress = progress;
            }

            @Override
            public void setMessage(String message) {
                this.message = message;
            }

            @Override
            public boolean isInterrupted() {
                return false;
            }

            @Override
            public int getProgress() {
                return progress;
            }

            @Override
            public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
            }
        };
        // 
        // generate fake data (and save?)
        // 
        // ImageTimeSeries<UShortImage> simulatedFluorescence = generateFakeData(localWorkspace, progressListener);
        // new ExportRawTimeSeriesToVFrapOp().exportToVFRAP(vfrapFile, simulatedFluorescence, null);
        // 
        // analyze raw data (from file?) using Keyworthy method.
        // 
        File vfrapFile = new File(baseDir, "vfrapPaper/rawData/sim3/workflow.txt.save");
        ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
        VFrapProcessResults results = compute(fluorTimeSeriesImages, 0.85, 0.4, localWorkspace, progressListener);
        new DisplayTimeSeriesOp().displayImageTimeSeries(fluorTimeSeriesImages, "raw data", null);
        new DisplayImageOp().displayImage(results.cellROI_2D.getRoiImages()[0], "cell ROI", null);
        new DisplayImageOp().displayImage(results.bleachROI_2D.getRoiImages()[0], "bleach ROI", null);
        new DisplayDependentROIsOp().displayDependentROIs(results.imageDataROIs, results.cellROI_2D, "data rois", null);
        new DisplayTimeSeriesOp().displayImageTimeSeries(results.normalizedTimeSeries, "normalized data", null);
        new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(results.profileDataOne, "one fluorescent pool", null);
        new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(results.profileDataTwoWithPenalty, "too pools", null);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : DisplayProfileLikelihoodPlotsOp(org.vcell.vmicro.op.display.DisplayProfileLikelihoodPlotsOp) LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) ProgressDialogListener(org.vcell.util.ProgressDialogListener) DisplayTimeSeriesOp(org.vcell.vmicro.op.display.DisplayTimeSeriesOp) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport) ImportRawTimeSeriesFromVFrapOp(org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp) DisplayDependentROIsOp(org.vcell.vmicro.op.display.DisplayDependentROIsOp) File(java.io.File)

Aggregations

UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)98 ROI (cbit.vcell.VirtualMicroscopy.ROI)26 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)20 Point (java.awt.Point)16 File (java.io.File)14 Extent (org.vcell.util.Extent)13 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)12 Origin (org.vcell.util.Origin)10 ImageException (cbit.image.ImageException)9 Element (org.jdom.Element)9 DataBufferByte (java.awt.image.DataBufferByte)8 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)7 ArrayList (java.util.ArrayList)7 ISize (org.vcell.util.ISize)7 FloatImage (cbit.vcell.VirtualMicroscopy.FloatImage)6 ClientTaskStatusSupport (org.vcell.util.ClientTaskStatusSupport)6 UserCancelException (org.vcell.util.UserCancelException)6 ProfileDataElement (org.vcell.optimization.ProfileDataElement)5 ImportRawTimeSeriesFromVFrapOp (org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp)5 OptContext (org.vcell.vmicro.workflow.data.OptContext)5