# Path: sktracker/utils/progress.py
# def print_progress(progress, message=None, out=None):
#     """Display a progress bar filled with a variable value. print_progress
#     also works under IPython notebook.
# 
#     Set `progress` to -1 to remove the progress bar.
# 
#     Parameters
#     ----------
#     progress: int
#         Variable value use to fill the progress bar. Should be between 0
#         and 100.
#     out: OutStream
#         Where to stream progress bar. None will redirect output to `sys.stdout`.
# 
#     Returns
#     -------
#     None. Display the progress bar.
# 
#     Examples
#     --------
#     >>> import time
#     >>> from sktracker.utils import print_progress
# 
#     >>> n = 5
#     >>> for i in range(n):
#     >>>     time.sleep(1)
# 
#     >>>     print_progress((i + 1) * 100 / n)
#     100% [=================================================>]
#     >>> print_progress(-1)
# 
#     """
# 
#     if out is None:
#         out = sys.stdout
# 
#     # If process is finished
#     if progress == -1:
#         out.write("\r" + " " * 80 + "\r\r")
#         out.flush()
#         return
# 
#     # Size of the progress bar
#     size = 50
# 
#     # Compute current progress
#     progress_bar = (progress) * size / 100
# 
#     # Build progress bar
#     bar = "["
#     for i in range(int(progress_bar - 1)):
#         bar += "="
#     bar += ">"
#     for i in range(int(size - progress_bar)):
#         bar += " "
#     bar += "]"
# 
#     if message:
#         bar = " ".join([bar, message])
# 
#     # Write progress bar
#     bar_str = "\r%d%% " % (progress) + bar
#     out.write(bar_str)
#     out.flush()


import os
import logging
import subprocess
import multiprocessing
import itertools
import numpy as np
import pandas as pd
            import signal
    from subprocess import DEVNULL  # py3k
from scipy.optimize import leastsq
from skimage import feature
from ..utils import print_progress
        pool = multiprocessing.Pool(processes=ncore, initializer=init_worker)

    # Build arguments list
    arguments = zip(data_iterator,
                    itertools.repeat(parameters),
                    range(n_stack))

    try:
        # Launch peak_detection
        if parallel:
            results = pool.imap_unordered(find_gaussian_peaks, arguments)
        else:
            results = map(find_gaussian_peaks, arguments)

        all_peaks = []

        # Get unordered results and log progress
        for i, (pos, peaks) in enumerate(results):

            n_peaks = len(peaks)
            percent_progression = (i + 1) / n_stack * 100

            if show_progress:
                message = ("%i/%i - %i peaks detected on stack n°%i" %
                           ((i + 1), n_stack, n_peaks, pos))
                print_progress(percent_progression, message)

            all_peaks.append((pos, peaks))

        if show_progress:

# Path: sktracker/utils/progress.py
# def print_progress(progress, message=None, out=None):
#     """Display a progress bar filled with a variable value. print_progress
#     also works under IPython notebook.
# 
#     Set `progress` to -1 to remove the progress bar.
# 
#     Parameters
#     ----------
#     progress: int
#         Variable value use to fill the progress bar. Should be between 0
#         and 100.
#     out: OutStream
#         Where to stream progress bar. None will redirect output to `sys.stdout`.
# 
#     Returns
#     -------
#     None. Display the progress bar.
# 
#     Examples
#     --------
#     >>> import time
#     >>> from sktracker.utils import print_progress
# 
#     >>> n = 5
#     >>> for i in range(n):
#     >>>     time.sleep(1)
# 
#     >>>     print_progress((i + 1) * 100 / n)
#     100% [=================================================>]
#     >>> print_progress(-1)
# 
#     """
# 
#     if out is None:
#         out = sys.stdout
# 
#     # If process is finished
#     if progress == -1:
#         out.write("\r" + " " * 80 + "\r\r")
#         out.flush()
#         return
# 
#     # Size of the progress bar
#     size = 50
# 
#     # Compute current progress
#     progress_bar = (progress) * size / 100
# 
#     # Build progress bar
#     bar = "["
#     for i in range(int(progress_bar - 1)):
#         bar += "="
#     bar += ">"
#     for i in range(int(size - progress_bar)):
#         bar += " "
#     bar += "]"
# 
#     if message:
#         bar = " ".join([bar, message])
# 
#     # Write progress bar
#     bar_str = "\r%d%% " % (progress) + bar
#     out.write(bar_str)
#     out.flush()


# Path: sktracker/detection/peak_detector.py
import os
import logging
import subprocess
import multiprocessing
import itertools
import numpy as np
import pandas as pd
            import signal
    from subprocess import DEVNULL  # py3k
from scipy.optimize import leastsq
from skimage import feature
from ..utils import print_progress

        pool = multiprocessing.Pool(processes=ncore, initializer=init_worker)

    # Build arguments list
    arguments = zip(data_iterator,
                    itertools.repeat(parameters),
                    range(n_stack))

    try:
        # Launch peak_detection
        if parallel:
            results = pool.imap_unordered(find_gaussian_peaks, arguments)
        else:
            results = map(find_gaussian_peaks, arguments)

        all_peaks = []

        # Get unordered results and log progress
        for i, (pos, peaks) in enumerate(results):

            n_peaks = len(peaks)
            percent_progression = (i + 1) / n_stack * 100

            if show_progress:
                message = ("%i/%i - %i peaks detected on stack n°%i" %
                           ((i + 1), n_stack, n_peaks, pos))
                print_progress(percent_progression, message)

            all_peaks.append((pos, peaks))

        if show_progress:

            print_progress(-1)