Skip to content

Commit

Permalink
add alternative to warping unfold->unfoldreg
Browse files Browse the repository at this point in the history
was getting bounding box errors with previous approach, when the
vertices were clearly within the bounding box..
  • Loading branch information
akhanf committed Jan 22, 2025
1 parent ba89e1d commit 38a3e89
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions hippunfold/workflow/rules/native_surf.smk
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,8 @@ def get_unfold_ref(wildcards):
)


rule warp_unfold_native_to_unfoldreg:
rule warp_unfold_native_to_unfoldreg_NOTWORKING:
"""this seems to give bounding box errors for no good reason.."""
input:
surf_gii=bids(
root=root,
Expand Down Expand Up @@ -1404,7 +1405,7 @@ rule warp_unfold_native_to_unfoldreg:
root=work,
datatype="surf",
suffix="{surfname}.surf.gii",
space="unfoldreg",
space="unfoldregNOTWORKING",
hemi="{hemi}",
label="{label}",
**inputs.subj_wildcards
Expand All @@ -1419,6 +1420,57 @@ rule warp_unfold_native_to_unfoldreg:
" -surface-secondary-type {params.secondary_type}"


rule warp_unfold_native_to_unfoldreg:
input:
surf_gii=bids(
root=root,
datatype="surf",
suffix="{surfname}.surf.gii",
space="unfold",
hemi="{hemi}",
label="{label}",
**inputs.subj_wildcards
),
warp=bids(
root=work,
suffix="xfm.nii.gz",
datatype="warps",
desc=unfoldreg_method,
from_="native",
to=config["atlas"],
space="unfold",
type_="surface",
hemi="{hemi}",
label="{label}",
**inputs.subj_wildcards,
),
params:
structure_type=lambda wildcards: get_structure(wildcards.hemi, wildcards.label),
secondary_type=lambda wildcards: surf_to_secondary_type[wildcards.surfname],
surface_type="FLAT",
output:
surf_gii=bids(
root=work,
datatype="surf",
suffix="{surfname}.surf.gii",
space="unfoldreg",
hemi="{hemi}",
label="{label}",
**inputs.subj_wildcards
),
container:
config["singularity"]["autotop"]
group:
"subj"
shadow:
"minimal"
shell:
"wb_command -volume-to-surface-mapping {input.warp} {input.surf_gii} warp.shape.gii -trilinear && "
"wb_command -surface-coordinates-to-metric {input.surf_gii} coords.shape.gii && "
"wb_command -metric-math 'COORDS + WARP' warpedcoords.shape.gii -var COORDS coords.shape.gii -var WARP warp.shape.gii && "
"wb_command -surface-set-coordinates {input.surf_gii} warpedcoords.shape.gii {output.surf_gii}"


# --- resampling using the unfoldreg surface to (legacy) standard densities (0p5mm, 1mm, 2mm, unfoldiso)
rule resample_atlas_subfields_to_std_density:
""" resamples subfields from a custom atlas mesh (e.g. from an atlas anatomical/native mesh
Expand Down

0 comments on commit 38a3e89

Please sign in to comment.