dosma package

Submodules

dosma.defaults module

Default parameters.

This is the first file that is imported from this software. All initialization imports should occur here.

Please change depending on your preferences.

dosma.file_constants module

Basic file constants to be shared with program

dosma.file_constants.set_debug()[source]

dosma.quant_vals module

class dosma.quant_vals.QuantitativeValue(volumetric_map: Optional[dosma.data_io.med_volume.MedicalVolume] = None)[source]

Bases: abc.ABC

This class handles tracking volumes associated with different quantitative values.

Quantitative MRI characterizes the relaxation profile of different regions in the volume. This profile is determined by the composition of the object and has been shown to be informative for early detection of pathology.

In practice, many of these quantitative relaxation parameters (\(T_1\), \(T_2\), \(T_2^*\), etc.) are computed per voxel by fitting to the exponential decay/recovery curves or by some analytical method. This results in a volume where different voxels have different relaxation parameters. These volumes are referred to as volumetric quantitative maps or quantitative maps.

These fitted/computed relaxation parameters are called quantitative values.

Parameters

volumetric_map (MedicalVolume, optional) – Volumetric quantitative map.

Variables
  • volumetric_map (MedicalVolume) – Volumetric quantitative map.

  • additional_volumes (Dict[str, MedicalVolume]) – Additional volumes associated with quantitative value. These are typically volumes associated with the goodness of fit of the value. For example, a volume could be pixel-wise r-squared, or error bounds, etc.

ID = 0
NAME = ''
add_additional_volume(name: str, volume: dosma.data_io.med_volume.MedicalVolume)[source]

Add volume that corresponds to quantitative value.

Additional volumes are typically volumes associated with the goodness of fit of the value. For example, a volume could be r-squared values per voxel, or error bounds, etc.

This should not be the volumetric quantitative map. To update that map, see self.volumetric_map.

Parameters
  • name (str) – Name of additional volume.

  • volume (MedicalVolume) –

static get_qv(qv_id: Union[int, str])[source]

Find QuantitativeValue enum using id or name.

Parameters

qv_id (int or str) – Either quantitative value enum number or name in lower case.

Returns

Quantitative value corresponding to id.

Return type

QuantitativeValue

Raises

ValueError – If no QuantitativeValue corresponding to qv_id found.

load_data(dir_path)[source]

Load data from disk.

Data will be loaded from folder ‘dir_path/self.NAME’.

Currently, additional volumes are not reloaded.

Parameters

dir_path (str) – Directory path.

static load_qvs(dir_path: str)[source]

Load all quantitative values from directory.

Parameters

dir_path (str) – Directory path.

Returns

Quantitative value wrappers.

Return type

list[QuantitativeValue]

property qv_type

quantitative value type.

Type

QuantitativeValueType

save_data(dir_path: str, data_format: dosma.data_io.format_io.ImageDataFormat = <ImageDataFormat.nifti: 1>)[source]

Save data to disk.

Data will be stored in folder ‘dir_path/self.NAME’.

Parameters
  • dir_path (str) – Directory path.

  • data_format (ImageDataFormat, optional) – Data format to save medical volumes. Defaults to preferences.image_data_format.

static save_qvs(dir_path: str, qvs)[source]

Save all quantitative values from directory.

Parameters
  • dir_path (str) – Directory path.

  • qvs (Sequence[QuantitativeValue]) – Quantitative values to save.

to_metrics(mask: Optional[dosma.data_io.med_volume.MedicalVolume] = None, labels: Optional[Dict[int, str]] = None, bounds: Optional[Tuple[float, float]] = None, closed: str = 'right')pandas.core.frame.DataFrame[source]

Compute scalar metrics for quantitative values.

Metrics include mean, median, standard deviation, and number of voxels. Valid voxels are defined as finite valued voxels within the interval bounds (if specified).

Parameters
  • mask (MedicalVolume, optional) – Label mask. Labels should be unsigned ints (uint). Metrics will be computed for each non-zero label(s). If labels specified, metrics computed only for keys in labels dictionary. If not specified, metrics will be calculated over all valid voxels.

  • labels (Dict[int, str], optional) – Mapping from label to label name. If specified, only labels in this argument will be computed.

  • bounds (float or Tuple[float, float], optional) – The left/right bounds for computing metrics. By default, the bounds are the open-interval (-inf, inf).

  • closed (str, optional) – If bounds specified, whether the bounds are closed on the left-side, right-side, both or neither. One of {‘right’, ‘left’, ‘both’, ‘neither’}.

Returns

Metrics for quantitative value. Columns include:
  • ”Region” (str): The label name.

  • ”Mean” (float): Average quantitative value in a region.

  • ”Median” (float): Median quantitative value in a region.

  • ”Std” (float): Standard deviation of quantitative value in a region.

  • ”# Voxels” (int): The number of valid voxels in the region.

Return type

metrics (pd.DataFrame)

class dosma.quant_vals.QuantitativeValueType(value)[source]

Bases: enum.Enum

Enum of types of quantitative values that can be analyzed.

For more information on quantitative parameters, see QuantitativeValue.

T1_RHO = 1
T2 = 2
T2_STAR = 3
class dosma.quant_vals.T1Rho(volumetric_map: Optional[dosma.data_io.med_volume.MedicalVolume] = None)[source]

Bases: dosma.quant_vals.QuantitativeValue

ID = 1
NAME = 't1_rho'
property qv_type

quantitative value type.

Type

QuantitativeValueType

class dosma.quant_vals.T2(volumetric_map: Optional[dosma.data_io.med_volume.MedicalVolume] = None)[source]

Bases: dosma.quant_vals.QuantitativeValue

ID = 2
NAME = 't2'
property qv_type

quantitative value type.

Type

QuantitativeValueType

class dosma.quant_vals.T2Star(volumetric_map: Optional[dosma.data_io.med_volume.MedicalVolume] = None)[source]

Bases: dosma.quant_vals.QuantitativeValue

ID = 3
NAME = 't2_star'
property qv_type

quantitative value type.

Type

QuantitativeValueType

Module contents

The core module contains functions and classes for musculoskeletal analysis.