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

[FIX] Remove hardcoded numbers of echoes. #95

Merged
merged 5 commits into from
Jul 25, 2018
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
4 changes: 2 additions & 2 deletions tedana/model/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ def fitmodels_direct(catd, mmix, mask, t2s, t2sG, tes, combmode, ref_img,
coeffs_S0 = (B * X1).sum(axis=0) / (X1**2).sum(axis=0)
SSE_S0 = (B - X1 * np.tile(coeffs_S0, (n_echos, 1)))**2
SSE_S0 = SSE_S0.sum(axis=0)
F_S0 = (alpha - SSE_S0) * 2 / (SSE_S0)
F_S0 = (alpha - SSE_S0) * (n_echos - 1) / (SSE_S0)
F_S0_maps[:, i] = F_S0

# R2 Model
coeffs_R2 = (B * X2).sum(axis=0) / (X2**2).sum(axis=0)
SSE_R2 = (B - X2 * np.tile(coeffs_R2, (n_echos, 1)))**2
SSE_R2 = SSE_R2.sum(axis=0)
F_R2 = (alpha - SSE_R2) * 2 / (SSE_R2)
F_R2 = (alpha - SSE_R2) * (n_echos - 1) / (SSE_R2)
F_R2_maps[:, i] = F_R2

# compute weights as Z-values
Expand Down
8 changes: 5 additions & 3 deletions tedana/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ def make_adaptive_mask(data, minimum=True, getsum=False):
first_echo = echo_means[echo_means[:, 0] != 0, 0]

# get 33rd %ile of `first_echo` and find corresponding index
perc_33 = np.percentile(first_echo, 33, interpolation='higher') # QUESTION: why 33%ile?
med_val = (echo_means[:, 0] == perc_33)
# NOTE: percentile is arbitrary
perc = np.percentile(first_echo, 33, interpolation='higher')
perc_val = (echo_means[:, 0] == perc)

# extract values from all echos at relevant index
lthrs = np.squeeze(echo_means[med_val].T) / 3 # QUESTION: why divide by 3?
# NOTE: threshold of 1/3 voxel value is arbitrary
lthrs = np.squeeze(echo_means[perc_val].T) / 3

# if multiple samples were extracted per echo, keep the one w/the highest signal
if lthrs.ndim > 1:
Expand Down