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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion tedana/metrics/kundu_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def dependence_metrics(catd, tsoc, mmix, t2s, tes, ref_img,
WTS = computefeats2(tsoc, mmixN, mask=None, normalize=False)

# compute PSC dataset - shouldn't have to refit data
tsoc_B = get_coeffs(tsoc_dm, mmix, mask=None)
tsoc_B = get_coeffs(tsoc_dm, mmix, mask=None, add_const=False)
del tsoc_dm
tsoc_Babs = np.abs(tsoc_B)
PSC = tsoc_B / tsoc.mean(axis=-1, keepdims=True) * 100
Expand Down
8 changes: 7 additions & 1 deletion tedana/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ def computefeats2(data, mmix, mask=None, normalize=True):
# demean masked data
if mask is not None:
data = data[mask, ...]
# normalize data (subtract mean and divide by standard deviation) in the last dimension
# so that least-squares estimates represent "approximate" correlation values (data_R)
# assuming mixing matrix (mmix) values are also normalized
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, 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 +90,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)
if normalize:
# subtract mean and dividing by standard deviation
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