Skip to content

Commit

Permalink
new age
Browse files Browse the repository at this point in the history
  • Loading branch information
mzouink committed Jan 14, 2020
1 parent 7864a17 commit 3615758
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 313 deletions.
109 changes: 4 additions & 105 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,108 +108,12 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-legacy</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-ij</artifactId>
</dependency>
<!-- <dependency> <groupId>net.imglib2</groupId> <artifactId>imglib2-ui</artifactId>
</dependency> <dependency> <groupId>net.imglib2</groupId> <artifactId>imglib2-realtransform</artifactId>
</dependency> <dependency> <groupId>net.imglib2</groupId> <artifactId>imglib2-algorithm</artifactId>
</dependency> -->
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>bigdataviewer-core</artifactId>
</dependency>
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>Fiji_Plugins</artifactId>
</dependency>
<dependency>
<groupId>io.scif</groupId>
<artifactId>scifio</artifactId>
</dependency>
<dependency>
<groupId>io.scif</groupId>
<artifactId>scifio-bf-compat</artifactId>
<scope>runtime</scope>
</dependency>
<!-- The formats-bsd component adds support for open formats. -->
<dependency>
<groupId>ome</groupId>
<artifactId>formats-bsd</artifactId>
<scope>runtime</scope>
</dependency>
<!-- The formats-gpl component adds support for proprietary formats. -->
<dependency>
<groupId>ome</groupId>
<artifactId>formats-gpl</artifactId>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r05</version>

</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka -->

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>net.preibisch</groupId>
<artifactId>multiview-reconstruction</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-imglib2</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>1.1.0</version>
</dependency>
<!-- <dependency> <groupId>ome</groupId> <artifactId>bio-formats_plugins</artifactId>
</dependency> -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>3.9.2</version>
<artifactId>distribution</artifactId>
<version>0.2.2-SNAPSHOT</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -252,7 +156,7 @@
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>net.preibisch.fusiontask.task.FusionV2</mainClass>
<mainClass>net.preibisch.fusiontask.task.Fusion</mainClass>
</manifest>
</archive>

Expand All @@ -268,11 +172,6 @@
</execution>
</executions>
</plugin>

</plugins>
<!-- <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId>
<configuration> <archive> <manifest> <mainClass>main.java.net.preibisch.fusiontask.task.MainJob</mainClass>
</manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </configuration> </plugin> </plugins> -->
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.preibisch.distribution.algorithm.blockmanager.block.BasicBlockInfo;
import net.preibisch.distribution.algorithm.clustering.kafka.KafkaManager;
import net.preibisch.distribution.algorithm.clustering.kafka.KafkaProperties;
import net.preibisch.distribution.algorithm.clustering.scripting.TaskType;
import net.preibisch.distribution.algorithm.clustering.scripting.JobType;
import net.preibisch.distribution.algorithm.controllers.items.BlocksMetaData;
import net.preibisch.distribution.algorithm.task.FusionParams;
import net.preibisch.distribution.io.img.XMLFile;
Expand All @@ -29,62 +29,60 @@
import picocli.CommandLine;
import picocli.CommandLine.Option;

