예제 #1
0
 def testFacts(self):
     np.testing.assert_allclose(cons(np.array([])), np.array([1]))
     np.testing.assert_allclose(cons(np.array([1])),
                                np.array([1, -2.718281828459046]))
     np.testing.assert_allclose(cons(np.array([2])),
                                np.array([1, -7.389056098930650]))
     np.testing.assert_allclose(cons(np.array([3])),
                                np.array([1, -20.085536923187668]))
예제 #2
0
def calculate_common_part(a, psi, t_r):
    fil_poles = np.array([psi * t_r])
    hden = np.real(cons(fil_poles))
    causal = np.array([x for x in fil_poles if np.real(x) < 0])
    n_causal = np.array([x for x in fil_poles if np.real(x) > 0])
    h_dc = cons(causal)
    h_dnc = cons(n_causal)
    reconstruct = {'num': np.real(cons(a * t_r)), 'den': np.array([np.real(h_dc), np.real(h_dnc)])}
    return reconstruct, hden
예제 #3
0
 def test_inputs_from_hrf_parameters_1(self):
     input = np.array([-0.27, -0.27, -0.4347 - 0.3497j, -0.4347 + 0.3497j])
     expected_output = [
         1, -2.743302542144524, 2.859320053352163, -1.348960571338628,
         0.244289813077911
     ]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #4
0
 def test_inputs_from_hrf_parameters_3(self):
     input = np.array(
         [-0.27, -0.27, -0.4347 - 0.3497j, -0.4347 + 0.3497j, 0])
     expected_output = [
         1, -3.743302542144524, 5.602622595496687, -4.208280624690792,
         1.593250384416538, -0.244289813077911
     ]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #5
0
 def test_inputs_from_hrf_parameters_6(self):
     input = np.array([
         -1.020408163265306, -3.092145949288806,
         -0.324675324675325 - 0.548716683350910j,
         -0.324675324675325 + 0.548716683350910j, 0
     ])
     expected_output = [
         1, -2.639165427154841, 2.678459114317751, -1.271489046879362,
         0.240744669196138, -0.008549309479686
     ]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #6
0
 def test_inputs_from_hrf_parameters_4(self):
     input = np.array([
         -1.020408163265306, -3.092145949288806,
         -0.324675324675325 - 0.548716683350910j,
         -0.324675324675325 + 0.548716683350910j
     ])
     expected_output = [
         1, -1.639165427154841, 1.039293687162910, -0.232195359716452,
         0.008549309479686
     ]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #7
0
 def test_inputs_from_hrf_parameters_5(self):
     input = np.array([-11.898107445013801])
     expected_output = [1, -6.803268190346306e-06]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #8
0
 def test_inputs_from_hrf_parameters_2(self):
     input = np.array([-0.1336])
     expected_output = [1, -0.874939970605710]
     np.testing.assert_allclose(cons(input), expected_output)
예제 #9
0
def block_filter(a, psi, t_r):
    reconstruct, hden = calculate_common_part(a, psi, t_r)
    hnum = cons(np.append(a * t_r, 0))
    _, h = signal.freqz(hnum, hden, 1024)
    maxeig = np.max(np.power(np.abs(h), 2))
    return {'num': np.real(hnum), 'den': reconstruct['den']}, reconstruct, maxeig
예제 #10
0
def spike_filter(a, psi, t_r):
    reconstruct, hden = calculate_common_part(a, psi, t_r)
    hnum = cons(a * t_r)
    _, h = signal.freqz(hnum, hden, 1024)
    maxeig = np.max(np.power(np.abs(h), 2))
    return reconstruct, reconstruct, maxeig