deepmr.custom_phantom

Contents

deepmr.custom_phantom#

deepmr.custom_phantom(segmentation, properties)[source]#

Initialize numerical phantom for MR simulations from user-provided segmentation.

This function generates a numerical phantom for qMR simulations based on the segmentation and parameters.

Parameters:
  • segmentation (torch.Tensor) – Hard (i.e. non probabilistic) segmentation of the object of shape (nslices, ny, nx).

  • properties (dict) – Dictionary with the properties for each class (e.g., properties.keys() = dict_keys(["M0", "T1", "T2", "T2star", "chi"])). Each property is a list, whose entries ordering should match the label values in “segmentation”. For example, properties["T1"][2] is the T1 value of the region corresponding to (segmentation == 2).

Returns:

phantom – Dictionary of maps (e.g., M0, T1, T2, T2star, chi) of shape (nslices, ny, nx).

Return type:

dict

Examples

>>> import torch
>>> import deepmr

We can initialize a simple tissue segmentation and its M0, T1 and T2 properties:

>>> segmentation = torch.tensor([0, 0, 0, 1, 1, 1], dtype=int)
>>> properties = {"M0": [0.7, 0.8], "T1": [500.0, 1000.0], "T2": [50.0, 100.0]}

Now, we can use “create_phantom” to generate our M0, T1 and T2 maps:

>>> phantom = deepmr.custom_phantom(segmentation, properties)
>>> phantom["M0"]
tensor([ 0.7, 0.7, 0.7, 0.8, 0.8, 0.8])
>>> phantom["T1"]
tensor([ 500., 500., 500., 1000., 1000., 1000.])
>>> phantom["T2"]
tensor([ 50., 50., 50., 100., 100., 100.])