Skip to content

Commit

Permalink
Fix isolate-cells creating a folder on output.
Browse files Browse the repository at this point in the history
  • Loading branch information
migueLib committed Aug 2, 2024
1 parent 35c0785 commit e1a4cb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
26 changes: 15 additions & 11 deletions mask2bbox/scripts/isolate_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# Get arguments
def get_arguments():
# Start with the description
description = "Converts all the masks in a folder to bounding boxes."
description = ("From a mask and an image file obtains the single nuclei crops and saves them to an output folder "
"as .png single cell images.")

# Add parser
parser = argparse.ArgumentParser(description=description)
Expand All @@ -38,21 +39,22 @@ def get_arguments():

filters.add_argument("-e", "--expand", dest="expand",
action="store", type=int, required=False, default=0,
help="Number of pixels to expand the bounding boxes.")
help="Number of pixels to expand the bounding boxes. [default = 0]")
filters.add_argument("-fv", "--filter-value", dest="filter_value",
action="store", type=float, required=False,
default=0.0, nargs="+", help="Filter bounding boxes with a given value value.")
default=0.0, nargs="+", help="Filter bounding boxes with a given value value. [default = 0.0]")
filters.add_argument("-fo", "--filter-operator", dest="filter_operator",
action="store", type=str, required=False,
choices=["less_equal", "greater_equal", "equal", "not_equal"], default="greater_equal",
help="Filter operator. Options = [less_equal, greater_equal, equal, not_equal]")
help="Filter operator. Options = [less_equal, greater_equal, equal, not_equal] "
"[default = greater_equal]")
filters.add_argument("-ft", "--filter-type", dest="filter_type",
action="store", type=str, required=False,
choices=["area", "ratio", "center", "sides"], default="area",
help="Filter type. Options = [area, ratio, center, sides]")
help="Filter type. Options = [area, ratio, center, sides][default = area]")
filters.add_argument("-fe", "--filter-edge", dest="filter_edge",
action="store_true", required=False,
default=False, help="Filter bounding boxes on the edge of the image.")
default=False, help="Filter bounding boxes on the edge of the image. [default = False]")

# Add a group of arguments for re-sizing
single_cell = parser.add_argument_group(
Expand All @@ -61,10 +63,10 @@ def get_arguments():

single_cell.add_argument("-s", "--size", dest="size",
action="store", type=int, required=False, default=256,
help="Final image size for the single cell crops.")
help="Final image size for the single cell crops. [default = 256]")
single_cell.add_argument("-rf", "--resize-factor", dest="resize_factor",
action="store", type=float, required=False,
default=1.0, help="Resize factor for the single cell crops.")
default=1.0, help="Resize factor for the single cell crops. [default = 1.0]")

# Add a group of arguments for output
output = parser.add_argument_group(
Expand All @@ -73,10 +75,11 @@ def get_arguments():

output.add_argument("-o", "--output", dest="output",
action="store", type=str, required=False, default=None,
help="Path to the output file with the bounding boxes.")
help="Path to the output file with the bounding boxes. [default = None]")
output.add_argument("-sm", "--sample", dest="sample",
action="store", type=int, required=False, default=0,
help="Working the same to `-osc` but randomly select n=5 cells to explore parameters.")
help="Working the same to `-osc` but randomly select n=5 cells to explore parameters. "
"[default = 0]")

tool = parser.add_argument_group(
title="Tool",
Expand Down Expand Up @@ -169,7 +172,8 @@ def main():
mask_boxes.extract(resize_factors=rf[mask_boxes.idx()],
size=args.size,
rescale_intensity=True,
output=args.output)
output=args.output / args.mask.name.split(".")[0])


# Run main
if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion mask2bbox/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.22"
__version__ = "0.0.23"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mask2bbox"
version = "0.0.22"
version = "0.0.23"
authors = [
{ name="Miguel A. Ibarra-Arellano", email="[email protected]"},
]
Expand Down

0 comments on commit e1a4cb2

Please sign in to comment.