Skip to content

Commit f1c6c5b

Browse files
committed
migrate to FusionTask
1 parent a73d8c2 commit f1c6c5b

File tree

3 files changed

+93
-109
lines changed

3 files changed

+93
-109
lines changed

pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595

9696
<!-- NB: Deploy releases to the SciJava Maven repository. -->
9797
<releaseProfiles>deploy-to-scijava</releaseProfiles>
98-
<imagej-clustering.version>0.2.1-SNAPSHOT</imagej-clustering.version>
9998
</properties>
10099
<repositories>
101100
<!-- NB: for project parent -->
@@ -192,7 +191,7 @@
192191
<dependency>
193192
<groupId>net.preibisch</groupId>
194193
<artifactId>multiview-reconstruction</artifactId>
195-
<version>0.2.17</version>
194+
<version>0.5.0-SNAPSHOT</version>
196195
</dependency>
197196
<dependency>
198197
<groupId>org.janelia.saalfeldlab</groupId>
@@ -211,12 +210,6 @@
211210
<artifactId>picocli</artifactId>
212211
<version>3.9.2</version>
213212
</dependency>
214-
215-
<dependency>
216-
<groupId>net.preibisch</groupId>
217-
<artifactId>imagej-clustering</artifactId>
218-
<version>0.2.1-SNAPSHOT</version><!-- <version>${imagej-clustering.version}</version> -->
219-
</dependency>
220213
</dependencies>
221214

