def main_noninteractive(): """The main routine for running non-interactively.""" global imcftpl args = parse_arguments() set_loglevel(args.verbose) log.info('Running in non-interactive mode.') log.debug('Python FluoView package file: %s' % fv.__file__) base = dirname(args.mosaiclog) fname = basename(args.mosaiclog) mosaics = fv.FluoViewMosaic(join(base, fname)) log.warn(gen_mosaic_details(mosaics)) if args.templates is not None: imcftpl = args.templates code = imagej.gen_stitching_macro_code(mosaics, 'templates/stitching', path=base, tplpath=imcftpl) if not args.dryrun: log.info('Writing stitching macro.') imagej.write_stitching_macro(code, fname='stitch_all.ijm', dname=base) log.info('Writing tile configuration files.') imagej.write_all_tile_configs(mosaics, fixsep=True) log.info('Launching stitching macro.') IJ.runMacro(flatten(code)) else: log.info('Dry-run was selected. Printing generated macro:') log.warn(flatten(code))
def main(): """Parse commandline arguments and run parser.""" args = parse_arguments() set_loglevel(args.verbosity) dname = dirname(args.mosaic.name) fname = basename(args.mosaic.name) if args.out == '': dout = dname else: dout = args.out mosaic = fv.FluoViewMosaic(args.mosaic.name) ij.write_all_tile_configs(mosaic, fixsep=args.fixsep) code = ij.gen_stitching_macro_code(mosaic, 'stitching', path=dname) ij.write_stitching_macro(code, 'stitch_all.ijm', dout)
def main_interactive(): """The main routine for running interactively.""" log.info('Running in interactive mode.') (base, fname) = ui_get_input_file() if (base is None): return log.warn("Parsing project file: %s" % (base + fname)) IJ.showStatus("Parsing experiment file...") mosaics = fv.FluoViewMosaic(join(base, fname), runparser=False) IJ.showStatus("Parsing mosaics...") progress = 0.0 count = len(mosaics.mosaictrees) step = 1.0 / count for subtree in mosaics.mosaictrees: IJ.showProgress(progress) mosaics.add_mosaic(subtree) progress += step IJ.showProgress(progress) IJ.showStatus("Parsed %i mosaics." % len(mosaics)) dialog = GenericDialog('FluoView OIF / OIB Stitcher') if len(mosaics) == 0: msg = ("Couldn't find any (valid) mosaics in the project file.\n" " \n" "Please make sure to have all files available!\n" " \n" "Will stop now.\n") log.warn(msg) dialog.addMessage(msg) dialog.showDialog() return msg = "------------------------ EXPORT OPTIONS ------------------------" dialog.addMessage(msg) formats = ["OME-TIFF", "ICS/IDS"] dialog.addChoice("Export Format", formats, formats[0]) dialog.addCheckbox("separate files by Z slices (OME-TIFF only)?", False) msg = "------------------------ EXPORT OPTIONS ------------------------" dialog.addMessage(msg) dialog.addMessage("") dialog.addMessage("") msg = gen_mosaic_details(mosaics) log.warn(msg) msg += "\n \nPress [OK] to write tile configuration files\n" msg += "and continue with running the stitcher." dialog.addMessage(msg) dialog.showDialog() opts = {} if dialog.getNextChoice() == 'ICS/IDS': opts['export_format'] = '".ids"' else: opts['export_format'] = '".ome.tif"' if dialog.getNextBoolean() == True: opts['split_z_slices'] = 'true' code = imagej.gen_stitching_macro_code(mosaics, 'templates/stitching', path=base, tplpath=imcftpl, opts=opts) log.warn("============= generated macro code =============") log.warn(flatten(code)) log.warn("============= end of generated macro code =============") if dialog.wasOKed(): log.warn('Writing stitching macro.') imagej.write_stitching_macro(code, fname='stitch_all.ijm', dname=base) log.warn('Writing tile configuration files.') imagej.write_all_tile_configs(mosaics, fixsep=True) log.warn('Launching stitching macro.') IJ.runMacro(flatten(code))