Example #1
0
def add_gaussv_noise(im: IntensityMatrix, scale: float, cutoff: int,
                     prop: float):
    """
    adds noise to an IntensityMatrix object

    :param im: the intensity matrix object
    :type im: pyms.IntensityMatrix.IntensityMatrix
    :param scale: the scale of the normal distribution from which the noise is drawn
    :type scale: float
    :param cutoff: The level below which the intensity of the ic at that point
        has no effect on the scale of the noise distribution
    :type cutoff: int
    :param scale: The scale of the normal distribution for ic values
    :type scale: int
    :param prop: For intensity values above the cutoff, the scale is
        multiplied by the ic value multiplied by prop
    :type prop: float

    :author: Sean O'Callaghan
    """

    n_scan, n_mz = im.size

    for i in range(n_mz):
        ic = im.get_ic_at_index(i)
        add_gaussv_noise_ic(ic, scale, cutoff, prop)
        im.set_ic_at_index(i, ic)
Example #2
0
def add_gaussc_noise(im: IntensityMatrix, scale: float):
    """
    Adds noise to an IntensityMatrix object

    :param im: the intensity matrix object
    :type im: pyms.IntensityMatrix.IntensityMatrix

    :param scale: the scale of the normal distribution from which the noise is drawn
    :type scale: float

    :author: Sean O'Callaghan
    """

    n_scan, n_mz = im.size

    for i in range(n_mz):
        ic = im.get_ic_at_index(i)
        add_gaussc_noise_ic(ic, scale)
        im.set_ic_at_index(i, ic)