Skip to content

Commit

Permalink
FIX pass expand_head_model value to all functions (#18)
Browse files Browse the repository at this point in the history
* added --expand-head-model arg + argparser

* fixed PR

* DOC minor doc fixes

* Minor ordering of things

* Add 0 in front of .1

---------

Co-authored-by: Matteo Visconti di Oleggio Castello <mvdoc@berkeley.edu>
  • Loading branch information
jenholmberg and mvdoc authored May 16, 2024
1 parent 865939d commit cca8bf2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/
*.obj
*.ply
*.mlx
*.stl

# temp folder
temp/
Expand Down
54 changes: 31 additions & 23 deletions make_headcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ def gen_case(
workdir=None,
casetype="s32",
nparts=4,
expand_head_model=0.1,
customizations=DEFAULT_CUSTOMIZATIONS,
):
expand_head_model=0.1):
"""
Generate a headcase.
Expand All @@ -246,11 +245,11 @@ def gen_case(
nparts : int, optional
Number of parts to divide the head case into. Possible values are 2 or 4.
Default is 4.
expand_head_model : float, optional
Factor (in mm) to expand the head model by. Default is 0.1.
customizations : str, optional
Path to the customizations file to remove additional parts from the headcase.
Default is `default_customizations.stl` in the `stls` folder.
expand_head_model : float, optional
Factor (in mm) to expand the head model by. Default is 0.1.
Examples
--------
Expand Down Expand Up @@ -313,6 +312,7 @@ def pipeline(
nparts=4,
workdir=None,
customizations=DEFAULT_CUSTOMIZATIONS,
expand_head_model=0.1,
):
"""
Run the pipeline to generate a head case from a head model.
Expand All @@ -333,6 +333,8 @@ def pipeline(
Path to the working directory, default is None.
customizations : dict, optional
Customizations for the head case, default is `default_customizations.stl`.
expand_head_model : float, optional
Factor (in mm) to expand the head model by, default is 0.1.
Notes
-----
Expand Down Expand Up @@ -368,6 +370,7 @@ def pipeline(
casetype=casetype,
nparts=nparts,
customizations=customizations,
expand_head_model=expand_head_model
)

if workdir is None:
Expand All @@ -388,15 +391,6 @@ def pipeline(
type=str,
help="output headcase model (*.zip)",
)
parser.add_argument(
"--expand-head-model",
type=float,
default="0.1",
help="Expand the head model by this amount (in mm) before generating the "
"headcase. The default (0.1 mm) should work for most cases. If the resulting "
"headcase is too tight, one can try increasing this value. It is not "
"recommended to pass a value greater than 1 mm.",
)
parser.add_argument(
"--headcoil",
"-c",
Expand All @@ -416,6 +410,18 @@ def pipeline(
help="Split the headcase model into 4 (default) or 2 parts. Four parts require "
"less support material when 3d printing the headcase.",
)
parser.add_argument(
"--workdir",
type=str,
required=False,
default=None,
help="Working directory to use. If this flag is not used, "
"then a temporary directory is created and deleted at the end. "
"If this flag is used, the intermediate models are stored "
"in the working directory and not deleted. "
"This option is useful for manual tuning of the alignment, "
"in combination with the flag --generated-headcase-only",
)
parser.add_argument(
"--generate-headcase-only",
action="store_true",
Expand All @@ -432,16 +438,15 @@ def pipeline(
f"to fine-tune the headcase. The default file is {DEFAULT_CUSTOMIZATIONS}",
)
parser.add_argument(
"--workdir",
type=str,
required=False,
default=None,
help="Working directory to use. If this flag is not used, "
"then a temporary directory is created and deleted at the end. "
"If this flag is used, the intermediate models are stored "
"in the working directory and not deleted. "
"This option is useful for manual tuning of the alignment, "
"in combination with the flag --generated-headcase-only",
"--expand-head-model",
type=float,
default=0.1,
help="Expand the head model by this amount (in mm) before generating the "
"headcase. The default (0.1 mm) should work for most cases. If the resulting "
"headcase is too tight, one can try increasing this value. If the resulting "
"headcase is too loose, one can try passing a negative value to shrink the head"
"model. It is not recommended to pass a value greater than 1 mm or less than "
"-1 mm.",
)
args = parser.parse_args()
infile = os.path.abspath(args.infile)
Expand All @@ -451,6 +456,7 @@ def pipeline(
workdir = args.workdir
customizations = args.customizations_file
generate_headcase_only = args.generate_headcase_only
expand_head_model = args.expand_head_model

if generate_headcase_only:
print("Making head case")
Expand All @@ -461,6 +467,7 @@ def pipeline(
nparts=nparts,
workdir=workdir,
customizations=customizations,
expand_head_model=expand_head_model,
)
else:
pipeline(
Expand All @@ -470,4 +477,5 @@ def pipeline(
nparts=nparts,
workdir=workdir,
customizations=customizations,
expand_head_model=expand_head_model,
)

0 comments on commit cca8bf2

Please sign in to comment.