def test_add_movies(): mv1 = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) mv2 = movie.Movie(np.ones((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) mv3 = mv1 + mv2 assert (mv3.data.shape == (2001, 120, 240)) assert (len(mv3.t_range) == 2001) assert (np.sum(mv3[1000, :, :]) == 0) assert (np.sum(mv3[1001, :, :]) == 120 * 240)
def test_movie(): mv = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) assert (mv.frame_rate == 1000.0) assert (mv.row_range.shape == (120, )) assert (mv.row_range[0] == 0) assert (mv.row_range[-1] == 119) assert (mv.col_range.shape == (240, )) assert (mv.col_range[0] == 0) assert (mv.col_range[-1] == 239) mv = movie.Movie(np.zeros((1001, 120, 240)), frame_rate=1000.0) assert (len(mv.t_range) == 1001) assert (mv.t_range[0] == 0.0) assert (mv.t_range[-1] == 1.0)
def test_get_tcross_from_temporal_kernel(): mv = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) tf = TemporalFilterCosineBump(weights=[33.328, -2.10059], kpeaks=[59.0, 120.0], delays=[0.0, 0.0]) tcross_ind = get_tcross_from_temporal_kernel( tf.get_kernel(threshold=-1.0).kernel) print(tcross_ind == 201)
def test_spatialfilter_kernel(): mv = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) gsf = GaussianSpatialFilter(translate=(-80, -20), sigma=(30, 10), rotation=15.0) kernel = gsf.get_kernel(row_range=mv.row_range, col_range=mv.col_range) assert (isinstance(kernel, Kernel2D)) assert (kernel.full().shape == (120, 240)) assert (np.isclose(np.sum(kernel.full()), 1.0))
def test_temporalfilter_kernel(): mv = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) tf = TemporalFilterCosineBump(weights=[33.328, -2.10059], kpeaks=[59.0, 120.0], delays=[0.0, 0.0]) kernel = tf.get_kernel(t_range=mv.t_range, threshold=0.0, reverse=True) assert (isinstance(kernel, Kernel1D)) assert (kernel.full().shape == (478, )) assert (sum(kernel.full()) > 1.0) kernel.normalize() assert (np.isclose(sum(kernel.full()), 1.0))
def test_spatiotemporalfilter_kernel(): mv = movie.Movie(np.zeros((1001, 120, 240)), t_range=np.linspace(0.0, 1.0, 1001, endpoint=True)) tf = TemporalFilterCosineBump(weights=[33.328, -2.10059], kpeaks=[59.0, 120.0], delays=[0.0, 0.0]) sf = GaussianSpatialFilter(translate=(-80, -20), sigma=(30, 10), rotation=15.0) stf = SpatioTemporalFilter(sf, tf) kernel = stf.get_spatiotemporal_kernel(row_range=mv.row_range, col_range=mv.col_range, t_range=mv.t_range) assert (isinstance(kernel, Kernel3D)) assert (kernel.full().shape == (987, 120, 240)) kernel.normalize() assert (np.isclose(np.sum(kernel.full()), 1.0))