Multi threads

Multi-threads processing is recommended when using MCMC estimation. The neural network estimators are relatively fast and take only minutes training on CPU.

Start julia in terminal with multi-threads

~ % julia --threads auto

You can also set enviornment variable by adding export JULIA_NUM_THREADS=auto in your bash profile, which will use multi-threads automatically when you start julia.

Multi-threads for MCMC estimation

Microstructure.threadingFunction

This method runs multi-threads MCMC estimation on dMRI data using a specified biophysical model, calls the voxel threading method and save estimated parameters as nifti files. savedir includes both output path and file name prefix. Two-stage MCMC sampling methods are run if provided sampler is a Tuple of two samplers, where it will sample all the unknown parameters using the first sampler then sample target tissue parameters in the second sampler while fixing the rest parameters to posterior means in the first MCMC.

threading(
    model_start::BiophysicalModel,
    sampler::Union{Sampler,Tuple{Sampler,Sampler}},
    dmri::MRI,
    mask::MRI,
    protocol::Protocol,
    noise_model::Noisemodel,
    savedir::String,
)

Methods that return mean and standard deviation of estimations from measurements array of size [Nmeas, Nvoxels] using single-stage or two-stage MCMC.

threading(
    model_start::BiophysicalModel,
    sampler::Sampler,
    measurements::Array{Float64,2},
    protocol::Protocol,
    noise_model::Noisemodel,
)


threading(
    model_start::BiophysicalModel,
    sampler::Tuple{Sampler,Sampler},
    measurements::Array{Float64,2},
    protocol::Protocol,
    noise_model::Noisemodel,
)
source

Function threading calls pre_allocate and mcmc! for multi-threads processing. When provided sampler is a Tuple containing two Samplers, it uses a two-stage MCMC to get final estimates.

Microstructure.pre_allocateFunction
pre_allocate(
    model::BiophysicalModel, sampler::Sampler, datasize::Tuple{Int64,Int64}
)

pre_allocate(
    model::BiophysicalModel, sampler::Tuple{Sampler,Sampler}, datasize::Tuple{Int64,Int64}
)

Allocating spaces for caching computing results based on model, sampler and datasize. datasize is the size of data (Nmeas, Nvoxels)

source