Skip to content

Commit bc6f528

Browse files
author
moon
committed
Merge branch 'dev' into 'master'
1.0.5 Closes #189, #190, and #188 See merge request scicomp/scidev_team/spimacquisition!2
2 parents bf89a77 + 5161e97 commit bc6f528

File tree

12 files changed

+247
-37
lines changed

12 files changed

+247
-37
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>org.openspim</groupId>
99
<artifactId>uOpenSPIM</artifactId>
10-
<version>1.0.4-SNAPSHOT</version>
10+
<version>1.0.5-SNAPSHOT</version>
1111
<packaging>jar</packaging>
1212

1313
<name>µOpenSPIM</name>

src/main/java/spim/algorithm/DefaultAntiDrift.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package spim.algorithm;
22

33
import ij.ImageStack;
4+
import ij.plugin.filter.Convolver;
5+
import ij.plugin.filter.GaussianBlur;
6+
import ij.plugin.filter.RankFilters;
47
import ij.process.*;
58
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
69

@@ -18,6 +21,14 @@ public class DefaultAntiDrift extends AbstractAntiDrift
1821
*/
1922
private final double sigma;
2023
private final AntiDrift.Type type;
24+
private final GaussianBlur gaussianBlur = new GaussianBlur();
25+
private final Convolver convolver = new Convolver();
26+
private final RankFilters filters = new RankFilters();
27+
private final float[] kernel = new float[]{-1, -1, -1, -1, -1,
28+
-1, -1, -1, -1, -1,
29+
-1, -1, 24, -1, -1,
30+
-1, -1, -1, -1, -1,
31+
-1, -1, -1, -1, -1,};
2132

