- Notifications
You must be signed in to change notification settings - Fork 536
ENH WIP: Use geodesic distance in FramewiseDisplacement #2607
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
Changes from 4 commits
422fbdd ea9f4dd 9c65c57 9a1cb9d 30098a5 b35fc5e 6199667 8e7f2ee c74a833 308e622 1e7e550 741f989 8d1b6f6 8fb79c4 8f9ce0f 5856288 0565df4 6089d27 c82b5fb c9a896c 4177f4e File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| | @@ -13,6 +13,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import nibabel as nb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from geomstats.invariant_metric import InvariantMetric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from geomstats.special_euclidean_group import SpecialEuclideanGroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from numpy.polynomial import Legendre | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from scipy import linalg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | @@ -26,6 +29,10 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IFLOGGER = logging.getLogger('interface') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SE3_GROUP = SpecialEuclideanGroup(n=3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DIM_TRANSLATIONS = SE3_GROUP.translations.dimension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DIM_ROTATIONS = SE3_GROUP.rotations.dimension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class ComputeDVARSInputSpec(BaseInterfaceInputSpec): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in_file = File( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | @@ -300,16 +307,37 @@ class FramewiseDisplacement(BaseInterface): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'tags': ['method'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _run_interface(self, runtime): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _run_interface(self, runtime, metric='L1'): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class FramewiseDisplacementInputSpec(BaseInterfaceInputSpec): | |
| in_file = File(exists=True, mandatory=True, desc='motion parameters') | |
| parameter_source = traits.Enum( | |
| "FSL", | |
| "AFNI", | |
| "SPM", | |
| "FSFAST", | |
| "NIPY", | |
| desc="Source of movement parameters", | |
| mandatory=True) | |
| radius = traits.Float( | |
| 50, | |
| usedefault=True, | |
| desc='radius in mm to calculate angular FDs, 50mm is the ' | |
| 'default since it is used in Power et al. 2012') | |
| out_file = File( | |
| 'fd_power_2012.txt', usedefault=True, desc='output file name') | |
| out_figure = File( | |
| 'fd_power_2012.pdf', usedefault=True, desc='output figure name') | |
| series_tr = traits.Float(desc='repetition time in sec.') | |
| save_plot = traits.Bool(False, usedefault=True, desc='write FD plot') | |
| normalize = traits.Bool( | |
| False, usedefault=True, desc='calculate FD in mm/s') | |
| figdpi = traits.Int( | |
| 100, usedefault=True, desc='output dpi for the FD plot') | |
| figsize = traits.Tuple( | |
| traits.Float(11.7), | |
| traits.Float(2.3), | |
| usedefault=True, | |
| desc='output figure size') |
I would suggest:
metric = traits.Enum('L1', 'SE3', usedefault=True, mandatory=True, desc='Distance metric to apply: ' 'L1 = Manhattan distance (original definition), 'SE3 = Special Euclidean group in 3D (geodesic)')Or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead and remove the metric='L1' parameter from _run_interface().
effigies marked this conversation as resolved. Show resolved Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then here (and below) you would use self.inputs.metric, instead of metric.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I said 'SE3' above. If 'riemannian' makes more sense, that's fine. I don't have strong opinions.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using the Enum trait with mandatory=True above, the only possible values are 'L1' or 'riemannian', so we can drop this final else.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,20 @@ | ||
| numpy>=1.9.0 | ||
| scipy>=0.14 | ||
| click>=6.6.0 | ||
| configparser | ||
| funcsigs | ||
| future>=0.16.0 | ||
| geomstats>=1.7 | ||
| ||
| mock | ||
| networkx>=1.9 | ||
| traits>=4.6 | ||
| python-dateutil>=2.2 | ||
| nibabel>=2.1.0 | ||
| future>=0.16.0 | ||
| simplejson>=3.8.0 | ||
| numpy>=1.9.0 | ||
| python-dateutil>=2.2 | ||
| packaging | ||
| prov==1.5.0 | ||
| click>=6.6.0 | ||
| funcsigs | ||
| configparser | ||
| pydotplus | ||
| pydot>=1.2.3 | ||
| pytest>=3.0 | ||
| pytest-xdist | ||
| pytest-env | ||
| mock | ||
| pydotplus | ||
| pydot>=1.2.3 | ||
| packaging | ||
| scipy>=0.14 | ||
| simplejson>=3.8.0 | ||
| traits>=4.6 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the sake of keeping the diff clean, can you remove this newline?