Skip to content

Commit

Permalink
Merge pull request #384 from effigies/fix/transform_surfs
Browse files Browse the repository at this point in the history
FIX: Update surfaces with fsnative2t1w_xfm
  • Loading branch information
effigies authored Nov 9, 2023
2 parents 05ae8c5 + 477063c commit e370a73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions smriprep/interfaces/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,18 @@ def normalize_surfs(

img = nb.load(in_file)
if transform_file is None:
transform = np.eye(4)
transform = nt.linear.Affine()
else:
xfm_fmt = {

Check warning on line 204 in smriprep/interfaces/surf.py

View check run for this annotation

Codecov / codecov/patch

smriprep/interfaces/surf.py#L204

Added line #L204 was not covered by tests
".txt": "itk",
".mat": "fsl",
".lta": "fs",
}[Path(transform_file).suffix]
transform = nt.linear.load(transform_file, fmt=xfm_fmt).matrix
transform = nt.linear.load(transform_file, fmt=xfm_fmt)

Check warning on line 209 in smriprep/interfaces/surf.py

View check run for this annotation

Codecov / codecov/patch

smriprep/interfaces/surf.py#L209

Added line #L209 was not covered by tests
pointset = img.get_arrays_from_intent("NIFTI_INTENT_POINTSET")[0]

if not np.allclose(transform, np.eye(4)):
pointset.data = nb.affines.apply_affine(transform, pointset.data)
if not np.allclose(transform.matrix, np.eye(4)):
pointset.data = transform.map(pointset.data, inverse=True)

Check warning on line 213 in smriprep/interfaces/surf.py

View check run for this annotation

Codecov / codecov/patch

smriprep/interfaces/surf.py#L213

Added line #L213 was not covered by tests

fname = os.path.basename(in_file)
if "graymid" in fname.lower():
Expand Down
13 changes: 8 additions & 5 deletions smriprep/workflows/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,14 @@ def init_gifti_surfaces_wf(
run_without_submitting=True,
)

# fmt:off
workflow.connect([
(inputnode, get_surfaces, [('subjects_dir', 'subjects_dir'),
('subject_id', 'subject_id')]),
(inputnode, get_surfaces, [
('subjects_dir', 'subjects_dir'),
('subject_id', 'subject_id'),
]),
(inputnode, fix_surfs, [
('fsnative2t1w_xfm', 'transform_file'),
]),
(get_surfaces, surface_list, [
(surf, f'in{i}') for i, surf in enumerate(surfaces, start=1)
]),
Expand All @@ -933,8 +937,7 @@ def init_gifti_surfaces_wf(
(surface_groups, outputnode, [
(f'out{i}', surf) for i, surf in enumerate(surfaces, start=1)
]),
])
# fmt:on
]) # fmt:skip
return workflow


Expand Down

0 comments on commit e370a73

Please sign in to comment.