Search in sources :

Example 11 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class ClientRequestManager method getDataManager.

/**
 * Insert the method's description here.
 * Creation date: (6/11/2004 10:53:47 AM)
 * @return cbit.vcell.desktop.controls.DataManager
 * @param vcDataIdentifier cbit.vcell.server.VCDataIdentifier
 */
public DataManager getDataManager(OutputContext outputContext, VCDataIdentifier vcDataId, boolean isSpatial) throws DataAccessException {
    // 
    // Create ODE or PDE or Merged Datamanager depending on ODE or PDE or Merged data.
    // 
    DataManager dataManager = null;
    VCDataManager vcDataManager = getClientServerManager().getVCDataManager();
    if (isSpatial) {
        dataManager = new PDEDataManager(outputContext, vcDataManager, vcDataId);
    } else {
        dataManager = new ODEDataManager(outputContext, vcDataManager, vcDataId);
    }
    // dataManager.connect();
    return dataManager;
}
Also used : PDEDataManager(cbit.vcell.simdata.PDEDataManager) VCDataManager(cbit.vcell.simdata.VCDataManager) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) VCDataManager(cbit.vcell.simdata.VCDataManager)

Example 12 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class NonGUIFRAPTest method runSolver.

/**
 * @param args
 */
public static void runSolver(String[] args) throws Exception {
    String startingIndexForRecovery = args[0];
    String freeDiffusionRateStr = args[1];
    String freeMobileFractionStr = args[2];
    String complexDiffusionRateStr = args[3];
    String complexMobileFractionStr = args[4];
    String bleachWhileMonitoringRateString = args[5];
    String immobileFractionStr = args[6];
    String bindingSiteConcentrationStr = args[7];
    String reacOnRateStr = args[8];
    String reacOffRateStr = args[9];
    String workingDirectoryPath = args[10];
    String inputFRAPDataFileName = args[11];
    String inputCellROIFileName = args[12];
    String inputBleachROIFileName = args[13];
    String inputBackgroundROIFileName = args[14];
    String outputXMLFileName = args[15];
    String commaSepTimeStamps = args[16];
    String commaSepExtentXYZ = args[17];
    LocalWorkspace localWorkspace = new LocalWorkspace(new File(workingDirectoryPath));
    ExternalDataFileContents extDataFileContents = readExternalDataContents(inputFRAPDataFileName, inputCellROIFileName, inputBleachROIFileName, inputBackgroundROIFileName);
    ROI cellROI = new ROI(extDataFileContents.cellROIData.getImage(0, 0, 0), FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name());
    ROI bleachROI = new ROI(extDataFileContents.bleachROIData.getImage(0, 0, 0), FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.name());
    ROI backgroundROI = new ROI(extDataFileContents.backgroundROIData.getImage(0, 0, 0), FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name());
    // Insert Time information
    double[] timeStamps = new double[extDataFileContents.imageData.getAllImages().length];
    StringTokenizer commaStringTokenizer = new StringTokenizer(commaSepTimeStamps, ",");
    int timeCount = 0;
    while (commaStringTokenizer.hasMoreTokens()) {
        timeStamps[timeCount] = Double.parseDouble(commaStringTokenizer.nextToken());
        timeCount++;
    }
    ImageDataset frapDataImageDataSet = new ImageDataset(extDataFileContents.imageData.getAllImages(), timeStamps, 1);
    // Insert Extent information
    commaStringTokenizer = new StringTokenizer(commaSepExtentXYZ, ",");
    Extent extent = new Extent(Double.parseDouble(commaStringTokenizer.nextToken()), Double.parseDouble(commaStringTokenizer.nextToken()), Double.parseDouble(commaStringTokenizer.nextToken()));
    frapDataImageDataSet.setExtent(extent);
    bleachROI.getRoiImages()[0].setExtent(extent);
    cellROI.getRoiImages()[0].setExtent(extent);
    backgroundROI.getRoiImages()[0].setExtent(extent);
    FRAPData frapData = FrapDataUtils.importFRAPDataFromImageDataSet(frapDataImageDataSet);
    frapData.addReplaceRoi(bleachROI);
    frapData.addReplaceRoi(cellROI);
    frapData.addReplaceRoi(backgroundROI);
    FRAPStudy frapStudy = new FRAPStudy();
    frapStudy.setFrapData(frapData);
    // old model parameters, need to rewrite
    // FRAPStudy.FRAPModelParameters frapModelParameters = new FRAPStudy.FRAPModelParameters(
    // new FRAPStudy.InitialModelParameters(freeDiffusionRateStr, freeMobileFractionStr, bleachWhileMonitoringRateString, startingIndexForRecovery),
    // null,
    // null);
    // frapStudy.setFrapModelParameters(frapModelParameters);
    frapStudy.refreshDependentROIs();
    ExternalDataInfo imageDatasetExternalDataInfo = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.IMAGE_EXTDATA_NAME);
    ExternalDataInfo roiExternalDataInfo = FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_EXTDATA_NAME);
    frapStudy.setFrapDataExternalDataInfo(imageDatasetExternalDataInfo);
    frapStudy.setRoiExternalDataInfo(roiExternalDataInfo);
    frapStudy.saveImageDatasetAsExternalData(localWorkspace, frapStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
    frapStudy.saveROIsAsExternalData(localWorkspace, frapStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
    // Double bleachWhileMonitoringRate =
    // (!bleachWhileMonitoringRateString.equals("-")
    // ?Double.parseDouble(bleachWhileMonitoringRateString)
    // :null);
    double fd, ff, bwmr, cd, cf, imf, bs, on, off;
    try {
        fd = Double.parseDouble(freeDiffusionRateStr);
        ff = Double.parseDouble(freeMobileFractionStr);
        bwmr = Double.parseDouble(bleachWhileMonitoringRateString);
        cd = Double.parseDouble(complexDiffusionRateStr);
        cf = Double.parseDouble(complexMobileFractionStr);
        imf = Double.parseDouble(immobileFractionStr);
        bs = Double.parseDouble(bindingSiteConcentrationStr);
        on = Double.parseDouble(reacOnRateStr);
        off = Double.parseDouble(reacOffRateStr);
    } catch (NumberFormatException e) {
        throw new Exception("Input parameters are not all valid. Check if they are empty or in illegal forms.");
    }
    BioModel bioModel = FRAPStudy.createNewSimBioModel(frapStudy, createParameterArray(fd, ff, bwmr, cd, cf, imf, bs, on, off), null, LocalWorkspace.createNewKeyValue(), LocalWorkspace.getDefaultOwner(), new Integer(frapStudy.getStartingIndexForRecovery()));
    frapStudy.setBioModel(bioModel);
    // no progress listener, need to change
    MicroscopyXmlproducer.writeXMLFile(frapStudy, new File(outputXMLFileName), true, null, false);
    FRAPStudy.runFVSolverStandalone(new File(localWorkspace.getDefaultSimDataDirectory()), bioModel.getSimulation(0), imageDatasetExternalDataInfo.getExternalDataIdentifier(), roiExternalDataInfo.getExternalDataIdentifier(), null);
    VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(bioModel.getSimulations()[0].getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), FieldDataFileOperationSpec.JOBINDEX_DEFAULT);
    PDEDataManager simulationDataManager = new PDEDataManager(null, localWorkspace.getVCDataManager(), vcSimulationDataIdentifier);
    double[] frapDataTimeStamps = frapData.getImageDataset().getImageTimeStamps();
    VCDataManager testVCDataManager = localWorkspace.getVCDataManager();
    double[] prebleachAverage = testVCDataManager.getSimDataBlock(null, frapStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), "prebleach_avg", 0).getData();
    // TODO: need to create parameters here.
    Parameter[] parameters = null;
    SpatialAnalysisResults spatialAnalysisResults = FRAPStudy.spatialAnalysis(simulationDataManager, new Integer(frapStudy.getStartingIndexForRecovery()), frapDataTimeStamps[new Integer(frapStudy.getStartingIndexForRecovery())], parameters, frapData, prebleachAverage);
    dumpSummaryReport(spatialAnalysisResults, frapDataTimeStamps, new Integer(startingIndexForRecovery).intValue(), new File(workingDirectoryPath, "nonguiSpatialResults.txt"));
    dumpSpatialResults(spatialAnalysisResults, frapDataTimeStamps, new File(workingDirectoryPath, "nonguiSpatialResults.txt"));
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Extent(org.vcell.util.Extent) ROI(cbit.vcell.VirtualMicroscopy.ROI) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) StringTokenizer(java.util.StringTokenizer) PDEDataManager(cbit.vcell.simdata.PDEDataManager) BioModel(cbit.vcell.biomodel.BioModel) Parameter(cbit.vcell.opt.Parameter) File(java.io.File) VCDataManager(cbit.vcell.simdata.VCDataManager)

