1
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
2
# vi: set ft=python sts=4 ts=4 sw=4 et:
3
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
4
#
5
#   See COPYING file distributed along with the NiBabel package for the
6
#   copyright and license terms.
7
#
8
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9 33
"""
10
Utilities for calculations related to MRI
11
"""
12

13 33
__all__ = ['calculate_dwell_time']
14

15 33
GYROMAGNETIC_RATIO = 42.576  # MHz/T for hydrogen nucleus
16 33
PROTON_WATER_FAT_SHIFT = 3.4  # ppm
17

18

19 33
class MRIError(ValueError):
20 33
    pass
21

22

23 33
def calculate_dwell_time(water_fat_shift, echo_train_length, field_strength):
24
    """Calculate the dwell time
25

26
    Parameters
27
    ----------
28
    water_fat_shift : float
29
        The water fat shift of the recording, in pixels.
30
    echo_train_length : int
31
        The echo train length of the imaging sequence.
32
    field_strength : float
33
        Strength of the magnet in Tesla, e.g. 3.0 for a 3T magnet recording.
34

35
    Returns
36
    -------
37
    dwell_time : float
38
        The dwell time in seconds.
39

40
    Raises
41
    ------
42
    MRIError
43
        if values are out of range
44
    """
45 33
    if field_strength < 0:
46 33
        raise MRIError("Field strength should be positive")
47 33
    if echo_train_length <= 0:
48 33
        raise MRIError("Echo train length should be >= 1")
49 33
    return ((echo_train_length - 1) * water_fat_shift /
50
            (GYROMAGNETIC_RATIO * PROTON_WATER_FAT_SHIFT *
51
             field_strength * (echo_train_length + 1)))

Read our documentation on viewing source code .

Loading