public class FusionV2 implements Callable<Void> {
@Option(names = { "-t", "--task" }, required = false, description = "The path of the Data")

public class Fusion implements Callable<Void> {
@Option(names = { "-t", "--task" }, required = true, description = "The path of the Data")
private String task;

@Option(names = { "-o", "--output" }, required = false, description = "The path of the Data")
@Option(names = { "-o", "--output" }, required = true, description = "The path of the Data")
private String output;

@Option(names = { "-i", "--input" }, required = false, description = "The path of the Data")
@Option(names = { "-i", "--input" }, required = true, description = "The path of the Data")
private String input;

@Option(names = { "-m", "--meta" }, required = false, description = "The path of the MetaData file")
@Option(names = { "-m", "--meta" }, required = true, description = "The path of the MetaData file")
private String metadataPath;

@Option(names = { "-p", "--param" }, required = false, description = "The path of the MetaData file")
@Option(names = { "-p", "--param" }, required = true, description = "The path of the MetaData file")
private String paramPath;

@Option(names = { "-v","-view" }, required = false, description = "The id of block")
private int view;
@Option(names = { "-id" }, required = false, description = "The id of block")
private Integer id;

public FusionV2() {
// TODO Auto-generated constructor stub
}

@Override
public Void call() throws Exception {

try {

try {
id = id - 1;
} catch (Exception e) {
KafkaManager.error(-1, e.toString());
System.out.println("Error id");
throw new Exception("Specify id!");
}
TaskType type = TaskType.of(task);
System.out.println("id: "+id);
id = id - 1;
} catch (Exception e) {
KafkaManager.error(-1, e.toString());
System.out.println("Error id");
throw new Exception("Specify id!");
}
// try {
System.out.println("task: "+task);
JobType type = JobType.of(task);

switch (type) {
case PREPARE:
System.out.println(type.toString());
generateN5(input, metadataPath,paramPath, output, id,view);
return null;
case PROCESS:
System.out.println(type.toString());
blockTask(input, metadataPath, paramPath, output, id,view);
return null;

default:
KafkaManager.error(id, "Specify task");
System.out.println("Error");
throw new Exception("Specify task!");
}
} catch (Exception e) {
KafkaManager.error(id, e.toString());
System.out.println("Error");
throw new Exception("Specify task!");
}
// } catch (Exception e) {
// KafkaManager.error(id, e.toString());
// System.out.println("Error "+e);
// throw new Exception("Specify task!");
// }
// MyLogger.log.info("Block " + id + " saved !");
return null;
}

public static void blockTask(String inputPath, String metadataPath, String paramPath, String outputPath, int id,int view) {
Expand All @@ -95,10 +93,7 @@ public static void blockTask(String inputPath, String metadataPath, String param
FusionParams params = FusionParams.fromJson(paramPath);
String jobId = md.getJobId();
KafkaProperties.setJobId(jobId);
KafkaManager.log(id, "Got metadata !");
BasicBlockInfo binfo = md.getBlocksInfo().get(id);
KafkaManager.log(id, "Got block info !");
// BoundingBox bb = new BoundingBox(Util.long2int(binfo.getMin()), Util.long2int(binfo.getMax()));
KafkaManager.log(id, "Bounding box created: " + params.getBb().toString());
List<ViewId> viewIds = params.getViewIds().get(view);
KafkaManager.log(id, "Got view ids ");
Expand All @@ -108,7 +103,6 @@ public static void blockTask(String inputPath, String metadataPath, String param
KafkaManager.log(id, "Input loaded. ");
// XMLFile inputFile = XMLFile.XMLFile(inputPath);
RandomAccessibleInterval<FloatType> block = inputFile.fuse(params.getBb(),view);

KafkaManager.log(id, "Got block. ");
N5File outputFile = N5File.open(outputPath);
outputFile.saveBlock(block, binfo.getGridOffset());
Expand All @@ -126,7 +120,8 @@ public static void generateN5(String inputPath, String metadataPath,String param
BlocksMetaData md = BlocksMetaData.fromJson(metadataPath);
FusionParams params = FusionParams.fromJson(paramPath);
BoundingBox bb = new BoundingBox(params.getBb());
long[] dims = bb.getDimensions((int)params.getDownsampling());
int down = ((int)params.getDownsampling()==0) ? 1 : (int) params.getDownsampling();
long[] dims = bb.getDimensions(down);
int blockUnit = md.getBlockUnit();
N5File outputFile = new N5File(outputPath, dims, blockUnit);
outputFile.create();
Expand Down Expand Up @@ -160,6 +155,9 @@ public static void generateN5fromXML(String inputPath, String metadataPath, Stri
}

public static void main(String[] args) {
CommandLine.call(new FusionV2(), args);
// new ImageJ();
// String str = "-t pre -i /Users/Marwan/Desktop/testtask/dataset.xml -o /Users/Marwan/Desktop/testtask/0_output.n5 -m /Users/Marwan/Desktop/testtask/0_metadata.json -p /Users/Marwan/Desktop/testtask/0_param.json -id 1";
// System.out.println(String.join(" ", args));
CommandLine.call(new Fusion(), args);
}
}
Loading

0 comments on commit 3615758

Please sign in to comment.