diff --git a/nextflow.config b/nextflow.config index 5e9cfd38..4783e523 100644 --- a/nextflow.config +++ b/nextflow.config @@ -1,5 +1,5 @@ // Execution environment for miscellaneous tasks -params.roadie = 'labsyspharm/roadie:2023-03-08' +params.roadie = 'ghcr.io/labsyspharm/mcmicro:roadie-2023-10-25' // Platform-specific profiles profiles { diff --git a/roadie/scripts/recyze.py b/roadie/scripts/recyze.py index 1c57dc78..0c69c349 100644 --- a/roadie/scripts/recyze.py +++ b/roadie/scripts/recyze.py @@ -223,7 +223,7 @@ def run(self): self.metadata.images[0].pixels.tiff_data_blocks[0].plane_count = self.num_channels # Write - tifffile.tiffcomment(self.out_path, to_xml(self.metadata)) + tifffile.tiffcomment(self.out_path, to_xml(self.metadata).encode()) if __name__ == '__main__': @@ -236,7 +236,14 @@ def run(self): parser.add_argument('--y2', type=int, required=False, default=None, help="Crop Y2") parser.add_argument('--w', type=int, required=False, default=None, help="Crop Width") parser.add_argument('--h', type=int, required=False, default=None, help="Crop Height") - parser.add_argument('--channels', type=int, nargs="+", required=False, default=None, help="Channels") + parser.add_argument( + '--channels', type=int, nargs="+", required=False, default=None, metavar="C", + help="Channels to keep (Default: all)", + ) + parser.add_argument( + '--num-threads', type=int, required=False, default=0, metavar="N", + help="Worker thread count (Default: auto-scale based on number of available CPUs)", + ) argument = parser.parse_args() # Automatically infer the output filename, if not specified @@ -256,6 +263,15 @@ def run(self): stem = os.extsep.join(tokens[0:-1]) + "_crop" out_path = os.extsep.join([stem, tokens[-1]]) + num_threads = argument.num_threads + if num_threads == 0: + if hasattr(os, "sched_getaffinity"): + num_threads = len(os.sched_getaffinity(0)) + else: + num_threads = os.cpu_count() + tifffile.TIFF.MAXWORKERS = num_threads + tifffile.TIFF.MAXIOWORKERS = num_threads * 5 + writer = PyramidWriter(in_path, out_path, argument.channels, argument.x, argument.y, argument.x2, argument.y2, argument.w, argument.h) writer.run()