use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class ASCIIExporter method getallSampleIndexes.
private int[] getallSampleIndexes(GeometrySpecs geometrySpecs, CartesianMesh mesh) throws DataAccessException {
ArrayList<Integer> sampleIndexes = new ArrayList<>();
SpatialSelection[] spatialSelections = geometrySpecs.getSelections();
for (int i = 0; i < spatialSelections.length; i++) {
spatialSelections[i].setMesh(mesh);
}
// Add points
if (geometrySpecs.getPointIndexes().length > 0) {
for (int i = 0; i < geometrySpecs.getPointIndexes().length; i++) {
sampleIndexes.add(geometrySpecs.getPointIndexes()[i]);
}
}
// Add curves
if (geometrySpecs.getCurves().length != 0) {
for (int i = 0; i < geometrySpecs.getCurves().length; i++) {
SpatialSelection curve = geometrySpecs.getCurves()[i];
curve.setMesh(mesh);
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
// crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
sampleIndexes.add(ssh.getSampledIndexes()[0]);
// numSamplePoints++;
// pointIndexes = new int[] {ssh.getSampledIndexes()[0]};
// distances = new double[] {0};
} else {
for (int j = 0; j < ssh.getSampledIndexes().length; j++) {
sampleIndexes.add(ssh.getSampledIndexes()[j]);
}
// numSamplePoints+= ssh.getSampledIndexes().length;
// pointIndexes = ssh.getSampledIndexes();
// distances = ssh.getWorldCoordinateLengths();
}
}
}
}
if (sampleIndexes.size() > 0) {
int[] allSampleIndexes = new int[sampleIndexes.size()];
for (int i = 0; i < allSampleIndexes.length; i++) {
allSampleIndexes[i] = sampleIndexes.get(i);
}
return allSampleIndexes;
}
return null;
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class ASCIIExporter method getCurveTimeSeries.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @throws IOException
*/
private FileDataContainerID getCurveTimeSeries(OutputContext outputContext, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, String variableName, SpatialSelection curve, double[] allTimes, int beginIndex, int endIndex, boolean switchRowsColumns, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
int[] pointIndexes = null;
double[] distances = null;
int[] crossingMembraneIndexes = null;
if (curve instanceof SpatialSelectionVolume) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionVolume) curve).getIndexSamples(0.0, 1.0);
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
crossingMembraneIndexes = ssh.getMembraneIndexesInOut();
} else if (curve instanceof SpatialSelectionMembrane) {
SpatialSelection.SSHelper ssh = ((SpatialSelectionMembrane) curve).getIndexSamples();
if (((SpatialSelectionMembrane) curve).getSelectionSource() instanceof SinglePoint) {
pointIndexes = new int[] { ssh.getSampledIndexes()[0] };
distances = new double[] { 0 };
} else {
pointIndexes = ssh.getSampledIndexes();
distances = ssh.getWorldCoordinateLengths();
}
}
org.vcell.util.document.TimeSeriesJobSpec timeSeriesJobSpec = new org.vcell.util.document.TimeSeriesJobSpec(new String[] { variableName }, new int[][] { pointIndexes }, new int[][] { crossingMembraneIndexes }, allTimes[beginIndex], 1, allTimes[endIndex], VCDataJobID.createVCDataJobID(user, false));
org.vcell.util.document.TSJobResultsNoStats timeSeriesJobResults = (org.vcell.util.document.TSJobResultsNoStats) dataServerImpl.getTimeSeriesValues(outputContext, user, vcdID, timeSeriesJobSpec);
// variableValues[0] is time array
// variableValues[1] is values for 1st spatial point.
// variableValues[2] is values for 2nd spatial point.
// variableValues[n] (n>=1) is values for nth spatial point.
// the length of variableValues should always be 1 + pointIndexes.length
// the length of variableValues[n] is allTimes.length
final double[][] variableValues = timeSeriesJobResults.getTimesAndValuesForVariable(variableName);
//
// put data in csv format
//
FileDataContainerID fileDataContainerID = fileDataContainerManager.getNewFileDataContainerID();
fileDataContainerManager.append(fileDataContainerID, "\"variable ('" + variableName + "') times (" + allTimes[beginIndex] + " " + allTimes[endIndex] + ") " + getSpatialSelectionDescription(curve) + "\"\n");
if (switchRowsColumns) {
fileDataContainerManager.append(fileDataContainerID, ",Distances\n");
fileDataContainerManager.append(fileDataContainerID, "Times,");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[j]);
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
} else {
fileDataContainerManager.append(fileDataContainerID, ",Times\n");
fileDataContainerManager.append(fileDataContainerID, "Distances,");
for (int i = 0; i < distances.length; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + distances[i]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
for (int i = beginIndex; i <= endIndex; i++) {
fileDataContainerManager.append(fileDataContainerID, "," + allTimes[i]);
for (int j = 0; j < distances.length; j++) {
fileDataContainerManager.append(fileDataContainerID, "," + variableValues[j + 1][i - beginIndex]);
}
fileDataContainerManager.append(fileDataContainerID, "\n");
}
}
return fileDataContainerID;
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class GeometrySpecs method getCurves.
/**
* This method was created in VisualAge.
* @return cbit.vcell.simdata.gui.SpatialSelection[]
*/
public SpatialSelection[] getCurves() {
int count = 0;
for (int i = 0; getSelections() != null && i < getSelections().length; i++) {
if (!isSinglePoint(getSelections()[i])) {
count++;
}
}
SpatialSelection[] curves = new SpatialSelection[count];
count = 0;
for (int i = 0; getSelections() != null && i < getSelections().length; i++) {
if (!isSinglePoint(getSelections()[i])) {
curves[count] = getSelections()[i];
count++;
}
}
return curves;
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class DisplayTimeSeriesOp method getDataSetControllerProvider.
private DataSetControllerProvider getDataSetControllerProvider(final ImageTimeSeries<? extends Image> imageTimeSeries, final PDEDataViewer pdeDataViewer) 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 {
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_START, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
if (!timeSeriesJobSpec.isCalcSpaceStats() && !timeSeriesJobSpec.isCalcTimeStats()) {
int[][] indices = timeSeriesJobSpec.getIndices();
double[] timeStamps = imageTimeSeries.getImageTimeStamps();
// [var][dataindex+1][timeindex]
double[][][] dataValues = new double[1][indices[0].length + 1][timeStamps.length];
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
// index 0 is time
dataValues[0][0][timeIndex] = timeStamps[timeIndex];
}
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
float[] pixelValues = imageTimeSeries.getAllImages()[timeIndex].getFloatPixels();
for (int samplePointIndex = 0; samplePointIndex < indices[0].length; samplePointIndex++) {
int pixelIndex = indices[0][samplePointIndex];
dataValues[0][samplePointIndex + 1][timeIndex] = pixelValues[pixelIndex];
}
}
TSJobResultsNoStats timeSeriesJobResults = new TSJobResultsNoStats(new String[] { "var" }, indices, timeStamps, dataValues);
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_COMPLETE, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
return timeSeriesJobResults;
}
return null;
}
@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;
}
};
return dataSetControllerProvider;
}
use of cbit.vcell.simdata.SpatialSelection in project vcell by virtualcell.
the class PDEDataContextPanel method setSpatialSelection.
/**
* Sets the pdeDataContext property (cbit.vcell.simdata.PDEDataContext) value.
* @param pdeDataContext The new value for the property.
* @see #getPdeDataContext
*/
private void setSpatialSelection(SpatialSelection spatialSelection) {
SpatialSelection oldValue = fieldSpatialSelection;
fieldSpatialSelection = spatialSelection;
firePropertyChange("spatialSelection", oldValue, spatialSelection);
}
Aggregations