The core approach of this simulation is:
The user inputs time series, baseline parameters including echo time,
and the proportion of $\Delta R_2^$ and $\Delta S_0$.
The code can then generate time series for echo times given the baseline parameters.
There can be many sources of the intial time series (pure simulation or real data),
and the resulting multi-echo data will be based on a ground-truth calculation
given the inputted proportions of $\Delta R_2^$ and
This also includes some functions to help generate the intial time series.
$S = (\overline{S_0} + \Delta S_0) * e^{-TE * (\overline{R_2^} + \Delta R_2^)}$
$Y = e^{-TE * (\overline{R_2^} + \Delta R_2^)}$
$S = XY$
$var(S) = var(XY)$
$E[X] = mean(X)=\overline{S_0}$
$E[Y] = mean(Y) = e^{-TE * \overline{R_2^}}$
$var(Y) = E[(e^{-TE * (\overline{R_2^} + \Delta R_2^)} - e^{-TE * (\Delta R_2^)})^2]=E[(e^{-TE * (\Delta R_2^)}(e^{-TE * \overline{R_2^}}-1))^2]$
Using identitiy
$var(XY) = (E[X])^2var(Y) + (E[Y])^2var(X) + var(X)*var(Y)$
$prop(\frac{\Delta S_0 }{ \Delta R_2^})$ = $p_{S_0}$ Proportion of $\Delta S_0$ to $\Delta R_2^$.
1 = pure
By the initial specificiation of the goal:
I think we'd need to solve for
The
Identity if the above is a constant
$pA + (1-p)B = (1-p)A + pB$
$pA +B -pB = A - pA +pB$
$2pA-A = 2pB-B$
Cancelling out p and claiming unequal things are equal so I'm doing something wrong.
That is, the variance explained by X and Y $(1-p_{S_0})(E[X])^2var(Y) + p_{S_0}(E[Y])^2var(X) = C$
older stuff
$prop(\frac{\Delta S_0 }{ \Delta R_2^})$ = $p_{S_0}$ Proportion of $\Delta S_0$ to $\Delta R_2^$.
1 = pure
If
Since only want to solve for
$\Delta S_0 = Se^{TE * R_2^} - S_0$
With a known
Replacing
$\Delta R_2^* = \frac{\frac{ln(p_{S_0}) + TE * R_2^}{TE} - R_2^}{1 - p_{S_0}}= $
Working here & trying to resolve some issues:
For proportion_s0_r2s==1:
0 = (np.log(s0_baseline + delta_s0_scale) - te*r2s_baseline - np.log(S)) / TE
np.log(s0_baseline + delta_s0_scale) = te*r2s_baseline + np.log(S)
delta_s0_scale = np.exp(te*r2s_baseline + np.log(S)) - s0_baseline
The above eq is used to calculate delta_s0_scale in the function
With a known delta_s0_scale, the above eq with proportion_s0_r2s can be used to solve for delta_r2s_scale
(1-proportion_s0_r2s)*delta_r2s_scale = (np.log(s0_baseline + proportion_s0_r2s*delta_s0_scale) - te*r2s_baseline- np.log(S)) / TE
delta_r2s_scale = (np.log(s0_baseline+proportion_s0_r2s*delta_s0_scale) - te*r2s_baseline - np.log(S))/((1-proportion_s0_r2s)*te)
The above eq is used to calculate delta_r2s_scale in the function, but it fails for 1-proportion_s0_r2s==0, but,
in that case (1-proportion_s0_r2s)*delta_r2s_scale should be 0 so it's just set to 0
The returned delta_s0 and delta_r2s values are the scaled values multiplied by their proportions