Skip to content
Snippets Groups Projects
Commit d6dd21d0 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Image.axisMapping is memoized (and corresponding bug-fix to memoizeMD5).

parent e6158d86
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ import numpy as np
import fsl.utils.transform as transform
import fsl.utils.notifier as notifier
import fsl.utils.memoize as memoize
import fsl.utils.path as fslpath
import fsl.data.constants as constants
import fsl.data.imagewrapper as imagewrapper
......@@ -209,7 +210,11 @@ class Nifti1(object):
return int(code)
# TODO Check what has worse performance - hashing
# a 4x4 array (via memoizeMD5), or the call
# to aff2axcodes. I'm guessing the latter,
# but am not 100% sure.
@memoize.memoizeMD5
def axisMapping(self, xform):
"""Returns the (approximate) correspondence of each axis in the source
coordinate system to the axes in the destination coordinate system,
......
......@@ -100,7 +100,7 @@ def memoizeMD5(func):
hashobj = hashlib.md5()
for arg in args:
arg = six.u(arg).encode('utf-8')
arg = six.u(str(arg)).encode('utf-8')
hashobj.update(arg)
digest = hashobj.hexdigest()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment