use of cbit.vcell.data.DataSymbol.DataSymbolType in project vcell by virtualcell.
the class XmlReader method getDataSymbols.
private ArrayList<DataSymbol> getDataSymbols(Element dataContextElement, DataContext dataContext, ModelUnitSystem modelUnitSystem) {
ArrayList<DataSymbol> dataSymbolsList = new ArrayList<DataSymbol>();
// iterate over fieldDatasymbols. When other dataSymbol types are implemented, repeat this loop.
Iterator dataSymbolsElementIter = dataContextElement.getChildren(XMLTags.FieldDataSymbolTag, vcNamespace).iterator();
while (dataSymbolsElementIter.hasNext()) {
Element dataSymbolElement = (Element) dataSymbolsElementIter.next();
String dataSymbolName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolNameTag));
DataSymbolType dataSymbolType = DataSymbolType.fromDatabaseName(unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolTypeTag)));
String symbol = dataSymbolElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
VCUnitDefinition vcUnitDefinition = null;
if (symbol != null) {
vcUnitDefinition = modelUnitSystem.getInstance(symbol);
}
// ExternalDataIdentifier dataSetID in FieldDataSymbol
Element dataSetIDElement = dataSymbolElement.getChild(XMLTags.ExternalDataIdentifierTag, vcNamespace);
String name = unMangle(dataSetIDElement.getAttributeValue(XMLTags.NameAttrTag));
String key = unMangle(dataSetIDElement.getAttributeValue(XMLTags.KeyValueAttrTag));
String userID = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerNameAttrTag));
String userKey = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerKeyAttrTag));
User owner = new User(userID, new KeyValue(userKey));
ExternalDataIdentifier edi = new ExternalDataIdentifier(new KeyValue(key), owner, name);
// ---
String fieldItemName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemNameTag));
String fieldItemType = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTypeTag));
double fieldItemTime = Double.parseDouble(unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTimeTag)));
FieldDataSymbol fds = new FieldDataSymbol(dataSymbolName, dataSymbolType, dataContext, vcUnitDefinition, edi, fieldItemName, fieldItemType, fieldItemTime);
dataSymbolsList.add(fds);
}
return dataSymbolsList;
}
use of cbit.vcell.data.DataSymbol.DataSymbolType in project vcell by virtualcell.
the class VFrapXmlHelper method LoadVFrapSpecialImages.
// // load and compute prebleach average and first postbleach images
// public void LoadVFrapSpecialImages(AnnotatedImageDataset annotatedImages, int startingIndexRecovery)
// {
// // unnormalized prebleach average
// prebleachAvg = new double[annotatedImages.getImageDataset().getImage(0, 0, startingIndexRecovery).getNumXYZ()];
// for(int j = 0; j < prebleachAvg.length; j++)
// {
// double pixelTotal = 0;
// for(int i = 0 ; i < startingIndexRecovery; i++)
// {
// pixelTotal = pixelTotal + (annotatedImages.getImageDataset().getImage(0, 0, i).getPixels()[j] & 0x0000FFFF);
// }
// prebleachAvg[j] = pixelTotal/startingIndexRecovery;
// }
//
// // unnormalized first post bleach
// firstPostBleach = new double[annotatedImages.getImageDataset().getImage(0, 0, startingIndexRecovery).getNumXYZ()];
// short[] pixels = annotatedImages.getImageDataset().getImage(0, 0, startingIndexRecovery).getPixels();
// for(int i = 0; i< pixels.length; i++)
// {
// firstPostBleach[i] = pixels[i] & 0x0000FFFF;
// }
// }
//
// Locate the special images within the vFrap files and load them in memory
//
public static boolean LoadVFrapSpecialImages(Hashtable<String, Object> hashTable, Element vFrapRoot) throws IOException, DataAccessException, MathException, ImageException {
// ------ parse the vfrap file and the log/zip files referred within -----
// many channels of 1 timepoint each
int NumTimePoints = 1;
// the channels: prebleach, postbleach, roi1, roi2 ... roiN
int NumChannels = tokenNames.length;
String[] channelNames = new String[NumChannels];
VariableType[] channelTypes = new VariableType[NumChannels];
DataSymbolType[] channelVFrapImageType = new DataSymbolType[NumChannels];
double[][][] pixData = new double[NumTimePoints][NumChannels][];
// get the path of the file tagged with "ROIExternalDataInfoTag" and open it
Element roiExternalDataInfoElement = vFrapRoot.getChild(MicroscopyXMLTags.ROIExternalDataInfoTag);
if (roiExternalDataInfoElement == null) {
// can't load FieldData for some reason, fall back to importing the biomodel only
return false;
}
// <ROIExternalDataInfo Filename="c:\vFrap\VirtualMicroscopy\SimulationData\SimID_1282941232246_0_.log">
// <ExternalDataIdentifier Name="timeData" KeyValue="1282941232246" OwnerName="SimulationData" OwnerKey="0" />
// </ImageDatasetExternalDataInfo>
// c:\VirtualMicroscopy\SimulationData\SimID_1284149203811_0_.log
String filename = (roiExternalDataInfoElement).getAttributeValue("Filename");
Element childElement = (roiExternalDataInfoElement).getChild("ExternalDataIdentifier");
if (childElement == null) {
// can't load FieldData for some reason, fall back to importing the biomodel only
return false;
}
StringTokenizer tokens = new StringTokenizer(filename, "/\\.");
final ArrayList<String> tokenArray = new ArrayList<String>();
while (tokens.hasMoreElements()) {
tokenArray.add(tokens.nextToken());
}
final String dataID = tokenArray.get(tokenArray.size() - 2);
final String userName = tokenArray.get(tokenArray.size() - 3);
VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {
public String getID() {
return dataID;
}
public KeyValue getDataKey() {
return null;
}
public User getOwner() {
return new User(userName, new KeyValue("123345432334"));
}
};
// ------- recover simulation data for this user name, load the images in memory ------------
// ex c:\\VirtualMicroscopy\\SimulationData
String userDirName = filename.substring(0, filename.indexOf(dataID) - 1);
File userDir = new File(userDirName);
SimulationData.SimDataAmplistorInfo simDataAmplistorInfo = AmplistorUtils.getSimDataAmplistorInfoFromPropertyLoader();
SimulationData simData = new SimulationData(vcDataIdentifier, userDir, null, simDataAmplistorInfo);
// build a valid mesh in 2 steps, what we have in simData is incomplete
CartesianMesh incompleteMesh = simData.getMesh();
Extent extent = incompleteMesh.getExtent();
ISize isize = new ISize(incompleteMesh.getSizeX(), incompleteMesh.getSizeY(), incompleteMesh.getSizeZ());
Origin origin = new Origin(0, 0, 0);
CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
DataIdentifier[] dataIdentifiers = simData.getVarAndFunctionDataIdentifiers(null);
double[] times = simData.getDataTimes();
for (int i = 0; i < dataIdentifiers.length; i++) {
// ex: prebleach_avg, postbleach_first, postbleach_last, bleached_mask, cell_mask, ring1_mask,... ring8_mask
System.out.println(dataIdentifiers[i].getName());
for (double time : times) {
// this loops only once, we have just 1 timepoint for each "special" image
SimDataBlock simDataBlock = simData.getSimDataBlock(null, dataIdentifiers[i].getName(), time);
channelNames[i] = dataIdentifiers[i].getName();
channelTypes[i] = VariableType.VOLUME;
channelVFrapImageType[i] = SymbolEquivalence.typeFromToken(dataIdentifiers[i].getName());
pixData[0][i] = simDataBlock.getData();
// var = prebleach_avg, time = 0.0, data = { 1.0832530361887216 1.0832530361887216 1.0832530361887216 1.0 .... }
System.out.print("var = " + dataIdentifiers[i].getName() + ", time = " + time + ", data = { ");
// show a few
for (int j = 0; j < 5; j++) {
System.out.print(pixData[0][i][j] + " ");
}
// show a few
;
// show a few
System.out.println(" ... ");
}
}
hashTable.put("mesh", mesh);
hashTable.put("pixData", pixData);
hashTable.put("channelNames", channelNames);
hashTable.put("channelTypes", channelTypes);
hashTable.put("channelVFrapImageType", channelVFrapImageType);
return true;
}
use of cbit.vcell.data.DataSymbol.DataSymbolType in project vcell by virtualcell.
the class DataSymbolTable method populateDataSymbols.
public void populateDataSymbols(Connection con, KeyValue simContextRef, DataContext dataContext, User simcontextOwner, VCUnitSystem unitSystem) throws SQLException, DataAccessException {
Statement stmt = null;
try {
HashMap<BigDecimal, ExternalDataIdentifier> extDataIDHashMap = new HashMap<BigDecimal, ExternalDataIdentifier>();
stmt = con.createStatement();
ResultSet rset = stmt.executeQuery("SELECT * FROM " + ExternalDataTable.table.getTableName() + " WHERE " + ExternalDataTable.table.ownerRef.getUnqualifiedColName() + " = " + simcontextOwner.getID().toString());
while (rset.next()) {
BigDecimal extdataIDBigDec = rset.getBigDecimal(ExternalDataTable.table.id.getUnqualifiedColName());
ExternalDataIdentifier extdataID = new ExternalDataIdentifier(new KeyValue(extdataIDBigDec), simcontextOwner, rset.getString(ExternalDataTable.table.externalDataName.getUnqualifiedColName()));
extDataIDHashMap.put(extdataIDBigDec, extdataID);
}
rset.close();
rset = stmt.executeQuery("SELECT * FROM " + DataSymbolTable.table.getTableName() + " WHERE " + DataSymbolTable.table.simContextRef.getUnqualifiedColName() + " = " + simContextRef.toString());
while (rset.next()) {
String nextDataSymbolName = rset.getString(DataSymbolTable.table.dataSymbolName.toString());
String nextDataSymbolTypeS = rset.getString(DataSymbolTable.table.dataSymbolType.toString());
DataSymbolType nextDataSymbolType = DataSymbolType.valueOf(nextDataSymbolTypeS);
String nextDataSymbolVCUnitDefS = rset.getString(DataSymbolTable.table.dataSymbolVCUnitDef.toString());
nextDataSymbolVCUnitDefS = TokenMangler.getSQLRestoredString(nextDataSymbolVCUnitDefS);
VCUnitDefinition nextVCUnitDefinition = unitSystem.getInstance(nextDataSymbolVCUnitDefS);
// FieldDataSymbol (ExternalDataIdentifier) - (only data symbol defined right now)
BigDecimal extDataBigDecimal = rset.getBigDecimal(DataSymbolTable.table.fieldDataRef.getUnqualifiedColName());
ExternalDataIdentifier nextExtDataID = null;
if (!rset.wasNull()) {
nextExtDataID = extDataIDHashMap.get(extDataBigDecimal);
if (nextExtDataID == null) {
throw new DataAccessException("PopulateDataSymbols extdataID " + extDataBigDecimal + " not found in database for user " + simcontextOwner.getName());
}
String nextFieldDataVarName = rset.getString(DataSymbolTable.table.fieldDataVarName.getUnqualifiedColName());
String nextFieldDataVarType = rset.getString(DataSymbolTable.table.fieldDataVarType.getUnqualifiedColName());
double nextFieldDataVarTime = rset.getDouble(DataSymbolTable.table.fieldDataVarTime.getUnqualifiedColName());
FieldDataSymbol fieldDataSymbol = new FieldDataSymbol(nextDataSymbolName, nextDataSymbolType, dataContext, nextVCUnitDefinition, nextExtDataID, nextFieldDataVarName, nextFieldDataVarType, nextFieldDataVarTime);
dataContext.addDataSymbol(fieldDataSymbol);
} else {
throw new DataAccessException("DataSymbol has no ExternalDataIdentifier");
}
}
} finally {
if (stmt != null) {
stmt.close();
}
}
}
use of cbit.vcell.data.DataSymbol.DataSymbolType in project vcell by virtualcell.
the class DataSymbolsSpecPanel method setDataSymbol.
// public void createDataSymbol() throws Exception, UserCancelException{
// final int VFRAP_DATASET = 0;
// final int VFRAP_SPECIALS = 1;
// final int ASSOCIATE_EXISTING_FD = 2;
// final int POINT_SPREAD_FUNCTION = 3;
// final int IMAGE_FILE = 4;
// final int COPY_FROM_BIOMODEL = 5;
// int[] dataSymbolSource = null;
//
// String[][] choices = new String[][] {{ADD_VFRAP_DATASET_MENU},{ADD_VFRAP_SPECIALS_MENU},{ADD_ASSOCIATE_EXISTING_FD_MENU},
// {ADD_PSF_MENU},{ADD_IMAGE_FILE_MENU},{ADD_COPY_FROM_BIOMODEL_MENU} };
//
// dataSymbolSource = DialogUtils.showComponentOKCancelTableList(
// getComponent(),
// "Choose a source for the data symbol.",
// new String[] {"Available Sources:"},
// choices, ListSelectionModel.SINGLE_SELECTION);
//
// if(dataSymbolSource[0] == VFRAP_DATASET){
// getDataSymbolsPanel().addVFrapOriginalImages();
// }else if(dataSymbolSource[0] == VFRAP_SPECIALS){
// getDataSymbolsPanel().addVFrapDerivedImages();
// }else if(dataSymbolSource[0] == ASSOCIATE_EXISTING_FD){
// Component requesterComponent = DataSymbolsSpecPanel.this;
// DocumentWindow documentWindow = (DocumentWindow)BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
// documentWindow.getTopLevelWindowManager().getRequestManager().showFieldDataWindow(new FieldDataWindowManager.DataSymbolCallBack() {
// public void createDataSymbol(ExternalDataIdentifier dataSetID,
// String fieldDataVarName, VariableType fieldDataVarType,
// double fieldDataVarTime) {
//
// System.out.println(dataSetID+" "+fieldDataVarName+" "+fieldDataVarType+" "+fieldDataVarTime);
// // ex: incomplete 51780592 danv(26766043) fluor Volume_VariableType 23.680419921875
//
// DecimalFormat df = new DecimalFormat("###000.00"); // max time interval we can display is about 11 days
// String fluorName = fieldDataVarName + "_" + df.format(fieldDataVarTime).substring(0, df.format(fieldDataVarTime).indexOf(".")) + "s" + df.format(fieldDataVarTime).substring(1+df.format(fieldDataVarTime).indexOf(".")) + "_" + dataSetID.getName();
// // TODO: symbol names may not be unique, must check for unicity and prompt the user
// FieldDataSymbol dataSymbol = new FieldDataSymbol(fluorName, DataSymbolType.GENERIC_SYMBOL,
// getSimulationContext().getDataContext(), VCUnitDefinition.UNIT_TBD,
// dataSetID,
// fieldDataVarName, fieldDataVarType.getTypeName(), fieldDataVarTime);
// getSimulationContext().getDataContext().addDataSymbol(dataSymbol);
//
// }
// });
// }else if(dataSymbolSource[0] == POINT_SPREAD_FUNCTION){
// PointSpreadFunctionManagement psfManager = new PointSpreadFunctionManagement(DataSymbolsSpecPanel.this,
// getSimulationContext());
// psfManager.importPointSpreadFunction();
// }else if(dataSymbolSource[0] == IMAGE_FILE){
// throw new RuntimeException("Option not yet implemented.");
// }else if(dataSymbolSource[0] == COPY_FROM_BIOMODEL){
// throw new RuntimeException("Option not yet implemented.");
// }else{
// throw new IllegalArgumentException("Error selecting data symbol, Unknown Source type " + dataSymbolSource[0]);
// }
// }
public void setDataSymbol(Object object) {
if (object == null) {
// TODO: display empty image
return;
}
if (((DataSymbol) object).equals(ivjCurrentSymbol)) {
return;
} else {
ivjCurrentSymbol = (DataSymbol) object;
}
// manage checkbox status depending on type of current data symbol
DataSymbolType dsType = ivjCurrentSymbol.getDataSymbolType();
switch(dsType) {
case GENERIC_SYMBOL:
getChckbxPointSpreadFunction().setEnabled(true);
getChckbxPointSpreadFunction().setSelected(false);
break;
case POINT_SPREAD_FUNCTION:
getChckbxPointSpreadFunction().setEnabled(true);
getChckbxPointSpreadFunction().setSelected(true);
break;
default:
getChckbxPointSpreadFunction().setEnabled(false);
getChckbxPointSpreadFunction().setSelected(false);
break;
}
// displays iconized image for the current (field?) data symbol
getImagePlaneManagerPanel().setMode(ImagePaneModel.MESH_MODE);
int w = Integer.valueOf(30).intValue() + 5 * (countW % 5);
int h = Integer.valueOf(20).intValue() + 3 * (countH % 7);
String type = "double";
System.out.println(" " + w + ", " + h);
SourceDataInfo sdi = ImagePaneScrollerTest.getExampleSDI(type, w, h);
getImagePlaneManagerPanel().setSourceDataInfo(sdi);
countW++;
countH++;
}
use of cbit.vcell.data.DataSymbol.DataSymbolType in project vcell by virtualcell.
the class VFrapXmlHelper method CreateSaveVFrapDataSymbols.
public static void CreateSaveVFrapDataSymbols(Hashtable<String, Object> hashTable, BioModel bioModel, ExternalDataIdentifier vfrapMisc) {
String[] channelNames = (String[]) hashTable.get("channelNames");
DataSymbolType[] channelVFrapImageType = (DataSymbolType[]) hashTable.get("channelVFrapImageType");
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
SimulationContext simContext = bioModel.getSimulationContexts()[0];
ModelUnitSystem modelUnitSystem = bioModel.getModel().getUnitSystem();
for (int i = 0; i < channelNames.length; i++) {
// TODO: construct dataSymbolName from vFrapConstants::nameFromToken()
// item name postfixed with field data name
String dataSymbolName = channelNames[i] + "_" + initialFieldDataName;
DataSymbol dataSymbol = new FieldDataSymbol(dataSymbolName, channelVFrapImageType[i], simContext.getDataContext(), modelUnitSystem.getInstance_TBD(), vfrapMisc, channelNames[i], VariableType.VOLUME.getTypeName(), 0D);
simContext.getDataContext().addDataSymbol(dataSymbol);
}
}
Aggregations