def import_files(self, file_list):
     file_import.import_files(self.chest, file_list)
     self.image_controller = MappableImageController(
         parent=self, treasure_chest=self.chest)
     self.cell_controller = CellController(parent=self,
                                           treasure_chest=self.chest)
     self.log_action(action="import", files=file_list)
 def open_treasure_chest(self, filename):
     if self.chest is not None:
         self.chest.close()
     chest = file_import.open_treasure_chest(filename)
     self.chest = chest
     self.image_controller = MappableImageController(parent=self,
                                                     treasure_chest=chest)
     self.cell_controller = CellController(parent=self,
                                           treasure_chest=chest)
     self.mda_controller = MDAViewController(parent=self,
                                             treasure_chest=chest)
     self.title = " - %s" % os.path.split(filename)[1]
     self.has_chest = True
 def import_files(self, file_list):
     file_import.import_files(self.chest, file_list)
     self.image_controller = MappableImageController(parent=self, 
                                                 treasure_chest=self.chest)
     self.cell_controller = CellController(parent=self,
                                           treasure_chest=self.chest)
     self.log_action(action="import", files=file_list)
 def new_treasure_chest(self, filename):
     if self.chest is not None:
         self.chest.close()
     # first, clear any existing controllers
     self.image_controller = MappableImageController(parent=self)
     self.cell_controller = CellController(parent=self)
     self.mda_controller = MDAViewController(parent=self)
     # open a new chest
     prefix, ext = os.path.splitext(filename)
     if "chest" in ext:
         filename = prefix
     chest = file_import.new_treasure_chest(filename)
     self.chest = chest
     self.image_controller = MappableImageController(parent=self, 
                                                 treasure_chest=chest)
     self.cell_controller = CellController(parent=self, 
                                           treasure_chest=chest)
     self.title = " - %s" % os.path.split(filename)[1]
     self.has_chest=True
 def new_treasure_chest(self, filename):
     if self.chest is not None:
         self.chest.close()
     # first, clear any existing controllers
     self.image_controller = MappableImageController(parent=self)
     self.cell_controller = CellController(parent=self)
     self.mda_controller = MDAViewController(parent=self)
     # open a new chest
     prefix, ext = os.path.splitext(filename)
     if "chest" in ext:
         filename = prefix
     chest = file_import.new_treasure_chest(filename)
     self.chest = chest
     self.image_controller = MappableImageController(parent=self,
                                                     treasure_chest=chest)
     self.cell_controller = CellController(parent=self,
                                           treasure_chest=chest)
     self.title = " - %s" % os.path.split(filename)[1]
     self.has_chest = True
 def open_treasure_chest(self, filename):
     if self.chest is not None:
         self.chest.close()
     chest = file_import.open_treasure_chest(filename)
     self.chest = chest
     self.image_controller = MappableImageController(parent=self, 
                                                 treasure_chest=chest)
     self.cell_controller = CellController(parent=self, 
                                           treasure_chest=chest)
     self.mda_controller = MDAViewController(parent=self, treasure_chest=chest)
     self.title = " - %s" % os.path.split(filename)[1]
     self.has_chest=True
 def update_cell_data(self):
     self.cell_controller = CellController(parent=self, 
                                           treasure_chest=self.chest)
 def __init__(self, *args, **kw):
     super(HighSeasAdventure, self).__init__(*args, **kw)
     self.image_controller = MappableImageController(parent=self)
     self.cell_controller = CellController(parent=self)
     self.mda_controller = MDAViewController(parent=self)
     self.chest = None
