def test_track_function_on_second_data(self):
        """Test tracking function on second data pair"""

        mesh_sequence = mesh.read_sequence_from_data(
            path.join(dirname(__file__), 'data', 'first_few_frames'))

        first_mesh = mesh_sequence[1]
        second_mesh = mesh_sequence[2]

        start_time = time.clock()
        tracked_ids = tracking.track(first_mesh, second_mesh)
        end_time = time.clock()

        print 'total time for second data pair is:'
        print end_time - start_time

        first_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'second_mesh_tracked_with_third_total.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())

        second_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'third_mesh_tracked_total.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())
    def test_track_function_on_first_data(self):
        """See whether we can fully track the mesh using the track function of the tracking module"""

        mesh_sequence = mesh.read_sequence_from_data(
            path.join(dirname(__file__), 'data', 'first_few_frames'))

        first_mesh = mesh_sequence[0]
        second_mesh = mesh_sequence[1]

        start_time = time.clock()
        tracked_ids = tracking.track(first_mesh, second_mesh)
        end_time = time.clock()

        print 'total time for first data pair is:'
        print end_time - start_time

        first_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'first_mesh_tracked_total.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())

        second_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'second_mesh_tracked_total.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())
    def test_track_and_write_sequence(self):

        mesh_sequence = mesh.read_sequence_from_data(
            path.join(dirname(__file__), 'data', 'first_few_frames'))

        tracking.track_and_write_sequence(
            path.join(dirname(__file__), 'data', 'first_few_frames'),
            path.join(dirname(__file__), 'output', 'first_few_frames'))
    def test_maximum_common_subgraph_for_data_pair(self):
        """Load two segmented data frames and track them"""

        mesh_sequence = mesh.read_sequence_from_data(
            path.join(dirname(__file__), 'data', 'first_few_frames'))

        first_mesh = mesh_sequence[0]

        second_mesh = mesh_sequence[1]

        print 'I am testing...'
        subgraph_finder = tracking.LocalisedSubgraphFinder(
            first_mesh, second_mesh)
        print 'Can I find a subgraph?'
        subgraph_finder.find_maximum_common_subgraph()
        print len(subgraph_finder.largest_mappings)
        post_processor = tracking.PostProcessor(
            first_mesh, second_mesh, subgraph_finder.largest_mappings)
        post_processor.index_global_ids_from_largest_mappings()

        #         tracked_ids = tracking.find_maximum_common_subgraph( first_mesh, second_mesh )

        first_mesh.plot(path.join(dirname(__file__), 'output',
                                  'first_mesh_tracked.pdf'),
                        color_by_global_id=True,
                        total_number_of_global_ids=len(first_mesh.elements))

        second_mesh.plot(path.join(dirname(__file__), 'output',
                                   'second_mesh_tracked.pdf'),
                         color_by_global_id=True,
                         total_number_of_global_ids=len(first_mesh.elements))

        first_mesh.save(
            path.join(dirname(__file__), 'output', 'first_mesh_tracked.mesh'))
        second_mesh.save(
            path.join(dirname(__file__), 'output', 'second_mesh_tracked.mesh'))

        post_processor.tidy_current_mapping()

        first_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'first_mesh_tracked_cleaned.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())

        second_mesh.plot(
            path.join(dirname(__file__), 'output',
                      'second_mesh_tracked_cleaned.pdf'),
            color_by_global_id=True,
            total_number_of_global_ids=first_mesh.get_num_elements())

        first_mesh.save(
            path.join(dirname(__file__), 'output',
                      'first_mesh_tracked_cleaned.mesh'))
        second_mesh.save(
            path.join(dirname(__file__), 'output',
                      'second_mesh_tracked_cleaned.mesh'))
Esempio n. 5
0
    def test_read_sequence(self):
        """Test whether we can read the seedwater output"""
        
        mesh_sequence = mesh.read_sequence_from_data(path.join(dirname(__file__),'data','first_few_frames')) 
        
        self.assertEqual(len(mesh_sequence), 3)

        for frame_number, this_mesh in enumerate( mesh_sequence ):
            print 'reading frame number ' + str(frame_number)
            this_network = this_mesh.generate_network()
            this_mesh.plot(path.join(dirname(__file__),'output','first_frames_' + str(frame_number) + '.pdf'))
            this_network = this_mesh.generate_network()
            self.assertGreater( this_mesh.get_num_elements(), 10)
            for this_element in this_mesh.elements:
                self.assertGreater(this_element.get_num_nodes(), 2)
                self.assertGreater(this_element.id_in_frame, 1)
                self.assert_(this_network.node[this_element.id_in_frame]['position'] != None )
                if not this_element.check_if_on_boundary():
                    self.assertEqual( this_element.get_num_nodes(), this_network.degree(this_element.id_in_frame))
    def xest_network_and_overlay(self):
        "overlay ilastik segmentation with real data for visual inspection"
        
        mesh_sequence = mesh.read_sequence_from_data(path.join(dirname(__file__), 'output','converted'))
        
        real_sequence = glob.glob(path.join(dirname(__file__), 'data', 'image_data', '*.tif'))
        
        real_sequence.sort(key=_natural_keys)

        output_dir = path.join(dirname(__file__),'output','overlays')
        if not path.isdir(output_dir):
            os.mkdir(output_dir)
        
        for mesh_counter, mesh_instance in enumerate( mesh_sequence ):
            print mesh_counter
            name_of_real_image = real_sequence[mesh_counter]
            mesh_instance.plot_with_data( path.join(output_dir, str(mesh_counter) + '.pdf' ), 
                                          name_of_real_image )
            
            this_network = mesh_instance.generate_network()
Esempio n. 7
0
    def xest_network_and_overlay(self):
        "overlay ilastik segmentation with real data for visual inspection"

        mesh_sequence = mesh.read_sequence_from_data(
            path.join(dirname(__file__), 'output', 'converted'))

        real_sequence = glob.glob(
            path.join(dirname(__file__), 'data', 'image_data', '*.tif'))

        real_sequence.sort(key=_natural_keys)

        output_dir = path.join(dirname(__file__), 'output', 'overlays')
        if not path.isdir(output_dir):
            os.mkdir(output_dir)

        for mesh_counter, mesh_instance in enumerate(mesh_sequence):
            print mesh_counter
            name_of_real_image = real_sequence[mesh_counter]
            mesh_instance.plot_with_data(
                path.join(output_dir,
                          str(mesh_counter) + '.pdf'), name_of_real_image)

            this_network = mesh_instance.generate_network()