Buggy code:
gui_ . openAcquisition ( acqName , "" , nrImages , 1 , 1 , 1 , true , false ) ; gui_ . initializeAcquisition ( acqName , ( ( int ) ( gui_ . getMMCore ( ) . getImageWidth ( ) ) ) , ( ( int ) ( gui_ . getMMCore ( ) . getImageHeight ( ) ) ) , ( ( int ) ( gui_ . getMMCore ( ) . getBytesPerPixel ( ) ) ) , ( ( int ) ( gui_ . getMMCore ( ) . getImageBitDepth ( ) ) ) ) ; } gui_ . getMMCore ( ) . clearCircularBuffer ( ) ; gui_ . getMMCore ( ) . initializeCircularBuffer ( ) ; cameras_ . setSPIMCamerasForAcquisition ( true ) ; gui_ . getMMCore ( ) . setExposure ( ( ( double ) ( sliceTiming . cameraExposure ) ) ) ; gui_ . getMMCore ( ) . startSequenceAcquisition ( camera , nrImages , 0 , true ) ; boolean success = controller_ . triggerControllerStartAcquisition ( SLICE_SCAN_ONLY , side . equals ( A ) ) ; if ( ! success ) { throw new ASIdiSPIMException ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>trigger<seq2seq4repair_space>controller" ) ; } long startTime = System . currentTimeMillis ( ) ; long now = startTime ; long timeout = 5000 ; while ( ( ( gui_ . getMMCore ( ) . getRemainingImageCount ( ) ) == 0 ) && ( ( now - startTime ) < timeout ) ) { now = System . currentTimeMillis ( ) ; Thread . sleep ( 5 ) ; } if ( ( now - startTime ) >= timeout ) { throw new ASIdiSPIMException ( "Camera<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>send<seq2seq4repair_space>first<seq2seq4repair_space>image<seq2seq4repair_space>within<seq2seq4repair_space>a<seq2seq4repair_space>reasonable<seq2seq4repair_space>time" ) ; } boolean done = false ; int counter = 0 ; startTime = System . currentTimeMillis ( ) ; while ( ( ( ( gui_ . getMMCore ( ) . getRemainingImageCount ( ) ) > 0 ) || ( gui_ . getMMCore ( ) . isSequenceRunning ( camera ) ) ) && ( ! done ) ) { now = System . currentTimeMillis ( ) ; if ( ( gui_ . getMMCore ( ) . getRemainingImageCount ( ) ) > 0 ) { TaggedImage timg = gui_ . getMMCore ( ) . popNextTaggedImage ( ) ; ImageProcessor ip = AutofocusUtils . makeProcessor ( timg ) ; focusScores [ counter ] = gui_ . getAutofocus ( ) . computeScore ( ip ) ; imageStore [ counter ] = timg ; ReportingUtils . logDebugMessage ( ( ( ( "Autofocus,<seq2seq4repair_space>image:<seq2seq4repair_space>" + counter ) + ",<seq2seq4repair_space>score:<seq2seq4repair_space>" ) + ( focusScores [ counter ] ) ) ) ; if ( debug ) { double zPos = piezoStart + ( counter * piezoStepSize ) ; double galvoPos = galvoStart + ( counter * galvoStepSize ) ; timg . tags . put ( "SlicePosition" , galvoPos ) ; timg . tags . put ( "ZPositionUm" , zPos ) ; gui_ . addImageToAcquisition ( acqName , 0 , 0 , counter , 0 , timg ) ; scoresToPlot [ 0 ] . add ( galvoPos , focusScores [ counter ] ) ; } counter ++ ; if ( counter >= nrImages ) { done = true ; } } if ( ( now - startTime ) > timeout ) { throw new ASIdiSPIMException ( "No<seq2seq4repair_space>image<seq2seq4repair_space>arrived<seq2seq4repair_space>in<seq2seq4repair_space>5<seq2seq4repair_space>seconds" ) ; } } if ( usingDemoCam ) { Thread . sleep ( 1000 ) ; } gui_ . getMMCore ( ) . setShutterOpen ( shutterOpen ) ; gui_ . getMMCore ( ) . setAutoShutter ( autoShutter ) ; double [ ] fitParms = Fitter . fit ( scoresToPlot [ 0 ] , function , null ) ; bestScore = Fitter . getMaxX ( scoresToPlot [ 0 ] , function , fitParms ) ; int highestIndex = Fitter . getIndex ( scoresToPlot [ 0 ] , bestScore ) ; scoresToPlot [ 1 ] = Fitter . getFittedSeries ( scoresToPlot [ 0 ] , function , fitParms ) ; ImageProcessor bestIP = AutofocusUtils . makeProcessor ( imageStore [ highestIndex ] ) ; ImagePlus bestIPlus = new ImagePlus ( ) ; bestIPlus . setProcessor ( bestIP ) ; if ( ( gui_ . getSnapLiveWin ( ) ) != null ) { try { gui_ . addImageToAcquisition ( "Snap//Live<seq2seq4repair_space>Window" , 0 , 0 , 0 , 0 , imageStore [ highestIndex ] ) ; } catch ( MMScriptException ex ) { ReportingUtils . logError ( ex , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>image<seq2seq4repair_space>to<seq2seq4repair_space>Snap//Live<seq2seq4repair_space>Window" ) ; } } if ( debug ) { PlotUtils plotter = new PlotUtils ( prefs_ , "AutofocusUtils" ) ; boolean [ ] showSymbols = new boolean [ ] { true , false } ; <START_BUG> plotter . plotDataN ( "Focus<seq2seq4repair_space>curve" , scoresToPlot , "Galvo<seq2seq4repair_space>position<seq2seq4repair_space>(degree)" , "Score" , showSymbols , false ) ; <END_BUG> } } catch ( ASIdiSPIMException ex ) { throw ex ; } catch ( Exception ex ) { throw new ASIdiSPIMException ( ex ) ; } finally { try { caller . setCursor ( Cursor . getDefaultCursor ( ) ) ; gui_ . getMMCore ( ) . stopSequenceAcquisition ( camera ) ; gui_ . getMMCore ( ) . setCameraDevice ( originalCamera ) ; if ( debug ) { gui_ . promptToSaveAcquisition ( acqName , false ) ; } controller_ . cleanUpControllerAfterAcquisition ( 1 , side . toString ( ) , false ) ; cameras_ . setSPIMCamerasForAcquisition ( false ) ; caller . refreshSelected ( ) ; positions_ . setPosition ( galvoDevice , Y , bestScore ) ; posUpdater_ . pauseUpdates ( false ) ; if ( liveModeOriginally ) { gui_ . getMMCore ( ) . waitForDevice ( camera ) ; gui_ . getMMCore ( ) . waitForDevice ( originalCamera ) ; gui_ . enableLiveMode ( true ) ; } } catch ( Exception ex ) { throw new ASIdiSPIMException ( ex , "Error<seq2seq4repair_space>while<seq2seq4repair_space>restoring<seq2seq4repair_space>hardware<seq2seq4repair_space>state" ) ; } } return bestScore ; } @ Override protected void done ( ) { try { get ( ) ; } catch ( InterruptedException ex ) { MyDialogUtils . showError ( ex ) ; }

Fix:
plotter . plotDataN ( "Focus<seq2seq4repair_space>curve" , scoresToPlot , "Galvo<seq2seq4repair_space>position<seq2seq4repair_space>(degree)" , "Score" , showSymbols ) ;