class HighSeasAdventure(Atom):
    has_chest = Bool(False)
    show_image_view = Bool(False)
    show_cell_view = Bool(False)
    show_score_view = Bool(False)
    show_factor_view = Bool(False)
    title = Unicode("")

    image_controller = Instance(MappableImageController)
    cell_controller = Instance(CellController)
    mda_controller = Instance(MDAViewController)
    chest = Instance(tb.File)
    
    def __init__(self, *args, **kw):
        super(HighSeasAdventure, self).__init__(*args, **kw)
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        self.chest = None

    def update_cell_data(self):
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=self.chest)
        
    def add_cell_data(self, data, name):
        self.cell_controller.add_cell_data(data,name)

    def update_mda_data(self):
        self.mda_controller = MDAViewController(parent=self, 
                                              treasure_chest=self.chest)
        self.show_factor_view = True
        self.show_score_view = True
        
    def update_image_data(self):
        self.image_controller.data_updated()
        self.crop_controller.data_updated()

    def new_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        # first, clear any existing controllers
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        # open a new chest
        prefix, ext = os.path.splitext(filename)
        if "chest" in ext:
            filename = prefix
        chest = file_import.new_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=chest)
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest=True

    def open_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        chest = file_import.open_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=chest)
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=chest)
        self.mda_controller = MDAViewController(parent=self, treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest=True

    def import_files(self, file_list):
        file_import.import_files(self.chest, file_list)
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=self.chest)
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=self.chest)
        self.log_action(action="import", files=file_list)

    def load_test_data(self):
        # create the test pattern
        tp = get_test_pattern((256,256))
        # save it as a file, for user's reference, and because we have
        #    to load files into chests (TODO: fix this to be more generic?)
        imsave('tp.png', tp)
        # create a new project
        self.new_treasure_chest('test_pattern')
        # import the newly saved test pattern file
        self.import_files(['tp.png'])
        # delete the file for cleanliness?

    def characterize_peaks(self):
        has_cells = self.cell_controller._can_change_idx
        # TODO: need to make peak width a user-specified value, or some
        #   auto-detect algorithm...
        self.image_controller.characterize_peaks()
        #if has_cells:
            # TODO: cell_controller accesses the database for 
            #  the image controller here.  Need to clean up.
            #self.cell_controller.map_peaks_to_cells()

    def open_crop_UI(self):
        crop_controller = CellCropController(parent=self,
                                                  treasure_chest=self.chest)
        cell_cropper = simple_session('cropper', 'Cell cropper', CellCropperInterface, 
                                      controller=crop_controller)
        Application.instance().add_factories([cell_cropper])
        session_id = Application.instance().start_session('cropper')
        crop_controller._session_id = session_id
        
    def open_MDA_UI(self):
        mda_controller = MDAExecutionController(parent=self, 
                                             treasure_chest=self.chest)
        mda_dialog = simple_session('mda', 'MDA dialog', MDAInterface, 
                                      controller=mda_controller)
        Application.instance().add_factories([mda_dialog])
        session_id = Application.instance().start_session('mda')
        mda_controller._session_id = session_id
        
    def log_action(self, action, **parameters):
        """
        action - a short string describing the action itself (e.g. crop cells)
        parameters - pass any number of named parameters.  These will be recorded as
            a string that can then be recovered as a dictionary at some later date.
        version - the version of analyzarr used to perform that action
        """
        row = self.chest.root.log.row
        row['date']=time()
        row['action']=action
        # record parameter dictionary as string.  Can be brought back with:
        #   dict2 = eval(string_from_table)
        # http://stackoverflow.com/questions/4547274/convert-a-python-dict-to-a-string-and-back
        row['parameters'] = parameters
        row['version'] = version
        row.append()
        self.chest.root.log.flush()
