Ejemplo n.º 1
0
    def test_vesselsegment_get_hausdorff_dimension(self):
        for voxel_size in self.voxel_sizes:
            vs_line = vessel_stats.VesselSegment(TEST_PATH_LINE, voxel_size)
            nose.tools.assert_equal(vs_line.get_hausdorff_dimension(), 1)

            vs = vessel_stats.VesselSegment(TEST_PATH_CYCLE, voxel_size)
            nose.tools.assert_equal(vs.get_hausdorff_dimension(), -0.0)
Ejemplo n.º 2
0
 def test_vesselsegment_get_displacement(self):
     for voxel_size, displacement in zip(self.voxel_sizes,
                                         self.expected_lengths_line):
         vs_line = vessel_stats.VesselSegment(TEST_PATH_LINE, voxel_size)
         nose.tools.assert_equal(vs_line.get_displacement(), displacement)
         vs = vessel_stats.VesselSegment([
             (1, 1, 1),
             (2, 2, 2),
             (1, 1, 1),
         ], voxel_size)
         nose.tools.assert_equal(vs.get_displacement(), 0)
Ejemplo n.º 3
0
    def test_vesselsegment_tortuosity_and_contraction(self):
        for voxel_size in self.voxel_sizes:
            vs_line = vessel_stats.VesselSegment(TEST_PATH_LINE, voxel_size)
            nose.tools.assert_equal(vs_line.get_tortuosity(), 1)
            nose.tools.assert_equal(vs_line.get_tortuosity(),
                                    1 / vs_line.get_contraction())

            # Test the limit behaviors
            vs = vessel_stats.VesselSegment(TEST_PATH_CYCLE, voxel_size)
            nose.tools.assert_equal(vs.get_tortuosity(), np.inf)

            vs = vessel_stats.VesselSegment(TEST_PATH_CYCLE, voxel_size)
            nose.tools.assert_equal(vs.get_contraction(), 0)
Ejemplo n.º 4
0
    def test_vesselsegment_get_length(self):
        for voxel_size, length_line, length_cycle in zip(
                self.voxel_sizes, self.expected_lengths_line,
                self.expected_lengths_cycle):
            vs_line = vessel_stats.VesselSegment(TEST_PATH_LINE, voxel_size)
            nose.tools.assert_equal(vs_line.get_length(), length_line)

            vs = vessel_stats.VesselSegment([
                (0, 0, 0),
                (2, 3, 4),
            ], voxel_size)
            dist = np.sqrt((2 * voxel_size[0])**2 + (3 * voxel_size[1])**2 +
                           (4 * voxel_size[2])**2)
            nose.tools.assert_equal(vs.get_length(), dist)

            vs = vessel_stats.VesselSegment(TEST_PATH_CYCLE, voxel_size)
            print(voxel_size, vs.get_length(), length_cycle)
            nose.tools.assert_equal(vs.get_length(), length_cycle)
Ejemplo n.º 5
0
    def _set_vessel_segment_stats(self, path: list):
        """
        :param stats - list
            ["length": float, "tortuosity": float,
             "contraction": float, "hausdorff dimension": float]

        :return a stats record for a segment based on path
        """
        vessel_segment = vessel_stats.VesselSegment(path, self.vox_dim)
        return [vessel_segment.get_vessel_stats()]
Ejemplo n.º 6
0
 def test_vesselsegment_get_vessel_stats(self):
     vs_line = vessel_stats.VesselSegment(TEST_PATH_LINE)
     nose.tools.assert_dict_equal(
         {
             "nodes": 5,
             "length": 4,
             "contraction": 1,
             "start_point": TEST_PATH_LINE[-1],
             "end_point": TEST_PATH_LINE[0],
         }, vs_line.get_vessel_stats())