Skip to content
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

[DOC] Improve documentation of computefeats2 #458

Merged
merged 6 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tedana/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ def computefeats2(data, mmix, mask=None, normalize=True):
# demean masked data
if mask is not None:
data = data[mask, ...]
# normalize data (minus mean and divide by std) in the last dimension
CesarCaballeroGaudes marked this conversation as resolved.
Show resolved Hide resolved
# so that least-squares estimates represent correlation values (data_R)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say they "approximate" correlation values, because this conversion isn't technically valid as far as I can tell.

# assuming mmix are also normalized
tsalo marked this conversation as resolved.
Show resolved Hide resolved
CesarCaballeroGaudes marked this conversation as resolved.
Show resolved Hide resolved
data_vn = stats.zscore(data, axis=-1)

# get betas of `data`~`mmix` and limit to range [-0.999, 0.999]
data_R = get_coeffs(data_vn, mmix, mask=None)
# Avoid abs(data_R) = 1 or -1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the standardized parameter estimates from a multiple regression are not the same as correlation coefficients and often go above or below what is possible with correlation coefficients, this step also avoids values > 1 or < -1.

# otherwise Fisher's transform will return Inf or -Inf
data_R[data_R < -0.999] = -0.999
data_R[data_R > 0.999] = 0.999

Expand All @@ -86,9 +91,11 @@ def computefeats2(data, mmix, mask=None, normalize=True):
if data_Z.ndim == 1:
data_Z = np.atleast_2d(data_Z).T

# normalize data
# normalize data (only division by std)
CesarCaballeroGaudes marked this conversation as resolved.
Show resolved Hide resolved
if normalize:
# minus mean and divided by std
CesarCaballeroGaudes marked this conversation as resolved.
Show resolved Hide resolved
data_Zm = stats.zscore(data_Z, axis=0)
# adding back the mean
data_Z = data_Zm + (data_Z.mean(axis=0, keepdims=True) /
data_Z.std(axis=0, keepdims=True))

Expand Down