class HighSeasAdventure(HasTraits):
    has_chest = Bool(False)
    show_image_view = Bool(False)
    show_cell_view = Bool(False)
    show_score_view = Bool(False)
    show_factor_view = Bool(False)
    title = String("")

    image_controller = Instance(MappableImageController)
    cell_controller = Instance(CellController)
    mda_controller = Instance(MDAViewController)
    
    def __init__(self, *args, **kw):
        super(HighSeasAdventure, self).__init__(*args, **kw)
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        self.chest = None

    def update_cell_data(self):
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=self.chest)
        
    def add_image_data(self, data, name):
        self.image_controller.add_data(data,name)
        
    def add_cell_data(self, data, name):
        self.cell_controller.add_data(data,name)

    def update_mda_data(self):
        self.mda_controller = MDAViewController(parent=self, 
                                              treasure_chest=self.chest)
        self.show_factor_view = True
        self.show_score_view = True
        
    def update_image_data(self):
        self.image_controller.data_updated()
        self.crop_controller.data_updated()

    def new_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        # first, clear any existing controllers
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        # open a new chest
        prefix, ext = os.path.splitext(filename)
        if "chest" in ext:
            filename = prefix
        chest = file_import.new_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=chest)
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest=True

    def open_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        chest = file_import.open_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=chest)
        self.cell_controller = CellController(parent=self, 
                                              treasure_chest=chest)
        self.mda_controller = MDAViewController(parent=self, treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest=True

    def import_files(self, file_list):
        file_import.import_files(self.chest, file_list)
        self.image_controller = MappableImageController(parent=self, 
                                                    treasure_chest=self.chest)
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=self.chest)
        self.log_action(action="import", files=file_list)

    def load_test_data(self):
        # create the test pattern
        tp = get_test_pattern((256,256))
        # save it as a file, for user's reference, and because we have
        #    to load files into chests (TODO: fix this to be more generic?)
        imsave('tp.png', tp)
        # create a new project
        self.new_treasure_chest('test_pattern')
        # import the newly saved test pattern file
        self.import_files(['tp.png'])
        # delete the file for cleanliness?

    def characterize_peaks(self):
        has_cells = self.cell_controller.get_num_files()>0
        # TODO: need to make peak width a user-specified value, or some
        #   auto-detect algorithm...
        self.image_controller.characterize_peaks()
        if has_cells:
            # TODO: cell_controller accesses the database for 
            #  the image controller here.  Need to clean up.
            self.map_global_peaks_to_cells()

    def open_crop_UI(self):
        crop_controller = CellCropController(parent=self,
                                                  treasure_chest=self.chest)
        cell_cropper = simple_session('cropper', 'Cell cropper', CellCropperInterface, 
                                      controller=crop_controller)
        Application.instance().add_factories([cell_cropper])
        session_id = Application.instance().start_session('cropper')
        crop_controller._session_id = session_id
        
    def open_MDA_UI(self):
        mda_controller = MDAExecutionController(parent=self, 
                                             treasure_chest=self.chest)
        mda_dialog = simple_session('mda', 'MDA dialog', MDAInterface, 
                                      controller=mda_controller)
        Application.instance().add_factories([mda_dialog])
        session_id = Application.instance().start_session('mda')
        mda_controller._session_id = session_id
        
    def log_action(self, action, **parameters):
        """
        action - a short string describing the action itself (e.g. crop cells)
        parameters - pass any number of named parameters.  These will be recorded as
            a string that can then be recovered as a dictionary at some later date.
        version - the version of analyzarr used to perform that action
        """
        row = self.chest.root.log.row
        row['date']=time()
        row['action']=action
        # record parameter dictionary as string.  Can be brought back with:
        #   dict2 = eval(string_from_table)
        # http://stackoverflow.com/questions/4547274/convert-a-python-dict-to-a-string-and-back
        row['parameters'] = parameters
        row['version'] = version
        row.append()
        self.chest.root.log.flush()

    def get_peak_data(self, node_name):
        indices = self.chest.get_node('/image_peaks').get_where_list(
                    '(filename=="%s")'%node_name)
        return self.chest.root.image_peaks[indices]

    def find_best_matching_global_peaks(self, target_locations_x_y, node_name):
        coords_x=self.image_controller.get_expression_data("x", "/image_peaks", node_name)
        coords_y=self.image_controller.get_expression_data("y", "/image_peaks", node_name)
        coords = np.vstack((coords_x, coords_y)).T
        indices=[pc.best_match(coords, target) for target in target_locations_x_y]
        return self.get_peak_data(node_name=node_name)[indices]

    def map_global_peaks_to_cells(self):        
        try:
            # wipe out old results
            self.chest.remove_node('/cell_peaks')        
        except:
            # any errors will be because the table doesn't exist. That's OK.
            pass                
        # get the average cell image and find peaks on it
        peaks=pc.two_dim_findpeaks(self.cell_controller.get_average_cell(), 
                                   xc_filter=False, kill_edges=False)
        # generate a list of column names
        names = [('x%i, y%i, dx%i, dy%i, h%i, o%i, e%i, sx%i, sy%i' % ((x,)*9)).split(', ') 
                 for x in xrange(peaks.shape[0])]
        # flatten that from a list of lists to a simple list
        names = [item for sublist in names for item in sublist]
        # make tuples of each column name and 'f8' for the data type
        dtypes = zip(names, ['f8', ] * peaks.shape[0]*9)
        # prepend the filename and index columns
        dtypes = [('filename', '|S250'), ('file_idx', 'i4'), ('omit', 'bool')] + dtypes
        # create an empty recarray with our data type
        desc = np.recarray((0,), dtype=dtypes)
        # create the table using the empty description recarray
        self.chest.create_table(self.chest.root,
                               'cell_peaks', description=desc)
        
        self.chest.set_node_attr('/cell_peaks','number_of_peaks', peaks.shape[0])
        self.chest.flush()
        
        # loop over each peak, finding the peak that best matches this cell's position
        #     plus the offset for the peak.
        for node in self.image_controller.get_node_iterator():
            cell_data = self.cell_controller.get_cell_set(node.name)
            data = np.zeros((cell_data.shape[0]),dtype=dtypes)
            data["filename"] = node.name
            data['file_idx'] = np.arange(cell_data.shape[0])
            for idx, peak in enumerate(peaks):            
                #TODO: need to rework this whole get_expression_data concept.  It is
                #    a column accessor.
                target_x = self.image_controller.get_expression_data("x_coordinate", 
                                                    table_loc="/cell_description",
                                                    filename=node.name)+peak[0]
                target_y = self.image_controller.get_expression_data("y_coordinate", 
                                                    table_loc="/cell_description",
                                                    filename=node.name)+peak[1]
                if target_x.shape[0]>0:
                    chars = self.find_best_matching_global_peaks(np.array([target_x,target_y]).T, 
                                                                 node.name)
                    # add the peak ids (or data) to table representing cell peak characteristics
                    
                    
                    data["x%i"%idx] = chars["x"]-target_x+peak[0]
                    data["y%i"%idx] = chars["y"]-target_y+peak[1]
                    data["dx%i"%idx] = chars["x"]-target_x
                    data["dy%i"%idx] = chars["y"]-target_y
                    data["h%i"%idx] = chars["h"]
                    data["o%i"%idx] = chars["o"]
                    data["e%i"%idx] = chars["e"]
                    data["sx%i"%idx] = chars["sx"]
                    data["sy%i"%idx] = chars["sy"]
                
            
            # commit the data to the table
            self.chest.root.cell_peaks.append(data)
            self.chest.root.cell_peaks.flush()
        self.chest.flush()
        self.cell_controller._can_show_peak_ids=True
            
        
 def update_cell_data(self):
     self.cell_controller = CellController(parent=self,
                                           treasure_chest=self.chest)
 def __init__(self, *args, **kw):
     super(HighSeasAdventure, self).__init__(*args, **kw)
     self.image_controller = MappableImageController(parent=self)
     self.cell_controller = CellController(parent=self)
     self.mda_controller = MDAViewController(parent=self)
     self.chest = None