222215
<build>
Lines changed: 72 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,77 @@
11
package net.preibisch.fusiontask.task;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
5-
6-
import ij.ImageJ;
7-
import mpicbg.spim.data.SpimDataException;
8-
import mpicbg.spim.data.sequence.ViewId;
9-
import net.imglib2.FinalInterval;
10-
import net.imglib2.Interval;
11-
import net.imglib2.RandomAccessibleInterval;
12-
import net.imglib2.img.display.imagej.ImageJFunctions;
13-
import net.imglib2.type.numeric.real.FloatType;
14-
import net.imglib2.util.Pair;
15-
import net.preibisch.mvrecon.fiji.spimdata.SpimData2;
16-
import net.preibisch.mvrecon.fiji.spimdata.XmlIoSpimData2;
17-
import net.preibisch.mvrecon.process.fusion.FusionTools;
18-
import net.preibisch.simulation.imgloader.SimulatedBeadsImgLoader;
19-
203
public class Fusion {
214

22-
public class FusionParameters
23-
{
24-
// imput: spimdata (xml)
25-
// which views (list of viewid, which is two integers - timepointid, setupid)
26-
// bounding box (which part to process)
27-
// downsampling
28-
// ...
29-
30-
}
31-
32-
33-
public static void main( String[] args ) throws SpimDataException
34-
{
35-
// imput: spimdata (xml)
36-
// which views (list of viewid, which is two integers - timepointid, setupid)
37-
// bounding box (which part to process)
38-
// downsampling
39-
// ...
40-
41-
List< Pair<Object, Class >> parameters;
42-
43-
// generate 4 views with 1000 corresponding beads, single timepoint
44-
SpimData2 spimData = SpimData2.convert( SimulatedBeadsImgLoader.spimdataExample( new int[]{ 0, 90, 135 } ) );
45-
46-
// load drosophila
47-
//spimData = new XmlIoSpimData2( "" ).load( "/Users/spreibi/Documents/Microscopy/SPIM/HisYFP-SPIM/dataset.xml" );
48-
49-
// select views to process
50-
final List< ViewId > viewIds = new ArrayList< ViewId >();
51-
viewIds.addAll( spimData.getSequenceDescription().getViewDescriptions().values() );
52-
53-
// small part of the bounding box\
54-
Interval bb = new FinalInterval( new long[] {0, 0, 0 }, new long[] {100, 250, 350} );
55-
56-
// downsampling
57-
double downsampling = Double.NaN; //2.0
58-
59-
// perforn the fusion virtually
60-
RandomAccessibleInterval< FloatType > virtual = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
61-
62-
// make a physical copy of the virtual randomaccessibleinterval
63-
//final RandomAccessibleInterval< FloatType > fusedImg = FusionTools.copyImg( virtual, new ImagePlusImgFactory<>( new FloatType() ), new FloatType(), null, true );
64-
65-
// save as one of the blocks of the N5
66-
new ImageJ();
67-
ImageJFunctions.show( virtual );
68-
69-
70-
// task #2
71-
// small part of the bounding box\
72-
bb = new FinalInterval( new long[] {101, 0, 0 }, new long[] {200, 250, 350} );
73-
74-
// perforn the fusion virtually
75-
final RandomAccessibleInterval< FloatType > virtual2 = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
76-
ImageJFunctions.show( virtual2 );
77-
}
78-
79-
80-
public static RandomAccessibleInterval<FloatType> Fusion(String xml, long[] x1, long[] x2) throws SpimDataException{
81-
System.out.println(xml);
82-
SpimData2 spimData = new XmlIoSpimData2( "" ).load(xml);
83-
Interval bb = new FinalInterval(x1, x2);
84-
85-
final List< ViewId > viewIds = new ArrayList< ViewId >();
86-
viewIds.addAll( spimData.getSequenceDescription().getViewDescriptions().values() );
87-
88-
double downsampling = Double.NaN;
89-
90-
final RandomAccessibleInterval< FloatType > virtual = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
91-
92-
return virtual;
93-
}
5+
// public class FusionParameters
6+
// {
7+
// // imput: spimdata (xml)
8+
// // which views (list of viewid, which is two integers - timepointid, setupid)
9+
// // bounding box (which part to process)
10+
// // downsampling
11+
// // ...
12+
//
13+
// }
14+
//
15+
//
16+
// public static void main( String[] args ) throws SpimDataException
17+
// {
18+
// // imput: spimdata (xml)
19+
// // which views (list of viewid, which is two integers - timepointid, setupid)
20+
// // bounding box (which part to process)
21+
// // downsampling
22+
// // ...
23+
//
24+
// List< Pair<Object, Class >> parameters;
25+
//
26+
// // generate 4 views with 1000 corresponding beads, single timepoint
27+
// SpimData2 spimData = SpimData2.convert( SimulatedBeadsImgLoader.spimdataExample( new int[]{ 0, 90, 135 } ) );
28+
//
29+
// // load drosophila
30+
// //spimData = new XmlIoSpimData2( "" ).load( "/Users/spreibi/Documents/Microscopy/SPIM/HisYFP-SPIM/dataset.xml" );
31+
//
32+
// // select views to process
33+
// final List< ViewId > viewIds = new ArrayList< ViewId >();
34+
// viewIds.addAll( spimData.getSequenceDescription().getViewDescriptions().values() );
35+
//
36+
// // small part of the bounding box\
37+
// Interval bb = new FinalInterval( new long[] {0, 0, 0 }, new long[] {100, 250, 350} );
38+
//
39+
// // downsampling
40+
// double downsampling = Double.NaN; //2.0
41+
//
42+
// // perforn the fusion virtually
43+
// RandomAccessibleInterval< FloatType > virtual = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
44+
//
45+
// // make a physical copy of the virtual randomaccessibleinterval
46+
// //final RandomAccessibleInterval< FloatType > fusedImg = FusionTools.copyImg( virtual, new ImagePlusImgFactory<>( new FloatType() ), new FloatType(), null, true );
47+
//
48+
// // save as one of the blocks of the N5
49+
// new ImageJ();
50+
// ImageJFunctions.show( virtual );
51+
//
52+
//
53+
// // task #2
54+
// // small part of the bounding box\
55+
// bb = new FinalInterval( new long[] {101, 0, 0 }, new long[] {200, 250, 350} );
56+
//
57+
// // perforn the fusion virtually
58+
// final RandomAccessibleInterval< FloatType > virtual2 = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
59+
// ImageJFunctions.show( virtual2 );
60+
// }
61+
//
62+
//
63+
// public static RandomAccessibleInterval<FloatType> Fusion(String xml, long[] x1, long[] x2) throws SpimDataException{
64+
// System.out.println(xml);
65+
// SpimData2 spimData = new XmlIoSpimData2( "" ).load(xml);
66+
// Interval bb = new FinalInterval(x1, x2);
67+
//
68+
// final List< ViewId > viewIds = new ArrayList< ViewId >();
69+
// viewIds.addAll( spimData.getSequenceDescription().getViewDescriptions().values() );
70+
//
71+
// double downsampling = Double.NaN;
72+
//
73+
// final RandomAccessibleInterval< FloatType > virtual = FusionTools.fuseVirtual( spimData, viewIds, bb, downsampling );
74+
//
75+
// return virtual;
76+
// }
9477
}

