use of mpicbg.spim.data.sequence.ViewId in project multiview-simulation by PreibischLab.
the class SimulatedBeadsImgLoader2 method createViewRegistrationsFromImgLoader.
public static ViewRegistrations createViewRegistrationsFromImgLoader(SimulatedBeadsImgLoader2 imgLoader, double relativeTileError, boolean centerAngles) {
SimulateBeads2 sb = imgLoader.getSimulateBeads();
final HashMap<ViewId, ViewRegistration> viewRegistrationList = new HashMap<ViewId, ViewRegistration>();
final RealInterval tilesExtent = sb.getTilesExtent();
double[] center = new double[tilesExtent.numDimensions()];
tilesExtent.realMax(center);
for (int d = 0; d < center.length; d++) center[d] /= -2.0;
for (int tp : new ArrayList<>(sb.tpTransforms.keySet()).stream().sorted().collect(Collectors.toList())) {
int vid = 0;
for (int a : new ArrayList<>(sb.angleTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int channel : new ArrayList<>(sb.channelTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int illum : new ArrayList<>(sb.illumTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int tile : new ArrayList<>(sb.tileTransforms.keySet()).stream().sorted().collect(Collectors.toList())) {
final VoxelDimensions voxelSize = new FinalVoxelDimensions("pixels", 1, 1, 1);
final Dimensions dim = imgLoader.getSimulateBeads().getImg(0, a, channel, tile, illum);
final ViewRegistration viewRegistration = new ViewRegistration(tp, vid++);
final double calX = voxelSize.dimension(0);
final double calY = voxelSize.dimension(1);
final double calZ = voxelSize.dimension(2);
final AffineTransform3D m = new AffineTransform3D();
m.set(calX, 0.0f, 0.0f, 0.0f, 0.0f, calY, 0.0f, 0.0f, 0.0f, 0.0f, calZ, 0.0f);
final ViewTransform vt = new ViewTransformAffine("calibration", m);
viewRegistration.preconcatenateTransform(vt);
double[] translation = sb.tileTransforms.get(tile).inverse().getTranslation();
for (int i = 0; i < translation.length; i++) translation[i] *= relativeTileError;
AffineTransform3D atr = new AffineTransform3D();
atr.translate(translation);
final ViewTransform vtT = new ViewTransformAffine("translation", atr.copy());
viewRegistration.preconcatenateTransform(vtT);
if (centerAngles) {
AffineTransform3D centerTr = new AffineTransform3D();
centerTr.translate(center);
final ViewTransform centerVt = new ViewTransformAffine("center angle", centerTr.copy());
viewRegistration.preconcatenateTransform(centerVt);
}
final ViewTransform vtA = new ViewTransformAffine("rotation", sb.angleTransforms.get(a));
viewRegistration.preconcatenateTransform(vtA);
viewRegistrationList.put(viewRegistration, viewRegistration);
}
}
return new ViewRegistrations(viewRegistrationList);
}
use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.
the class ReorderedImageLoader method getVoxelSize.
public VoxelDimensions getVoxelSize(int setupId, int timepointId) {
SpimDataViewId svi = order.getOriginalLocation(new ViewId(timepointId, setupId));
AbstractSpimData asd = svi.asd;
int setupIdRedirect = svi.viewId.getViewSetupId();
int timepointRedirect = svi.viewId.getTimePointId();
return getOrFetchImageLoader(asd).getSetupImgLoader(setupIdRedirect).getVoxelSize(timepointRedirect);
}
use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.
the class ReorderedImageLoader method getImage.
public RandomAccessibleInterval getImage(int setupId, int timepointId, int level, ImgLoaderHint... hints) {
SpimDataViewId sdvi = order.getOriginalLocation(new ViewId(timepointId, setupId));
AbstractSpimData asd = sdvi.asd;
int setupIdRedirect = sdvi.viewId.getViewSetupId();
int timepointRedirect = sdvi.viewId.getTimePointId();
return getOrFetchImageLoader(asd).getSetupImgLoader(setupIdRedirect).getImage(timepointRedirect, level, hints);
}
use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.
the class ReorderedImageLoader method getSetupImgLoader.
public ReorderedSetupLoader getSetupImgLoader(int setupId) {
if (imgLoaders.containsKey(setupId)) {
return imgLoaders.get(setupId);
} else {
logger.debug("loading setupId = " + setupId);
ViewId currentViewId = new ViewId(0, setupId);
SpimDataViewId svi = order.getOriginalLocation(currentViewId);
AbstractSpimData originSpimData = svi.asd;
ViewId originViewId = svi.viewId;
BasicImgLoader originImageLoader = getOrFetchImageLoader(originSpimData);
BasicSetupImgLoader setupImgLoader = originImageLoader.getSetupImgLoader(originViewId.getViewSetupId());
if (!(setupImgLoader instanceof AbstractViewerSetupImgLoader)) {
logger.error("Origin setup loader is not of instance AbstractViewerSetupImgLoader, reoredering is not supported");
throw new UnsupportedOperationException("Unsupported setup loader class " + setupImgLoader.getClass());
}
if (!(setupImgLoader instanceof MultiResolutionSetupImgLoader)) {
logger.error("Origin setup loader is not of instance MultiResolutionSetupImgLoader, reoredering is not supported");
throw new UnsupportedOperationException("Unsupported setup loader class " + setupImgLoader.getClass());
}
T originSetupLoader = (T) setupImgLoader;
originImgLoaders.put(setupId, originSetupLoader);
ReorderedSetupLoader setupLoader = new ReorderedSetupLoader(this, setupId, (NumericType) originSetupLoader.getImageType(), originSetupLoader.getVolatileImageType());
imgLoaders.put(setupId, setupLoader);
return setupLoader;
}
}
use of mpicbg.spim.data.sequence.ViewId in project mars-fx by duderstadt-lab.
the class MarsBdvFrame method loadAsSpimDataMinimal.
private Source<T> loadAsSpimDataMinimal(MarsBdvSource source, MarsMetadata meta) {
SpimDataMinimal spimData;
try {
spimData = new XmlIoSpimDataMinimal().load(source.getPath());
// Add transforms to spimData...
Map<ViewId, ViewRegistration> registrations = spimData.getViewRegistrations().getViewRegistrations();
for (ViewId id : registrations.keySet()) {
if (source.getCorrectDrift()) {
double dX = meta.getPlane(0, 0, 0, id.getTimePointId()).getXDrift();
double dY = meta.getPlane(0, 0, 0, id.getTimePointId()).getYDrift();
registrations.get(id).getModel().set(source.getAffineTransform3D(dX, dY));
} else
registrations.get(id).getModel().set(source.getAffineTransform3D());
}
if (spimData.getSequenceDescription().getTimePoints().size() > numTimePoints)
numTimePoints = spimData.getSequenceDescription().getTimePoints().size();
return new SpimSource<T>(spimData, 0, source.getName());
} catch (SpimDataException e) {
e.printStackTrace();
}
return null;
}
Aggregations