def source_extraction(in1, tolerance, mode="cpu", store_on_gpu=False,
                      neg_comp=False):
    """
    Convenience function for allocating work to cpu or gpu, depending on the selected mode.

    INPUTS:
    in1         (no default):   Array containing the wavelet decomposition.
    tolerance   (no default):   Percentage of maximum coefficient at which objects are deemed significant.
    mode        (default="cpu"):Mode of operation - either "gpu" or "cpu".

    OUTPUTS:
    Array containing the significant wavelet coefficients of extracted sources.
    """

    if mode=="cpu":
        return cpu_source_extraction(in1, tolerance, neg_comp)
    elif mode=="gpu":
        return gpu_source_extraction(in1, tolerance, store_on_gpu, neg_comp)
Convenience function for allocating work to cpu or gpu, depending on the selected mode.

    INPUTS:
    in1         (no default):   Array containing the wavelet decomposition.
    tolerance   (no default):   Percentage of maximum coefficient at which objects are deemed significant.
    mode        (default="cpu"):Mode of operation - either "gpu" or "cpu".

    OUTPUTS:
    Array containing the significant wavelet coefficients of extracted sources.