Search in sources :

Example 76 with UShortImage

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

the class FluorescenceNoiseTest method getUniformFluorescenceImage.

private UShortImage getUniformFluorescenceImage(ISize size, Extent extent, Origin origin, double mean) throws ImageException {
    ExponentialDistribution expDistribution = new ExponentialDistribution(mean);
    short[] shortPixels = new short[size.getXYZ()];
    for (int i = 0; i < shortPixels.length; i++) {
        // consider that we have unsigned short (must use 32 bit integer first)
        double sample = expDistribution.sample();
        if (sample > 65535) {
            sample = 65535;
            System.err.println("sample " + sample + " overflows 16 bit unsigned");
        }
        shortPixels[i] = (short) (0xffff & ((int) Math.round(sample)));
    }
    UShortImage rawImage = new UShortImage(shortPixels, origin, extent, size.getX(), size.getY(), size.getZ());
    return rawImage;
}
Also used : ExponentialDistribution(org.apache.commons.math3.distribution.ExponentialDistribution) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Example 77 with UShortImage

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

the class KenworthyWorkflowTest method generateFakeData.

private static ImageTimeSeries<UShortImage> generateFakeData(LocalWorkspace localWorkspace, ClientTaskStatusSupport progressListener) throws Exception {
    // 
    // technical simulation parameters
    // 
    double deltaX = 0.3;
    double outputTimeStep = 0.3;
    // 
    // circular 2D cell geometry
    // 
    double cellRadius = 50.0;
    String extracellularName = "ec";
    String cytosolName = "cytosol";
    // 
    // bleaching experimental protocol
    // 
    double bleachRadius = 1.5;
    double bleachDuration = 0.003;
    double bleachRate = 500.0;
    double postbleachDelay = 0.001;
    double postbleachDuration = 25.0;
    double psfSigma = 0.01;
    // 
    // underlying physiological model
    // 
    double primaryDiffusionRate = 2.0;
    double primaryFraction = 1.0;
    double bleachMonitorRate = 0.0000005;
    double secondaryDiffusionRate = 0.0;
    double secondaryFraction = 0.0;
    // 
    // generate corresponding BioModel with Application and Simulation ready for simulation.
    // 
    Context context = new Context() {

        @Override
        public User getDefaultOwner() {
            return LocalWorkspace.getDefaultOwner();
        }

        @Override
        public KeyValue createNewKeyValue() {
            return LocalWorkspace.createNewKeyValue();
        }
    };
    GeneratedModelResults results = new Generate2DExpModel_GaussianBleachOp().generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, context);
    Simulation simulation = results.simulation_2D;
    double bleachBlackoutStartTime = results.bleachBlackoutBeginTime;
    double bleachBlackoutStopTime = results.bleachBlackoutEndTime;
    // 
    // run simulation to get simulated fluorescence (with noise)
    // 
    boolean hasNoise = true;
    double maxIntensity = 60000.0;
    ImageTimeSeries<UShortImage> simulatedFluorescence = new RunFakeSimOp().runRefSimulation(localWorkspace, simulation, maxIntensity, bleachBlackoutStartTime, bleachBlackoutStopTime, hasNoise, progressListener);
    return simulatedFluorescence;
}
Also used : OptContext(org.vcell.vmicro.workflow.data.OptContext) Context(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.Context) RunFakeSimOp(org.vcell.vmicro.op.RunFakeSimOp) Simulation(cbit.vcell.solver.Simulation) GeneratedModelResults(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.GeneratedModelResults) Generate2DExpModel_GaussianBleachOp(org.vcell.vmicro.op.Generate2DExpModel_GaussianBleachOp) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Example 78 with UShortImage

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

the class KenworthyWorkflowTest 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");
        // File vfrapFile = new File(baseDir, "tryit.vfrap");
        ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
        analyzeKeyworthy(fluorTimeSeriesImages, localWorkspace);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) ProgressDialogListener(org.vcell.util.ProgressDialogListener) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport) ImportRawTimeSeriesFromVFrapOp(org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) File(java.io.File)

Example 79 with UShortImage

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

the class KenworthyParticleTest 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);
        // 
        // analyze raw data (from file?) using Keyworthy method.
        // 
        // File vfrapFile = new File(baseDir, "vfrapPaper/rawData/sim3/workflow.txt.save");
        File vfrapFile = new File(baseDir, "tryit.vfrap");
        ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
        RowColumnResultSet reducedData = new CSV().importFrom(new FileReader(new File(baseDir, "tryit.csv")));
        analyzeKeyworthy(fluorTimeSeriesImages, reducedData, localWorkspace);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : LocalWorkspace(org.vcell.vmicro.workflow.data.LocalWorkspace) CSV(cbit.vcell.math.CSV) ImportRawTimeSeriesFromVFrapOp(org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) FileReader(java.io.FileReader) File(java.io.File) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 80 with UShortImage

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

the class PhotoactivationExperimentTest method generateFakeData.

private static ImageTimeSeries<UShortImage> generateFakeData(LocalWorkspace localWorkspace, ClientTaskStatusSupport progressListener) throws Exception {
    // 
    // technical simulation parameters
    // 
    double deltaX = 0.3;
    double outputTimeStep = 0.3;
    // 
    // circular 2D cell geometry
    // 
    double cellRadius = 50.0;
    String extracellularName = "ec";
    String cytosolName = "cytosol";
    // 
    // bleaching experimental protocol
    // 
    double bleachRadius = 1.5;
    double bleachDuration = 0.003;
    double bleachRate = 500.0;
    double postbleachDelay = 0.001;
    double postbleachDuration = 25.0;
    double psfSigma = 0.01;
    // 
    // underlying physiological model
    // 
    double primaryDiffusionRate = 2.0;
    double primaryFraction = 1.0;
    double bleachMonitorRate = 0.0000005;
    double secondaryDiffusionRate = 0.0;
    double secondaryFraction = 0.0;
    // 
    // generate corresponding BioModel with Application and Simulation ready for simulation.
    // 
    Context context = new Context() {

        @Override
        public User getDefaultOwner() {
            return LocalWorkspace.getDefaultOwner();
        }

        @Override
        public KeyValue createNewKeyValue() {
            return LocalWorkspace.createNewKeyValue();
        }
    };
    GeneratedModelResults results = new Generate2DExpModel_GaussianBleachOp().generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, context);
    Simulation simulation = results.simulation_2D;
    double bleachBlackoutStartTime = results.bleachBlackoutBeginTime;
    double bleachBlackoutStopTime = results.bleachBlackoutEndTime;
    // 
    // run simulation to get simulated fluorescence (with noise)
    // 
    boolean hasNoise = true;
    double maxIntensity = 60000.0;
    ImageTimeSeries<UShortImage> simulatedFluorescence = new RunFakeSimOp().runRefSimulation(localWorkspace, simulation, maxIntensity, bleachBlackoutStartTime, bleachBlackoutStopTime, hasNoise, progressListener);
    return simulatedFluorescence;
}
Also used : OptContext(org.vcell.vmicro.workflow.data.OptContext) Context(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.Context) RunFakeSimOp(org.vcell.vmicro.op.RunFakeSimOp) Simulation(cbit.vcell.solver.Simulation) GeneratedModelResults(org.vcell.vmicro.op.Generate2DExpModelOpAbstract.GeneratedModelResults) Generate2DExpModel_GaussianBleachOp(org.vcell.vmicro.op.Generate2DExpModel_GaussianBleachOp) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

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