Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naturalinterpolation #305

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,23 @@ parse_args:
- synthseg_v0.2
- neonateT1w_v2



# --- surface specific configuration --

autotop_labels:
- 'hipp'
- 'dentate'


surf_types:
hipp:
- midthickness
- inner
- outer
dentate:
- midthickness
# - inner
# - outer

gifti_metric_types:
hipp:
Expand All @@ -358,7 +363,13 @@ cifti_metric_types:
- gyrification.dscalar
- curvature.dscalar


# params for detecting and removing outlier vertices
outlierSmoothDist:
unfoldiso: 15
0p5mm: 7
1mm: 3
2mm: 1
vertexOutlierThreshold: 3



Expand Down Expand Up @@ -601,7 +612,7 @@ unfold_vol_ref:
unfold_crop_epsilon_fractions:
- 0
- 0
- 0.0625 #1/16
- 1

# space for uniform unfolded grid:
# currently only used for interpolating hipp subfields on surface
Expand Down
43 changes: 36 additions & 7 deletions hippunfold/workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,69 @@ def get_modality_suffix(modality):


def get_final_spec():
if len(config["hemi"]) == 2:
specs = expand(
specs = expand(
bids(
root=root,
datatype="surf",
den="{density}",
space="{space}",
hemi="{hemi}",
label="{autotop}",
suffix="surfaces.spec",
**config["subj_wildcards"],
),
density=config["output_density"],
space=ref_spaces,
hemi=config["hemi"],
autotop=config["autotop_labels"],
allow_missing=True,
)
return specs


def get_final_surf():
gii = []
gii.extend(
expand(
bids(
root=root,
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
space="{space}",
hemi="{hemi}",
label="{autotop}",
suffix="surfaces.spec",
**config["subj_wildcards"],
),
density=config["output_density"],
space=ref_spaces,
hemi=config["hemi"],
autotop=config["autotop_labels"],
surfname=config["surf_types"]["hipp"],
allow_missing=True,
)
else:
specs = expand(
)
gii.extend(
expand(
bids(
root=root,
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
space="{space}",
hemi="{hemi}",
label="{autotop}",
suffix="surfaces.spec",
**config["subj_wildcards"],
),
density=config["output_density"],
space=ref_spaces,
hemi=config["hemi"],
autotop=config["autotop_labels"],
surfname=config["surf_types"]["dentate"],
allow_missing=True,
)
return specs
)
return gii


def get_final_subfields():
Expand Down Expand Up @@ -313,6 +341,7 @@ def get_final_qc():
def get_final_subj_output():
subj_output = []
subj_output.extend(get_final_spec())
subj_output.extend(get_final_surf())
subj_output.extend(get_final_subfields())
subj_output.extend(get_final_coords())
subj_output.extend(get_final_transforms())
Expand Down
26 changes: 16 additions & 10 deletions hippunfold/workflow/rules/gifti.smk
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ rule warp_gii_unfold2corobl1:
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
desc="nonancorrect",
desc="nobadcorrect",
space="corobl",
unfoldreg="none",
hemi="{hemi}",
Expand All @@ -198,21 +198,24 @@ rule warp_gii_unfold2corobl1:
" -surface-secondary-type {params.secondary_type}"


# previous rule seems to be where nan vertices emerge, so we'll correct them here immediately after
rule correct_nan_vertices1:
# previous rule seems to be where bad vertices emerge, so we'll correct them here immediately after
rule correct_bad_vertices1:
input:
gii=bids(
root=work,
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
desc="nonancorrect",
desc="nobadcorrect",
space="corobl",
unfoldreg="none",
hemi="{hemi}",
label="hipp",
**config["subj_wildcards"]
),
params:
dist=lambda wildcards: config["outlierSmoothDist"][wildcards.density],
threshold=config["vertexOutlierThreshold"],
output:
gii=bids(
root=work,
Expand All @@ -230,7 +233,7 @@ rule correct_nan_vertices1:
container:
config["singularity"]["autotop"]
script:
"../scripts/fillnanvertices.py"
"../scripts/fillbadvertices.py"


# morphological features, calculated in native space:
Expand Down Expand Up @@ -730,7 +733,7 @@ rule warp_gii_unfold2corobl2:
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
desc="nonancorrect",
desc="nobadcorrect",
space="corobl",
hemi="{hemi}",
label="{autotop}",
Expand All @@ -746,20 +749,23 @@ rule warp_gii_unfold2corobl2:
" -surface-secondary-type {params.secondary_type}"


# previous rule seems to be where nan vertices emerge, so we'll correct them here immediately after
rule correct_nan_vertices2:
# previous rule seems to be where bad vertices emerge, so we'll correct them here immediately after
rule correct_bad_vertices2:
input:
gii=bids(
root=work,
datatype="surf",
den="{density}",
suffix="{surfname}.surf.gii",
desc="nonancorrect",
desc="nobadcorrect",
space="corobl",
hemi="{hemi}",
label="{autotop}",
**config["subj_wildcards"]
),
params:
dist=lambda wildcards: config["outlierSmoothDist"][wildcards.density],
threshold=config["vertexOutlierThreshold"],
output:
gii=bids(
root=work,
Expand All @@ -776,7 +782,7 @@ rule correct_nan_vertices2:
container:
config["singularity"]["autotop"]
script:
"../scripts/fillnanvertices.py"
"../scripts/fillbadvertices.py"


# needed for if native_modality is corobl
Expand Down
5 changes: 0 additions & 5 deletions hippunfold/workflow/rules/warps.smk
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ rule create_warps_hipp:
hemi="{hemi}",
suffix="create_warps-hipp.txt"
),
container:
config["singularity"]["autotop"]
script:
"../scripts/create_warps.py"

Expand Down Expand Up @@ -294,7 +292,6 @@ rule create_warps_dentate:
),
labelmap=get_labels_for_laplace,
params:
interp_method="linear",
gm_labels=lambda wildcards: config["laplace_labels"]["PD"]["sink"],
epsilon=lambda wildcards: config["unfold_crop_epsilon_fractions"],
resources:
Expand Down Expand Up @@ -353,8 +350,6 @@ rule create_warps_dentate:
hemi="{hemi}",
suffix="create_warps-dentate.txt"
),
container:
config["singularity"]["autotop"]
script:
"../scripts/create_warps.py"

Expand Down
Loading
Loading