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

FIX: Update surfaces with fsnative2t1w_xfm #384

Merged
merged 1 commit into from
Nov 9, 2023
Merged
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
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 @@

img = nb.load(in_file)
if transform_file is None:
transform = np.eye(4)
transform = nt.linear.Affine()
else:
xfm_fmt = {
".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
Loading