# Path: molyso/mm/tracking_output.py
# def s_to_h(s):
#     """
#     converts seconds to hours
#     :param s: seconds
#     :return: hours
#     """
#     return s / (60.0 * 60.0)
# 
# Path: molyso/generic/etc.py
# class QuickTableDumper(object):
# 
#     """
# 
#     :param recipient:
#     """
#     delimiter = '\t'
#     line_end = '\n'
# 
#     precision = 8
# 
#     def __init__(self, recipient=None):
#         if recipient is None:
#             recipient = sys.stdout
# 
#         self.recipient = recipient
#         self.headers = []
# 
#     def write_list(self, the_list):
#         """
# 
#         :param the_list:
#         """
#         self.recipient.write(self.delimiter.join(map(self.stringify, the_list)) + self.line_end)
# 
#     def add(self, row):
#         """
# 
#         :param row:
#         """
#         if len(self.headers) == 0:
#             self.headers = list(sorted(row.keys()))
#             self.write_list(self.headers)
# 
#         self.write_list(row[k] for k in self.headers)
# 
#     def stringify(self, obj):
#         """
# 
#         :param obj:
#         :return:
#         """
#         if type(obj) in (float, np.float32, np.float64) and self.precision:
#             return str(round(obj, self.precision))
#         else:
#             return str(obj)
# 
# Path: molyso/mm/fluorescence.py
# class FluorescentChannel(Channel):
#     """
#     A subclass to handle fluorescences.
# 
#     :param image:
#     :param left:
#     :param right:
#     :param top:
#     :param bottom:
#     """
#     __slots__ = 'fluorescences_channel_image'
#     cells_type = FluorescentCells
# 
#     def __init__(self, image, left, right, top, bottom):
#         super(FluorescentChannel, self).__init__(image, left, right, top, bottom)
# 
#         fluorescences_count = len(image.image_fluorescences)
# 
#         self.fluorescences_channel_image = [None] * fluorescences_count
# 
#         for f in range(fluorescences_count):
#             if image.image_fluorescences[f] is None:
#                 continue
# 
#             self.fluorescences_channel_image[f] = self.crop_out_of_image(image.image_fluorescences[f])


import numpy as np
import time
import json
import jsonpickle
import jsonpickle.ext.numpy as jsonpickle_numpy
        import matplotlib.pyplot as plt
                import code
from .tracking_output import s_to_h
from ..generic.etc import QuickTableDumper
from .fluorescence import FluorescentChannel
        data[:, n_width_cumsum] = np.cumsum(data[:, n_width])

        max_top, min_top = data[:, n_top].max(), data[:, n_top].min()
        max_bottom, min_bottom = data[:, n_bottom].max(), data[:, n_bottom].min()

        low, high = int(np.floor(min_top)), int(np.ceil(max_bottom))

        large_image = np.zeros((high - low, int(data[-1, n_width_cumsum])), dtype=some_channel_image.dtype)
        large_fluorescences_image = None
        if fluorescence_count and some_fluorescence_channel_image is not None:
            large_fluorescences_image = np.zeros(
                (fluorescence_count, high - low, int(data[-1, n_width_cumsum])),
                dtype=some_fluorescence_channel_image.dtype)

        large_image_min_max = [float('+Inf'), float('-Inf')]

        large_fluorescence_image_min_max = [[float('+Inf'), float('-Inf')]] * fluorescence_count

        fluorescence_backgrounds = [dict() for _ in range(fluorescence_count)]

        for n, cc in enumerate(channels):
            lower_border = int(np.floor(data[n, n_top] - low))
            large_image[
                lower_border:int(lower_border + data[n, n_height]),
                int(data[n, n_width_cumsum] - data[n, n_width]):int(data[n, n_width_cumsum])
            ] = cc.channel_image

            large_image_min_max = [min(cc.channel_image.min(), large_image_min_max[0]),
                                   max(cc.channel_image.max(), large_image_min_max[1])]


