Skip to content

Commit

Permalink
added --expand-head-model arg + argparser
Browse files Browse the repository at this point in the history
  • Loading branch information
jenholmberg committed May 16, 2024
1 parent d5ad20d commit a891cc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 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
17 changes: 12 additions & 5 deletions make_headcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ def align_scan(infile, outfile):
def gen_case(
scanfile,
outfile,
expand_head_model,
workdir=None,
casetype="s32",
nparts=4,
expand_head_model=0.1,
customizations=DEFAULT_CUSTOMIZATIONS,
):
"""
Expand All @@ -236,6 +236,8 @@ def gen_case(
Path to the cleaned and aligned head model.
outfile : str
Path to the output file where the generated head case will be saved.
expand_head_model : float, optional
Factor (in mm) to expand the head model by. Default is 0.1.
workdir : str, optional
Path to the working directory. If not provided, a temporary directory will be
created and deleted after processing.
Expand All @@ -246,8 +248,6 @@ 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 All @@ -267,7 +267,7 @@ def gen_case(
if workdir is None:
workdir = mkdtemp()
cleanup = True

print(expand_head_model)
blender_params = dict(
preview=casefile,
scan=scanfile,
Expand Down Expand Up @@ -309,6 +309,7 @@ def pymeshlab_version():
def pipeline(
infile,
outfile,
expand_head_model=.1,
casetype="s32",
nparts=4,
workdir=None,
Expand All @@ -324,6 +325,8 @@ def pipeline(
generated by the Structure Sensor or an obj file containing the head model.
outfile : str
Path to the output file containing the generated head case.
expand_head_model : float, optional
Factor (in mm) to expand the head model by, default is 0.1.
casetype : str, optional
Type of head case, default is "s32" (Siemens 32ch). Possible values are
"s32", "s64", "n32", "meg_ctf275".
Expand Down Expand Up @@ -364,6 +367,7 @@ def pipeline(
gen_case(
aligned,
outfile,
expand_head_model,
working_dir,
casetype=casetype,
nparts=nparts,
Expand Down Expand Up @@ -391,7 +395,7 @@ def pipeline(
parser.add_argument(
"--expand-head-model",
type=float,
default="0.1",
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 "
Expand Down Expand Up @@ -451,12 +455,14 @@ 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")
gen_case(
infile,
outfile,
expand_head_model,
casetype=casetype,
nparts=nparts,
customizations=customizations,
Expand All @@ -465,6 +471,7 @@ def pipeline(
pipeline(
infile,
outfile,
expand_head_model=expand_head_model,
casetype=casetype,
nparts=nparts,
workdir=workdir,
Expand Down

0 comments on commit a891cc3

Please sign in to comment.