1919import net .preibisch .distribution .algorithm .blockmanager .block .BasicBlockInfo ;
2020import net .preibisch .distribution .algorithm .clustering .kafka .KafkaManager ;
2121import net .preibisch .distribution .algorithm .clustering .kafka .KafkaProperties ;
22- import net .preibisch .distribution .algorithm .clustering .scripting .TaskType ;
22+ import net .preibisch .distribution .algorithm .clustering .scripting .JobType ;
2323import net .preibisch .distribution .algorithm .controllers .items .BlocksMetaData ;
2424import net .preibisch .distribution .algorithm .task .FusionParams ;
2525import net .preibisch .distribution .io .img .XMLFile ;
2929import picocli .CommandLine ;
3030import picocli .CommandLine .Option ;
3131
32- public class FusionV2 implements Callable <Void > {
33- @ Option (names = { "-t" , "--task" }, required = false , description = "The path of the Data" )
32+
33+ public class Fusion implements Callable <Void > {
34+ @ Option (names = { "-t" , "--task" }, required = true , description = "The path of the Data" )
3435 private String task ;
3536
36- @ Option (names = { "-o" , "--output" }, required = false , description = "The path of the Data" )
37+ @ Option (names = { "-o" , "--output" }, required = true , description = "The path of the Data" )
3738 private String output ;
3839
39- @ Option (names = { "-i" , "--input" }, required = false , description = "The path of the Data" )
40+ @ Option (names = { "-i" , "--input" }, required = true , description = "The path of the Data" )
4041 private String input ;
4142
42- @ Option (names = { "-m" , "--meta" }, required = false , description = "The path of the MetaData file" )
43+ @ Option (names = { "-m" , "--meta" }, required = true , description = "The path of the MetaData file" )
4344 private String metadataPath ;
4445
45- @ Option (names = { "-p" , "--param" }, required = false , description = "The path of the MetaData file" )
46+ @ Option (names = { "-p" , "--param" }, required = true , description = "The path of the MetaData file" )
4647 private String paramPath ;
4748
4849 @ Option (names = { "-v" ,"-view" }, required = false , description = "The id of block" )
4950 private int view ;
5051 @ Option (names = { "-id" }, required = false , description = "The id of block" )
5152 private Integer id ;
5253
53- public FusionV2 () {
54- // TODO Auto-generated constructor stub
55- }
56-
5754 @ Override
5855 public Void call () throws Exception {
56+
5957 try {
60-
61- try {
62- id = id - 1 ;
63- } catch (Exception e ) {
64- KafkaManager .error (-1 , e .toString ());
65- System .out .println ("Error id" );
66- throw new Exception ("Specify id!" );
67- }
68- TaskType type = TaskType .of (task );
58+ System .out .println ("id: " +id );
59+ id = id - 1 ;
60+ } catch (Exception e ) {
61+ KafkaManager .error (-1 , e .toString ());
62+ System .out .println ("Error id" );
63+ throw new Exception ("Specify id!" );
64+ }
65+ // try {
66+ System .out .println ("task: " +task );
67+ JobType type = JobType .of (task );
68+
6969 switch (type ) {
7070 case PREPARE :
71+ System .out .println (type .toString ());
7172 generateN5 (input , metadataPath ,paramPath , output , id ,view );
7273 return null ;
7374 case PROCESS :
75+ System .out .println (type .toString ());
7476 blockTask (input , metadataPath , paramPath , output , id ,view );
7577 return null ;
76-
77- default :
78- KafkaManager .error (id , "Specify task" );
79- System .out .println ("Error" );
80- throw new Exception ("Specify task!" );
8178 }
82- } catch (Exception e ) {
83- KafkaManager .error (id , e .toString ());
84- System .out .println ("Error" );
85- throw new Exception ("Specify task!" );
86- }
79+ // } catch (Exception e) {
80+ // KafkaManager.error(id, e.toString());
81+ // System.out.println("Error "+e );
82+ // throw new Exception("Specify task!");
83+ // }
8784 // MyLogger.log.info("Block " + id + " saved !");
85+ return null ;
8886 }
8987
9088 public static void blockTask (String inputPath , String metadataPath , String paramPath , String outputPath , int id ,int view ) {
@@ -95,10 +93,7 @@ public static void blockTask(String inputPath, String metadataPath, String param
9593 FusionParams params = FusionParams .fromJson (paramPath );
9694 String jobId = md .getJobId ();
9795 KafkaProperties .setJobId (jobId );
98- KafkaManager .log (id , "Got metadata !" );
9996 BasicBlockInfo binfo = md .getBlocksInfo ().get (id );
100- KafkaManager .log (id , "Got block info !" );
101- // BoundingBox bb = new BoundingBox(Util.long2int(binfo.getMin()), Util.long2int(binfo.getMax()));
10297 KafkaManager .log (id , "Bounding box created: " + params .getBb ().toString ());
10398 List <ViewId > viewIds = params .getViewIds ().get (view );
10499 KafkaManager .log (id , "Got view ids " );
@@ -108,7 +103,6 @@ public static void blockTask(String inputPath, String metadataPath, String param
108103 KafkaManager .log (id , "Input loaded. " );
109104 // XMLFile inputFile = XMLFile.XMLFile(inputPath);
110105 RandomAccessibleInterval <FloatType > block = inputFile .fuse (params .getBb (),view );
111-
112106 KafkaManager .log (id , "Got block. " );
113107 N5File outputFile = N5File .open (outputPath );
114108 outputFile .saveBlock (block , binfo .getGridOffset ());
@@ -126,7 +120,8 @@ public static void generateN5(String inputPath, String metadataPath,String param
126120 BlocksMetaData md = BlocksMetaData .fromJson (metadataPath );
127121 FusionParams params = FusionParams .fromJson (paramPath );
128122 BoundingBox bb = new BoundingBox (params .getBb ());
129- long [] dims = bb .getDimensions ((int )params .getDownsampling ());
123+ int down = ((int )params .getDownsampling ()==0 ) ? 1 : (int ) params .getDownsampling ();
124+ long [] dims = bb .getDimensions (down );
130125 int blockUnit = md .getBlockUnit ();
131126 N5File outputFile = new N5File (outputPath , dims , blockUnit );
132127 outputFile .create ();
@@ -160,6 +155,9 @@ public static void generateN5fromXML(String inputPath, String metadataPath, Stri
160155 }
161156
162157 public static void main (String [] args ) {
163- CommandLine .call (new FusionV2 (), args );
158+ // new ImageJ();
159+ // 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";
160+ // System.out.println(String.join(" ", args));
161+ CommandLine .call (new Fusion (), args );
164162 }
165163}
0 commit comments