コード例 #1
0
def test_eda_plot():

    sampling_rate = 1000
    eda = nk.eda_simulate(duration=30, sampling_rate=sampling_rate,
                          scr_number=6, noise=0, drift=0.01, random_state=42)
    eda_summary, _ =nk.eda_process(eda, sampling_rate=sampling_rate)

    # Plot data over samples.
    nk.eda_plot(eda_summary)
    # This will identify the latest figure.
    fig = plt.gcf()
    assert len(fig.axes) == 3
    titles = ["Raw and Cleaned Signal",
              "Skin Conductance Response (SCR)",
              "Skin Conductance Level (SCL)"]
    for (ax, title) in zip(fig.get_axes(), titles):
        assert ax.get_title() == title
    assert fig.get_axes()[2].get_xlabel() == "Samples"
    np.testing.assert_array_equal(fig.axes[0].get_xticks(),
                                  fig.axes[1].get_xticks(),
                                  fig.axes[2].get_xticks())
    plt.close(fig)

    # Plot data over seconds.
    nk.eda_plot(eda_summary, sampling_rate=sampling_rate)
    # This will identify the latest figure.
    fig = plt.gcf()
    assert fig.get_axes()[2].get_xlabel() == "Seconds"
コード例 #2
0
def load_csv_file():
    file = open( "EDA3.csv", "r")
    reader = csv.reader(file)
    data = []
    i =0
    for line in reader:
        if i!=0:
            value = float(line[0])
            data.append(value) #TODO: se podria usar el promedio (D[i-1] + D[i])/2.0
            data.append(value)
        i+=1

    data_eda = np.array(data)
   
    # Preprocess the data (filter, find peaks, etc.)
    #signals, info = nk.bio_process(eda=data_eda, sampling_rate=f_muestreo)
    signals, info = nk.eda_process(data_eda, sampling_rate=f_muestreo)
    #signals, info = nk.bio_process(ecg=data["ECG"], rsp=data["RSP"], eda=data["EDA"], sampling_rate=100)

    # Compute relevant features
    #results = nk.bio_analyze(signals, sampling_rate=f_muestreo)
    #print(results)
    # Extract clean EDA and SCR features
    cleaned = signals["EDA_Clean"]
    features = [info["SCR_Onsets"], info["SCR_Peaks"], info["SCR_Recovery"]]
    #print(features)
    #print(cleaned[0])
    plt.plot(cleaned)
    plt.ylabel('some numbers')
    plt.show()

    # Visualise the processing
    nk.eda_plot(signals, sampling_rate=f_muestreo)
コード例 #3
0
def generarDataSintetica():
    #generando datos
    # Generate 10 seconds of EDA signal (recorded at 250 samples / second) with 2 SCR peaks
    eda = nk.eda_simulate(duration=20, sampling_rate=250, scr_number=3, drift=0.01)

    # Process
    signals, info = nk.eda_process(eda, sampling_rate=250)

    # Visualise the processing
    nk.eda_plot(signals, sampling_rate=250)
コード例 #4
0
ファイル: README_examples.py プロジェクト: ayushmh/NeuroKit
fig.set_size_inches(10, 6, forward=True)
[ax.legend(loc=1) for ax in plt.gcf().axes]
fig.savefig("README_simulation.png", dpi=300, h_pad=3)

# =============================================================================
# Electrodermal Activity (EDA) processing
# =============================================================================

# Generate 10 seconds of EDA signal (recorded at 250 samples / second) with 2 SCR peaks
eda = nk.eda_simulate(duration=10, sampling_rate=250, scr_number=2, drift=0.1)

# Process it
signals, info = nk.eda_process(eda, sampling_rate=250)

# Visualise the processing
nk.eda_plot(signals, sampling_rate=None)

# Save it
plot = nk.eda_plot(signals, sampling_rate=None)
plot.set_size_inches(10, 6, forward=True)
plot.savefig("README_eda.png", dpi=300, h_pad=3)

# =============================================================================
# Cardiac activity (ECG) processing
# =============================================================================

# Generate 15 seconds of ECG signal (recorded at 250 samples / second)
ecg = nk.ecg_simulate(duration=15,
                      sampling_rate=250,
                      heart_rate=70,
                      random_state=333)