Skip to content

Commit 2089616

Browse files
most robust definition of ivim regime for simulation
1 parent 66aafb4 commit 2089616

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

phantoms/brain/sim_brain_phantom.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
import nibabel as nib
66
from scipy.ndimage import zoom
77

8-
regime = 'diffusive'#'ballistic' #
8+
DIFFUSIVE_REGIME = 'diffusive'
9+
BALLISTIC_REGIME = 'ballistic'
10+
11+
folder = os.path.dirname(__file__)
12+
13+
###########################
14+
# Simulation parameters #
15+
regime = DIFFUSIVE_REGIME
916
snr = 200
1017
resolution = [3,3,3]
18+
# #
19+
###########################
1120

12-
folder = os.path.dirname(__file__)
1321

1422
# Ground truth
1523
nii = nib.load(os.path.join(folder,'ground_truth','hrgt_icbm_2009a_nls_3t.nii.gz'))
@@ -22,14 +30,14 @@
2230
# Sequence parameters
2331
bval_file = os.path.join(folder,'ground_truth',regime+'.bval')
2432
b = np.loadtxt(bval_file)
25-
if regime == 'ballistic':
33+
if regime == BALLISTIC_REGIME:
2634
cval_file = bval_file.replace('bval','cval')
2735
c = np.loadtxt(cval_file)
2836

2937
# Calculate signal
3038
S = np.zeros(list(np.shape(segmentation))+[b.size])
3139

32-
if regime == 'ballistic':
40+
if regime == BALLISTIC_REGIME:
3341
Db = ivim_pars["Db"]
3442
for i,(D,f,vd) in enumerate(zip(ivim_pars["D"],ivim_pars["f"],ivim_pars["vd"])):
3543
S[segmentation==i+1,:] = S0*((1-f)*np.exp(-b*D)+f*np.exp(-b*Db-c**2*vd**2))
@@ -49,5 +57,5 @@
4957
base_name = os.path.join(folder,'data','{}_snr{}'.format(regime,snr))
5058
nib.save(nii_out,base_name+'.nii.gz')
5159
shutil.copyfile(bval_file,base_name+'.bval')
52-
if regime == 'ballistic':
60+
if regime == BALLISTIC_REGIME:
5361
shutil.copyfile(cval_file,base_name+'.cval')

0 commit comments

Comments
 (0)