Example 13 with PDEDataManager

use of cbit.vcell.simdata.PDEDataManager in project vcell by virtualcell.

the class DisplayTimeSeries method displayImageTimeSeries.

public static void displayImageTimeSeries(final ImageTimeSeries<Image> imageTimeSeries, String title, WindowListener windowListener) throws ImageException, IOException {
    ISize size = imageTimeSeries.getISize();
    int dimension = (size.getZ() > 0) ? (3) : (2);
    Extent extent = imageTimeSeries.getExtent();
    Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
    // don't care ... no surfaces
    double filterCutoffFrequency = 0.5;
    VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
    RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
    final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
    final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
    final DataSetController dataSetController = new DataSetController() {

        @Override
        public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
            double timePoint = time;
            double[] timePoints = getDataSetTimes(vcdataID);
            int index = -1;
            for (int i = 0; i < timePoints.length; i++) {
                if (timePoint == timePoints[i]) {
                    index = i;
                    break;
                }
            }
            double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
            PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
            VariableType varType = VariableType.VOLUME;
            return new SimDataBlock(pdeDataInfo, data, varType);
        }

        @Override
        public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return false;
        }

        @Override
        public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return mesh;
        }

        @Override
        public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return new AnnotatedFunction[0];
        }

        @Override
        public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return imageTimeSeries.getImageTimeStamps();
        }

        @Override
        public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return new DataIdentifier[] { dataIdentifier };
        }

        @Override
        public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {

        @Override
        public DataSetController getDataSetController() throws DataAccessException {
            return dataSetController;
        }
    };
    VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
    OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
    VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {

        public User getOwner() {
            return new User("nouser", null);
        }

        public KeyValue getDataKey() {
            return null;
        }

        public String getID() {
            return "mydata";
        }
    };
    PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
    ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
    PDEDataViewer pdeDataViewer = new PDEDataViewer();
    JFrame jframe = new JFrame();
    jframe.setTitle(title);
    jframe.getContentPane().add(pdeDataViewer);
    jframe.setSize(1000, 600);
    jframe.setVisible(true);
    if (windowListener != null) {
        jframe.addWindowListener(windowListener);
    }
    pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