2233
public DefaultAntiDrift(double sigmaValue)
2334
{
@@ -49,14 +60,16 @@ public void reset()
4960
@Override public void addXYSlice( ImageProcessor ip )
5061
{
5162
ImageProcessor copy = ip.duplicate();
63+
gaussianBlur.blurGaussian( copy, sigma );
64+
convolver.convolve( copy, kernel, 5, 5 );
65+
filters.rank( copy, 2, 2 );
5266

5367
switch (type) {
5468
case CenterOfMass:
5569
if(stack == null) stack = new ImageStack( ip.getWidth(), ip.getHeight() );
5670
stack.addSlice( copy );
5771
break;
5872
case PhaseCorrelation:
59-
copy.blurGaussian( sigma );
6073
latest.addXYSlice( copy );
6174
break;
6275
}

src/main/java/spim/mm/MicroManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,14 +1331,14 @@ public static void shutdown()
13311331

13321332
@Subscribe
13331333
public void onAcquisitionStart( AcquisitionStartedEvent ae) {
1334-
System.out.println("Acquisition started");
1334+
// System.out.println("Acquisition started");
13351335
// store_ = ae.getDatastore();
13361336
}
13371337

13381338

13391339
@Subscribe
13401340
public void onAcquisitionEnd( AcquisitionEndedEvent ae) {
1341-
System.out.println("Acquisition stopped");
1341+
// System.out.println("Acquisition stopped");
13421342
// store_ = null;
13431343
}
13441344

@@ -1349,7 +1349,7 @@ public void onSystemConfigurationLoaded(SystemConfigurationLoadedEvent event) {
13491349

13501350
@Subscribe
13511351
public void onStagePositionChanged(StagePositionChangedEvent event) {
1352-
System.out.println("Stage changed");
1352+
// System.out.println("Stage changed");
13531353
}
13541354

13551355
@Subscribe

src/main/java/spim/model/data/PositionItem.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package spim.model.data;
22

3+
import javafx.beans.InvalidationListener;
4+
import javafx.beans.property.BooleanProperty;
5+
import javafx.beans.property.SimpleBooleanProperty;
6+
import javafx.beans.property.SimpleStringProperty;
7+
import javafx.beans.property.StringProperty;
8+
39
/**
410
* Description: PositionItem is used for position table.
511
*
@@ -15,19 +21,23 @@ public class PositionItem
1521
private double zStart;
1622
private double zEnd;
1723
private double zStep;
24+
private final BooleanProperty selected = new SimpleBooleanProperty();
25+
private final StringProperty name = new SimpleStringProperty();
1826

1927
public PositionItem()
2028
{
2129
}
2230

23-
public PositionItem( double x, double y, double r, double zStart, double zEnd, double zStep )
31+
public PositionItem( double x, double y, double r, double zStart, double zEnd, double zStep, InvalidationListener invalidationListener )
2432
{
2533
this.x = x;
2634
this.y = y;
2735
this.r = r;
2836
this.zStart = zStart;
2937
this.zEnd = zEnd;
3038
this.zStep = zStep;
39+
this.name.set("");
40+
selectedProperty().addListener( observable -> invalidationListener.invalidated( observable ) );
3141
}
3242

3343
public double getX()
@@ -74,6 +84,12 @@ public String getPosZString() {
7484
return String.format( "%.0f", zStart );
7585
}
7686

87+
public String getName() {
88+
return name.getValue();
89+
}
90+
91+
public StringProperty getNameProperty() { return name; }
92+
7793
public void setX( double x )
7894
{
7995
this.x = x;
@@ -105,7 +121,21 @@ public void setZStep( double zStep )
105121
}
106122

107123
public int getNumberOfSlices() {
108-
return (int) ((int) (getZEnd() - getZStart() + getZStep()) / getZStep());
124+
return (int) ((int) (getZEnd() - getZStart() + getZStep()) / getZStep() + 1);
125+
}
126+
127+
public BooleanProperty selectedProperty() { return selected; }
128+
129+
public boolean getSelected() {
130+
return selected.get();
131+
}
132+
133+
public void setSelected(boolean selected) {
134+
this.selected.set( selected );
135+
}
136+
137+
public void setName(String name) {
138+
this.name.set(name);
109139
}
110140

111141
@Override public String toString()

src/main/java/spim/ui/view/component/AcquisitionPanel.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public AcquisitionPanel(SPIMSetup setup, Studio studio, StagePanel stagePanel, T
389389
{
390390
@Override public void changed( ObservableValue< ? extends Number > observable, Number oldValue, Number newValue )
391391
{
392+
// System.out.println(String.format("%f / %d", newValue.doubleValue(), totalImages.getValue()));
392393
pi.setProgress( newValue.doubleValue() / totalImages.getValue() );
393394
}
394395
} );
@@ -1207,6 +1208,13 @@ private void updateUI ( AcquisitionSetting setting ) {
12071208
positionItems = setting.getPositionItems();
12081209
positionItemTableView.getItems().setAll( positionItems );
12091210

1211+
InvalidationListener invalidationListener = observable -> computeTotalPositionImages();
1212+
for(int i = 0; i < positionItems.size(); i++) {
1213+
// positionItems.get( i ).setValue( positionItems.get(i).getValue() );
1214+
// positionItems.get( i ).setSelected( positionItems.get(i).getSelected() );
1215+
positionItems.get( i ).selectedProperty().addListener( observable -> invalidationListener.invalidated( observable ) );
1216+
}
1217+
12101218
// 3. Z-Stack panel
12111219
enabledZStacks.set( setting.getEnabledZStacks() );
12121220

@@ -1353,7 +1361,7 @@ public boolean startAcquisition( Button acquireButton )
13531361
if ( enabledSaveImages.get() )
13541362
{
13551363
if(null != folder.listFiles()) {
1356-
boolean found = folder.exists();
1364+
boolean found = folder.exists() && folder.listFiles().length > 1;
13571365

13581366
if(found) {
13591367
Optional< ButtonType > results = new Alert( Alert.AlertType.WARNING, "The filename already exists. All files with the same name will be replaced. Do you want to proceed?\nPress No to create another folder and keep all files.",
@@ -1462,7 +1470,7 @@ public boolean startAcquisition( Button acquireButton )
14621470
engine.performAcquisition( getStudio(), getSpimSetup(), stagePanel, ( java.awt.Rectangle) roiRectangle.get(), tp,
14631471
timePointItemTableView.getItems(), currentTP, waitSeconds,
14641472
arduinoSelected, finalFolder, filename.getValue(),
1465-
positionItemTableView.getItems(), channelItemList, processedImages,
1473+
positionItemTableView.getItems().filtered(p -> p.getSelected()), channelItemList, processedImages,
14661474
enabledSaveImages.get(), savingFormat.getValue(), saveMIP.getValue(), antiDrift.getValue(), experimentNote.getValue(),
14671475
antiDriftLog, antiDriftRefCh.get(), antiDriftTypeToggle, onTheFly.getValue() );
14681476

@@ -1515,17 +1523,19 @@ static double getUnit(String unitString) {
15151523
private Node createPositionListPane( TableView< PositionItem > positionItemTableView ) {
15161524
positionItemTableView.setEditable( true );
15171525

1526+
InvalidationListener invalidationListener = observable -> computeTotalPositionImages();
1527+
15181528
EventHandler newEventHandler = ( EventHandler< ActionEvent > ) event -> {
15191529
SPIMSetup spimSetup = getSpimSetup();
15201530
if(spimSetup != null ) {
15211531
double r = spimSetup.getThetaStage().getPosition();
15221532
double x = spimSetup.getXStage().getPosition();
15231533
double y = spimSetup.getYStage().getPosition();
15241534
double z = spimSetup.getZStage().getPosition();
1525-
positionItemTableView.getItems().add( new PositionItem( x, y, r, z, z, zStackStepSize ) );
1535+
positionItemTableView.getItems().add( new PositionItem( x, y, r, z, z, zStackStepSize, invalidationListener ) );
15261536
}
15271537
else {
1528-
positionItemTableView.getItems().add( new PositionItem( 10, 20, 30, 20, 50, 10 ) );
1538+
positionItemTableView.getItems().add( new PositionItem( 10, 20, 30, 20, 50, 10, invalidationListener ) );
15291539
}
15301540
};
15311541

@@ -1610,12 +1620,12 @@ public void computeTotalPositionImages() {
16101620
long totalImages = 0;
16111621
for(PositionItem item : positionItemTableView.getItems())
16121622
{
1613-
if(item.getZEnd() > item.getZStart()) {
1623+
if(item.getSelected() && item.getZEnd() > item.getZStart()) {
16141624
totalImages += item.getNumberOfSlices();
16151625
}
16161626
}
16171627

1618-
propertyMap.get("positions").setValue( positionItemTableView.getItems().size() + "" );
1628+
propertyMap.get("positions").setValue( positionItemTableView.getItems().filtered(p -> p.getSelected()).size() + "" );
16191629
propertyMap.get("slices").setValue( totalImages + "" );
16201630
}
16211631

@@ -1853,6 +1863,8 @@ private LabeledPane createSummaryPane() {
18531863
label.textProperty().bind( propertyMap.get("positions") );
18541864
label.textProperty().addListener( observable -> computeTotal() );
18551865

1866+
propertyMap.get("slices").addListener( observable -> computeTotal() );
1867+
18561868
Label label2 = new Label();
18571869
label2.textProperty().bind( propertyMap.get("totalImages") );
18581870
gridpane.addRow( 0, new Label("No. of positions: "), label, new Label("Total images: "), label2 );
@@ -2097,7 +2109,8 @@ public void changed(ObservableValue<? extends String> observable, String oldValu
20972109
// }
20982110
// } );
20992111

2100-
Button clearButton = new Button( "New Z-stack" );
2112+
Button clearButton = new Button( "Define new Z-stack" );
2113+
clearButton.setStyle("-fx-base: #ffbec4;");
21012114
clearButton.setOnAction(new EventHandler<ActionEvent>() {
21022115
@Override
21032116
public void handle(ActionEvent event) {
@@ -2134,7 +2147,7 @@ public void handle(ActionEvent event) {
21342147
}
21352148
} );
21362149

2137-
zStackGridPane.addRow( 3, new HBox( newButton, clearButton ) );
2150+
zStackGridPane.addRow( 3, new VBox( newButton, clearButton ) );
21382151

21392152
// create a group
21402153
HBox b = new HBox(new Label("Stage"));
@@ -2148,13 +2161,15 @@ public void handle(ActionEvent event) {
21482161
Button helpButton = createHelpButton();
21492162
helpButton.setOnAction( event -> new HelpWindow().show(HelpType.ZSTACK));
21502163

2151-
CheckboxPane pane = new CheckboxPane( "Define Z-stacks", zStackGroup, helpButton );
2164+
CheckboxPane pane = new CheckboxPane( "Z-stacks", zStackGroup, helpButton );
21522165
enabledZStacks = pane.selectedProperty();
21532166
return pane;
21542167
}
21552168

21562169
private void addNewPosition( int zStart, int zEnd, double zStep ) {
21572170
SPIMSetup spimSetup = getSpimSetup();
2171+
InvalidationListener invalidationListener = observable -> computeTotalPositionImages();
2172+
21582173
if(spimSetup != null ) {
21592174
double r = spimSetup.getThetaStage().getPosition();
21602175
double x = spimSetup.getXStage().getPosition();
@@ -2164,13 +2179,13 @@ private void addNewPosition( int zStart, int zEnd, double zStep ) {
21642179

21652180
if( zStart < 0 && zEnd < 0 ) {
21662181
double z = spimSetup.getZStage().getPosition();
2167-
positionItemTableView.getItems().add(new PositionItem(x, y, r, z, z, zStep));
2182+
positionItemTableView.getItems().add(new PositionItem(x, y, r, z, z, zStep, invalidationListener));
21682183
} else {
2169-
positionItemTableView.getItems().add(new PositionItem(x, y, r, zStart, zEnd, zStep));
2184+
positionItemTableView.getItems().add(new PositionItem(x, y, r, zStart, zEnd, zStep, invalidationListener));
21702185
}
21712186
}
21722187
else {
2173-
positionItemTableView.getItems().add( new PositionItem( 10, 20, 30, zStart, zEnd, zStep ) );
2188+
positionItemTableView.getItems().add( new PositionItem( 10, 20, 30, zStart, zEnd, zStep, invalidationListener ) );
21742189
}
21752190
}
21762191

src/main/java/spim/ui/view/component/MMAcquisitionEngine.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ private void runNormalSmartImagingMMAcq(SPIMSetup setup, final Studio frame, Dat
380380
if(toogleGroupValue.equals("Centre of mass")) {
381381
driftCompMap.put(positionItem, new DefaultAntiDrift());
382382
} else if(toogleGroupValue.equals("Phase correlation")) {
383-
driftCompMap.put(positionItem, new DefaultAntiDrift(10));
383+
driftCompMap.put(positionItem, new DefaultAntiDrift(2));
384384
}
385385
}
386386
}
387387

388388
AcqWrapperEngine engine = new AcqWrapperEngine( setup, frame, store, currentCamera, cameras, outFolder, acqFilenamePrefix, channelItems, arduinoSelected, processedImages, driftCompMap, adReferenceChannel, onTheFly);
389389

390+
SystemInfo.dumpMemoryStatusToLog(core);
391+
390392
mainLoop:
391393
for(TimePointItem tpItem : timePointItems ) {
392394
if(tpItem.getType().equals( TimePointItem.Type.Acq ))
@@ -398,8 +400,6 @@ private void runNormalSmartImagingMMAcq(SPIMSetup setup, final Studio frame, Dat
398400

399401
int step = 0;
400402

401-
SystemInfo.dumpMemoryStatusToLog(core);
402-
403403
for ( PositionItem positionItem : positionItems )
404404
{
405405
final int tp = timePoints;
@@ -482,7 +482,7 @@ private void runNormalSmartImagingMMAcq(SPIMSetup setup, final Studio frame, Dat
482482
}
483483

484484
core.logMessage("MMAcquisition started");
485-
System.out.println("MMAcquisition started");
485+
// System.out.println("MMAcquisition started");
486486
engine.startAcquire( timePoints, step, positionItem );
487487

488488
while(engine.isAcquisitionRunning()) {
@@ -498,7 +498,7 @@ private void runNormalSmartImagingMMAcq(SPIMSetup setup, final Studio frame, Dat
498498
}
499499

500500
core.logMessage("MMAcquisition finished");
501-
System.out.println("MMAcquisition finished");
501+
// System.out.println("MMAcquisition finished");
502502

503503
if(setup.getArduino1() != null)
504504
setup.getArduino1().setSwitchState( "0" );
@@ -594,6 +594,8 @@ else if(tpItem.getType().equals( TimePointItem.Type.Wait ))
594594
}
595595
}
596596

597+
SystemInfo.dumpMemoryStatusToLog(core);
598+
597599
engine.exit();
598600
store.freeze();
599601
System.err.println("AcquisitionEngine exited.");

0 commit comments

Comments
 (0)