5
5
import nibabel as nib
6
6
from scipy .ndimage import zoom
7
7
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
9
16
snr = 200
10
17
resolution = [3 ,3 ,3 ]
18
+ # #
19
+ ###########################
11
20
12
- folder = os .path .dirname (__file__ )
13
21
14
22
# Ground truth
15
23
nii = nib .load (os .path .join (folder ,'ground_truth' ,'hrgt_icbm_2009a_nls_3t.nii.gz' ))
22
30
# Sequence parameters
23
31
bval_file = os .path .join (folder ,'ground_truth' ,regime + '.bval' )
24
32
b = np .loadtxt (bval_file )
25
- if regime == 'ballistic' :
33
+ if regime == BALLISTIC_REGIME :
26
34
cval_file = bval_file .replace ('bval' ,'cval' )
27
35
c = np .loadtxt (cval_file )
28
36
29
37
# Calculate signal
30
38
S = np .zeros (list (np .shape (segmentation ))+ [b .size ])
31
39
32
- if regime == 'ballistic' :
40
+ if regime == BALLISTIC_REGIME :
33
41
Db = ivim_pars ["Db" ]
34
42
for i ,(D ,f ,vd ) in enumerate (zip (ivim_pars ["D" ],ivim_pars ["f" ],ivim_pars ["vd" ])):
35
43
S [segmentation == i + 1 ,:] = S0 * ((1 - f )* np .exp (- b * D )+ f * np .exp (- b * Db - c ** 2 * vd ** 2 ))
49
57
base_name = os .path .join (folder ,'data' ,'{}_snr{}' .format (regime ,snr ))
50
58
nib .save (nii_out ,base_name + '.nii.gz' )
51
59
shutil .copyfile (bval_file ,base_name + '.bval' )
52
- if regime == 'ballistic' :
60
+ if regime == BALLISTIC_REGIME :
53
61
shutil .copyfile (cval_file ,base_name + '.cval' )
0 commit comments