# Path: molyso/mm/tracking_output.py
# def s_to_h(s):
#     """
#     converts seconds to hours
#     :param s: seconds
#     :return: hours
#     """
#     return s / (60.0 * 60.0)
# 
# Path: molyso/generic/etc.py
# class QuickTableDumper(object):
# 
#     """
# 
#     :param recipient:
#     """
#     delimiter = '\t'
#     line_end = '\n'
# 
#     precision = 8
# 
#     def __init__(self, recipient=None):
#         if recipient is None:
#             recipient = sys.stdout
# 
#         self.recipient = recipient
#         self.headers = []
# 
#     def write_list(self, the_list):
#         """
# 
#         :param the_list:
#         """
#         self.recipient.write(self.delimiter.join(map(self.stringify, the_list)) + self.line_end)
# 
#     def add(self, row):
#         """
# 
#         :param row:
#         """
#         if len(self.headers) == 0:
#             self.headers = list(sorted(row.keys()))
#             self.write_list(self.headers)
# 
#         self.write_list(row[k] for k in self.headers)
# 
#     def stringify(self, obj):
#         """
# 
#         :param obj:
#         :return:
#         """
#         if type(obj) in (float, np.float32, np.float64) and self.precision:
#             return str(round(obj, self.precision))
#         else:
#             return str(obj)
# 
# Path: molyso/mm/fluorescence.py
# class FluorescentChannel(Channel):
#     """
#     A subclass to handle fluorescences.
# 
#     :param image:
#     :param left:
#     :param right:
#     :param top:
#     :param bottom:
#     """
#     __slots__ = 'fluorescences_channel_image'
#     cells_type = FluorescentCells
# 
#     def __init__(self, image, left, right, top, bottom):
#         super(FluorescentChannel, self).__init__(image, left, right, top, bottom)
# 
#         fluorescences_count = len(image.image_fluorescences)
# 
#         self.fluorescences_channel_image = [None] * fluorescences_count
# 
#         for f in range(fluorescences_count):
#             if image.image_fluorescences[f] is None:
#                 continue
# 
#             self.fluorescences_channel_image[f] = self.crop_out_of_image(image.image_fluorescences[f])


# Path: molyso/mm/highlevel_interactive_advanced_ground_truth.py
import numpy as np
import time
import json
import jsonpickle
import jsonpickle.ext.numpy as jsonpickle_numpy
        import matplotlib.pyplot as plt
                import code
from .tracking_output import s_to_h
from ..generic.etc import QuickTableDumper
from .fluorescence import FluorescentChannel

        data[:, n_width_cumsum] = np.cumsum(data[:, n_width])

        max_top, min_top = data[:, n_top].max(), data[:, n_top].min()
        max_bottom, min_bottom = data[:, n_bottom].max(), data[:, n_bottom].min()

        low, high = int(np.floor(min_top)), int(np.ceil(max_bottom))

        large_image = np.zeros((high - low, int(data[-1, n_width_cumsum])), dtype=some_channel_image.dtype)
        large_fluorescences_image = None
        if fluorescence_count and some_fluorescence_channel_image is not None:
            large_fluorescences_image = np.zeros(
                (fluorescence_count, high - low, int(data[-1, n_width_cumsum])),
                dtype=some_fluorescence_channel_image.dtype)

        large_image_min_max = [float('+Inf'), float('-Inf')]

        large_fluorescence_image_min_max = [[float('+Inf'), float('-Inf')]] * fluorescence_count

        fluorescence_backgrounds = [dict() for _ in range(fluorescence_count)]

        for n, cc in enumerate(channels):
            lower_border = int(np.floor(data[n, n_top] - low))
            large_image[
                lower_border:int(lower_border + data[n, n_height]),
                int(data[n, n_width_cumsum] - data[n, n_width]):int(data[n, n_width_cumsum])
            ] = cc.channel_image

            large_image_min_max = [min(cc.channel_image.min(), large_image_min_max[0]),
                                   max(cc.channel_image.max(), large_image_min_max[1])]


            if isinstance(cc, FluorescentChannel):