use of gdsc.smlm.ij.settings.Compound in project GDSC-SMLM by aherbert.
the class CreateData method logExampleCompounds.
private void logExampleCompounds() {
comment(TITLE + " example compounds");
IJ.log("");
comment("Compounds are described using XML");
comment("Multiple compounds can be combined using fractional ratios");
comment("Coordinates are specified in nanometres");
comment("Coordinates describe the relative positions of molecules in the compound. Compounds will have a randomly assigned XYZ position for their centre-of-mass. Rotation will be about the centre of mass");
IJ.log("");
Atom a1 = new Atom(10, 0, 0, 0);
Atom a2 = new Atom(30, 0, 0, 0);
Atom a3 = new Atom(20, 1000, 0, 0);
Compound m1 = new Compound(1, 0, DiffusionType.RANDOM_WALK.toString(), a1);
Compound m2 = new Compound(1, 1, DiffusionType.GRID_WALK.toString(), a2, a3);
// Create a hexamer big enough to see with the default pixel pitch
Atom b1 = new Atom(1, 0, 0, 0);
Atom b2 = new Atom(1, 1000, 0, 0);
Atom b3 = new Atom(1, 1500, 866, 0);
Atom b4 = new Atom(1, 1000, 1732, 0);
Atom b5 = new Atom(1, 0, 1732, 0);
Atom b6 = new Atom(1, -500, 866, 0);
Compound m3 = new Compound(1, 2, DiffusionType.RANDOM_WALK.toString(), b1, b2, b3, b4, b5, b6);
comment("Single compounds");
IJ.log("");
comment("Monomer");
demo(m1);
comment("Dimer");
demo(m2);
comment("Hexamer");
demo(m3);
comment("Combined compounds");
IJ.log("");
comment("Two compounds with a ratio of 2:1");
m1.fraction = 2;
demo(m1, m2);
}
use of gdsc.smlm.ij.settings.Compound in project GDSC-SMLM by aherbert.
the class CreateData method demo.
private void demo(Compound... compounds) {
List<Compound> list = new LinkedList<Compound>();
for (Compound c : compounds) list.add(c);
IJ.log(createXStream().toXML(list));
IJ.log("");
}
use of gdsc.smlm.ij.settings.Compound in project GDSC-SMLM by aherbert.
the class CreateData method createCompoundMolecules.
@SuppressWarnings("unchecked")
private List<CompoundMoleculeModel> createCompoundMolecules() {
// Diffusion rate is um^2/sec. Convert to pixels per simulation frame.
final double diffusionFactor = (1000000.0 / (settings.pixelPitch * settings.pixelPitch)) / settings.stepsPerSecond;
List<CompoundMoleculeModel> compounds;
if (settings.compoundMolecules) {
// Try and load the compounds from the XML specification
try {
Object fromXML = createXStream().fromXML(settings.compoundText);
List<Compound> rawCompounds = (List<Compound>) fromXML;
// Convert from the XML serialised objects to the compound model
compounds = new ArrayList<CompoundMoleculeModel>(rawCompounds.size());
int id = 1;
for (Compound c : rawCompounds) {
MoleculeModel[] molecules = new MoleculeModel[c.atoms.length];
for (int i = 0; i < c.atoms.length; i++) {
Atom a = c.atoms[i];
molecules[i] = new MoleculeModel(a.mass, a.x, a.y, a.z);
}
CompoundMoleculeModel m = new CompoundMoleculeModel(id++, 0, 0, 0, Arrays.asList(molecules));
m.setFraction(c.fraction);
m.setDiffusionRate(c.D * diffusionFactor);
m.setDiffusionType(DiffusionType.fromString(c.diffusionType));
compounds.add(m);
}
// Convert coordinates from nm to pixels
final double scaleFactor = 1.0 / settings.pixelPitch;
for (CompoundMoleculeModel c : compounds) {
c.scale(scaleFactor);
}
} catch (Exception e) {
IJ.error(TITLE, "Unable to create compound molecules");
return null;
}
} else {
// Create a simple compound with one molecule at the origin
compounds = new ArrayList<CompoundMoleculeModel>(1);
CompoundMoleculeModel m = new CompoundMoleculeModel(1, 0, 0, 0, Arrays.asList(new MoleculeModel(0, 0, 0, 0)));
m.setDiffusionRate(settings.diffusionRate * diffusionFactor);
m.setDiffusionType(settings.getDiffusionType());
compounds.add(m);
}
return compounds;
}
Aggregations