class HighSeasAdventure(HasTraits):
    has_chest = Bool(False)
    show_image_view = Bool(False)
    show_cell_view = Bool(False)
    show_score_view = Bool(False)
    show_factor_view = Bool(False)
    title = String("")

    image_controller = Instance(MappableImageController)
    cell_controller = Instance(CellController)
    mda_controller = Instance(MDAViewController)

    def __init__(self, *args, **kw):
        super(HighSeasAdventure, self).__init__(*args, **kw)
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        self.chest = None

    def update_cell_data(self):
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=self.chest)

    def add_image_data(self, data, name):
        self.image_controller.add_data(data, name)

    def add_cell_data(self, data, name):
        self.cell_controller.add_data(data, name)

    def update_mda_data(self):
        self.mda_controller = MDAViewController(parent=self,
                                                treasure_chest=self.chest)
        self.show_factor_view = True
        self.show_score_view = True

    def update_image_data(self):
        self.image_controller.data_updated()
        self.crop_controller.data_updated()

    def new_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        # first, clear any existing controllers
        self.image_controller = MappableImageController(parent=self)
        self.cell_controller = CellController(parent=self)
        self.mda_controller = MDAViewController(parent=self)
        # open a new chest
        prefix, ext = os.path.splitext(filename)
        if "chest" in ext:
            filename = prefix
        chest = file_import.new_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self,
                                                        treasure_chest=chest)
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest = True

    def open_treasure_chest(self, filename):
        if self.chest is not None:
            self.chest.close()
        chest = file_import.open_treasure_chest(filename)
        self.chest = chest
        self.image_controller = MappableImageController(parent=self,
                                                        treasure_chest=chest)
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=chest)
        self.mda_controller = MDAViewController(parent=self,
                                                treasure_chest=chest)
        self.title = " - %s" % os.path.split(filename)[1]
        self.has_chest = True

    def import_files(self, file_list):
        file_import.import_files(self.chest, file_list)
        self.image_controller = MappableImageController(
            parent=self, treasure_chest=self.chest)
        self.cell_controller = CellController(parent=self,
                                              treasure_chest=self.chest)
        self.log_action(action="import", files=file_list)

    def load_test_data(self):
        # create the test pattern
        tp = get_test_pattern((256, 256))
        # save it as a file, for user's reference, and because we have
        #    to load files into chests (TODO: fix this to be more generic?)
        imsave('tp.png', tp)
        # create a new project
        self.new_treasure_chest('test_pattern')
        # import the newly saved test pattern file
        self.import_files(['tp.png'])
        # delete the file for cleanliness?

    def characterize_peaks(self):
        has_cells = self.cell_controller.get_num_files() > 0
        # TODO: need to make peak width a user-specified value, or some
        #   auto-detect algorithm...
        self.image_controller.characterize_peaks()
        if has_cells:
            # TODO: cell_controller accesses the database for
            #  the image controller here.  Need to clean up.
            self.map_global_peaks_to_cells()

    def open_crop_UI(self):
        crop_controller = CellCropController(parent=self,
                                             treasure_chest=self.chest)
        cell_cropper = simple_session('cropper',
                                      'Cell cropper',
                                      CellCropperInterface,
                                      controller=crop_controller)
        Application.instance().add_factories([cell_cropper])
        session_id = Application.instance().start_session('cropper')
        crop_controller._session_id = session_id

    def open_MDA_UI(self):
        mda_controller = MDAExecutionController(parent=self,
                                                treasure_chest=self.chest)
        mda_dialog = simple_session('mda',
                                    'MDA dialog',
                                    MDAInterface,
                                    controller=mda_controller)
        Application.instance().add_factories([mda_dialog])
        session_id = Application.instance().start_session('mda')
        mda_controller._session_id = session_id

    def log_action(self, action, **parameters):
        """
        action - a short string describing the action itself (e.g. crop cells)
        parameters - pass any number of named parameters.  These will be recorded as
            a string that can then be recovered as a dictionary at some later date.
        version - the version of analyzarr used to perform that action
        """
        row = self.chest.root.log.row
        row['date'] = time()
        row['action'] = action
        # record parameter dictionary as string.  Can be brought back with:
        #   dict2 = eval(string_from_table)
        # http://stackoverflow.com/questions/4547274/convert-a-python-dict-to-a-string-and-back
        row['parameters'] = parameters
        row['version'] = version
        row.append()
        self.chest.root.log.flush()

    def get_peak_data(self, node_name):
        indices = self.chest.get_node('/image_peaks').get_where_list(
            '(filename=="%s")' % node_name)
        return self.chest.root.image_peaks[indices]

    def find_best_matching_global_peaks(self, target_locations_x_y, node_name):
        coords_x = self.image_controller.get_expression_data(
            "x", "/image_peaks", node_name)
        coords_y = self.image_controller.get_expression_data(
            "y", "/image_peaks", node_name)
        coords = np.vstack((coords_x, coords_y)).T
        indices = [
            pc.best_match(coords, target) for target in target_locations_x_y
        ]
        return self.get_peak_data(node_name=node_name)[indices]

    def map_global_peaks_to_cells(self):
        try:
            # wipe out old results
            self.chest.remove_node('/cell_peaks')
        except:
            # any errors will be because the table doesn't exist. That's OK.
            pass
        # get the average cell image and find peaks on it
        peaks = pc.two_dim_findpeaks(self.cell_controller.get_average_cell(),
                                     xc_filter=False,
                                     kill_edges=False)
        # generate a list of column names
        names = [('x%i, y%i, dx%i, dy%i, h%i, o%i, e%i, sx%i, sy%i' %
                  ((x, ) * 9)).split(', ') for x in xrange(peaks.shape[0])]
        # flatten that from a list of lists to a simple list
        names = [item for sublist in names for item in sublist]
        # make tuples of each column name and 'f8' for the data type
        dtypes = zip(names, [
            'f8',
        ] * peaks.shape[0] * 9)
        # prepend the filename and index columns
        dtypes = [('filename', '|S250'), ('file_idx', 'i4'),
                  ('omit', 'bool')] + dtypes
        # create an empty recarray with our data type
        desc = np.recarray((0, ), dtype=dtypes)
        # create the table using the empty description recarray
        self.chest.create_table(self.chest.root,
                                'cell_peaks',
                                description=desc)

        self.chest.set_node_attr('/cell_peaks', 'number_of_peaks',
                                 peaks.shape[0])
        self.chest.flush()

        # loop over each peak, finding the peak that best matches this cell's position
        #     plus the offset for the peak.
        for node in self.image_controller.get_node_iterator():
            cell_data = self.cell_controller.get_cell_set(node.name)
            data = np.zeros((cell_data.shape[0]), dtype=dtypes)
            data["filename"] = node.name
            data['file_idx'] = np.arange(cell_data.shape[0])
            for idx, peak in enumerate(peaks):
                #TODO: need to rework this whole get_expression_data concept.  It is
                #    a column accessor.
                target_x = self.image_controller.get_expression_data(
                    "x_coordinate",
                    table_loc="/cell_description",
                    filename=node.name) + peak[0]
                target_y = self.image_controller.get_expression_data(
                    "y_coordinate",
                    table_loc="/cell_description",
                    filename=node.name) + peak[1]
                if target_x.shape[0] > 0:
                    chars = self.find_best_matching_global_peaks(
                        np.array([target_x, target_y]).T, node.name)
                    # add the peak ids (or data) to table representing cell peak characteristics

                    data["x%i" % idx] = chars["x"] - target_x + peak[0]
                    data["y%i" % idx] = chars["y"] - target_y + peak[1]
                    data["dx%i" % idx] = chars["x"] - target_x
                    data["dy%i" % idx] = chars["y"] - target_y
                    data["h%i" % idx] = chars["h"]
                    data["o%i" % idx] = chars["o"]
                    data["e%i" % idx] = chars["e"]
                    data["sx%i" % idx] = chars["sx"]
                    data["sy%i" % idx] = chars["sy"]

            # commit the data to the table
            self.chest.root.cell_peaks.append(data)
            self.chest.root.cell_peaks.flush()
        self.chest.flush()
        self.cell_controller._can_show_peak_ids = True