src/net/preibisch/fusiontask/task/MainJob.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import mpicbg.spim.data.sequence.ViewId;
1717
import net.imglib2.RandomAccessibleInterval;
1818
import net.imglib2.type.numeric.real.FloatType;
19-
import net.imglib2.util.Util;
2019
import net.preibisch.distribution.algorithm.blockmanager.block.BasicBlockInfo;
2120
import net.preibisch.distribution.algorithm.clustering.kafka.KafkaManager;
2221
import net.preibisch.distribution.algorithm.clustering.kafka.KafkaProperties;
2322
import net.preibisch.distribution.algorithm.clustering.scripting.TaskType;
2423
import net.preibisch.distribution.algorithm.controllers.items.BlocksMetaData;
24+
import net.preibisch.distribution.algorithm.task.FusionParams;
2525
import net.preibisch.distribution.io.img.XMLFile;
2626
import net.preibisch.distribution.io.img.n5.N5File;
2727
import net.preibisch.distribution.tools.Tools;
@@ -41,7 +41,12 @@ public class MainJob implements Callable<Void> {
4141

4242
@Option(names = { "-m", "--meta" }, required = false, description = "The path of the MetaData file")
4343
private String metadataPath;
44-
44+
45+
@Option(names = { "-p", "--param" }, required = false, description = "The path of the MetaData file")
46+
private String paramPath;
47+
48+
@Option(names = { "-v","-view" }, required = false, description = "The id of block")
49+
private int view;
4550
@Option(names = { "-id" }, required = false, description = "The id of block")
4651
private Integer id;
4752

@@ -63,10 +68,10 @@ public Void call() throws Exception {
6368
TaskType type = TaskType.of(task);
6469
switch (type) {
6570
case PREPARE:
66-
generateN5(input, metadataPath, output, id);
71+
generateN5(input, metadataPath,paramPath, output, id,view);
6772
return null;
6873
case PROCESS:
69-
blockTask(input, metadataPath, output, id);
74+
blockTask(input, metadataPath, paramPath, output, id,view);
7075
return null;
7176

7277
default:
@@ -82,26 +87,27 @@ public Void call() throws Exception {
8287
// MyLogger.log.info("Block " + id + " saved !");
8388
}
8489

85-
public static void blockTask(String inputPath, String metadataPath, String outputPath, int id) {
90+
public static void blockTask(String inputPath, String metadataPath, String paramPath, String outputPath, int id,int view) {
8691
try {
8792
KafkaManager.log(id, "Start process");
8893
// XMLFile inputFile = XMLFile.XMLFile(inputPath);
8994
BlocksMetaData md = BlocksMetaData.fromJson(metadataPath);
95+
FusionParams params = FusionParams.fromJson(paramPath);
9096
String jobId = md.getJobId();
9197
KafkaProperties.setJobId(jobId);
9298
KafkaManager.log(id, "Got metadata !");
9399
BasicBlockInfo binfo = md.getBlocksInfo().get(id);
94100
KafkaManager.log(id, "Got block info !");
95-
BoundingBox bb = new BoundingBox(Util.long2int(binfo.getMin()), Util.long2int(binfo.getMax()));
96-
KafkaManager.log(id, "Bounding box created: " + bb.toString());
97-
List<ViewId> viewIds = md.getViewIds();
101+
// BoundingBox bb = new BoundingBox(Util.long2int(binfo.getMin()), Util.long2int(binfo.getMax()));
102+
KafkaManager.log(id, "Bounding box created: " + params.getBb().toString());
103+
List<ViewId> viewIds = params.getViewIds().get(view);
98104
KafkaManager.log(id, "Got view ids ");
99105

100-
XMLFile inputFile = XMLFile.XMLFile(inputPath, bb, md.getDownsample(), viewIds);
106+
XMLFile inputFile = XMLFile.XMLFile(inputPath, params.getBb(), params.getDownsampling(), viewIds);
101107

102108
KafkaManager.log(id, "Input loaded. ");
103109
// XMLFile inputFile = XMLFile.XMLFile(inputPath);
104-
RandomAccessibleInterval<FloatType> block = inputFile.fuse(bb);
110+
RandomAccessibleInterval<FloatType> block = inputFile.fuse(params.getBb(),view);
105111

106112
KafkaManager.log(id, "Got block. ");
107113
N5File outputFile = N5File.open(outputPath);
@@ -114,11 +120,13 @@ public static void blockTask(String inputPath, String metadataPath, String outpu
114120
}
115121
}
116122

117-
public static void generateN5(String inputPath, String metadataPath, String outputPath, int id) {
123+
public static void generateN5(String inputPath, String metadataPath,String paramPath, String outputPath, int id,int view) {
118124
try {
119125
KafkaManager.log(id, "Start generate n5");
120126
BlocksMetaData md = BlocksMetaData.fromJson(metadataPath);
121-
long[] dims = md.getDimensions();
127+
FusionParams params = FusionParams.fromJson(paramPath);
128+
BoundingBox bb = new BoundingBox(params.getBb());
129+
long[] dims = bb.getDimensions((int)params.getDownsampling());
122130
int blockUnit = md.getBlockUnit();
123131
N5File outputFile = new N5File(outputPath, dims, blockUnit);
124132
outputFile.create();

0 commit comments

Comments
 (0)