Diffusion-induced Signal Attenuation
The purpose of this tutorial is to showcase the simulation of diffusion-related effects. For this, we are going to define a path motion to simulate the Brownian motion of spins. This is not the most efficient way of simulating diffusion, but it is a good way to understand the phenomenon. In particular, we will going to simulate isotropic diffusion, characterized by the Apparent Diffusion Coefficient (ADC).
Creating a phantom with isotropic diffusion
First we will define a Phantom without motion containing
Nspins = 10_000
obj = Phantom(;
x = zeros(Nspins),
T1 = ones(Nspins) * 1000e-3,
T2 = ones(Nspins) * 100e-3,
);Now we will define the Brownian motion of the spins using the path motion definition. The motion will be defined by the displacements in the x, y, and z directions (dx, dy, and dz) of the spins. The displacements will be generated by a random walk with mean square displacement
where
D = 2e-9 # Diffusion Coefficient of water in m^2/s
T = 100e-3 # Duration of the motion
Nt = 100 # Number of time steps
Δt = T / (Nt - 1) # Time sep
Δr = sqrt(2 * D * Δt); # √ Mean square displacementRandom walk is defined as the cumulative sum of random displacements:
rng = MersenneTwister(1234) # Setting up the random seed
dx = cumsum([zeros(Nspins) Δr .* randn(rng, Nspins, Nt - 1)]; dims=2)
dy = cumsum([zeros(Nspins) Δr .* randn(rng, Nspins, Nt - 1)]; dims=2)
dz = cumsum([zeros(Nspins) Δr .* randn(rng, Nspins, Nt - 1)]; dims=2);Including the random_walk into the Phantom definition:
random_walk = KomaMRI.path(dx, dy, dz, TimeRange(0.0, T))
obj.motion = random_walk
p1 = plot_phantom_map(obj, :T1; time_samples=Nt÷4, height=450)