Skip to content

Commit 5bf2d54

Browse files
author
Shoshana Berleant
committed
improve code readability
1 parent bd9113a commit 5bf2d54

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

nipype/algorithms/tsnr.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from nipype.interfaces.base import (BaseInterface, traits, TraitedSpec, File,
1414
InputMultiPath, BaseInterfaceInputSpec,
1515
isdefined)
16-
16+
from numpy import newaxis
1717
import nibabel as nb
1818
import numpy as np
1919
import os.path as op
@@ -95,11 +95,16 @@ def _list_outputs(self):
9595
return outputs
9696

9797
def regress_poly(degree, data):
98+
''' returns data with degree polynomial regressed out.
99+
The last dimension (i.e. data.shape[-1]) should be time.
100+
'''
98101
timepoints = data.shape[-1]
99102
X = np.ones((timepoints, 1))
100103
for i in range(degree):
101-
X = np.hstack((X, legendre(
102-
i + 1)(np.linspace(-1, 1, timepoints))[:, None]))
104+
polynomial_func = legendre(i+1)
105+
value_array = np.linspace(-1, 1, timepoints)
106+
X = np.hstack((X, polynomial_func(value_array)[:, newaxis]))
107+
103108
betas = np.dot(np.linalg.pinv(X), np.rollaxis(data, 3, 2))
104109
datahat = np.rollaxis(np.dot(X[:, 1:],
105110
np.rollaxis(

0 commit comments

Comments
 (0)