use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.
the class ExportTransformAsXmlTest method showFixedAndWarpedMoving.
private static void showFixedAndWarpedMoving(File warpedXml, File fixedImageXml) throws SpimDataException {
final SpimData warpedSpimData = new XmlIoSpimData().load(warpedXml.getAbsolutePath());
final BdvStackSource<?> bdvStackSource = BdvFunctions.show(warpedSpimData).get(0);
bdvStackSource.setDisplayRange(0, 255);
final SpimData fixedSpimData = new XmlIoSpimData().load(fixedImageXml.getAbsolutePath());
final BdvStackSource<?> bdvStackSource2 = BdvFunctions.show(fixedSpimData, BdvOptions.options().addTo(bdvStackSource.getBdvHandle())).get(0);
bdvStackSource2.setDisplayRange(0, 255);
}
use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.
the class BigWarpBdvCommand method run.
@Override
public void run() {
try {
final SpimData fixedSpimData = new XmlIoSpimData().load(fixedImageXml.getAbsolutePath());
final SpimData movingSpimData = new XmlIoSpimData().load(movingImageXml.getAbsolutePath());
new RepeatingReleasedEventsFixer().install();
final BigWarp.BigWarpData<?> bigWarpData = BigWarpInit.createBigWarpData(movingSpimData, fixedSpimData);
bw = new BigWarp(bigWarpData, "Big Warp", new ProgressWriterIJ());
bw.getViewerFrameP().getViewerPanel().requestRepaint();
bw.getViewerFrameQ().getViewerPanel().requestRepaint();
bw.getLandmarkFrame().repaint();
bw.setMovingSpimData(movingSpimData, movingImageXml);
} catch (final SpimDataException e) {
e.printStackTrace();
return;
}
}
use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.
the class BigWarpImagePlusPlugIn method run.
@Override
public void run(final String arg) {
if (IJ.versionLessThan("1.40"))
return;
// don't need any open windows if we're using N5
final int[] ids = WindowManager.getIDList();
// Find any open images
final int N = ids == null ? 0 : ids.length;
final String[] titles = new String[N + 1];
for (int i = 0; i < N; ++i) {
titles[i] = (WindowManager.getImage(ids[i])).getTitle();
}
titles[N] = "<None>";
// Build a dialog to choose the moving and fixed images
final GenericDialogPlus gd = new GenericDialogPlus("Big Warp Setup");
gd.addMessage("Image Selection:");
ImagePlus currimg = WindowManager.getCurrentImage();
String current = titles[N];
if (currimg != null) {
current = currimg.getTitle();
}
gd.addChoice("moving_image", titles, current);
if (titles.length > 1)
gd.addChoice("target_image", titles, current.equals(titles[0]) ? titles[1] : titles[0]);
else
gd.addChoice("target_image", titles, titles[0]);
gd.addMessage("\nN5/Zarr/HDF5/BDV-XML");
gd.addDirectoryOrFileField("Moving", "");
gd.addStringField("Moving dataset", "");
gd.addDirectoryOrFileField("Target", "");
gd.addStringField("Target dataset", "");
gd.addMessage("");
gd.addFileField("Landmarks file", "");
gd.addCheckbox("Apply transform from landmarks", true);
gd.showDialog();
if (gd.wasCanceled())
return;
final int mvgImgIdx = gd.getNextChoiceIndex();
final int tgtImgIdx = gd.getNextChoiceIndex();
movingIp = mvgImgIdx < N ? WindowManager.getImage(ids[mvgImgIdx]) : null;
targetIp = tgtImgIdx < N ? WindowManager.getImage(ids[tgtImgIdx]) : null;
final String mvgRoot = gd.getNextString();
final String mvgDataset = gd.getNextString();
final String tgtRoot = gd.getNextString();
final String tgtDataset = gd.getNextString();
final String landmarkPath = gd.getNextString();
final boolean applyTransform = gd.getNextBoolean();
// build bigwarp data
BigWarpData<?> bigwarpdata = BigWarpInit.initData();
int id = 0;
if (movingIp != null) {
id += BigWarpInit.add(bigwarpdata, movingIp, id, 0, true);
}
SpimData movingSpimData = null;
if (!mvgRoot.isEmpty()) {
if (openWithImageJ(mvgRoot)) {
final ImagePlus mvgIpFromFile = IJ.openImage(mvgRoot);
mvgIpFromFile.show();
BigWarpInit.add(bigwarpdata, mvgIpFromFile, id, 0, true);
} else {
movingSpimData = BigWarpInit.addToData(bigwarpdata, true, id, mvgRoot, mvgDataset);
}
id++;
}
if (targetIp != null) {
id += BigWarpInit.add(bigwarpdata, targetIp, id, 0, false);
}
if (!tgtRoot.isEmpty()) {
if (openWithImageJ(tgtRoot)) {
final ImagePlus tgtIpFromFile = IJ.openImage(tgtRoot);
tgtIpFromFile.show();
BigWarpInit.add(bigwarpdata, tgtIpFromFile, id, 0, false);
} else {
BigWarpInit.addToData(bigwarpdata, false, id, tgtRoot, tgtDataset);
}
id++;
}
bigwarpdata.wrapUp();
// run BigWarp
try {
new RepeatingReleasedEventsFixer().install();
final BigWarp<?> bw = new BigWarp<>(bigwarpdata, "Big Warp", new ProgressWriterIJ());
if (landmarkPath != null && !landmarkPath.isEmpty()) {
bw.loadLandmarks(landmarkPath);
if (applyTransform)
bw.setIsMovingDisplayTransformed(applyTransform);
}
if (movingSpimData != null)
bw.setMovingSpimData(movingSpimData, new File(mvgRoot));
bw.getViewerFrameP().getViewerPanel().requestRepaint();
bw.getViewerFrameQ().getViewerPanel().requestRepaint();
bw.getLandmarkFrame().repaint();
} catch (final SpimDataException e) {
e.printStackTrace();
return;
}
}
use of mpicbg.spim.data.SpimData in project multiview-simulation by PreibischLab.
the class SimulatedBeadsImgLoader method spimdataExample.
public static SpimData spimdataExample(final int[] angles, final int axis, final int numPoints, final double[] sigma, final Interval range) {
final TimePoints timepoints = LegacySimulatedBeadsImgLoader.createTimepoints();
final ArrayList<ViewSetup> setups = LegacySimulatedBeadsImgLoader.createViewSetups(angles, axis, range);
final MissingViews missingViews = null;
final SimulateBeads sb = new SimulateBeads(angles, axis, numPoints, range, range, sigma);
final SequenceDescription sequenceDescription = new SequenceDescription(timepoints, setups, null, missingViews);
final ImgLoader imgLoader = new SimulatedBeadsImgLoader(sb);
sequenceDescription.setImgLoader(imgLoader);
// get the minimal resolution of all calibrations
final double minResolution = 1.0;
final ViewRegistrations viewRegistrations = LegacySimulatedBeadsImgLoader.createViewRegistrations(sequenceDescription.getViewDescriptions(), minResolution);
// finally create the SpimData itself based on the sequence description and the view registration
final SpimData spimData = new SpimData(new File(""), sequenceDescription, viewRegistrations);
return spimData;
}
use of mpicbg.spim.data.SpimData in project multiview-simulation by PreibischLab.
the class SimulatedBeadsImgLoader2 method createSpimData.
public static SpimData createSpimData(int numPoints, double[] sigma, Interval rangeSimulation, Interval intervalRender, int rotAxis, double[] ratations, List<double[]> channelShifts, List<double[]> illumShifts, List<double[]> timeShifts, List<double[]> tileShifts, double relativeTileError, boolean centerAngles) {
SimulateBeads2 sb = new SimulateBeads2(numPoints, sigma, rangeSimulation, intervalRender);
SimulatedBeadsImgLoader2 loader = new SimulatedBeadsImgLoader2(sb, rotAxis, ratations, channelShifts, illumShifts, timeShifts, tileShifts);
SequenceDescription sd = new SequenceDescription(createTimePointsFromImgLoader(loader), createViewSetupsFromImgLoader(loader), null, new MissingViews(new ArrayList<>()));
sd.setImgLoader(loader);
SpimData res = new SpimData(new File(""), sd, createViewRegistrationsFromImgLoader(loader, relativeTileError, centerAngles));
return res;
}
Aggregations