def add_to_parser(cls, subparsers): """Adds the decoder component to the CLI argument parser.""" decoder_group = subparsers.add_parser("decode") decoder_group.add_argument("-i", "--input", type=FsExistsType(), required=True) decoder_group.add_argument("-o", "--output", required=True) decoder_group.add_argument("--codebook", type=FsExistsType(), required=True) decoder_group.set_defaults(starfish_command=Decoder._cli) decoder_subparsers = decoder_group.add_subparsers(dest="decoder_algorithm_class") for algorithm_cls in cls.algorithm_to_class_map().values(): group_parser = decoder_subparsers.add_parser(algorithm_cls.get_algorithm_name()) group_parser.set_defaults(decoder_algorithm_class=algorithm_cls) algorithm_cls.add_arguments(group_parser) cls.decoder_group = decoder_group
def add_to_parser(cls, subparsers): """Adds the segmentation component to the CLI argument parser.""" segmentation_group = subparsers.add_parser("segment") segmentation_group.add_argument("--hybridization-stack", type=FsExistsType(), required=True) segmentation_group.add_argument("--nuclei-stack", type=FsExistsType(), required=True) segmentation_group.add_argument("-o", "--output", required=True) segmentation_group.set_defaults(starfish_command=Segmentation._cli) segmentation_subparsers = segmentation_group.add_subparsers(dest="segmentation_algorithm_class") for algorithm_cls in cls.algorithm_to_class_map().values(): group_parser = segmentation_subparsers.add_parser(algorithm_cls.get_algorithm_name()) group_parser.set_defaults(segmentation_algorithm_class=algorithm_cls) algorithm_cls.add_arguments(group_parser) cls.segmentation_group = segmentation_group
def add_arguments(cls, group_parser): group_parser.add_argument("--blobs-stack", type=FsExistsType(), required=True) group_parser.add_argument( "--min-sigma", default=4, type=int, help="Minimum spot size (in standard deviation)") group_parser.add_argument( "--max-sigma", default=6, type=int, help="Maximum spot size (in standard deviation)") group_parser.add_argument("--num-sigma", default=20, type=int, help="Number of sigmas to try") group_parser.add_argument("--threshold", default=.01, type=float, help="Dots threshold") group_parser.add_argument( "--overlap", default=0.5, type=float, help="dots with overlap of greater than this fraction are combined" ) group_parser.add_argument("--show", default=False, action='store_true', help="display results visually")
def add_to_parser(parser): parser.add_argument( "output_dir", type=FsExistsType()) parser.add_argument( "--fov-count", type=int, required=True, help="Number of FOVs in this experiment.") parser.add_argument( "--hybridization-dimensions", type=StarfishIndex(), required=True, help="Dimensions for the hybridization images. Should be a json dict, with {}, {}, " "and {} as the possible keys. The value should be the shape along that " "dimension. If a key is not present, the value is assumed to be 0.".format( Indices.ROUND.value, Indices.CH.value, Indices.Z.value)) for aux_image_name in AUX_IMAGE_NAMES: arg = parser.add_argument( "--{}-dimensions".format(aux_image_name), type=StarfishIndex(), help="Dimensions for the {} images. Should be a json dict, with {}, {}, and {} as " "the possible keys. The value should be the shape along that dimension. If " "a key is not present, the value is assumed to be 0.".format( aux_image_name, Indices.ROUND, Indices.CH, Indices.Z)) Cli.name_arg_map[aux_image_name] = arg.dest parser.set_defaults(starfish_command=Cli.run) Cli.parser_group = parser
def add_arguments(cls, group_parser): group_parser.add_argument("--upsampling", default=1, type=int, help="Amount of up-sampling") group_parser.add_argument( "--reference-stack", type=FsExistsType(), required=True, help="The image stack to align the input image stack to.")
def _add_to_parser(cls, subparsers): """Adds the registration component to the CLI argument parser.""" register_group = subparsers.add_parser("registration") register_group.add_argument("-i", "--input", type=FsExistsType(), required=True) register_group.add_argument("-o", "--output", required=True) register_group.set_defaults(starfish_command=Registration._cli) registration_subparsers = register_group.add_subparsers(dest="registration_algorithm_class") for algorithm_cls in cls._algorithm_to_class_map().values(): group_parser = registration_subparsers.add_parser(algorithm_cls._get_algorithm_name()) group_parser.set_defaults(registration_algorithm_class=algorithm_cls) algorithm_cls._add_arguments(group_parser) cls.register_group = register_group
def add_to_parser(cls, subparsers): """Adds the spot finder component to the CLI argument parser.""" spot_finder_group = subparsers.add_parser("detect_spots") spot_finder_group.add_argument("-i", "--input", type=FsExistsType(), required=True) spot_finder_group.add_argument("-o", "--output", required=True) spot_finder_group.set_defaults(starfish_command=SpotFinder._cli) spot_finder_subparsers = spot_finder_group.add_subparsers(dest="spot_finder_algorithm_class") for algorithm_cls in cls.algorithm_to_class_map().values(): group_parser = spot_finder_subparsers.add_parser(algorithm_cls.get_algorithm_name()) group_parser.set_defaults(spot_finder_algorithm_class=algorithm_cls) algorithm_cls.add_arguments(group_parser) cls.spot_finder_group = spot_finder_group
def add_to_parser(cls, subparsers): """Adds the gene_assignment component to the CLI argument parser.""" gene_assignment_group = subparsers.add_parser("gene_assignment") gene_assignment_group.add_argument("--coordinates-geojson", type=FsExistsType(), required=True) gene_assignment_group.add_argument("--intensities", type=FsExistsType(), required=True) gene_assignment_group.add_argument("-o", "--output", required=True) gene_assignment_group.set_defaults( starfish_command=GeneAssignment._cli) gene_assignment_subparsers = gene_assignment_group.add_subparsers( dest="gene_assignment_algorithm_class") for algorithm_cls in cls.algorithm_to_class_map().values(): group_parser = gene_assignment_subparsers.add_parser( algorithm_cls.get_algorithm_name()) group_parser.set_defaults( gene_assignment_algorithm_class=algorithm_cls) algorithm_cls.add_arguments(group_parser) cls.gene_assignment_group = gene_assignment_group
def _add_to_parser(cls, subparsers): """Adds the filter component to the CLI argument parser.""" filter_group = subparsers.add_parser("filter") filter_group.add_argument("-i", "--input", type=FsExistsType(), required=True) filter_group.add_argument("-o", "--output", required=True) filter_group.set_defaults(starfish_command=Filter._cli) filter_subparsers = filter_group.add_subparsers( dest="filter_algorithm_class") for algorithm_cls in cls._algorithm_to_class_map().values(): group_parser = filter_subparsers.add_parser( algorithm_cls._get_algorithm_name()) group_parser.set_defaults(filter_algorithm_class=algorithm_cls) algorithm_cls._add_arguments(group_parser) cls.filter_group = filter_group
Indices.CH: 1, Indices.Z: 1, } }, hyb_image_fetcher=HybridizationImageFetcher(input_dir), aux_image_fetcher={ 'nuclei': AuxImageFetcher(os.path.join(input_dir, "DO", "c1.TIF")), 'dots': AuxImageFetcher(os.path.join(input_dir, "DO", "c2.TIF")), }, postprocess_func=add_codebook, default_shape=SHAPE, ) codebook = [ {'barcode': "AAGC", 'gene': "ACTB_human"}, {'barcode': "AGGC", 'gene': "ACTB_mouse"}, ] codebook_json_filename = "codebook.json" write_json(codebook, os.path.join(output_dir, codebook_json_filename)) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("input_dir", type=FsExistsType()) parser.add_argument("output_dir", type=FsExistsType()) parser.add_argument("--d", help="Download data", type=bool) args = parser.parse_args() format_data(args.input_dir, args.output_dir, args.d)
write_experiment_json( path=output_dir, fov_count=num_fovs, primary_image_dimensions=primary_image_dimensions, aux_name_to_dimensions=aux_name_to_dimensions, primary_tile_fetcher=ISSCroppedBreastPrimaryTileFetcher(input_dir), aux_tile_fetcher={ 'nuclei': ISSCroppedBreastAuxTileFetcher(input_dir, 'nuclei'), 'dots': ISSCroppedBreastAuxTileFetcher(input_dir, 'dots'), }, postprocess_func=add_codebook, default_shape=(1044, 1390)) if __name__ == "__main__": s3_bucket = "s3://czi.starfish.data.public/browse/raw/20180820/iss_breast/" input_help_msg = "Path to raw data. Raw data can be downloaded from: {}".format( s3_bucket) output_help_msg = "Path to output experment.json and all formatted images it references" fov_help_msg = "The number of fovs that should be extracted from the directory" parser = argparse.ArgumentParser() parser.add_argument("input_dir", type=FsExistsType(), help=input_help_msg) parser.add_argument("output_dir", type=FsExistsType(), help=output_help_msg) parser.add_argument("num_fovs", type=int, help=fov_help_msg) args = parser.parse_args() format_data(args.input_dir, args.output_dir, args.num_fovs)