Beispiel #1
0
 def test_transform_from_mov_exceptions(self,key,clust,last_time,i):
     """
     We test exceptions raised when there are not enough usable markers,
     the frame number is out of range, and the marker name does not exist.
     """
     data = self.data
     with pytest.raises(Exception):
         Pipelines.transform_from_mov(data,key,clust,last_time,i)
Beispiel #2
0
    def test_transform_from_mov_SampleData(self,key,clust,last_time,i,expected_result):
        """
        This function tests Pipelines.transform_from_mov(data,key,clust,last_time,i),
        where data is an array of dictionaries of marker data,
        key is the name of the missing marker to perform gap filling for,
        clust is a list of markers in the same cluster as key,
        last_time is the last frame the the missing marker was visible, and
        i is the frame number the marker is missing for.

        We use files from SampleData/Sample_2/ for testing.
        We test for 6 missing frames from the loaded data.
        """
        data = self.data
        data[key][i] = np.array([np.nan, np.nan, np.nan])
        result = Pipelines.transform_from_mov(data,key,clust,last_time,i)
        np.testing.assert_almost_equal(result, expected_result, self.rounding_precision)
Beispiel #3
0
    def test_transform_from_mov(self):
        """
        This function tests Pipelines.transform_from_mov().

        Pipelines.transform_from_mov() uses a transformation that is stored between a 4 marker cluster.  
        It requires an inverse transformation matrix to be stored between the 
        combination of 3 marker groupings, with the 4th marker stored in relation to that frame. 
        
        Pipelines.transform_from_mov() takes in as input the missing marker, and uses previous frames of motion data to 
        create an inverse transformation matrix, multiplying the new frame by the stored 
        inverse transform to get the missing marker position.

        We test that Pipelines.transform_from_mov() is accurate by creating four markers
        in a square at frame zero, and adding one to all but one of their x-coordinates
        in frame 1.

        We ensure that the correct position is reconstructed from the previous frame 
        data, and that the fourth marker is in the correct position after
        the transform.
        """
        #Define the four markers, A, B, C, D, as the four corners of a square in frame 0.
        #Add one to the x-coordinate of all markers but A in frame 1.
        data = {
            'A': np.array([[1, 1, 0], [np.nan, np.nan, np.nan]]),
            'B': np.array([[-1, 1, 0], [0, 1, 0]]),
            'C': np.array([[1, -1, 0], [2, -1, 0]]),
            'D': np.array([[-1, -1, 0], [0, -1, 0]])
        }
        #Use the three markers, B, C, D to reconstruct the position of A
        clust = ['B', 'C', 'D']
        #Last frame in which all four markers were visible
        last_time = 0
        #Frame for which a marker is missing data
        i = 1

        #We expect that A is at [2, 1, 0]
        expected = np.array([2, 1, 0])
        result = Pipelines.transform_from_mov(data, 'A', clust, last_time, i)
        np.testing.assert_equal(result, expected)