Ejemplo n.º 1
0
def Entropy_analysis(parallel_inputs):
    t0 = time.time()

    # Unpack the parallel input
    x = parallel_inputs['x']  # Input EEG segment
    r = parallel_inputs['r']  # Tolerance value
    emb_dim = parallel_inputs['emb_dim']  # Embedding dimension

    ### Perform entropy analysis
    ApEn = measures.ApEn(x, emb_dim, r)

    # Sample Entropy
    SampEn = measures.SampEn(x, emb_dim, r)

    # RangeEn-A (Modified Approximate Entropy)
    RangeEn_A = measures.RangeEn_A(x, emb_dim, r)

    # RangeEn-B (Modified Sample Entropy)
    RangeEn_B = measures.RangeEn_B(x, emb_dim, r)

    print('Entropy analysis of the EEG segment was finished! Elapsed time: ' +
          str(time.time() - t0))

    return ApEn, SampEn, RangeEn_A, RangeEn_B
Ejemplo n.º 2
0
        ApEn_r[2, n_r] = measures.ApEn(x3 / np.std(x3), m_single, r_span[0,
                                                                         n_r])

        # Sample Entropy
        SampEn_r[0, n_r] = measures.SampEn(x1, m_single, r_span[0, n_r])
        SampEn_r[1, n_r] = measures.SampEn(x2, m_single, r_span[0, n_r])
        SampEn_r[2, n_r] = measures.SampEn(x3 / np.std(x3), m_single,
                                           r_span[0, n_r])

        # RangeEn-A (Modified Approximate Entropy)
        RangeEn_A_r[0, n_r] = measures.RangeEn_A(x1, m_single, r_span[0, n_r])
        RangeEn_A_r[1, n_r] = measures.RangeEn_A(x2, m_single, r_span[0, n_r])
        RangeEn_A_r[2, n_r] = measures.RangeEn_A(x3, m_single, r_span[0, n_r])

        # RangeEn-B (Modified Sample Entropy)
        RangeEn_B_r[0, n_r] = measures.RangeEn_B(x1, m_single, r_span[0, n_r])
        RangeEn_B_r[1, n_r] = measures.RangeEn_B(x2, m_single, r_span[0, n_r])
        RangeEn_B_r[2, n_r] = measures.RangeEn_B(x3, m_single, r_span[0, n_r])

        ##### Save the entropy values in an external .npz file
        np.savez(output_filename,
                 SampEn_r=SampEn_r,
                 ApEn_r=ApEn_r,
                 RangeEn_B_r=RangeEn_B_r,
                 RangeEn_A_r=RangeEn_A_r)

        print('r = ' + str(r_span[0, n_r]) + ', elapsed time = ' +
              str(time.time() - t0))

else:
    ##### Load the existing output .npz file
Ejemplo n.º 3
0
                x, y, z = sim_data.Roessler_osc(N_single, t1=0, t2=50)

            # Approximate Entropy
            ApEn_r[n_surr, n_r] = measures.ApEn(x, m_single, r_span[0, n_r])

            # Sample Entropy
            SampEn_r[n_surr, n_r] = measures.SampEn(x, m_single, r_span[0,
                                                                        n_r])

            # RangeEn-A (Modified Approximate Entropy)
            RangeEn_A_r[n_surr,
                        n_r] = measures.RangeEn_A(x, m_single, r_span[0, n_r])

            # RangeEn-B (Modified Sample Entropy)
            RangeEn_B_r[n_surr,
                        n_r] = measures.RangeEn_B(x, m_single, r_span[0, n_r])

        ##### Save the entropy values in an external .npz file
        np.savez(output_filename,
                 SampEn_r=SampEn_r,
                 ApEn_r=ApEn_r,
                 RangeEn_B_r=RangeEn_B_r,
                 RangeEn_A_r=RangeEn_A_r)

        print('Tolerance ' + str(r_span[0, n_r]) + ', elapsed time = ' +
              str(time.time() - t0))

    print('Entire elapsed time = ' + str(time.time() - t00))

else:
    ##### Load the existing output .npz file
Ejemplo n.º 4
0
            elif (sig_type == 'pink_noise'):
                x = sim_data.Pink_noise(N_span[0, n_N])
            elif (sig_type == 'brown_noise'):
                x = sim_data.fBm(int(N_span[0, n_N]), 0.5)

            # Approximate Entropy
            ApEn_N[n_surr, n_N]      = measures.ApEn(x, m_single, r_single)

            # Sample Entropy
            SampEn_N[n_surr, n_N]    = measures.SampEn(x, m_single, r_single)

            # RangeEn-A (Modified Approximate Entropy)
            RangeEn_A_N[n_surr, n_N] = measures.RangeEn_A(x, m_single, r_single)

            # RangeEn-B (Modified Sample Entropy)
            RangeEn_B_N[n_surr, n_N] = measures.RangeEn_B(x, m_single, r_single)

        ##### Save the entropy values in an external .npz file
        np.savez(output_filename, SampEn_N=SampEn_N, ApEn_N=ApEn_N, RangeEn_B_N=RangeEn_B_N, RangeEn_A_N=RangeEn_A_N)

        print('Length ' + str(N_span[0, n_N]) + ', elapsed time = ' + str(time.time()-t0))

    print('Entire elapsed time = ' + str(time.time() - t00))

else:
    ##### Load the existing output .npz file
    out         = np.load(output_filename)
    ApEn_N      = out['ApEn_N']
    SampEn_N    = out['SampEn_N']
    RangeEn_A_N = out['RangeEn_A_N']
    RangeEn_B_N = out['RangeEn_B_N']