Skip to content

Commit 06929ef

Browse files
committed
Replace data loading for long template resampling
1 parent 2f95eff commit 06929ef

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/rbc/bids/longitudinal/anatomical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def resolve_longitudinal_anat(
4343
Dict with keys matching ``longitudinal_process`` parameters.
4444
"""
4545
return {
46-
"template": tpl_q.expect(tpl_df, suffix=Suffix.T1W),
46+
"template": tpl_q.expect(tpl_df, suffix=Suffix.T1W, without=["res"]),
4747
"subj_to_template_xfm": tpl_q.expect(
4848
tpl_df,
4949
suffix="xfm",

src/rbc/core/longitudinal/resampling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Resampling utiltiies for longitudinal templates."""
1+
"""Resampling utilities for longitudinal templates."""
22

33
from __future__ import annotations
44

@@ -13,7 +13,7 @@
1313
from rbc.core.niwrap import generate_exec_folder
1414

1515

16-
def resample_template_to_bold(bold_ref: Path, template: Path) -> Path:
16+
def resample_template_to_bold_grid(bold_ref: Path, template: Path) -> Path:
1717
"""Resample template to BOLD grid if shapes differ.
1818
1919
Args:
@@ -32,7 +32,7 @@ def resample_template_to_bold(bold_ref: Path, template: Path) -> Path:
3232

3333
# If 4D, extract first volume
3434
if len(bold_ref_img.shape) > 3:
35-
bold_ref_img = bold_ref_img[..., 0]
35+
bold_ref_img = nib.four_to_three(bold_ref_img)[0]
3636
# If same shape, no need to resample
3737
if bold_ref_img.shape == template_img.shape:
3838
return template_img

src/rbc/workflows/longitudinal/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
fs_to_itk_xfm,
1515
generate_robust_template,
1616
)
17-
from rbc.core.longitudinal.resampling import resample_template_to_bold
17+
from rbc.core.longitudinal.resampling import resample_template_to_bold_grid
1818

1919
if TYPE_CHECKING:
2020
from collections.abc import Sequence
@@ -71,7 +71,7 @@ def generate_subject_template(
7171
)
7272

7373
if bold_ref is not None:
74-
bold_ref = resample_template_to_bold(bold_ref, robust.template)
74+
bold_ref = resample_template_to_bold_grid(bold_ref, robust.template)
7575

7676
return LongitudinalTemplateOutputs(
7777
template=robust.template,

tests/unit/bids/test_longitudinal_anatomical.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _anat_row(
9999
"sub": sub,
100100
"ses": ses,
101101
"desc": desc,
102+
"res": None,
102103
"root": "/data",
103104
"path": path,
104105
"extra_entities": extra or [],

0 commit comments

Comments
 (0)