diff options
Diffstat (limited to 'nitime/algorithms/correlation.py')
-rw-r--r-- | nitime/algorithms/correlation.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nitime/algorithms/correlation.py b/nitime/algorithms/correlation.py new file mode 100644 index 0000000..488a721 --- /dev/null +++ b/nitime/algorithms/correlation.py @@ -0,0 +1,16 @@ +import numpy as np + +__all__ = ["seed_corrcoef"] + + +def seed_corrcoef(seed, target): + """Compute seed-based correlation coefficient""" + + x = target - np.mean(target, -1)[..., np.newaxis] + y = seed - np.mean(seed) + xx = np.sum(x ** 2, -1) + yy = np.sum(y ** 2, -1) + xy = np.dot(x, y) + r = xy / np.sqrt(xx * yy) + + return r |