Skip to content

Commit

Permalink
Merge pull request #95 from tsalo/master
Browse files Browse the repository at this point in the history
Remove hardcoded numbers of echoes.
  • Loading branch information
emdupre committed Jul 25, 2018
2 parents 6cec053 + 92201f2 commit 31504f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tedana/model/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,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

0 comments on commit 31504f6

Please sign in to comment.