Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyfeeds-tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
pyfeeds-tests
Commits
4ab6198c
Commit
4ab6198c
authored
1 year ago
by
Paul McCarthy
Committed by
Paul McCarthy
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Basic unit test for vecreg
parent
8a81da22
No related branches found
Branches containing commit
Tags
2401.0
Tags containing commit
1 merge request
!61
Unit tests for vecreg
Pipeline
#22307
passed
1 year ago
Stage: fsl-ci-build
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unit_tests/fdt/vecreg/feedsInputs
+1
-0
1 addition, 0 deletions
unit_tests/fdt/vecreg/feedsInputs
unit_tests/fdt/vecreg/feedsRun
+91
-0
91 additions, 0 deletions
unit_tests/fdt/vecreg/feedsRun
with
92 additions
and
0 deletions
unit_tests/fdt/vecreg/feedsInputs
0 → 100644
+
1
−
0
View file @
4ab6198c
fsl_course_data/fdt2
This diff is collapsed.
Click to expand it.
unit_tests/fdt/vecreg/feedsRun
0 → 100755
+
91
−
0
View file @
4ab6198c
#!/usr/bin/env fslpython
import os
import sys
sys.path.append('/home/paulmc/Projects/fslpy/')
from pathlib import Path
import numpy as np
from fsl.data.image import Image
from fsl.wrappers import vecreg, concatxfm, invxfm, convertwarp
from pyfeeds.evaluate import cmpVectorArrays
def main():
fsldir = Path(os.environ['FSLDIR'])
outdir = Path(sys.argv[1])
indir = Path(sys.argv[2])/'fsl_course_data'/'fdt2'
dyads = indir/'diffusion.bedpostX'/'dyads1.nii.gz'
std = fsldir/'data'/'standard'/'MNI152_T1_2mm.nii.gz'
str2std = indir/'diffusion.bedpostX'/'xfms'/'str2standard.mat'
diff2str = indir/'structural'/'xfms'/'diff2str.mat'
diff2std_warp = indir/'structural'/'xfms'/'diff2standard_warp.nii.gz'
# Create diff2std/std2diff affines
std2diff = outdir/'std2diff.mat'
diff2std = outdir/'diff2std.mat'
concatxfm(diff2str, str2std, diff2std)
invxfm(diff2std, std2diff)
# create a copy of the diff2std warp
# which does not encode the diff2std
# affine
diff2std_warp_no_premat = outdir/'diff2std_warp_no_premat.nii.gz'
convertwarp(diff2std_warp_no_premat, std,
warp1=diff2std_warp,
premat=std2diff,
relout=True)
# Transform dyads with the full diff2std
# warp (which encodes the diff->standard
# affine transform) - this will be used
# as a benchmark
dyads_std = outdir/'dyads1_std.nii.gz'
vecreg(dyads, dyads_std, std, warpfield=diff2std_warp)
# Transform dyads with the raw diff2std
# warp, and specify the diff2std affine
# as premat. The result should match
# that from the first vecreg call above.
dyads_std_with_premat = outdir/'dyads1_std_with_premat.nii.gz'
vecreg(dyads, dyads_std_with_premat, std,
warpfield=diff2std_warp_no_premat,
premat=diff2std)
# compare the result
dyads1 = Image(dyads_std).data
dyads2 = Image(dyads_std_with_premat).data
diff = cmpVectorArrays(dyads1, dyads2)
assert np.isclose(diff, 0, atol=1e-4), diff
# Create a nonsense warp field with a postmat
diff2std_warp_postmat = outdir/'diff2std_warp_postmat.nii.gz'
convertwarp(diff2std_warp_postmat, std,
warp1=diff2std_warp_no_premat,
premat=diff2std,
postmat=std2diff)
# Warp dyads with the nonsense warp
dyads_postmat1 = outdir/'dyads_postmat1.nii.gz'
vecreg(dyads, dyads_postmat1, std,
warpfield=diff2std_warp_postmat)
# And with the original warp+premat+postmat
dyads_postmat2 = outdir/'dyads_postmat2.nii.gz'
vecreg(dyads, dyads_postmat2, std,
warpfield=diff2std_warp_no_premat,
premat=diff2std, postmat=std2diff)
# And check that the results are equivalent
dyads1 = Image(dyads_postmat1).data
dyads2 = Image(dyads_postmat2).data
diff = cmpVectorArrays(dyads1, dyads2)
assert np.isclose(diff, 0, atol=1e-4), diff
if __name__ == '__main__':
main()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment