Skip to content

Commit

Permalink
Merge pull request #3 from openspim/dev
Browse files Browse the repository at this point in the history
1.0.11
  • Loading branch information
hkmoon authored Nov 28, 2024
2 parents d971541 + 8620f72 commit 0215fdf
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 121 deletions.
Binary file added lib/MMAcqEngine.jar
Binary file not shown.
Binary file modified lib/MMJ_.jar
Binary file not shown.
27 changes: 26 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.openspim</groupId>
<artifactId>uOpenSPIM</artifactId>
<version>1.0.10-SNAPSHOT</version>
<version>1.0.11-SNAPSHOT</version>
<packaging>jar</packaging>

<name>µOpenSPIM</name>
Expand All @@ -18,6 +18,7 @@
<ij.version>1.52p</ij.version>
<mmj.jar.path>${project.basedir}/lib/MMJ_.jar</mmj.jar.path>
<mmcore.jar.path>${project.basedir}/lib/MMCoreJ.jar</mmcore.jar.path>
<mmacq.jar.path>${project.basedir}/lib/MMAcqEngine.jar</mmacq.jar.path>
</properties>

<repositories>
Expand Down Expand Up @@ -161,6 +162,12 @@
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>org.micromanager</groupId>
<artifactId>MMAcqEngine</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>net.haesleinhuepf</groupId>
<artifactId>clijx_</artifactId>
Expand Down Expand Up @@ -261,6 +268,24 @@
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>spim.microOpenSPIM</mainClass>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion scripts/installMMDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
-DartifactId=MMJ_ -Dversion=2.0.0 \
-Dpackaging=jar -DlocalRepositoryPath=local-repo/

mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.8 -Dfile=lib/tools.jar -DgeneratePom=true
mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
-Dfile=lib/MMAcqEngine.jar -DgroupId=org.micromanager \
-DartifactId=MMAcqEngine -Dversion=2.0.0 \
-Dpackaging=jar -DlocalRepositoryPath=local-repo/

mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.8 -Dfile=lib/tools.jar -DgeneratePom=true
5 changes: 3 additions & 2 deletions src/main/java/spim/io/BDVMicroManagerStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ public static void main( String[] args ) throws SpimDataException, IOException {

// create SourceTransform from the images calibration
final AffineTransform3D sourceTransform = new AffineTransform3D();
sourceTransform.set( 1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 9.378, 0 );
double zUnit = 1.524d;
sourceTransform.set( 1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, zUnit, 0 );

for ( int t = 0; t < numTimepoints; ++t )
registrations.add( new ViewRegistration( t, angles * j + i, sourceTransform ) );
Expand Down Expand Up @@ -555,7 +556,7 @@ public void putImage(Image image) throws IOException {
}
}

System.out.println(coords.getC() + "/" + channels);
// System.out.println(coords.getC() + "/" + channels);

