Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve stage scanning with multiple positions #276

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ public AcquisitionEvent run(AcquisitionEvent event) {
// TODO: add later when autofocus is complete, prevent errors if no time index is found for now
//int timePoint = firstAcqEvent.getTIndex();

try {
core_.waitForSystem();
} catch (Exception e) {
throw new RuntimeException(e);
}
////////////////////////////////////
///////// Run autofocus ////////////
///////////////////////////////////
Expand Down Expand Up @@ -351,15 +356,18 @@ public AcquisitionEvent run(AcquisitionEvent event) {
// }
// }
// }
// move between positions fast
scanSpeedX_ = 1.0;
scanAccelX_ = 1.0;
if (acqSettings_.isUsingStageScanning()) {
final ASIXYStage xyStage = model_.devices().getDevice("SampleXY");
scanSpeedX_ = xyStage.getSpeedX();
scanAccelX_ = xyStage.getAccelerationX();
xyStage.setSpeedX(origSpeedX_);
xyStage.setAccelerationX(origAccelX_);

if (isUsingPLC) {
// move between positions fast
scanSpeedX_ = 1.0;
scanAccelX_ = 1.0;
if (acqSettings_.isUsingStageScanning() && acqSettings_.isUsingMultiplePositions()) {
final ASIXYStage xyStage = model_.devices().getDevice("SampleXY");
scanSpeedX_ = xyStage.getSpeedX();
scanAccelX_ = xyStage.getAccelerationX();
xyStage.setSpeedX(origSpeedX_);
xyStage.setAccelerationX(origAccelX_);
}
}
return event;
}
Expand All @@ -371,29 +379,31 @@ public void close() {
}, Acquisition.BEFORE_HARDWARE_HOOK);


final PLogicSCAPE finalController = controller;
currentAcquisition_.addHook(new AcquisitionHook() {
@Override
public AcquisitionEvent run(AcquisitionEvent event) {
// for stage scanning: restore speed and set up scan at new position
// non-multi-position situation is handled in prepareControllerForAcquisition instead
if (acqSettings_.isUsingStageScanning()) {
final ASIXYStage xyStage = model_.devices().getDevice("SampleXY");
final Point2D.Double pos = xyStage.getXYPosition();
xyStage.setSpeedX(scanSpeedX_);
xyStage.setAccelerationX(scanAccelX_);
finalController.prepareStageScanForAcquisition(pos.x, pos.y, acqSettings_);
finalController.triggerControllerStartAcquisition(acqSettings_.acquisitionMode(),
acqSettings_.volumeSettings().firstView());
}
return event;
}

@Override
public void close() {

}
}, Acquisition.AFTER_HARDWARE_HOOK);
// final PLogicSCAPE finalController = controller;
// currentAcquisition_.addHook(new AcquisitionHook() {
// @Override
// public AcquisitionEvent run(AcquisitionEvent event) {
// System.out.println("After hardware hook");
// // for stage scanning: restore speed and set up scan at new position
// // non-multi-position situation is handled in prepareControllerForAcquisition instead
//// if (acqSettings_.isUsingStageScanning() && acqSettings_.isUsingMultiplePositions()) {
//// final ASIXYStage xyStage = model_.devices().getDevice("SampleXY");
//// final Point2D.Double pos = xyStage.getXYPosition();
//// xyStage.setSpeedX(scanSpeedX_);
//// xyStage.setAccelerationX(scanAccelX_);
//// System.out.println("AFTER_HARDWARE_HOOK trigger");
//// finalController.prepareStageScanForAcquisition(pos.x, pos.y, acqSettings_);
///// finalController.triggerControllerStartAcquisition(acqSettings_.acquisitionMode(),
//// acqSettings_.volumeSettings().firstView());
//// }
// return event;
// }
//
// @Override
// public void close() {
//
// }
// }, Acquisition.AFTER_HARDWARE_HOOK);

final PLogicSCAPE controllerInstance = controller;
// TODO This after camera hook is called after the camera has been readied to acquire a
Expand All @@ -403,8 +413,18 @@ public void close() {
public AcquisitionEvent run(AcquisitionEvent event) {
// TODO: Cameras are now ready to receive triggers, so we can send (software) trigger
// to the tiger to tell it to start outputting TTLs
if (isUsingPLC) {
if (acqSettings_.isUsingStageScanning() && acqSettings_.isUsingMultiplePositions()) {
final ASIXYStage xyStage = model_.devices().getDevice("SampleXY");
final Point2D.Double pos = xyStage.getXYPosition();
xyStage.setSpeedX(scanSpeedX_);
xyStage.setAccelerationX(scanAccelX_);
controllerInstance.prepareStageScanForAcquisition(pos.x, pos.y, acqSettings_);
controllerInstance.triggerControllerStartAcquisition(acqSettings_.acquisitionMode(),
acqSettings_.volumeSettings().firstView());
return event;
}

if (isUsingPLC) { // if not in demo mode
// TODO: is this the best place to set state to idle?
ASIScanner scanner = model_.devices().getDevice("IllumSlice");
// need to set to IDLE to re-arm for each z-stack
Expand All @@ -413,6 +433,7 @@ public AcquisitionEvent run(AcquisitionEvent event) {
scanner.setSPIMState(ASIScanner.SPIMState.IDLE);
}
}

int side = 0;
// NOTE: not sure why this is being triggered twice with only 1 camera; so we need guard
// TODO: enable 2 sided acquisition
Expand Down
Loading