Also used : Origin(org.vcell.util.Origin) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) User(org.vcell.util.document.User) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) ExportSpecs(cbit.vcell.export.server.ExportSpecs) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) VCImage(cbit.image.VCImage) PDEDataInfo(cbit.vcell.simdata.PDEDataInfo) DataSetControllerProvider(cbit.vcell.server.DataSetControllerProvider) SimDataBlock(cbit.vcell.simdata.SimDataBlock) SpatialSelection(cbit.vcell.simdata.SpatialSelection) JFrame(javax.swing.JFrame) VCDataManager(cbit.vcell.simdata.VCDataManager) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) DataOperation(cbit.vcell.simdata.DataOperation) VariableType(cbit.vcell.math.VariableType) DataSetController(cbit.vcell.server.DataSetController) VCImageUncompressed(cbit.image.VCImageUncompressed) OutputContext(cbit.vcell.simdata.OutputContext) CartesianMesh(cbit.vcell.solvers.CartesianMesh) PDEDataManager(cbit.vcell.simdata.PDEDataManager) RegionImage(cbit.vcell.geometry.RegionImage) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) Domain(cbit.vcell.math.Variable.Domain) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) PDEDataViewer(cbit.vcell.client.data.PDEDataViewer)

Aggregations

PDEDataManager (cbit.vcell.simdata.PDEDataManager)13 ClientPDEDataContext (cbit.vcell.simdata.ClientPDEDataContext)7 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)7 OutputContext (cbit.vcell.simdata.OutputContext)6 VCDataManager (cbit.vcell.simdata.VCDataManager)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 ExportSpecs (cbit.vcell.export.server.ExportSpecs)5 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)5 Hashtable (java.util.Hashtable)5 ODEDataManager (cbit.vcell.simdata.ODEDataManager)4 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)4 User (org.vcell.util.document.User)4 BioModel (cbit.vcell.biomodel.BioModel)3 PDEDataViewer (cbit.vcell.client.data.PDEDataViewer)3 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)3 DataIdentifier (cbit.vcell.simdata.DataIdentifier)3 Simulation (cbit.vcell.solver.Simulation)3 ArrayList (java.util.ArrayList)3 ExportEvent (cbit.rmi.event.ExportEvent)2 SimulationWorkspaceModelInfo (cbit.vcell.client.data.SimulationWorkspaceModelInfo)2