Skip to content

Commit 33b0c3a

Browse files
committed
Added example test with phantom data
1 parent 9e75a4a commit 33b0c3a

File tree

4 files changed

+431
-802
lines changed

4 files changed

+431
-802
lines changed

phantoms/MR_XCAT_qMRI/sim_ivim_sig.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,33 +355,36 @@ def XCAT_to_MR_DCE(XCAT, TR, TE, bvalue, D, f, Ds, b0=3, ivim_cont = True):
355355
Dtemp=5e-4+np.random.rand(1)*3e-3
356356
ftemp=np.random.rand(1)*0.5
357357
Dstemp=5e-3+np.random.rand(1)*1e-1
358-
#S0 = np.zeros(len(bvalue))
359358
S0 = ivim(bvalue,Dtemp,ftemp,Dstemp)
360359
if T1 > 0 or T2 > 0:
361-
MR = MR + np.tile(np.expand_dims(XCAT == iTissue,3),len(S0)) * S0 * (1 - 2 * np.exp(-(TR - TE / 2) / T1) + np.exp(-TR / T1)) * np.exp(
362-
-TE / T2)
360+
MR = MR + np.tile(np.expand_dims(XCAT == iTissue,3),len(S0)) * S0 * (1 - 2 * np.exp(-(TR - TE / 2) / T1) + np.exp(-TR / T1)) * np.exp(-TE / T2)
363361
Dim = Dim + (XCAT == iTissue) * Dtemp
364362
fim = fim + (XCAT == iTissue) * ftemp
365363
Dpim = Dpim + (XCAT == iTissue) * Dstemp
366364
return MR, Dim, fim, Dpim, legend
367365

368366
if __name__ == '__main__':
369367
bvalue = np.array([0., 1, 2, 5, 10, 20, 30, 50, 75, 100, 150, 250, 350, 400, 550, 700, 850, 1000])
370-
noise = 0.005
368+
noise = 0.0 # 0.005
371369
motion = False
372370
sig, XCAT, Dim, fim, Dpim, legend = phantom(bvalue, noise,motion=motion,interleaved=False)
373-
sig = np.flip(sig,axis=0)
374-
sig = np.flip(sig,axis=1)
371+
# sig = np.flip(sig,axis=0)
372+
# sig = np.flip(sig,axis=1)
375373
res=np.eye(4)
376374
res[2]=2
377375

376+
D, f, Ds = contrast_curve_calc()
377+
ignore = np.isnan(D)
378378
generic_data = {}
379379
for level, name in legend.items():
380+
if len(ignore) > level and ignore[level]:
381+
continue
380382
selector = XCAT == level
381383
voxels = sig[selector]
382384
if len(voxels) < 1:
383385
continue
384386
signals = np.mean(voxels, axis=0).tolist()
387+
std = np.std(XCAT[selector], axis=0).tolist()
385388
generic_data[name] = {
386389
'D': np.mean(Dim[selector], axis=0),
387390
'f': np.mean(fim[selector], axis=0),

src/original/ETP_SRI/LinearFitting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def linear_fit(self, bvalues, signal, weighting=None, stats=False):
3333
stats : boolean
3434
If true, return the polyfit statistics
3535
"""
36+
bvalues = np.asarray(bvalues)
37+
signal = np.asarray(signal)
3638
assert bvalues.size == signal.size, "Signal and b-values don't have the same number of values"
3739
if stats:
3840
D, stats = poly.polyfit(np.asarray(bvalues), signal, 1, full=True, w=weighting)

0 commit comments

Comments
 (0)