deepmr.brainweb#
- deepmr.brainweb(idx, npix=None, nslices=1, B0=3.0, cache_dir=None)[source]#
Initialize a brain-shaped phantom for MR simulations.
This function generates a brain-shaped phantom [1-3] for qMR or MR simulations based on the provided parameters.
- Parameters:
idx (int) – Brainweb ID (
0
to19
).npix (Iterable[int], optional) – In-plane matrix size. The default is
None
.nslices (int, optional) – Number of slices. An isotropic
[npix, npix, npix]
phantom can be generated, for convenience, by setting nslices to-1
. The default is1
.B0 (float, optional) – Static field strength in
[T]
. The default is3.0
.cache_dir (os.PathLike) – Directory to download the data.
- Returns:
phantom – Dictionary of BrainWeb maps (
M0
,T1
,T2
,T2star
,chi
) of shape(nslices, ny, nx)
(qmr == True
). Units forT1
,T2
andT2star
are[ms]
; forchi
, units are[ppm]
.- Return type:
Examples
>>> import deepmr
We can generate a single-slice BrainWeb phantom as:
>>> phantom = deepmr.brainweb(128) >>> phantom.keys() dict_keys(['M0', 'T1', 'T2', 'T2star', 'chi'])
Each map will have
(nslices, npix, npix)
shape:>>> phantom["M0"].shape torch.Size([128, 128])
We also support multiple slices:
>>> phantom = deepmr.brainweb(128, 32) >>> phantom["M0"].shape torch.Size([32, 128, 128])
Notes
The brainweb is set in the following order:
The
cache_dir
passed as argument.The environment variable
BRAINWEB_DIR
.The default cache__dir
~/brainweb
.
References
- [1] D.L. Collins, A.P. Zijdenbos, V. Kollokian, J.G. Sled, N.J. Kabani, C.J. Holmes, A.C. Evans,
Design and Construction of a Realistic Digital Brain Phantom, IEEE Transactions on Medical Imaging, vol.17, No.3, p.463–468, June 1998