if(fusionChannel_ && coords.getC() % 2 == 1)
{
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/spim/model/data/PositionItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public double getZEnd()

public double getZStep()
{
if( zStep == 0 ) zStep = 1.524;
return zStep;
}

Expand Down Expand Up @@ -118,7 +119,8 @@ public void setZEnd( double zEnd )

public void setZStep( double zStep )
{
this.zStep = zStep;
if (zStep != 0)
this.zStep = zStep;
}

public int getNumberOfSlices() {
Expand All @@ -139,6 +141,12 @@ public void setName(String name) {
this.name.set(name);
}

public PositionItem clone(InvalidationListener invalidationListener) {
PositionItem clone = new PositionItem(x, y, r, zStart, zEnd, zStep, invalidationListener );
clone.setName( getName() + " Copy" );
return clone;
}

@Override public String toString()
{
StringBuilder sb = new StringBuilder( );
Expand Down
107 changes: 82 additions & 25 deletions src/main/java/spim/ui/view/component/AcquisitionPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
Expand Down Expand Up @@ -47,9 +48,11 @@
import org.micromanager.display.DisplayWindow;
import org.micromanager.events.internal.DefaultGUIRefreshEvent;
import org.micromanager.internal.MMStudio;
import org.micromanager.internal.utils.ReportingUtils;
import spim.hardware.Camera;
import spim.hardware.SPIMSetup;
import spim.hardware.VersaLase;
import spim.mm.MicroManager;
import spim.model.data.AcquisitionSetting;
import spim.model.data.ChannelItem;
import spim.model.data.PinItem;
Expand All @@ -75,6 +78,10 @@
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import static spim.ui.view.component.util.TableViewUtil.createTimePointItemDataView;
Expand Down Expand Up @@ -749,7 +756,7 @@ public void handle(ActionEvent actionEvent) {
Tab onTheFlyTab = new Tab("On-the-fly", new VBox(2, onTheFlyHBox, onFusionchannelHBox));
onTheFlyTab.setClosable(false);

CheckBox ablationCheckbox = new CheckBox( "Generate ablation.tiff (works with OMETIFF as saving format)" );
CheckBox ablationCheckbox = new CheckBox( "Generate ablation.tiff (works with Single Plane TIFF as saving format)" );

ablationSupport = ablationCheckbox.selectedProperty();
ablationDisabled = ablationCheckbox.disableProperty();
Expand Down Expand Up @@ -1495,6 +1502,14 @@ public boolean startAcquisition( Button acquireButton )
return false;
}

if ((savingFormat.getValue().equals("BDV format") || savingFormat.getValue().equals("N5 format")) &&
!positionItemTableView.getItems().filtered(p -> p.getSelected() && p.getZStart() == p.getZEnd()).isEmpty()) {
new Alert( Alert.AlertType.WARNING, "BDV and N5 format support only multi-stack images.").showAndWait();

System.err.println("Acquisition stopped due to a single stack setup.");
return false;
}

// Write the experiment note
try {
writeNote(folderFile);
Expand Down Expand Up @@ -1541,39 +1556,66 @@ public boolean startAcquisition( Button acquireButton )
fileName = fileName.replace("<timepoints>", timepoints);

String finalFileName = fileName;
acquisitionThread = new Thread(() ->
{
Thread.currentThread().setContextClassLoader( HalcyonMain.class.getClassLoader() );

try
{
engine.performAcquisition( getStudio(), getSpimSetup(), stagePanel, ( java.awt.Rectangle) roiRectangle.get(), tp,
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception
{
engine.performAcquisition( getStudio(), getSpimSetup(), stagePanel, (java.awt.Rectangle) roiRectangle.get(), tp,
timePointItemTableView.getItems(), currentTP, waitSeconds,
arduinoSelected, finalFolder, finalFileName,
positionItemTableView.getItems().filtered(p -> p.getSelected()), channelItemList, processedImages, totalImages.getValue(),
enabledSaveImages.get(), savingFormat.getValue(), saveMIP.getValue(), ablationSupport.getValue(), antiDrift.getValue(), experimentNote.getValue(),
antiDriftLog, antiDriftRefCh.get(), antiDriftTypeToggle, onTheFly.getValue(), onChannelFusion.getValue() );

// new MMAcquisitionRunner().runAcquisition();

// engine.performAcquisitionMM( spimSetup, stagePanel, (java.awt.Rectangle) roiRectangle.get(), tp, deltaT * unit, arduinoSelected, new File(directory.getValue()), filename.getValue(), positionItemTableView.getItems(), channelItemList, processedImages, enabledSaveImages.get());


acquisitionThread = null;
engine = null;
Platform.runLater( () -> {
acquireButton.setText( "Acquire" );
acquireButton.setStyle("-fx-font: 18 arial; -fx-base: #69e760;");
} );
return null;
}
};

// Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
}
catch ( Exception e )
{
e.printStackTrace();
}
task.setOnSucceeded( (e) -> {
System.out.println("task.onSucceeded");

// CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
// //read data through usb device and add it into array;
// try {
// Thread.sleep(10000);
// } catch (InterruptedException ex) {
// throw new RuntimeException(ex);
// }
// });
//
// try {
// future.get(5, TimeUnit.SECONDS);
// ReportingUtils.showErrorOn( true );
// // get here if read was successful
// } catch (InterruptedException ie) {
// Thread.currentThread().interrupt();
// } catch (ExecutionException ee) {
// // exception was thrown by code reading usb device
// } catch (TimeoutException te) {
// // timeout occurred
// }

Timer timer = new java.util.Timer();

timer.schedule(new TimerTask() {
public void run() {
ReportingUtils.showErrorOn( true );

}
}, 5000);
} );
task.setOnFailed(e -> {
} );

ReportingUtils.showErrorOn( false );
acquisitionThread = new Thread(task);
acquisitionThread.start();

return true;
Expand Down Expand Up @@ -1618,14 +1660,23 @@ private Node createPositionListPane( TableView< PositionItem > positionItemTable
double r = spimSetup.getAngle();
double x = spimSetup.getXStage().getPosition();
double y = spimSetup.getYStage().getPosition();
double z = spimSetup.getZStage().getPosition();
double z = stagePanel.getZTargetValue();
// double z = spimSetup.getZStage().getPosition();
positionItemTableView.getItems().add( new PositionItem( x, y, r, z, z, zStackStepSize, invalidationListener ) );
}
else {
positionItemTableView.getItems().add( new PositionItem( 10, 20, 30, 20, 50, 10, invalidationListener ) );
}
};

EventHandler dupEventHandler = ( EventHandler< ActionEvent > ) event -> {
if(positionItemTableView.getSelectionModel().getSelectedIndex() > -1) {
PositionItem clone = positionItemTableView.getItems().get(positionItemTableView.getSelectionModel().getSelectedIndex()).clone(invalidationListener);
positionItemTableView.getItems().add( clone );
}
};


EventHandler deleteEventHandler = new EventHandler< ActionEvent >()
{
@Override public void handle( ActionEvent event )
Expand All @@ -1639,6 +1690,10 @@ private Node createPositionListPane( TableView< PositionItem > positionItemTable
newButton.setMinHeight(30);
newButton.setOnAction( newEventHandler );

Button dupButton = new Button("Duplicate");
dupButton.setMinHeight(30);
dupButton.setOnAction( dupEventHandler );

Button deleteButton = new Button("Delete position");
deleteButton.setMinHeight(30);
deleteButton.setOnAction( deleteEventHandler );
Expand Down Expand Up @@ -1690,7 +1745,7 @@ private Node createPositionListPane( TableView< PositionItem > positionItemTable
Button helpButton = createHelpButton();
helpButton.setOnAction( event -> new HelpWindow().show(HelpType.POSITION));

HBox hbox = new HBox( 5, newButton, deleteButton, showAllPositionsButton );
HBox hbox = new HBox( 5, newButton, dupButton, deleteButton, showAllPositionsButton );

// If it gives the confusion changing position values without intention,
// Remove the currentPosition change event handler,
Expand Down Expand Up @@ -1837,14 +1892,14 @@ public void handle(ActionEvent event) {
c.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observableValue, Object o, Object t1) {
if(ablationSupport != null && !t1.equals("OMETIFF Image stack")) {
if(ablationSupport != null && !t1.equals("Single Plane TIFF")) {
ablationSupport.set(false);
}
}
});

savingFormat = c.valueProperty();
ablationDisabled.bind(savingFormat.isNotEqualTo("OMETIFF Image stack"));
ablationDisabled.bind(savingFormat.isNotEqualTo("Single Plane TIFF"));

gridpane.addRow( 3, new Label( "Saving format:" ), c );

Expand Down Expand Up @@ -2380,7 +2435,7 @@ private void addNewPosition( int zStart, int zEnd, double zStep ) {
y = Math.ceil(y * 100) / 100;

if( zStart < 0 && zEnd < 0 ) {
double z = spimSetup.getZStage().getPosition();
double z = stagePanel.getZTargetValue();
positionItemTableView.getItems().add(new PositionItem(x, y, r, z, z, zStep, invalidationListener));
} else {
positionItemTableView.getItems().add(new PositionItem(x, y, r, zStart, zEnd, zStep, invalidationListener));
Expand All @@ -2403,7 +2458,8 @@ private void setupMouseClickedHandler( Button startButton, TextField zStartField
{
SPIMSetup spimSetup = getSpimSetup();
if(spimSetup != null && spimSetup.getZStage() != null) {
int currPos = (int) spimSetup.getZStage().getPosition();
// int currPos = (int) spimSetup.getZStage().getPosition();
int currPos = (int) stagePanel.getZTargetValue();
if(zEndField.getText().isEmpty()) {
zStartField.setText(currPos + "");
zStartField.setDisable(true);
Expand Down Expand Up @@ -2436,7 +2492,8 @@ private void setupMouseClickedHandler( Button startButton, TextField zStartField
zStepComboBox.getSelectionModel().select(1);
}

int currPos = (int) spimSetup.getZStage().getPosition();
// int currPos = (int) spimSetup.getZStage().getPosition();
int currPos = (int) stagePanel.getZTargetValue();
if(zStartField.getText().isEmpty()) {
zEndField.setText(currPos + "");
zEndField.setDisable(true);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spim/ui/view/component/BeanshellEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import spim.hardware.SPIMSetup;
import spim.mm.MicroManager;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -203,6 +204,7 @@ final void createBeanshellREPL() {
}

beanshellThread = new Thread(beanshellREPLint_, "BeanShell interpreter");
beanshellThread.setContextClassLoader( MicroManager.getMMStudio().getClass().getClassLoader() );
beanshellThread.start();

running_ = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spim/ui/view/component/HalcyonMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void start( Stage primaryStage )
{
@Override public void run()
{
Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
// Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
try
{
Thread.sleep(1000);
Expand Down
Loading

0 comments on commit 0215fdf

Please sign in to comment.