Skip to content

Commit

Permalink
most robust definition of ivim regime for simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarjalnefjord committed Aug 18, 2023
1 parent 98f7b33 commit 148f218
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Binary file modified phantoms/brain/data/ballistic_snr200.nii.gz
Binary file not shown.
Binary file modified phantoms/brain/data/diffusive_snr200.nii.gz
Binary file not shown.
18 changes: 13 additions & 5 deletions phantoms/brain/sim_brain_phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
import nibabel as nib
from scipy.ndimage import zoom

regime = 'diffusive'#'ballistic' #
DIFFUSIVE_REGIME = 'diffusive'
BALLISTIC_REGIME = 'ballistic'

folder = os.path.dirname(__file__)

###########################
# Simulation parameters #
regime = DIFFUSIVE_REGIME
snr = 200
resolution = [3,3,3]
# #
###########################

folder = os.path.dirname(__file__)

# Ground truth
nii = nib.load(os.path.join(folder,'ground_truth','hrgt_icbm_2009a_nls_3t.nii.gz'))
Expand All @@ -22,14 +30,14 @@
# Sequence parameters
bval_file = os.path.join(folder,'ground_truth',regime+'.bval')
b = np.loadtxt(bval_file)
if regime == 'ballistic':
if regime == BALLISTIC_REGIME:
cval_file = bval_file.replace('bval','cval')
c = np.loadtxt(cval_file)

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

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

0 comments on commit 148f218

Please sign in to comment.