@@ -185,29 +185,27 @@ def simulate_training_data(self, bvalues, SNR = (5,100), n = 1000000, Drange = (
185185 - Noise is applied after generating noise-free IVIM signals, using either Gaussian or Rician noise.
186186 - Simulated signals are normalized by the mean S0 (b = 0) signal.
187187 """
188- test = self ._rng .uniform (0 , 1 , (n , 3 ))
188+ test = self ._rng .uniform (0 , 1 , (n , 4 ))
189189 D = Drange [0 ] + test [:, [0 ]] * (Drange [1 ] - Drange [0 ])
190190 f = frange [0 ] + test [:, [1 ]] * (frange [1 ] - frange [0 ])
191191 Dp = Dprange [0 ] + test [:, [2 ]] * (Dprange [1 ] - Dprange [0 ])
192192 #data_sim = np.zeros([len(D), len(bvalues)])
193193 bvalues = np .array (bvalues )
194194 if type (SNR ) == tuple :
195- test = self ._rng .uniform (0 , 1 , (n , 1 ))
196- SNR = np .exp (np .log (SNR [1 ]) + (test * (np .log (SNR [0 ]) - np .log (SNR [1 ]))))
195+ noise_std = 1 / SNR [1 ] + test [:,4 ] * (1 / SNR [0 ] - 1 / SNR [1 ])
197196 addnoise = True
198197 elif SNR == 0 :
199198 addnoise = False
200- SNR = np .ones ((n , 1 ))
199+ noise_std = np .ones ((n , 1 ))
201200 else :
202- SNR = np .full ((n , 1 ), SNR )
201+ noise_std = np .full ((n , 1 ), 1 / SNR )
203202 addnoise = True
204203 # loop over array to fill with simulated IVIM data
205204 bvalues = np .array (bvalues ).reshape (1 , - 1 )
206205 data_sim = 1 * (f * np .exp (- bvalues * Dp ) + (1 - f ) * np .exp (- bvalues * D ))
207206
208207 # if SNR is set to zero, don't add noise
209208 if addnoise :
210- noise_std = 1 / SNR # shape (n, 1)
211209 noise_real = self ._rng .normal (0 , noise_std , data_sim .shape )
212210 noise_imag = self ._rng .normal (0 , noise_std , data_sim .shape )
213211
0 commit comments