diff --git a/.DS_Store b/.DS_Store index 04bfdd8..5617982 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Coherence_Lab_Part_1.ipynb b/Coherence_Lab_Part_1.ipynb index 646b025..08259ae 100644 --- a/Coherence_Lab_Part_1.ipynb +++ b/Coherence_Lab_Part_1.ipynb @@ -93,8 +93,8 @@ "Yf = np.fft.fft(y - y.mean()) # Compute Fourier transform of y\n", "\n", "# Compute the spectra\n", - "Sxx = \"SOMETHING\" # Spectrum of E1 trials\n", - "Syy = \"SOMETHING\" # ... and E2 trials\n", + "Sxx = \"SOMETHING\" # Spectrum of x\n", + "Syy = \"SOMETHING\" # ... and y\n", "Sxy = \"SOMETHING\" # ... and the cross spectrum\n", "\n", "# Compute the coherence.\n", @@ -124,7 +124,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.18" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/Coherence_Lab_Part_3.ipynb b/Coherence_Lab_Part_3.ipynb index 7c9934d..90e26f6 100644 --- a/Coherence_Lab_Part_3.ipynb +++ b/Coherence_Lab_Part_3.ipynb @@ -374,7 +374,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.18" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/Slides/Coherence_Lecture_2.pdf b/Slides/Coherence_Lecture_2.pdf index 883fe52..5053d1d 100644 Binary files a/Slides/Coherence_Lecture_2.pdf and b/Slides/Coherence_Lecture_2.pdf differ diff --git a/docs/Analyzing_Rhythms_Lab_1.html b/docs/Analyzing_Rhythms_Lab_1.html index 4f6dd8d..fd4f511 100644 --- a/docs/Analyzing_Rhythms_Lab_1.html +++ b/docs/Analyzing_Rhythms_Lab_1.html @@ -2,7 +2,7 @@ - + diff --git a/docs/Analyzing_Rhythms_Lab_2a.html b/docs/Analyzing_Rhythms_Lab_2a.html index 178dc27..40668a4 100644 --- a/docs/Analyzing_Rhythms_Lab_2a.html +++ b/docs/Analyzing_Rhythms_Lab_2a.html @@ -2,7 +2,7 @@ - + diff --git a/docs/Analyzing_Rhythms_Lab_2b.html b/docs/Analyzing_Rhythms_Lab_2b.html index 1a2fc5a..a09c24a 100644 --- a/docs/Analyzing_Rhythms_Lab_2b.html +++ b/docs/Analyzing_Rhythms_Lab_2b.html @@ -2,7 +2,7 @@ - + diff --git a/docs/Analyzing_Rhythms_Lab_3.html b/docs/Analyzing_Rhythms_Lab_3.html index f8b3b9d..17ec556 100644 --- a/docs/Analyzing_Rhythms_Lab_3.html +++ b/docs/Analyzing_Rhythms_Lab_3.html @@ -2,7 +2,7 @@ - + diff --git a/docs/Backpropagation.html b/docs/Backpropagation.html index dfabbeb..26ead0c 100644 --- a/docs/Backpropagation.html +++ b/docs/Backpropagation.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd","options":{"fig-cap":"","warning":"true","out-width":"700px","message":"true","results":"markup","classes":"","fig-width":7,"dpi":72,"out-height":"","comment":"","context":"interactive","output":"true","label":"","autorun":"","read-only":"false","fig-height":5},"id":1},{"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/backpropagation_example_data.csv\")\n\n# Extract the variables from the loaded data\nin_true = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nout_true = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe","options":{"fig-cap":"","warning":"true","out-width":"700px","message":"true","results":"markup","classes":"","fig-width":7,"dpi":72,"out-height":"","comment":"","context":"interactive","output":"true","label":"","autorun":"","read-only":"false","fig-height":5},"id":2},{"code":"print(np.transpose([in_true, out_true]))","options":{"fig-cap":"","warning":"true","out-width":"700px","message":"true","results":"markup","classes":"","fig-width":7,"dpi":72,"out-height":"","comment":"","context":"interactive","output":"true","label":"","autorun":"","read-only":"false","fig-height":5},"id":3},{"code":"def sigmoid(x):\n return 1/(1+np.exp(-x)) # Define the sigmoid anonymous function.\n\ndef feedforward(w, s0): # Define feedforward solution.\n # ... x1 = activity of first neuron,\n # ... s1 = output of first neuron,\n # ... x2 = activity of second neuron,\n # ... s2 = output of second neuron,\n # ... out = output of neural network.\n return out,s1,s2","options":{"fig-cap":"","warning":"true","out-width":"700px","message":"true","results":"markup","classes":"","fig-width":7,"dpi":72,"out-height":"","comment":"","context":"interactive","output":"true","label":"","autorun":"","read-only":"false","fig-height":5},"id":4},{"code":"w = [0.5,0.5] # Choose initial values for the weights.\nalpha = 0.01 # Set the learning constant.\n\nK = np.size(in_true);\nresults = np.zeros([K,3]) # Define a variable to hold the results of each iteration. \n\nfor k in np.arange(K):\n s0 = in_true[k] # Define the input,\n target = out_true[k] # ... and the target output.\n \n #Calculate feedforward solution to get output.\n \n #Update the weights.\n w0 = w[0]; w1 = w[1];\n w[1] = \"SOMETHING\"\n w[0] = \"SOMETHING\"\n \n # Save the results of this step. --------------------------------------\n # Here we save the 3 weights, and the neural network output.\n # results[k,:] = [w[0],w[1], out]\n\n# Plot the NN weights and error during training \n# plt.clf()\n# plt.plot(results[:,1], label='w1')\n# plt.plot(results[:,0], label='w0')\n# plt.plot(results[:,2]-target, label='error')\n# plt.legend() #Include a legend,\n# plt.xlabel('Iteration number'); #... and axis label.\n\n# Print the NN weights\n# print(results[-1,0:2])","options":{"fig-cap":"","warning":"true","out-width":"700px","message":"true","results":"markup","classes":"","fig-width":7,"dpi":72,"out-height":"","comment":"","context":"interactive","output":"true","label":"","autorun":"","read-only":"false","fig-height":5},"id":5}]; +globalThis.qpyodideCellDetails = [{"id":1,"options":{"autorun":"","read-only":"false","fig-width":7,"warning":"true","comment":"","context":"interactive","dpi":72,"label":"","out-width":"700px","message":"true","output":"true","fig-height":5,"classes":"","results":"markup","fig-cap":"","out-height":""},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd"},{"id":2,"options":{"autorun":"","read-only":"false","fig-width":7,"warning":"true","comment":"","context":"interactive","dpi":72,"label":"","out-width":"700px","message":"true","output":"true","fig-height":5,"classes":"","results":"markup","fig-cap":"","out-height":""},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/backpropagation_example_data.csv\")\n\n# Extract the variables from the loaded data\nin_true = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nout_true = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe"},{"id":3,"options":{"autorun":"","read-only":"false","fig-width":7,"warning":"true","comment":"","context":"interactive","dpi":72,"label":"","out-width":"700px","message":"true","output":"true","fig-height":5,"classes":"","results":"markup","fig-cap":"","out-height":""},"code":"print(np.transpose([in_true, out_true]))"},{"id":4,"options":{"autorun":"","read-only":"false","fig-width":7,"warning":"true","comment":"","context":"interactive","dpi":72,"label":"","out-width":"700px","message":"true","output":"true","fig-height":5,"classes":"","results":"markup","fig-cap":"","out-height":""},"code":"def sigmoid(x):\n return 1/(1+np.exp(-x)) # Define the sigmoid anonymous function.\n\ndef feedforward(w, s0): # Define feedforward solution.\n # ... x1 = activity of first neuron,\n # ... s1 = output of first neuron,\n # ... x2 = activity of second neuron,\n # ... s2 = output of second neuron,\n # ... out = output of neural network.\n return out,s1,s2"},{"id":5,"options":{"autorun":"","read-only":"false","fig-width":7,"warning":"true","comment":"","context":"interactive","dpi":72,"label":"","out-width":"700px","message":"true","output":"true","fig-height":5,"classes":"","results":"markup","fig-cap":"","out-height":""},"code":"w = [0.5,0.5] # Choose initial values for the weights.\nalpha = 0.01 # Set the learning constant.\n\nK = np.size(in_true);\nresults = np.zeros([K,3]) # Define a variable to hold the results of each iteration. \n\nfor k in np.arange(K):\n s0 = in_true[k] # Define the input,\n target = out_true[k] # ... and the target output.\n \n #Calculate feedforward solution to get output.\n \n #Update the weights.\n w0 = w[0]; w1 = w[1];\n w[1] = \"SOMETHING\"\n w[0] = \"SOMETHING\"\n \n # Save the results of this step. --------------------------------------\n # Here we save the 3 weights, and the neural network output.\n # results[k,:] = [w[0],w[1], out]\n\n# Plot the NN weights and error during training \n# plt.clf()\n# plt.plot(results[:,1], label='w1')\n# plt.plot(results[:,0], label='w0')\n# plt.plot(results[:,2]-target, label='error')\n# plt.legend() #Include a legend,\n# plt.xlabel('Iteration number'); #... and axis label.\n\n# Print the NN weights\n# print(results[-1,0:2])"}]; diff --git a/docs/Coherence_Lab_Part_1.html b/docs/Coherence_Lab_Part_1.html index d209e0b..ec41b16 100644 --- a/docs/Coherence_Lab_Part_1.html +++ b/docs/Coherence_Lab_Part_1.html @@ -2,7 +2,7 @@ - + @@ -238,8 +238,8 @@

Compute the coherenc Yf = np.fft.fft(y - y.mean()) # Compute Fourier transform of y # Compute the spectra -Sxx = "SOMETHING" # Spectrum of E1 trials -Syy = "SOMETHING" # ... and E2 trials +Sxx = "SOMETHING" # Spectrum of x +Syy = "SOMETHING" # ... and y Sxy = "SOMETHING" # ... and the cross spectrum # Compute the coherence. diff --git a/docs/Coherence_Lab_Part_2.html b/docs/Coherence_Lab_Part_2.html index bfb1397..1b4d599 100644 --- a/docs/Coherence_Lab_Part_2.html +++ b/docs/Coherence_Lab_Part_2.html @@ -2,7 +2,7 @@ - + diff --git a/docs/Coherence_Lab_Part_3.html b/docs/Coherence_Lab_Part_3.html index ea43e86..23e106e 100644 --- a/docs/Coherence_Lab_Part_3.html +++ b/docs/Coherence_Lab_Part_3.html @@ -2,7 +2,7 @@ - + diff --git a/docs/HH.html b/docs/HH.html index 42e0467..a48f812 100644 --- a/docs/HH.html +++ b/docs/HH.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"id":1,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"import numpy as np\nimport matplotlib.pyplot as plt"},{"id":2,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"import requests\nurl = \"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/HH_functions.py\"\nresponse = requests.get(url)\nexec(response.text)"},{"id":3,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"I0 = 0"},{"id":4,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"T0 = 100"},{"id":5,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"[V,m,h,n,t]=HH(I0,T0)"},{"id":6,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"I0 = 10"},{"id":7,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"[V,m,h,n,t] = HH(I0,T0)"},{"id":8,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nplt.plot(t,V,'k')\nplt.xlim([35, 55])\nplt.ylabel('V [mV]')\nplt.show()"},{"id":9,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nplt.plot(t,m,'r', label='m')\nplt.xlim([35, 55])\nplt.show()"},{"id":10,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nplt.plot(t,m,'r', label='m')\nplt.plot(t,h,'b', label='h')\nplt.plot(t,n,'g', label='n')\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]');\nplt.legend();\nplt.show()"},{"id":11,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nax1 = plt.subplot(211); # Define axis for 1st subplot,\nax2 = plt.subplot(212, sharex=ax1); # ... and link axis of 2nd subplot to the 1st.\nax1.plot(t,V,'k') # Plot the voltage in the first subplot,\nplt.xlim([35, 55])\nax2.plot(t,m,'r', label='m') # ... and the gating variables in the other subplot.\nax2.plot(t,h,'b', label='h')\nax2.plot(t,n,'g', label='n')\nplt.xlabel('Time [ms]')\nplt.legend()\nplt.show()"},{"id":12,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nplt.plot(t,V,'k') #Plot the voltage,\nplt.xlim([35, 55])\nplt.ylabel('V [mV]') #... with y-axis labeled.\nplt.show()"},{"id":13,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"gNa0 = 120\n# gNa = ??? #Sodium conductance\ngK0 = 36\n# gK = ??? #Potassium conductance\ngL0 = 0.3\n# gL = ??? #Leak conductance"},{"id":14,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"plt.figure()\nplt.plot(t,gNa,'m', label='gNa')#... and plot the sodium conductance,\nplt.plot(t,gK, 'g', label='gK') #... and plot the potassium conductance,\nplt.plot(t,gL, 'k', label='gL') #... and plot the leak conductance.\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]') #... label the x-axis.\nplt.ylabel('mS/cm^2') #... and label the y-axis.\nplt.legend() #... make a legend.\nplt.show()"},{"id":15,"options":{"context":"interactive","message":"true","out-width":"700px","read-only":"false","results":"markup","warning":"true","label":"","output":"true","dpi":72,"out-height":"","fig-cap":"","classes":"","fig-width":7,"fig-height":5,"autorun":"","comment":""},"code":"gNa0 = 120\nENa = 115\n# INa = ??? Sodium current.\ngK0 = 36\nEK =-12\n# IK = ??? Potassium current.\ngL0 = 0.3\nEL = 10.6;\n# IL = ??? Leak current.\n\nplt.figure()\nplt.plot(t,INa,'m', label='INa') #... and plot the sodium current,\nplt.plot(t,IK, 'g', label='IK') #... and plot the potassium current,\nplt.plot(t,IL, 'k', label='IL') #... and plot the leak current.\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]') #... label the x-axis.\nplt.ylabel('mA/cm^2') #... and label the y-axis.\nplt.legend() #... make a legend.\nplt.show()"}]; +globalThis.qpyodideCellDetails = [{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":1,"code":"import numpy as np\nimport matplotlib.pyplot as plt"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":2,"code":"import requests\nurl = \"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/HH_functions.py\"\nresponse = requests.get(url)\nexec(response.text)"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":3,"code":"I0 = 0"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":4,"code":"T0 = 100"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":5,"code":"[V,m,h,n,t]=HH(I0,T0)"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":6,"code":"I0 = 10"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":7,"code":"[V,m,h,n,t] = HH(I0,T0)"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":8,"code":"plt.figure()\nplt.plot(t,V,'k')\nplt.xlim([35, 55])\nplt.ylabel('V [mV]')\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":9,"code":"plt.figure()\nplt.plot(t,m,'r', label='m')\nplt.xlim([35, 55])\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":10,"code":"plt.figure()\nplt.plot(t,m,'r', label='m')\nplt.plot(t,h,'b', label='h')\nplt.plot(t,n,'g', label='n')\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]');\nplt.legend();\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":11,"code":"plt.figure()\nax1 = plt.subplot(211); # Define axis for 1st subplot,\nax2 = plt.subplot(212, sharex=ax1); # ... and link axis of 2nd subplot to the 1st.\nax1.plot(t,V,'k') # Plot the voltage in the first subplot,\nplt.xlim([35, 55])\nax2.plot(t,m,'r', label='m') # ... and the gating variables in the other subplot.\nax2.plot(t,h,'b', label='h')\nax2.plot(t,n,'g', label='n')\nplt.xlabel('Time [ms]')\nplt.legend()\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":12,"code":"plt.figure()\nplt.plot(t,V,'k') #Plot the voltage,\nplt.xlim([35, 55])\nplt.ylabel('V [mV]') #... with y-axis labeled.\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":13,"code":"gNa0 = 120\n# gNa = ??? #Sodium conductance\ngK0 = 36\n# gK = ??? #Potassium conductance\ngL0 = 0.3\n# gL = ??? #Leak conductance"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":14,"code":"plt.figure()\nplt.plot(t,gNa,'m', label='gNa')#... and plot the sodium conductance,\nplt.plot(t,gK, 'g', label='gK') #... and plot the potassium conductance,\nplt.plot(t,gL, 'k', label='gL') #... and plot the leak conductance.\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]') #... label the x-axis.\nplt.ylabel('mS/cm^2') #... and label the y-axis.\nplt.legend() #... make a legend.\nplt.show()"},{"options":{"warning":"true","message":"true","label":"","fig-cap":"","out-height":"","comment":"","read-only":"false","autorun":"","classes":"","results":"markup","output":"true","context":"interactive","fig-width":7,"fig-height":5,"out-width":"700px","dpi":72},"id":15,"code":"gNa0 = 120\nENa = 115\n# INa = ??? Sodium current.\ngK0 = 36\nEK =-12\n# IK = ??? Potassium current.\ngL0 = 0.3\nEL = 10.6;\n# IL = ??? Leak current.\n\nplt.figure()\nplt.plot(t,INa,'m', label='INa') #... and plot the sodium current,\nplt.plot(t,IK, 'g', label='IK') #... and plot the potassium current,\nplt.plot(t,IL, 'k', label='IL') #... and plot the leak current.\nplt.xlim([35, 55])\nplt.xlabel('Time [ms]') #... label the x-axis.\nplt.ylabel('mA/cm^2') #... and label the y-axis.\nplt.legend() #... make a legend.\nplt.show()"}]; diff --git a/docs/IF.html b/docs/IF.html index bd3c6f0..e9977dd 100644 --- a/docs/IF.html +++ b/docs/IF.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":1,"code":"import numpy as np\nimport matplotlib.pyplot as plt"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":2,"code":"C=1.0\nI=1.0"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":3,"code":"dt=0.01"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":4,"code":"V = np.zeros([1000,1])\nnp.shape(V)"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":5,"code":"V[0]=0.2"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":6,"code":"for k in range(1,999):\n V[k+1] = V[k] + dt*(I/C)"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":7,"code":"plt.figure()\nplt.plot(V)\nplt.show()"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":8,"code":"t = np.arange(0,len(V))*dt"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":9,"code":"plt.figure()\nplt.plot(t,V)\nplt.xlabel('Time [s]')\nplt.ylabel('V')\nplt.show()"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":10,"code":"import numpy as np\nimport matplotlib.pyplot as plt\n\nI = 1 #Set the parameter I.\nC = 1 #Set the parameter C.\ndt = 0.01 #Set the timestep.\nV = np.zeros([1000,1]) #Initialize V.\nV[0]= 0.2; #Set the initial value of V.\n\nfor k in range(1,999): #March forward in time,\n V[k+1] = V[k] + dt*(I/C) #... updating V along the way.\n\nt = np.arange(0,len(V))*dt #Define the time axis.\n\nplt.figure()\nplt.plot(t,V) #Plot the results.\nplt.xlabel('Time [s]')\nplt.ylabel('Voltage [mV]')\nplt.show()"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":11,"code":"Vth = 1; #Define the voltage threshold.\nVreset = 0; #Define the reset voltage.\n\nfor k in range(1,999): #March forward in time,\n V[k+1] = V[k] + dt*(I/C) #Update the voltage,\n ### ADD SOMETHING HERE??? --------------------------"},{"options":{"warning":"true","read-only":"false","label":"","fig-height":5,"comment":"","out-height":"","message":"true","output":"true","dpi":72,"out-width":"700px","results":"markup","classes":"","context":"interactive","autorun":"","fig-width":7,"fig-cap":""},"id":12,"code":"### ADD YOUR CODE!"}]; +globalThis.qpyodideCellDetails = [{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"import numpy as np\nimport matplotlib.pyplot as plt","id":1},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"C=1.0\nI=1.0","id":2},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"dt=0.01","id":3},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"V = np.zeros([1000,1])\nnp.shape(V)","id":4},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"V[0]=0.2","id":5},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"for k in range(1,999):\n V[k+1] = V[k] + dt*(I/C)","id":6},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"plt.figure()\nplt.plot(V)\nplt.show()","id":7},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"t = np.arange(0,len(V))*dt","id":8},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"plt.figure()\nplt.plot(t,V)\nplt.xlabel('Time [s]')\nplt.ylabel('V')\nplt.show()","id":9},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"import numpy as np\nimport matplotlib.pyplot as plt\n\nI = 1 #Set the parameter I.\nC = 1 #Set the parameter C.\ndt = 0.01 #Set the timestep.\nV = np.zeros([1000,1]) #Initialize V.\nV[0]= 0.2; #Set the initial value of V.\n\nfor k in range(1,999): #March forward in time,\n V[k+1] = V[k] + dt*(I/C) #... updating V along the way.\n\nt = np.arange(0,len(V))*dt #Define the time axis.\n\nplt.figure()\nplt.plot(t,V) #Plot the results.\nplt.xlabel('Time [s]')\nplt.ylabel('Voltage [mV]')\nplt.show()","id":10},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"Vth = 1; #Define the voltage threshold.\nVreset = 0; #Define the reset voltage.\n\nfor k in range(1,999): #March forward in time,\n V[k+1] = V[k] + dt*(I/C) #Update the voltage,\n ### ADD SOMETHING HERE??? --------------------------","id":11},{"options":{"dpi":72,"read-only":"false","label":"","output":"true","message":"true","warning":"true","results":"markup","autorun":"","fig-width":7,"fig-cap":"","comment":"","fig-height":5,"classes":"","context":"interactive","out-width":"700px","out-height":""},"code":"### ADD YOUR CODE!","id":12}]; diff --git a/docs/Introduction.html b/docs/Introduction.html index b6a6618..2843859 100644 --- a/docs/Introduction.html +++ b/docs/Introduction.html @@ -2,7 +2,7 @@ - + @@ -262,7 +262,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\ndf = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\nd = np.array(df.iloc[:,0])\nt = np.array(df.iloc[:,1])\n\n# Print useful information about the data.\nprint(\"Sampling frequency is \" + str( 1/(t[2]-t[1])) + ' Hz.')\nprint(\"Total duration of recording is \" + str(t[-1]) + ' s.')\nprint(\"Dimensions of data are \" + str(np.shape(d)) + ' data points.')\n\n# Choose an initial interval of time, from onset to 5 s,\ninitial_time_interval = t < 5 \n\n# ... and plot it.\nplt.plot(t[initial_time_interval], d[initial_time_interval])\nplt.xlabel('Time [s]')\nplt.ylabel('Data')\nplt.title('Initial interval of data');\nplt.show()","id":1},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"4+9","id":2},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"4/3","id":3},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"4/10**2","id":4},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport math","id":5},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"np.sin(2*np.pi)","id":6},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"math.atan(2*np.pi)","id":7},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\na = np.array([[1, 2, 3, 4]])\nprint(a)","id":8},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a = np.array( [[1, 2, 3, 4]] )\nprint( a * 3 )\nprint( 4 * a )\nprint( a + 1 )","id":9},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\na = np.array([1,2,3,4])\na * a","id":10},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\na = 2\nb = np.array( [[0, 4, 7, 6]] )\nc = np.array( [[1, 5, 6, 8]] )\n\nprint( b * c )\nprint( b / c + a)\nprint( np.multiply( b, c ))","id":11},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a = np.array([[1,2,3,4]])\nprint(a.shape)\nprint(np.shape(a))","id":12},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\n\np = np.array( [[1,2,3],[4,5,6]] )","id":13},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( p )","id":14},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( p + 2 )\nprint( 2 * p )\nprint( p * p )","id":15},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\na = np.array( [1, 2, 3, 4, 5] )\nb = np.array( [6, 7, 8, 9, 10] )","id":16},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( \"a[1] = \" + str(a[1]) )\nprint( \"b[1] = \" + str(b[1]) )","id":17},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"c = np.array([a,b])\nprint( \"c = \\n\" + str(c) ) # \\n is a newline, or carriage return, which makes the printed matrix lineup better ","id":18},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( \"shape of c = \" + str( np.shape(c) ) )","id":19},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( \"c[0,3] = \" + str( c[0,3] ) )","id":20},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print( \"c[0,:] = \" + str( c[0,:] ) )\nprint( \"2nd through 4th columns of the first row are c[0,1:4] = \" + str(c[0,1:4]) )","id":21},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print(\"c[0, :4] = \" + str( c[0,:4]))\nprint(\"c[0, 1:] = \" + str( c[0,1:]))","id":22},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"c[0,::2]","id":23},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a = np.arange(1,10) # this creates a vector of increasing values from 1 to 9\na = 2*a \n\nprint( \"a = \" + str(a) )","id":24},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a[a > 10]","id":25},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"lgIdx = a > 10\nlgIdx","id":26},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a[lgIdx]","id":27},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"lgIdx.nonzero()","id":28},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"a[ (a > 10).nonzero() ]","id":29},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print(\"a = \" + str(a))\na[a > 10] = 100\nprint(\"a = \" + str(a))","id":30},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"b = np.array([[1,2,3],[4,5,6],[7,8,9]])\nprint( \"b = \\n\" + str(b) )\nprint( \" b > 5 is \\n\" + str(b > 5) )\nprint(\" b[b>5] is an array: \" + str(b[b>5]) )","id":31},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\n\nx = np.linspace(0,10,11) \nprint( \"x = \" + str(x) )\n\n# The above line constructs a vector that starts at 0, ends at 10, and\n# has 11 entries (takes steps of size 1 from 0 to 10). Let\n\ny = np.sin(x)\nprint( \"y = \" + str(y) )","id":32},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import matplotlib.pyplot as plt\nx = ([1, 2, 3, 4])\ny = x\nplt.figure()\nplt.plot(x,y) \nplt.show() # this is the plotting equivalent of print()","id":33},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"x = np.linspace(0,10,11) \ny = np.sin(x)\n\nplt.figure()\nplt.plot(x, y)\nplt.show()","id":34},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nx = np.linspace(0,10, 101)\nprint(x)","id":35},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"y = np.sin(x)\nplt.figure()\nplt.plot(x,y,'k') # the 'k' we've added makes the curve black instead of blue\nplt.show()","id":36},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nx = np.linspace(0,10, 101)\nz = np.cos(x)","id":37},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import matplotlib.pyplot as plt\nplt.figure()\nplt.plot(x,z)\nplt.show()","id":38},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"y = np.sin(x)\nplt.figure()\nplt.plot(x,z) # plot z vs x.\nplt.plot(x,y,'r') # plot y vs x in red\nplt.show()","id":39},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"plt.figure()\nplt.plot(x,z) # plot z vs x\nplt.plot(x,y,'r') # plot y vs x in red\nplt.xlabel('x') # x-axis label\nplt.ylabel('y or z') # y-axis label\nplt.title('y vs x and z vs x') # title\nplt.legend(('y','z')) # make a legend labeling each line\nplt.show()","id":40},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"plt.figure()\nplt.plot(x,y, label='y') # sometimes it is easier to name a trace within the plot() call\nplt.plot(x,z, label='z') # notice without a color matplotlib will assign one\nplt.xlabel('x', fontsize=14)\nplt.ylabel('y', fontsize=14)\nplt.title('y vs x', fontsize=18)\nplt.legend(fontsize=12)\nplt.show()","id":41},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\n\nprint(\"a Gaussian random number (mean=0, variance=1): \" + str( np.random.randn() ))\n\n# a uniform random number on [0,1)\nprint(\"a uniform random number from [0,1): \" + str(np.random.rand()))","id":42},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"r = np.random.randn(1000)","id":43},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import matplotlib.pyplot as plt\nplt.figure()\nplt.hist(r)\nplt.show()","id":44},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.arange(0,10,0.1) # Define a vector x that ranges from 0 to 9.9 with step 0.1.\nk = 1 # Fix k=1,\ny = np.sin(x + k*np.pi/4) # ... and define y at this k.\n\nplt.figure() # Make a new figure,\nplt.plot(x,y) # ... and plot y versus x.\n\nk = 2 # Let's repeat this, for k=2,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 3 # Let's repeat this, for k=3,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 4 # Let's repeat this, for k=4,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 5 # Let's repeat this, for k=5,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nplt.show()","id":45},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"x = np.arange(0,10,0.1) #First, define the vector x.","id":46},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"plt.figure()\nfor k in range(1,6): \n y = np.sin(x + k*np.pi/4) #Define y (note the variable 'k' in sin), also note we have indented here!\n plt.plot(x,y) #Plot y versus x\n \n# no indentation now, so this code follows the loop\nplt.show()","id":47},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"def my_square_function(x, c):\n \"\"\"Square a vector and add a constant.\n\n Arguments:\n x -- vector to square\n c -- constant to add to the square of x\n \n Returns:\n x*x + c\n \"\"\"\n \n return x * x + c","id":48},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nv = np.linspace(0.,10.,11)\nb = 2.5\n\n# Now let's run the code,\nv2 = my_square_function(v, b)\nprint(\"v = \" + str(v))\nprint(\"v*v+2.5 = \" + str(v2))","id":49},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import pandas as pd","id":50},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\ndf.info()","id":51},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"print(df)","id":52},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nd = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nt = np.array(df.iloc[:,1]) #Get the values associated with the first column of the dataframe","id":53},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import matplotlib.pyplot as plt\n\n# Choose a subset to plot\nt = t[0:500]\nd = d[0:500]\n\nplt.figure()\nplt.plot(t, d)\nplt.title('My plot')\nplt.xlabel('Time [s]')\nplt.ylabel('Voltage [mV]')\nplt.show()","id":54},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt","id":55},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"mu = np.mean(d)\nsd = np.std(d)","id":56},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"samps = np.random.normal(mu, sd, 500)","id":57},{"options":{"dpi":72,"fig-width":7,"label":"","output":"true","fig-cap":"","message":"true","fig-height":5,"context":"interactive","out-width":"700px","warning":"true","comment":"","autorun":"","classes":"","read-only":"false","out-height":"","results":"markup"},"code":"plt.figure()\nplt.hist(samps)\nplt.hist(d)\nplt.show()","id":58}]; +globalThis.qpyodideCellDetails = [{"id":1,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\ndf = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\nd = np.array(df.iloc[:,0])\nt = np.array(df.iloc[:,1])\n\n# Print useful information about the data.\nprint(\"Sampling frequency is \" + str( 1/(t[2]-t[1])) + ' Hz.')\nprint(\"Total duration of recording is \" + str(t[-1]) + ' s.')\nprint(\"Dimensions of data are \" + str(np.shape(d)) + ' data points.')\n\n# Choose an initial interval of time, from onset to 5 s,\ninitial_time_interval = t < 5 \n\n# ... and plot it.\nplt.plot(t[initial_time_interval], d[initial_time_interval])\nplt.xlabel('Time [s]')\nplt.ylabel('Data')\nplt.title('Initial interval of data');\nplt.show()"},{"id":2,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"4+9"},{"id":3,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"4/3"},{"id":4,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"4/10**2"},{"id":5,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport math"},{"id":6,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"np.sin(2*np.pi)"},{"id":7,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"math.atan(2*np.pi)"},{"id":8,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\na = np.array([[1, 2, 3, 4]])\nprint(a)"},{"id":9,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a = np.array( [[1, 2, 3, 4]] )\nprint( a * 3 )\nprint( 4 * a )\nprint( a + 1 )"},{"id":10,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\na = np.array([1,2,3,4])\na * a"},{"id":11,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\na = 2\nb = np.array( [[0, 4, 7, 6]] )\nc = np.array( [[1, 5, 6, 8]] )\n\nprint( b * c )\nprint( b / c + a)\nprint( np.multiply( b, c ))"},{"id":12,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a = np.array([[1,2,3,4]])\nprint(a.shape)\nprint(np.shape(a))"},{"id":13,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\n\np = np.array( [[1,2,3],[4,5,6]] )"},{"id":14,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( p )"},{"id":15,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( p + 2 )\nprint( 2 * p )\nprint( p * p )"},{"id":16,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\na = np.array( [1, 2, 3, 4, 5] )\nb = np.array( [6, 7, 8, 9, 10] )"},{"id":17,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( \"a[1] = \" + str(a[1]) )\nprint( \"b[1] = \" + str(b[1]) )"},{"id":18,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"c = np.array([a,b])\nprint( \"c = \\n\" + str(c) ) # \\n is a newline, or carriage return, which makes the printed matrix lineup better "},{"id":19,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( \"shape of c = \" + str( np.shape(c) ) )"},{"id":20,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( \"c[0,3] = \" + str( c[0,3] ) )"},{"id":21,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print( \"c[0,:] = \" + str( c[0,:] ) )\nprint( \"2nd through 4th columns of the first row are c[0,1:4] = \" + str(c[0,1:4]) )"},{"id":22,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print(\"c[0, :4] = \" + str( c[0,:4]))\nprint(\"c[0, 1:] = \" + str( c[0,1:]))"},{"id":23,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"c[0,::2]"},{"id":24,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a = np.arange(1,10) # this creates a vector of increasing values from 1 to 9\na = 2*a \n\nprint( \"a = \" + str(a) )"},{"id":25,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a[a > 10]"},{"id":26,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"lgIdx = a > 10\nlgIdx"},{"id":27,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a[lgIdx]"},{"id":28,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"lgIdx.nonzero()"},{"id":29,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"a[ (a > 10).nonzero() ]"},{"id":30,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print(\"a = \" + str(a))\na[a > 10] = 100\nprint(\"a = \" + str(a))"},{"id":31,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"b = np.array([[1,2,3],[4,5,6],[7,8,9]])\nprint( \"b = \\n\" + str(b) )\nprint( \" b > 5 is \\n\" + str(b > 5) )\nprint(\" b[b>5] is an array: \" + str(b[b>5]) )"},{"id":32,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\n\nx = np.linspace(0,10,11) \nprint( \"x = \" + str(x) )\n\n# The above line constructs a vector that starts at 0, ends at 10, and\n# has 11 entries (takes steps of size 1 from 0 to 10). Let\n\ny = np.sin(x)\nprint( \"y = \" + str(y) )"},{"id":33,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import matplotlib.pyplot as plt\nx = ([1, 2, 3, 4])\ny = x\nplt.figure()\nplt.plot(x,y) \nplt.show() # this is the plotting equivalent of print()"},{"id":34,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"x = np.linspace(0,10,11) \ny = np.sin(x)\n\nplt.figure()\nplt.plot(x, y)\nplt.show()"},{"id":35,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nx = np.linspace(0,10, 101)\nprint(x)"},{"id":36,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"y = np.sin(x)\nplt.figure()\nplt.plot(x,y,'k') # the 'k' we've added makes the curve black instead of blue\nplt.show()"},{"id":37,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nx = np.linspace(0,10, 101)\nz = np.cos(x)"},{"id":38,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import matplotlib.pyplot as plt\nplt.figure()\nplt.plot(x,z)\nplt.show()"},{"id":39,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"y = np.sin(x)\nplt.figure()\nplt.plot(x,z) # plot z vs x.\nplt.plot(x,y,'r') # plot y vs x in red\nplt.show()"},{"id":40,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"plt.figure()\nplt.plot(x,z) # plot z vs x\nplt.plot(x,y,'r') # plot y vs x in red\nplt.xlabel('x') # x-axis label\nplt.ylabel('y or z') # y-axis label\nplt.title('y vs x and z vs x') # title\nplt.legend(('y','z')) # make a legend labeling each line\nplt.show()"},{"id":41,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"plt.figure()\nplt.plot(x,y, label='y') # sometimes it is easier to name a trace within the plot() call\nplt.plot(x,z, label='z') # notice without a color matplotlib will assign one\nplt.xlabel('x', fontsize=14)\nplt.ylabel('y', fontsize=14)\nplt.title('y vs x', fontsize=18)\nplt.legend(fontsize=12)\nplt.show()"},{"id":42,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\n\nprint(\"a Gaussian random number (mean=0, variance=1): \" + str( np.random.randn() ))\n\n# a uniform random number on [0,1)\nprint(\"a uniform random number from [0,1): \" + str(np.random.rand()))"},{"id":43,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"r = np.random.randn(1000)"},{"id":44,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import matplotlib.pyplot as plt\nplt.figure()\nplt.hist(r)\nplt.show()"},{"id":45,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.arange(0,10,0.1) # Define a vector x that ranges from 0 to 9.9 with step 0.1.\nk = 1 # Fix k=1,\ny = np.sin(x + k*np.pi/4) # ... and define y at this k.\n\nplt.figure() # Make a new figure,\nplt.plot(x,y) # ... and plot y versus x.\n\nk = 2 # Let's repeat this, for k=2,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 3 # Let's repeat this, for k=3,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 4 # Let's repeat this, for k=4,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nk = 5 # Let's repeat this, for k=5,\ny = np.sin(x + k*np.pi/4) # ... and redefine y at this k,\nplt.plot(x,y) # ... and plot it.\n\nplt.show()"},{"id":46,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"x = np.arange(0,10,0.1) #First, define the vector x."},{"id":47,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"plt.figure()\nfor k in range(1,6): \n y = np.sin(x + k*np.pi/4) #Define y (note the variable 'k' in sin), also note we have indented here!\n plt.plot(x,y) #Plot y versus x\n \n# no indentation now, so this code follows the loop\nplt.show()"},{"id":48,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"def my_square_function(x, c):\n \"\"\"Square a vector and add a constant.\n\n Arguments:\n x -- vector to square\n c -- constant to add to the square of x\n \n Returns:\n x*x + c\n \"\"\"\n \n return x * x + c"},{"id":49,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nv = np.linspace(0.,10.,11)\nb = 2.5\n\n# Now let's run the code,\nv2 = my_square_function(v, b)\nprint(\"v = \" + str(v))\nprint(\"v*v+2.5 = \" + str(v2))"},{"id":50,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import pandas as pd"},{"id":51,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\ndf.info()"},{"id":52,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"print(df)"},{"id":53,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nd = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nt = np.array(df.iloc[:,1]) #Get the values associated with the first column of the dataframe"},{"id":54,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import matplotlib.pyplot as plt\n\n# Choose a subset to plot\nt = t[0:500]\nd = d[0:500]\n\nplt.figure()\nplt.plot(t, d)\nplt.title('My plot')\nplt.xlabel('Time [s]')\nplt.ylabel('Voltage [mV]')\nplt.show()"},{"id":55,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt"},{"id":56,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"mu = np.mean(d)\nsd = np.std(d)"},{"id":57,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"samps = np.random.normal(mu, sd, 500)"},{"id":58,"options":{"warning":"true","context":"interactive","results":"markup","message":"true","read-only":"false","fig-height":5,"label":"","comment":"","autorun":"","out-height":"","fig-cap":"","classes":"","out-width":"700px","output":"true","fig-width":7,"dpi":72},"code":"plt.figure()\nplt.hist(samps)\nplt.hist(d)\nplt.show()"}]; diff --git a/docs/Perceptron.html b/docs/Perceptron.html index 34ff55b..2939fda 100644 --- a/docs/Perceptron.html +++ b/docs/Perceptron.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"id":1,"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport time","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":2,"code":"def my_perceptron(input1, input2, w1, w2, theta):\n print(\"Do something!\")\n # Define the activity of the perceptron, x. \n # Apply a binary threshold.","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":3,"code":"my_perceptron(1,0,0.5,-0.5,0)","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":4,"code":"def known_answer(slope, intercept, x, y):\n print(\"Do something!\")\n #Determine yline\n #Determine if y is above yline","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":5,"code":"x,y = 0.7,3\nslope = 2\nintercept = 1\ncorrect_answer = known_answer(slope, intercept, x, y)\nprint(correct_answer)","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":6,"code":"def feedforward(x, y, wx, wy, wb):\n print(\"Do something!\")\n # Fix the bias.\n # Define the activity of the neuron, activity.\n # Apply the binary threshold.","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":7,"code":"x,y = 0.7,3\nwx,wy,wb = 3*[0.5]\nperceptron_guess = feedforward(x, y, wx, wy, wb)\nprint(perceptron_guess)","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":8,"code":"error = 'SOMETHING?'\nprint(error)","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":9,"code":"learning_constant = 0.01","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":10,"code":"wx = \"SOMETHING\"\nwy = \"SOMETHING\"\nwb = \"SOMETHING\"\nprint(wx)","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}},{"id":11,"code":"slope = 2; # Define the line with slope, \nintercept = 1; # ... and intercept.\n\nwx,wy,wb = 3*[0.5]; # Choose initial values for the perceptron's weights\n\nlearning_constant = 0.01; # And, set the learning constant.\n\nestimated_slope = np.zeros(2000) # Variables to hold the perceptron estimates.\nestimated_intercept = np.zeros(2000)\n\nfor k in np.arange(2000): # For 2000 iteractions,\n x = np.random.randn(1); # Choose a random (x,y) point in the plane\n y = np.random.randn(1);\n # Step 1: Calculate known answer.\n \n # Step 2. Ask perceptron to guess an answer.\n \n # Step 3. Compute the error.\n \n # Step 4. Adjust weights according to error.\n \n estimated_slope[k] = -wx/wy; # Compute estimated slope from perceptron.\n estimated_intercept[k] = -wb/wy;# Compute estimated intercept from perceptron.\n\n# Display the results! ------------------------------------------------------------------------\nx_range = np.linspace(-2,2,100); # For a range of x-values,\nfig, ax = plt.subplots()\nax.plot(x_range, slope*x_range+intercept, 'k') # ... plot the true line,\n\nfor k in range(1,2000,100): # ... and plot some intermediate perceptron guess\n ax.plot(x_range, estimated_slope[k]*x_range+estimated_intercept[k], 'r', alpha=0.25)\n # ... and plot the last perceptron guess\nplt.xlabel('x')\nplt.title('Known answer (black), Perceptron final guess (blue)')\nplt.show()","options":{"out-height":"","warning":"true","fig-width":7,"context":"interactive","label":"","output":"true","message":"true","dpi":72,"read-only":"false","comment":"","out-width":"700px","autorun":"","results":"markup","fig-height":5,"classes":"","fig-cap":""}}]; +globalThis.qpyodideCellDetails = [{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"import numpy as np\nimport matplotlib.pyplot as plt\nimport time","id":1},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"def my_perceptron(input1, input2, w1, w2, theta):\n print(\"Do something!\")\n # Define the activity of the perceptron, x. \n # Apply a binary threshold.","id":2},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"my_perceptron(1,0,0.5,-0.5,0)","id":3},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"def known_answer(slope, intercept, x, y):\n print(\"Do something!\")\n #Determine yline\n #Determine if y is above yline","id":4},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"x,y = 0.7,3\nslope = 2\nintercept = 1\ncorrect_answer = known_answer(slope, intercept, x, y)\nprint(correct_answer)","id":5},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"def feedforward(x, y, wx, wy, wb):\n print(\"Do something!\")\n # Fix the bias.\n # Define the activity of the neuron, activity.\n # Apply the binary threshold.","id":6},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"x,y = 0.7,3\nwx,wy,wb = 3*[0.5]\nperceptron_guess = feedforward(x, y, wx, wy, wb)\nprint(perceptron_guess)","id":7},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"error = 'SOMETHING?'\nprint(error)","id":8},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"learning_constant = 0.01","id":9},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"wx = \"SOMETHING\"\nwy = \"SOMETHING\"\nwb = \"SOMETHING\"\nprint(wx)","id":10},{"options":{"label":"","comment":"","out-width":"700px","results":"markup","read-only":"false","fig-cap":"","message":"true","context":"interactive","warning":"true","dpi":72,"autorun":"","output":"true","out-height":"","fig-width":7,"fig-height":5,"classes":""},"code":"slope = 2; # Define the line with slope, \nintercept = 1; # ... and intercept.\n\nwx,wy,wb = 3*[0.5]; # Choose initial values for the perceptron's weights\n\nlearning_constant = 0.01; # And, set the learning constant.\n\nestimated_slope = np.zeros(2000) # Variables to hold the perceptron estimates.\nestimated_intercept = np.zeros(2000)\n\nfor k in np.arange(2000): # For 2000 iteractions,\n x = np.random.randn(1); # Choose a random (x,y) point in the plane\n y = np.random.randn(1);\n # Step 1: Calculate known answer.\n \n # Step 2. Ask perceptron to guess an answer.\n \n # Step 3. Compute the error.\n \n # Step 4. Adjust weights according to error.\n \n estimated_slope[k] = -wx/wy; # Compute estimated slope from perceptron.\n estimated_intercept[k] = -wb/wy;# Compute estimated intercept from perceptron.\n\n# Display the results! ------------------------------------------------------------------------\nx_range = np.linspace(-2,2,100); # For a range of x-values,\nfig, ax = plt.subplots()\nax.plot(x_range, slope*x_range+intercept, 'k') # ... plot the true line,\n\nfor k in range(1,2000,100): # ... and plot some intermediate perceptron guess\n ax.plot(x_range, estimated_slope[k]*x_range+estimated_intercept[k], 'r', alpha=0.25)\n # ... and plot the last perceptron guess\nplt.xlabel('x')\nplt.title('Known answer (black), Perceptron final guess (blue)')\nplt.show()","id":11}]; diff --git a/docs/Readings/Lepage_Neural_Comp_2011.pdf b/docs/Readings/Lepage_Neural_Comp_2011.pdf new file mode 100644 index 0000000..bc2f849 Binary files /dev/null and b/docs/Readings/Lepage_Neural_Comp_2011.pdf differ diff --git a/docs/Regression.html b/docs/Regression.html index 7854948..0c54e88 100644 --- a/docs/Regression.html +++ b/docs/Regression.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"code":"# Load modules\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom scipy.stats import pearsonr\nimport statsmodels.api as sm","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":1},{"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/regression_example_data.csv\")\n\n# Extract the variables from the loaded data\ntask_performance = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nfiring_rate = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":2},{"code":"# Plot it ...\nplt.figure()\nplt.plot(firing_rate, task_performance, '.')\nplt.xlabel('Firing rate [Hz]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":3},{"code":"N = np.size(firing_rate)\nx = firing_rate - np.mean(firing_rate)\ny = task_performance - np.mean(task_performance)\nsigma_x = 'SOMETHING' #Standard deviation of x\nsigma_y = 'SOMETHING' #Standard deviation of y\n\ncorrelation = 'SOMETHING'\nprint(correlation)","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":4},{"code":"from statsmodels.formula.api import ols\n\ndata = {\"x\": firing_rate, \"y\": task_performance}\n\nres1 = ols(\"y ~1 + x\", data=data).fit()\nres1.summary()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":5},{"code":"# Get model prediction.\nfitted_values = res1.fittedvalues\n\n# Sort x values for better plotting of the regression line\nx_sorted = np.sort(firing_rate)\nfitted_sorted = np.sort(fitted_values)\n\n# Plot the regression line (fitted model)\nplt.figure()\nplt.scatter(firing_rate,task_performance)\nplt.plot(x_sorted, fitted_sorted, label=\"Fitted Model\", color=\"red\")\n\nplt.xlabel('Firing rate [Hz]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":6},{"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/regression_example_data.csv\")\n\n# Extract the variables from the loaded data\ntask_performance = np.array(df.iloc[:,0])\nfiring_rate = np.array(df.iloc[:,1])\nage = np.array(df.iloc[:,2])","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":7},{"code":"# Plot it ...\nplt.figure()\nplt.plot(age, task_performance, '.')\nplt.xlabel('Age [months]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":8},{"code":"# Compute the correlation between task performance and age","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":9},{"code":"fig = plt.figure(figsize=(12, 12))\nax = fig.add_subplot(projection='3d')\nax.scatter(age, firing_rate, task_performance)\nax.set_xlabel('Age [months]')\nax.set_ylabel('Firing Rate [Hz]')\nax.set_zlabel('Task Performance');\nplt.show()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":10},{"code":"from statsmodels.formula.api import ols\ndata = {\"firing_rate\": firing_rate, \"age\": age, \"y\": task_performance}\n# Write the model and print out the summary","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":11},{"code":"# Plot the mean model fit.\n\n# First, plot the data.\nfig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(projection='3d')\nax.set_xlabel('Age [months]')\nax.set_ylabel('Firing Rate [Hz]')\nax.set_zlabel('Task Performance')\nax.scatter(age, firing_rate, task_performance)\n\n# Then, define model parameter estimates.\n# REPLACE THESE VALUES WITH YOUR PARAMETER ESTIMATES\nalpha = 1\nbeta_1 = 1\nbeta_2 = 1\n\n# Finally, plot the model fit.\nx = np.arange(8, 12, 0.1) # Firing rate\ny = np.arange(10,20, 0.1) # Age\nxx, yy = np.meshgrid(x, y) # Two dim coordinates\nzz = alpha + beta_1*xx + beta_2*yy # Model predictions\nax.plot_surface(yy,xx,zz);\nplt.show()","options":{"output":"true","warning":"true","results":"markup","out-width":"700px","fig-width":7,"fig-cap":"","label":"","message":"true","fig-height":5,"comment":"","autorun":"","classes":"","dpi":72,"read-only":"false","out-height":"","context":"interactive"},"id":12}]; +globalThis.qpyodideCellDetails = [{"id":1,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Load modules\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom scipy.stats import pearsonr\nimport statsmodels.api as sm"},{"id":2,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/regression_example_data.csv\")\n\n# Extract the variables from the loaded data\ntask_performance = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nfiring_rate = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe"},{"id":3,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Plot it ...\nplt.figure()\nplt.plot(firing_rate, task_performance, '.')\nplt.xlabel('Firing rate [Hz]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()"},{"id":4,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"N = np.size(firing_rate)\nx = firing_rate - np.mean(firing_rate)\ny = task_performance - np.mean(task_performance)\nsigma_x = 'SOMETHING' #Standard deviation of x\nsigma_y = 'SOMETHING' #Standard deviation of y\n\ncorrelation = 'SOMETHING'\nprint(correlation)"},{"id":5,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"from statsmodels.formula.api import ols\n\ndata = {\"x\": firing_rate, \"y\": task_performance}\n\nres1 = ols(\"y ~1 + x\", data=data).fit()\nres1.summary()"},{"id":6,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Get model prediction.\nfitted_values = res1.fittedvalues\n\n# Sort x values for better plotting of the regression line\nx_sorted = np.sort(firing_rate)\nfitted_sorted = np.sort(fitted_values)\n\n# Plot the regression line (fitted model)\nplt.figure()\nplt.scatter(firing_rate,task_performance)\nplt.plot(x_sorted, fitted_sorted, label=\"Fitted Model\", color=\"red\")\n\nplt.xlabel('Firing rate [Hz]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()"},{"id":7,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/regression_example_data.csv\")\n\n# Extract the variables from the loaded data\ntask_performance = np.array(df.iloc[:,0])\nfiring_rate = np.array(df.iloc[:,1])\nage = np.array(df.iloc[:,2])"},{"id":8,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Plot it ...\nplt.figure()\nplt.plot(age, task_performance, '.')\nplt.xlabel('Age [months]')\nplt.ylabel('Task Performance [a.u.]')\nplt.show()"},{"id":9,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Compute the correlation between task performance and age"},{"id":10,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"fig = plt.figure(figsize=(12, 12))\nax = fig.add_subplot(projection='3d')\nax.scatter(age, firing_rate, task_performance)\nax.set_xlabel('Age [months]')\nax.set_ylabel('Firing Rate [Hz]')\nax.set_zlabel('Task Performance');\nplt.show()"},{"id":11,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"from statsmodels.formula.api import ols\ndata = {\"firing_rate\": firing_rate, \"age\": age, \"y\": task_performance}\n# Write the model and print out the summary"},{"id":12,"options":{"read-only":"false","context":"interactive","fig-cap":"","results":"markup","fig-width":7,"comment":"","label":"","warning":"true","fig-height":5,"out-height":"","classes":"","out-width":"700px","message":"true","autorun":"","output":"true","dpi":72},"code":"# Plot the mean model fit.\n\n# First, plot the data.\nfig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(projection='3d')\nax.set_xlabel('Age [months]')\nax.set_ylabel('Firing Rate [Hz]')\nax.set_zlabel('Task Performance')\nax.scatter(age, firing_rate, task_performance)\n\n# Then, define model parameter estimates.\n# REPLACE THESE VALUES WITH YOUR PARAMETER ESTIMATES\nalpha = 1\nbeta_1 = 1\nbeta_2 = 1\n\n# Finally, plot the model fit.\nx = np.arange(8, 12, 0.1) # Firing rate\ny = np.arange(10,20, 0.1) # Age\nxx, yy = np.meshgrid(x, y) # Two dim coordinates\nzz = alpha + beta_1*xx + beta_2*yy # Model predictions\nax.plot_surface(yy,xx,zz);\nplt.show()"}]; diff --git a/docs/Rhythms_1.html b/docs/Rhythms_1.html index f0c79d1..8c3856f 100644 --- a/docs/Rhythms_1.html +++ b/docs/Rhythms_1.html @@ -2,7 +2,7 @@ - + @@ -228,7 +228,7 @@ } // Store cell data -globalThis.qpyodideCellDetails = [{"id":1,"code":"# Load modules\nimport scipy.io as sio\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt","options":{"out-width":"700px","output":"true","read-only":"false","out-height":"","fig-height":5,"message":"true","fig-width":7,"results":"markup","label":"","warning":"true","fig-cap":"","classes":"","dpi":72,"autorun":"","context":"interactive","comment":""}},{"id":2,"code":"t = np.arange(0, 2, 0.001)","options":{"out-width":"700px","output":"true","read-only":"false","out-height":"","fig-height":5,"message":"true","fig-width":7,"results":"markup","label":"","warning":"true","fig-cap":"","classes":"","dpi":72,"autorun":"","context":"interactive","comment":""}},{"id":3,"code":"x = np.sin(2*np.pi*t)","options":{"out-width":"700px","output":"true","read-only":"false","out-height":"","fig-height":5,"message":"true","fig-width":7,"results":"markup","label":"","warning":"true","fig-cap":"","classes":"","dpi":72,"autorun":"","context":"interactive","comment":""}},{"id":4,"code":"f1 = 10;\nx1 = np.cos(2*np.pi*t*f1);\n\nf2 = 2;\nx2 = np.cos(2*np.pi*t*f2);","options":{"out-width":"700px","output":"true","read-only":"false","out-height":"","fig-height":5,"message":"true","fig-width":7,"results":"markup","label":"","warning":"true","fig-cap":"","classes":"","dpi":72,"autorun":"","context":"interactive","comment":""}},{"id":5,"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\n\n# Extract the variables from the loaded data\ndata = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nt = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe","options":{"out-width":"700px","output":"true","read-only":"false","out-height":"","fig-height":5,"message":"true","fig-width":7,"results":"markup","label":"","warning":"true","fig-cap":"","classes":"","dpi":72,"autorun":"","context":"interactive","comment":""}}]; +globalThis.qpyodideCellDetails = [{"id":1,"options":{"fig-width":7,"comment":"","classes":"","message":"true","read-only":"false","autorun":"","context":"interactive","fig-cap":"","out-width":"700px","dpi":72,"warning":"true","output":"true","out-height":"","results":"markup","fig-height":5,"label":""},"code":"# Load modules\nimport scipy.io as sio\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt"},{"id":2,"options":{"fig-width":7,"comment":"","classes":"","message":"true","read-only":"false","autorun":"","context":"interactive","fig-cap":"","out-width":"700px","dpi":72,"warning":"true","output":"true","out-height":"","results":"markup","fig-height":5,"label":""},"code":"t = np.arange(0, 2, 0.001)"},{"id":3,"options":{"fig-width":7,"comment":"","classes":"","message":"true","read-only":"false","autorun":"","context":"interactive","fig-cap":"","out-width":"700px","dpi":72,"warning":"true","output":"true","out-height":"","results":"markup","fig-height":5,"label":""},"code":"x = np.sin(2*np.pi*t)"},{"id":4,"options":{"fig-width":7,"comment":"","classes":"","message":"true","read-only":"false","autorun":"","context":"interactive","fig-cap":"","out-width":"700px","dpi":72,"warning":"true","output":"true","out-height":"","results":"markup","fig-height":5,"label":""},"code":"f1 = 10;\nx1 = np.cos(2*np.pi*t*f1);\n\nf2 = 2;\nx2 = np.cos(2*np.pi*t*f2);"},{"id":5,"options":{"fig-width":7,"comment":"","classes":"","message":"true","read-only":"false","autorun":"","context":"interactive","fig-cap":"","out-width":"700px","dpi":72,"warning":"true","output":"true","out-height":"","results":"markup","fig-height":5,"label":""},"code":"df = pd.read_csv(\"https://raw.githubusercontent.com/Mark-Kramer/BU-MA665-MA666/master/Data/Rhythms_1.csv\")\n\n# Extract the variables from the loaded data\ndata = np.array(df.iloc[:,0]) #Get the values associated with the first column of the dataframe\nt = np.array(df.iloc[:,1]) #Get the values associated with the second column of the dataframe"}]; diff --git a/docs/index.html b/docs/index.html index 0eb0a4f..0c0eee5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - + @@ -277,6 +277,7 @@

Coherence

  • Read: Fries, A mechanism for cognitive dynamics: neuronal communication through neuronal coherence, TINS, 2005
  • Extra Read: Chapter 25 @ M. X. Cohen, Analyzing neural time series data, 2014.
  • Extra Read: Chapter 26 @ M. X. Cohen, Analyzing neural time series data, 2014.
  • +
  • Advanced Read: Lepage et al, The Dependence of Spike Field Coherence on Expected Intensity, 2011.
  • Lecture 1 Slides
  • Lecture Code 1: Coherence Lab 1
  • Lecture Code 2: Coherence Lab 2
  • diff --git a/docs/search.json b/docs/search.json index 12772c8..3f39668 100644 --- a/docs/search.json +++ b/docs/search.json @@ -130,21 +130,21 @@ "href": "Dont-Sync-2024/8. Analyzing Rhythms/Untitled.html", "title": "Make noise signal", "section": "", - "text": "from scipy.io import loadmat\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.signal import spectrogram\n\n\ndata = loadmat('EEG-1.mat') # Load the EEG data\n# Data available here\n# https://github.com/Mark-Kramer/BU-MA665-MA666/tree/master/Data\n#\nEEG = data['EEG'].reshape(-1) # Extract the EEG variable\nt = data['t'][0] # ... and the t variablea\n\n\nplt.plot(t,EEG)\nplt.xlabel('Time [s]')\nplt.ylabel('EEG');\n\n\n#dt = t[-1]/len(t)\ndt = t[2]-t[1]\nprint(dt)\n\n\nf0 = 1/dt\nprint(f0)\n\n\nN = len(t)\nprint(N)\n\n\nT = N*dt\nprint(T)\n\n\n# Q. What is the Nyquist frequency and frequency resolution?\nfNQ = f0/2\ndf = 1/T\n\n# Q. What is the frequency axis?\nfj = np.arange(0,fNQ,df)\n\n# Then, compute the Fourier transform \"by hand\".\nx = EEG\nX = np.ndarray(np.size(fj), complex);\nfor j in range( np.size(fj) ):\n X[j] = np.sum(x * np.exp(-2*np.pi*1j*fj[j]*t) )\n\n# And the spectrum,\nSxx = 2*dt**2/T * (X * np.conjugate(X))\n\n# Plot it,\nplt.plot(fj, Sxx.real)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [mV^2/Hz]');\n\n\nx = EEG\nX = np.fft.fft(x) # Compute Fourier transform of x\nSxx = 2*dt**2/T * (X * np.conjugate(X)) # Compute spectrum\nSxx = Sxx[0:int(N / 2)].real # Ignore negative frequencies\n\n\n# Plot it,\nplt.plot(fj, Sxx)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [mV^2/Hz]');\n\n\ndf = 1/T # Determine frequency resolution\nfNQ = f0/2 # Determine Nyquist frequency\nfaxis = np.arange(0,fNQ,df) # Construct frequency axis\n\n\nplt.plot(faxis, Sxx)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [$\\mu V^2$/Hz]');\n\n\nplt.figure()\nplt.plot(faxis, 10*np.log10(Sxx)) # Plot the spectrum in decibels.\n#plt.xlim([0, 100]) # Select the frequency range.\nplt.ylim([-60, 0]) # Select the decibel range.\nplt.xlabel('Frequency [Hz]') # Label the axes.\nplt.ylabel('Power [dB]');\n\n\nplt.figure()\nplt.plot(faxis, Sxx) # Plot the spectrum in decibels.\n#plt.xlim([df, 100]) # Select frequency range\nplt.ylim([10**-7, 0]) # ... and the decibel range.\nplt.xlabel('Frequency [Hz]') # Label the axes.\nplt.ylabel('Power [dB]');\n\n\nx_tapered = np.hanning(N) * x\nplt.figure()\nplt.plot(t,x)\nplt.plot(t,x_tapered);\n\n\nxf_tapered = np.fft.fft(x_tapered) # Compute Fourier transform of x.\nSxx_tapered = 2*dt**2/T*(xf_tapered*np.conj(xf_tapered)) # Compute the spectrum,\nSxx_tapered = np.real(Sxx_tapered[:int(N / 2)]) # ... and ignore negative frequencies.\n\nplt.figure()\nplt.semilogx(faxis,10*np.log10(Sxx)) # Plot spectrum of untapered signal. \nplt.semilogx(faxis,10*np.log10(Sxx_tapered)) # Plot spectrum vs tapered signal.\nplt.xlim([faxis[1], 100]) # Select frequency range,\nplt.ylim([-70, 20]) # ... and the power range.\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [$\\mu V^2$/Hz]')\n\n\n# Plot the spectrogram.\n\nFs = 1 / dt # Define the sampling frequency,\ninterval = int(Fs) # ... the interval size,\noverlap = int(Fs * 0.95) # ... and the overlap intervals\n\n # Compute the spectrogram\nf0, t0, Sxx0 = spectrogram(\n EEG, # Provide the signal,\n fs=Fs, # ... the sampling frequency,\n nperseg=interval, # ... the length of a segment,\n noverlap=overlap) # ... the number of samples to overlap,\nplt.pcolormesh(t0, f0, 10 * np.log10(Sxx0),\n cmap='jet')# Plot the result\nplt.colorbar() # ... with a color bar,\nplt.ylim([0, 70]) # ... set the frequency range,\nplt.xlabel('Time [s]') # ... and label the axes\nplt.ylabel('Frequency [Hz]');\n\n\nN = 1000;\ndt= 0.001;\nT = N*dt;\nx = np.random.randn(N)\nt = np.arange(0,N)*dt\n\n#plt.plot(t,x)\n#plt.xlabel('Time [s]');\n\n\nlags = np.arange(-N+1,N)\nac_xx = np.zeros(np.size(lags))\nfor index,L in enumerate(lags):\n if L>= 0:\n ac_xx[index] = 1/N*np.sum( x[L:N]*x[0:N-L] )\n else:\n ac_xx[index] = 1/N*np.sum( x[0:N+L]*x[-L:N] )\nplt.plot(lags, ac_xx) # ... and plot the result.\nplt.xlabel('Lag')\nplt.ylabel('Autocovariance');\n\n\nac_xx = 1/N*np.correlate(x,x,'full')\nplt.plot(lags, ac_xx)\n\n\n# Load modules we'll need.\nfrom scipy.io import loadmat\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.signal import spectrogram\n\n\n# Load the data.\ndata = loadmat('AC_Example.mat') # Load the data,\n# Data available here\n# https://github.com/Mark-Kramer/BU-MA665-MA666/tree/master/Data\n#\nd = data['d'][0] # ... from the first electrode.\nt = data['t'][0] # Load the time axis\nN = np.size(d,0) # Store number of observations.\ndt = t[1]-t[0] # Store sampling interval.\n\n\nplt.plot(t,d)\n\n\nT = t[-1]\ndf = 1/T\nf0 = 1/dt\nfNQ= f0/2\nfaxis = np.arange(0, fNQ, df)\n\nX = np.fft.fft(d - np.mean(d))\nS = 2*dt**2/T * (np.conj(X)*X)\nS = S[0:int(N/2)]\n\nplt.plot(faxis, S)\nplt.xlabel('Freq [Hz]')\n\n\nac = 1/N*np.correlate(d,d, 'full')\nlags = np.arange(-N+1,N)\nplt.plot(lags, ac);\n\n\ndt = 0.001\nN = 1000\nt = np.arange(0,N)*dt\nd = 1*np.sin(2*np.pi*10.25*t) + 0.1*np.random.randn(N)\nplt.plot(t,d)\n\n\nrxx = [];\nlags = np.arange(-int(N/2),int(N/2));\nfor idx,L in enumerate(lags):\n rxx = np.append(rxx, 1/N*np.sum(np.roll(d,L) * d))\nplt.plot(lags, rxx)\nplt.xlabel('Lags [indices]');\nplt.ylabel('Autocovariance rxx');\n\n\n# Compute the spectrum from the FT{rxx}\nSxx_via_rxx = 2*dt*np.fft.fft(rxx)\n\n# Compute the spectrum from the data.\nT = t[-1];\nxf = np.fft.fft(d);\nSxx = 2 * dt ** 2 / T * (xf * xf.conj()) \n\nplt.plot(10*np.log10(Sxx))\nplt.plot(10*np.log10(Sxx_via_rxx), 'o')\nplt.xlabel('Freq Index')\nplt.legend({'Direct Sxx', 'Sxx via rxx'})\nplt.xlim([0,150]);\n\n\n# Load modules we'll need.\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\nN = 5000; # Number of bins. \ndt = 0.001; # Duration of each bin [s].\nT = N*dt; # Total time of observation [s].\ntm = np.arange(0,N)*dt; # Time axis for plotting\n\nlambda0 = 5 # Average firing rate [Hz]\np0 = lambda0*dt; # Probability of a spike in a time bin\ndn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\n\nplt.plot(tm, dn) # Plot it.\nplt.xlabel('Time [s]');\n\n\n\n\n\n\n\n\n\n# Compute the autocovariance.\n\nac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\nlags = np.arange(-N + 1, N) # Create a lag axis,\nplt.plot(lags * dt, ac_xx) # ... and plot the result.\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nprint('lambda0*dt = ',lambda0*dt) # Compare expected r_{nn}[0] to computed value.\nprint('r_{nn}[0] = ',ac_xx[N-1])\n\nlambda0*dt = 0.005\nr_{nn}[0] = 0.0033884399999999796\n\n\n\n\n\n\n\n\n\n\n# Compute the spectrum.\n\nDj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\nPj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum.\nf = np.fft.fftfreq(N, dt) # Create frequency axis.\nplt.plot(f, np.real(Pj)) # Plot the spectrum.\nin_class_guess = 2*dt**2*lambda0 # And our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n\n\n\n\n\n\n\n\n# Repeat the entire simulation many times, and plot the average autocovariance and spectrum\n\nK = 1000 # Number of times to repeat the simulation.\nlambda_est = np.zeros(K) # Vector to store estimate of lambda.\nP = np.zeros([K,np.size(Pj)]) # Matrix to store spectra,\nAC = np.zeros([K,2*N-1]) # ... and AC.\n\nfor k in np.arange(K): # For each repeat,\n dn = np.random.binomial(1,p0,N) # ... create a new spike train.\n\n lambda_est[k] = np.sum(dn)/T\n # Compute the AC,\n ac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\n AC[k,:] = ac_xx # ... and save the result.\n \n Dj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\n Pj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum,\n P[k,:] = Pj # ... and save the result.\n\nplt.figure() # Plot it.\nplt.plot(lags*dt, np.mean(AC,0))\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\n\nplt.figure()\nplt.plot(f, np.mean(P,0)) # Plot the spectrum, averaged over repeats\nin_class_guess = 2*dt**2*np.mean(lambda_est) # Use lambda_est to compute our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n/var/folders/mt/qz9sczyj4ys72smgdmwl7dc00016ry/T/ipykernel_29220/429407619.py:18: ComplexWarning: Casting complex values to real discards the imaginary part\n P[k,:] = Pj # ... and save the result.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nN = 5000; # Number of bins. \ndt = 0.001; # Duration of each bin [s].\nT = N*dt; # Total time of observation [s].\ntm = np.arange(0,N)*dt; # Time axis for plotting\n\nlambda0 = 5 # Average firing rate [Hz]\np0 = lambda0*dt; # Probability of a spike in a time bin\ndn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\nrefractory_period = 10 # Add a refractory period\nfor i in np.arange(N):\n if dn[i]==1:\n dn[i+1:i+refractory_period] = 0\n\nplt.plot(tm, dn) # Plot it.\nplt.xlabel('Time [s]');\n\n\n\n\n\n\n\n\n\nac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\nlags = np.arange(-N + 1, N) # Create a lag axis,\nplt.plot(lags * dt, ac_xx) # ... and plot the result.\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nprint('lambda0*dt = ',lambda0*dt) # Compare expected r_{nn}[0] to computed value.\nprint('r_{nn}[0] = ',ac_xx[N-1])\n\nlambda0*dt = 0.005\nr_{nn}[0] = 0.00438064\n\n\n\n\n\n\n\n\n\n\n# Compute the spectrum.\nDj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\nPj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum.\nf = np.fft.fftfreq(N, dt) # Create frequency axis.\nplt.plot(f, np.real(Pj)) # Plot the spectrum.\nin_class_guess = 2*dt**2*lambda0 # And our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n\n\n\n\n\n\n\n\n# Repeat the entire simulation many times, and plot the average autocovariance and spectrum\nK = 1000 # Number of times to repeat the simulation.\nlambda_est = np.zeros(K) # Vector to store estimate of lambda.\nP = np.zeros([K,np.size(Pj)]) # Matrix to store spectra,\nAC = np.zeros([K,2*N-1]) # ... and AC.\n\nfor k in np.arange(K): # For each repeat,\n dn = np.random.binomial(1,p0,N) # ... create a new spike train.\n refractory_period = 100 # Add a refractory period\n for i in np.arange(N):\n if dn[i]==1:\n dn[i+1:i+refractory_period] = 0\n \n lambda_est[k] = np.sum(dn)/T\n # Compute the AC,\n ac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\n AC[k,:] = ac_xx # ... and save the result.\n \n Dj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\n Pj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum,\n P[k,:] = Pj # ... and save the result.\n\nplt.figure() # Plot it.\nplt.plot(lags*dt, np.mean(AC,0))\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nplt.xlim([-0.1, 0.1])\nplt.ylim([-0.0005, 0.001])\n\nplt.figure()\nplt.plot(f, np.mean(P,0)) # Plot the spectrum, averaged over repeats\nin_class_guess = 2*dt**2*np.mean(lambda_est) # Use lambda_est to compute our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n/var/folders/mt/qz9sczyj4ys72smgdmwl7dc00016ry/T/ipykernel_29220/2145871062.py:21: ComplexWarning: Casting complex values to real discards the imaginary part\n P[k,:] = Pj # ... and save the result." + "text": "from scipy.io import loadmat\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.signal import spectrogram\n\n\ndata = loadmat('EEG-1.mat') # Load the EEG data\n# Data available here\n# https://github.com/Mark-Kramer/BU-MA665-MA666/tree/master/Data\n#\nEEG = data['EEG'].reshape(-1) # Extract the EEG variable\nt = data['t'][0] # ... and the t variablea\n\n\nplt.plot(t,EEG)\nplt.xlabel('Time [s]')\nplt.ylabel('EEG');\n\n\n#dt = t[-1]/len(t)\ndt = t[2]-t[1]\nprint(dt)\n\n\nf0 = 1/dt\nprint(f0)\n\n\nN = len(t)\nprint(N)\n\n\nT = N*dt\nprint(T)\n\n\n# Q. What is the Nyquist frequency and frequency resolution?\nfNQ = f0/2\ndf = 1/T\n\n# Q. What is the frequency axis?\nfj = np.arange(0,fNQ,df)\n\n# Then, compute the Fourier transform \"by hand\".\nx = EEG\nX = np.ndarray(np.size(fj), complex);\nfor j in range( np.size(fj) ):\n X[j] = np.sum(x * np.exp(-2*np.pi*1j*fj[j]*t) )\n\n# And the spectrum,\nSxx = 2*dt**2/T * (X * np.conjugate(X))\n\n# Plot it,\nplt.plot(fj, Sxx.real)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [mV^2/Hz]');\n\n\nx = EEG\nX = np.fft.fft(x) # Compute Fourier transform of x\nSxx = 2*dt**2/T * (X * np.conjugate(X)) # Compute spectrum\nSxx = Sxx[0:int(N / 2)].real # Ignore negative frequencies\n\n\n# Plot it,\nplt.plot(fj, Sxx)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [mV^2/Hz]');\n\n\ndf = 1/T # Determine frequency resolution\nfNQ = f0/2 # Determine Nyquist frequency\nfaxis = np.arange(0,fNQ,df) # Construct frequency axis\n\n\nplt.plot(faxis, Sxx)\nplt.xlim([0, 100]) # Select frequency range\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [$\\mu V^2$/Hz]');\n\n\nplt.figure()\nplt.plot(faxis, 10*np.log10(Sxx)) # Plot the spectrum in decibels.\n#plt.xlim([0, 100]) # Select the frequency range.\nplt.ylim([-60, 0]) # Select the decibel range.\nplt.xlabel('Frequency [Hz]') # Label the axes.\nplt.ylabel('Power [dB]');\n\n\nplt.figure()\nplt.plot(faxis, Sxx) # Plot the spectrum in decibels.\n#plt.xlim([df, 100]) # Select frequency range\nplt.ylim([10**-7, 0]) # ... and the decibel range.\nplt.xlabel('Frequency [Hz]') # Label the axes.\nplt.ylabel('Power [dB]');\n\n\nx_tapered = np.hanning(N) * x\nplt.figure()\nplt.plot(t,x)\nplt.plot(t,x_tapered);\n\n\nxf_tapered = np.fft.fft(x_tapered) # Compute Fourier transform of x.\nSxx_tapered = 2*dt**2/T*(xf_tapered*np.conj(xf_tapered)) # Compute the spectrum,\nSxx_tapered = np.real(Sxx_tapered[:int(N / 2)]) # ... and ignore negative frequencies.\n\nplt.figure()\nplt.semilogx(faxis,10*np.log10(Sxx)) # Plot spectrum of untapered signal. \nplt.semilogx(faxis,10*np.log10(Sxx_tapered)) # Plot spectrum vs tapered signal.\nplt.xlim([faxis[1], 100]) # Select frequency range,\nplt.ylim([-70, 20]) # ... and the power range.\nplt.xlabel('Frequency [Hz]') # Label the axes\nplt.ylabel('Power [$\\mu V^2$/Hz]')\n\n\n# Plot the spectrogram.\n\nFs = 1 / dt # Define the sampling frequency,\ninterval = int(Fs) # ... the interval size,\noverlap = int(Fs * 0.95) # ... and the overlap intervals\n\n # Compute the spectrogram\nf0, t0, Sxx0 = spectrogram(\n EEG, # Provide the signal,\n fs=Fs, # ... the sampling frequency,\n nperseg=interval, # ... the length of a segment,\n noverlap=overlap) # ... the number of samples to overlap,\nplt.pcolormesh(t0, f0, 10 * np.log10(Sxx0),\n cmap='jet')# Plot the result\nplt.colorbar() # ... with a color bar,\nplt.ylim([0, 70]) # ... set the frequency range,\nplt.xlabel('Time [s]') # ... and label the axes\nplt.ylabel('Frequency [Hz]');\n\n\nN = 1000;\ndt= 0.001;\nT = N*dt;\nx = np.random.randn(N)\nt = np.arange(0,N)*dt\n\n#plt.plot(t,x)\n#plt.xlabel('Time [s]');\n\n\nlags = np.arange(-N+1,N)\nac_xx = np.zeros(np.size(lags))\nfor index,L in enumerate(lags):\n if L>= 0:\n ac_xx[index] = 1/N*np.sum( x[L:N]*x[0:N-L] )\n else:\n ac_xx[index] = 1/N*np.sum( x[0:N+L]*x[-L:N] )\nplt.plot(lags, ac_xx) # ... and plot the result.\nplt.xlabel('Lag')\nplt.ylabel('Autocovariance');\n\n\nac_xx = 1/N*np.correlate(x,x,'full')\nplt.plot(lags, ac_xx)\n\n\n# Load modules we'll need.\nfrom scipy.io import loadmat\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.signal import spectrogram\n\n\n# Load the data.\ndata = loadmat('AC_Example.mat') # Load the data,\n# Data available here\n# https://github.com/Mark-Kramer/BU-MA665-MA666/tree/master/Data\n#\nd = data['d'][0] # ... from the first electrode.\nt = data['t'][0] # Load the time axis\nN = np.size(d,0) # Store number of observations.\ndt = t[1]-t[0] # Store sampling interval.\n\n\nplt.plot(t,d)\n\n\nT = t[-1]\ndf = 1/T\nf0 = 1/dt\nfNQ= f0/2\nfaxis = np.arange(0, fNQ, df)\n\nX = np.fft.fft(d - np.mean(d))\nS = 2*dt**2/T * (np.conj(X)*X)\nS = S[0:int(N/2)]\n\nplt.plot(faxis, S)\nplt.xlabel('Freq [Hz]')\n\n\nac = 1/N*np.correlate(d,d, 'full')\nlags = np.arange(-N+1,N)\nplt.plot(lags, ac);\n\n\ndt = 0.001\nN = 1000\nt = np.arange(0,N)*dt\nd = 1*np.sin(2*np.pi*10.25*t) + 0.1*np.random.randn(N)\nplt.plot(t,d)\n\n\nrxx = [];\nlags = np.arange(-int(N/2),int(N/2));\nfor idx,L in enumerate(lags):\n rxx = np.append(rxx, 1/N*np.sum(np.roll(d,L) * d))\nplt.plot(lags, rxx)\nplt.xlabel('Lags [indices]');\nplt.ylabel('Autocovariance rxx');\n\n\n# Compute the spectrum from the FT{rxx}\nSxx_via_rxx = 2*dt*np.fft.fft(rxx)\n\n# Compute the spectrum from the data.\nT = t[-1];\nxf = np.fft.fft(d);\nSxx = 2 * dt ** 2 / T * (xf * xf.conj()) \n\nplt.plot(10*np.log10(Sxx))\nplt.plot(10*np.log10(Sxx_via_rxx), 'o')\nplt.xlabel('Freq Index')\nplt.legend({'Direct Sxx', 'Sxx via rxx'})\nplt.xlim([0,150]);\n\n\n# Load modules we'll need.\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\nN = 5000; # Number of bins. \ndt = 0.001; # Duration of each bin [s].\nT = N*dt; # Total time of observation [s].\ntm = np.arange(0,N)*dt; # Time axis for plotting\n\nlambda0 = 5 # Average firing rate [Hz]\np0 = lambda0*dt; # Probability of a spike in a time bin\ndn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\n\nplt.plot(tm, dn) # Plot it.\nplt.xlabel('Time [s]');\n\n\n\n\n\n\n\n\n\n# Compute the autocovariance.\n\nac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\nlags = np.arange(-N + 1, N) # Create a lag axis,\nplt.plot(lags * dt, ac_xx) # ... and plot the result.\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nprint('lambda0*dt = ',lambda0*dt) # Compare expected r_{nn}[0] to computed value.\nprint('r_{nn}[0] = ',ac_xx[N-1])\n\nlambda0*dt = 0.005\nr_{nn}[0] = 0.0033884399999999796\n\n\n\n\n\n\n\n\n\n\n# Compute the spectrum.\n\nDj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\nPj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum.\nf = np.fft.fftfreq(N, dt) # Create frequency axis.\nplt.plot(f, np.real(Pj)) # Plot the spectrum.\nin_class_guess = 2*dt**2*lambda0 # And our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n\n\n\n\n\n\n\n\n# Repeat the entire simulation many times, and plot the average autocovariance and spectrum\n\nK = 1000 # Number of times to repeat the simulation.\nlambda_est = np.zeros(K) # Vector to store estimate of lambda.\nP = np.zeros([K,np.size(Pj)]) # Matrix to store spectra,\nAC = np.zeros([K,2*N-1]) # ... and AC.\n\nfor k in np.arange(K): # For each repeat,\n dn = np.random.binomial(1,p0,N) # ... create a new spike train.\n\n lambda_est[k] = np.sum(dn)/T\n # Compute the AC,\n ac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\n AC[k,:] = ac_xx # ... and save the result.\n \n Dj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\n Pj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum,\n P[k,:] = Pj # ... and save the result.\n\nplt.figure() # Plot it.\nplt.plot(lags*dt, np.mean(AC,0))\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\n\nplt.figure()\nplt.plot(f, np.mean(P,0)) # Plot the spectrum, averaged over repeats\nin_class_guess = 2*dt**2*np.mean(lambda_est) # Use lambda_est to compute our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n/var/folders/mt/qz9sczyj4ys72smgdmwl7dc00016ry/T/ipykernel_29220/429407619.py:18: ComplexWarning: Casting complex values to real discards the imaginary part\n P[k,:] = Pj # ... and save the result.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nN = 5000; # Number of bins. \ndt = 0.001; # Duration of each bin [s].\nT = N*dt; # Total time of observation [s].\ntm = np.arange(0,N)*dt; # Time axis for plotting\n\nlambda0 = 5 # Average firing rate [Hz]\np0 = lambda0*dt; # Probability of a spike in a time bin\ndn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\nrefractory_period = 10 # Add a refractory period\nfor i in np.arange(N):\n if dn[i]==1:\n dn[i+1:i+refractory_period] = 0\n\nplt.plot(tm, dn) # Plot it.\nplt.xlabel('Time [s]');\n\n\n\n\n\n\n\n\n\nac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\nlags = np.arange(-N + 1, N) # Create a lag axis,\nplt.plot(lags * dt, ac_xx) # ... and plot the result.\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nprint('lambda0*dt = ',lambda0*dt) # Compare expected r_{nn}[0] to computed value.\nprint('r_{nn}[0] = ',ac_xx[N-1])\n\nlambda0*dt = 0.005\nr_{nn}[0] = 0.00438064\n\n\n\n\n\n\n\n\n\n\n# Compute the spectrum.\nDj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\nPj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum.\nf = np.fft.fftfreq(N, dt) # Create frequency axis.\nplt.plot(f, np.real(Pj)) # Plot the spectrum.\nin_class_guess = 2*dt**2*lambda0 # And our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n\n\n\n\n\n\n\n\n# Repeat the entire simulation many times, and plot the average autocovariance and spectrum\nK = 1000 # Number of times to repeat the simulation.\nlambda_est = np.zeros(K) # Vector to store estimate of lambda.\nP = np.zeros([K,np.size(Pj)]) # Matrix to store spectra,\nAC = np.zeros([K,2*N-1]) # ... and AC.\n\nfor k in np.arange(K): # For each repeat,\n dn = np.random.binomial(1,p0,N) # ... create a new spike train.\n refractory_period = 100 # Add a refractory period\n for i in np.arange(N):\n if dn[i]==1:\n dn[i+1:i+refractory_period] = 0\n \n lambda_est[k] = np.sum(dn)/T\n # Compute the AC,\n ac_xx = 1/N*np.correlate(dn-np.mean(dn), dn-np.mean(dn), 'full')\n AC[k,:] = ac_xx # ... and save the result.\n \n Dj = np.fft.fft(dn - np.mean(dn)) # Compute the FT,\n Pj = 2*dt**2/T * (Dj * np.conj(Dj)) # ... and the spectrum,\n P[k,:] = Pj # ... and save the result.\n\nplt.figure() # Plot it.\nplt.plot(lags*dt, np.mean(AC,0))\nplt.xlabel('Lag [s]')\nplt.ylabel('Autocovariance');\nplt.xlim([-0.1, 0.1])\nplt.ylim([-0.0005, 0.001])\n\nplt.figure()\nplt.plot(f, np.mean(P,0)) # Plot the spectrum, averaged over repeats\nin_class_guess = 2*dt**2*np.mean(lambda_est) # Use lambda_est to compute our guess from in-class analysis.\nplt.plot(f,in_class_guess*np.ones(N), 'b')\nplt.xlabel('Frequency [Hz]');\n\n/var/folders/mt/qz9sczyj4ys72smgdmwl7dc00016ry/T/ipykernel_29220/2145871062.py:21: ComplexWarning: Casting complex values to real discards the imaginary part\n P[k,:] = Pj # ... and save the result.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Load modules we'll need.\nfrom scipy.io import loadmat\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.signal import spectrogram\n\n\nN = 1000;\ndt= 0.001;\nT = N*dt;\nx = np.random.randn(N)\ny = np.random.randn(N)\nt = np.arange(0,N)*dt\n\nplt.plot(t,x)\nplt.plot(t,y)\nplt.xlabel('Time [s]');\n\n\n\n\n\n\n\n\n\ncc_xy = 1/N*np.correlate(x-np.mean(x), y-np.mean(y), 'full')\nlags = np.arange(-N + 1, N) # Create a lag axis,\nplt.plot(lags * dt, cc_xy) # ... and plot the result.\nplt.xlabel('Lag [s]')\nplt.ylabel('Cross-covariance xy');\n\n\n\n\n\n\n\n\n\nX = np.fft.fft(d - np.mean(d))\nS = 2*dt**2/T * (np.conj(X)*X)\nS = S[0:int(N/2)]\n\nplt.plot(faxis, S)\nplt.xlabel('Freq [Hz]')\n\n\nXf = np.fft.fft(x - x.mean()) # Compute Fourier transform of x\nYf = np.fft.fft(y - y.mean()) # Compute Fourier transform of y\n\n# Compute the spectra\nSxx = 2*dt**2/T * (np.conj(Xf)*Xf) # Spectrum of E1 trials\nSyy = 2*dt**2/T * (np.conj(Yf)*Yf) # ... and E2 trials\nSxy = 2*dt**2/T * (np.conj(Xf)*Yf) # ... and the cross spectrum\n\n# Compute the coherence.\ncohr = np.abs(Sxy) / (np.sqrt(Sxx) * np.sqrt(Syy))\n\n# Define a frequency axis.\nf = np.fft.fftfreq(N, dt)\n\n# Plot the result.\nplt.plot(f, cohr.real);" }, { "objectID": "Dont-Sync-2024/12. Bursting Models/Bursting_Lab-SOLUTION.html", "href": "Dont-Sync-2024/12. Bursting Models/Bursting_Lab-SOLUTION.html", "title": "Bursting Neuron", "section": "", - "text": "The goal in this notebook is to update the HH equations to include a new (slow) current and produce bursting activity.\nTo do so, start with the HH code available here.\nUpdate the HH model to include the \\(\\bf{g_K-}\\)“M” current listed in Table A2 of this publication." + "text": "The goal in this notebook is to update the HH equations to include a new (slow) current and produce bursting activity.\nTo do so, start with the HH code available here.\nUpdate the HH model to include the \\(\\bf{g_K-}\\)“M” current listed in Table A2 of this publication.\nIn the code below, we’ll use the variable B to define the gate for this current." }, { "objectID": "Dont-Sync-2024/12. Bursting Models/Bursting_Lab-SOLUTION.html#challenges", "href": "Dont-Sync-2024/12. Bursting Models/Bursting_Lab-SOLUTION.html#challenges", "title": "Bursting Neuron", - "section": "1 Challenges", - "text": "1 Challenges\n\n1.0.1 1. Plot the steady-state function and time constant for this new current.\nHINT: In Table A2 of this publication, the authors provide the forward rate function (\\(\\alpha[V]\\)) and backward rate function (\\(\\beta[V]\\)) for this current. Use these functions to compute the steady-state function and time constant, and plot both versus V.\n\n\n1.0.2 2. Update the HH model to include this new current.\nHINT: Update the HH model to accept three inputs: HH(I0, T0, gB0), where gB0 is the maximal conductance of the new current.\nHINT: Update the HH model to return six outputs: return V,m,h,n,B,t, where B is the gate variable of the new current.\n\n\n1.0.3 3. Find parameter settings so that the model produces bursting activity.\nHINT: Fix I0=10 and T0=500 and vary the maximal conductance of the new current, gB0, until you find a value that supports bursting in the voltage.\nHINT: Plot the voltage V and the new current gate B to visualize how the dynamics behave.\n\n\n1.0.4 4. Compute the spectrum to characterize the dominant rhythms.\nHINT: Be sure to carefully define T.\n\n\nCode\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\n\n\nCode\ndef alphaM(V):\n return (2.5-0.1*(V+65)) / (np.exp(2.5-0.1*(V+65)) -1)\n\ndef betaM(V):\n return 4*np.exp(-(V+65)/18)\n\ndef alphaH(V):\n return 0.07*np.exp(-(V+65)/20)\n\ndef betaH(V):\n return 1/(np.exp(3.0-0.1*(V+65))+1)\n\ndef alphaN(V):\n return (0.1-0.01*(V+65)) / (np.exp(1-0.1*(V+65)) -1)\n\ndef betaN(V):\n return 0.125*np.exp(-(V+65)/80)\n\ndef alphaB(V):\n return 0.02 / (1+ np.exp((-V-20)/5))\n\ndef betaB(V):\n return 0.01 * np.exp((-V-43)/18)\n\ndef HHB(I0,T0,gB0):\n dt = 0.01;\n T = int(np.ceil(T0/dt)) # [ms]\n gNa0 = 120 # [mS/cm^2]\n ENa = 125; # [mV]\n gK0 = 36; # [mS/cm^2]\n EK = -12; # [mV]\n gL0 = 0.3; # [mS/cm^2]\n EL = 10.6; # [mV]\n\n t = np.arange(0,T)*dt\n V = np.zeros([T,1])\n m = np.zeros([T,1])\n h = np.zeros([T,1])\n n = np.zeros([T,1])\n B = np.zeros([T,1]) ##########################\n\n V[0]=-70.0\n m[0]=0.05\n h[0]=0.54\n n[0]=0.34\n B[0]=0.0 #####################\n\n for i in range(0,T-1):\n V[i+1] = V[i] + dt*(gNa0*m[i]**3*h[i]*(ENa-(V[i]+65)) + gK0*n[i]**4*(EK-(V[i]+65)) + gL0*(EL-(V[i]+65)) + I0 + gB0*B[i]*(EK-(V[i]+65)));\n m[i+1] = m[i] + dt*(alphaM(V[i])*(1-m[i]) - betaM(V[i])*m[i]);\n h[i+1] = h[i] + dt*(alphaH(V[i])*(1-h[i]) - betaH(V[i])*h[i]);\n n[i+1] = n[i] + dt*(alphaN(V[i])*(1-n[i]) - betaN(V[i])*n[i]);\n B[i+1] = B[i] + dt*(alphaB(V[i])*(1-B[i]) - betaB(V[i])*B[i]);\n return V,m,h,n,B,t\n\n\n\n\nCode\nV = np.arange(-100,50,1)\n\nxinfB = alphaB(V) / (alphaB(V) + betaB(V))\ntauB = 1 / (alphaB(V) + betaB(V))\n\nplt.subplot(2,1,1)\nplt.plot(V,xinfB); plt.xlabel('Voltage [mV]'); plt.ylabel('xinfB')\nplt.subplot(2,1,2)\nplt.plot(V,tauB); plt.xlabel('Voltage [mV]'); plt.ylabel('tauB');\n\n\n\n\n\n\n\n\n\n\n\nCode\nI0 = 10;\nT0 = 1000;\ngB0 = 8\n[V,m,h,n,B,t]=HHB(I0,T0,gB0)\nplt.subplot(2,1,1)\nplt.plot(t,V)\nplt.subplot(2,1,2)\nplt.plot(t,B);\n\n\n\n\n\n\n\n\n\n\n\nCode\n# Decimate\nV = V.flatten()\nVd = sig.decimate(V, 50)\ntd = t[::50]\ndt = (td[2]-td[1])/1000; print(dt)\nf0 = 1/dt; print(f0)\n\n\n0.0005\n2000.0\n\n\n\n\nCode\n# \nimport scipy.signal as sig\nidx, _ = sig.find_peaks(Vd.flatten(), height=0)\ndn = np.zeros(np.shape(Vd))\ndn[idx] = 1\nplt.plot(td,dn)\nplt.xlim([0, 200])\n\n\n\n\n\n\n\n\n\n\n\nCode\nN = np.size(td)\nT = td[-1]/1000; print(T)\ndt = (td[2]-td[1])/1000; print(dt)\nf0 = 1/dt\ndf = 1/T; print(df)\nfNQ = f0/2; print(fNQ)\n\n#x = V - np.mean(V);\n\n#x = x + 0*np.random.randn(np.size(x),1)\n\nX = np.fft.fft(Vd-np.mean(Vd));\nS = 2*dt**2/T * (X * np.conj(X))\nS = S[0:int(N/2)]\nfaxis = np.arange(0,fNQ,df)\n\nplt.plot(faxis, S.real)\nplt.xlim([0, 200])\n\n\n0.9995\n0.0005\n1.0005002501250624\n1000.0\n\n\n\n\n\n\n\n\n\n\n\nCode\ntest = np.random.randn(np.size(x),1)\nprint(test.shape)\nprint(x.shape)\ntest2 = x+test\n\n\n(100000, 1)\n(100000, 1)" + "section": "Challenges", + "text": "Challenges\n\n1. Plot the steady-state function and time constant for this new current.\nHINT: In Table A2 of this publication, the authors provide the forward rate function (\\(\\alpha[V]\\)) and backward rate function (\\(\\beta[V]\\)) for this current. Use these functions to compute the steady-state function and time constant, and plot both versus V.\n\n\n2. Update the HH model to include this new current.\nHINT: Update the HH model to accept three inputs: HH(I0, T0, gB0), where gB0 is the maximal conductance of the new current.\nHINT: Update the HH model to return six outputs: return V,m,h,n,B,t, where B is the gate variable of the new current.\n\n\n3. Find parameter settings so that the model produces bursting activity.\nHINT: Fix I0=10 and T0=500 and vary the maximal conductance of the new current, gB0, until you find a value that supports bursting in the voltage.\nHINT: Plot the voltage V and the new current gate B to visualize how the dynamics behave.\n\n\n4. Compute the spectrum to characterize the dominant rhythms.\nHINT: Be sure to carefully define T.\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef alphaM(V):\n return (2.5-0.1*(V+65)) / (np.exp(2.5-0.1*(V+65)) -1)\n\ndef betaM(V):\n return 4*np.exp(-(V+65)/18)\n\ndef alphaH(V):\n return 0.07*np.exp(-(V+65)/20)\n\ndef betaH(V):\n return 1/(np.exp(3.0-0.1*(V+65))+1)\n\ndef alphaN(V):\n return (0.1-0.01*(V+65)) / (np.exp(1-0.1*(V+65)) -1)\n\ndef betaN(V):\n return 0.125*np.exp(-(V+65)/80)\n\ndef alphaB(V):\n return 0.02 / (1+ np.exp((-V-20)/5))\n\ndef betaB(V):\n return 0.01 * np.exp((-V-43)/18)\n\ndef HHB(I0,T0,gB0):\n dt = 0.01;\n T = int(np.ceil(T0/dt)) # [ms]\n gNa0 = 120 # [mS/cm^2]\n ENa = 125; # [mV]\n gK0 = 36; # [mS/cm^2]\n EK = -12; # [mV]\n gL0 = 0.3; # [mS/cm^2]\n EL = 10.6; # [mV]\n\n t = np.arange(0,T)*dt\n V = np.zeros([T,1])\n m = np.zeros([T,1])\n h = np.zeros([T,1])\n n = np.zeros([T,1])\n B = np.zeros([T,1]) ##########################\n\n V[0]=-70.0\n m[0]=0.05\n h[0]=0.54\n n[0]=0.34\n B[0]=0.0 #####################\n\n for i in range(0,T-1):\n V[i+1] = V[i] + dt*(gNa0*m[i]**3*h[i]*(ENa-(V[i]+65)) + gK0*n[i]**4*(EK-(V[i]+65)) + gL0*(EL-(V[i]+65)) + I0 + gB0*B[i]*(EK-(V[i]+65)));\n m[i+1] = m[i] + dt*(alphaM(V[i])*(1-m[i]) - betaM(V[i])*m[i]);\n h[i+1] = h[i] + dt*(alphaH(V[i])*(1-h[i]) - betaH(V[i])*h[i]);\n n[i+1] = n[i] + dt*(alphaN(V[i])*(1-n[i]) - betaN(V[i])*n[i]);\n B[i+1] = B[i] + dt*(alphaB(V[i])*(1-B[i]) - betaB(V[i])*B[i]);\n return V,m,h,n,B,t\n\n\nV = np.arange(-100,50,1)\n\nxinfB = alphaB(V) / (alphaB(V) + betaB(V))\ntauB = 1 / (alphaB(V) + betaB(V))\n\nplt.subplot(2,1,1)\nplt.plot(V,xinfB); plt.xlabel('Voltage [mV]'); plt.ylabel('xinfB')\nplt.subplot(2,1,2)\nplt.plot(V,tauB); plt.xlabel('Voltage [mV]'); plt.ylabel('tauB');\n\n\nI0 = 10;\nT0 = 1000;\ngB0 = 8\n[V,m,h,n,B,t]=HHB(I0,T0,gB0)\nplt.subplot(2,1,1)\nplt.plot(t,V)\nplt.subplot(2,1,2)\nplt.plot(t,B);\n\n\n# Decimate\nV = V.flatten()\nVd = sig.decimate(V, 50)\ntd = t[::50]\ndt = (td[2]-td[1])/1000; print(dt)\nf0 = 1/dt; print(f0)\n\n\n# \nimport scipy.signal as sig\nidx, _ = sig.find_peaks(Vd.flatten(), height=0)\ndn = np.zeros(np.shape(Vd))\ndn[idx] = 1\nplt.plot(td,dn)\nplt.xlim([0, 200])\n\n\nN = np.size(td)\nT = td[-1]/1000; print(T)\ndt = (td[2]-td[1])/1000; print(dt)\nf0 = 1/dt\ndf = 1/T; print(df)\nfNQ = f0/2; print(fNQ)\n\n#x = V - np.mean(V);\n\n#x = x + 0*np.random.randn(np.size(x),1)\n\nX = np.fft.fft(Vd-np.mean(Vd));\nS = 2*dt**2/T * (X * np.conj(X))\nS = S[0:int(N/2)]\nfaxis = np.arange(0,fNQ,df)\n\nplt.plot(faxis, S.real)\nplt.xlim([0, 200])\n\n\ntest = np.random.randn(np.size(x),1)\nprint(test.shape)\nprint(x.shape)\ntest2 = x+test" }, { "objectID": "Dont-Sync-2024/11. Gamma Models/Gamma_Lab.html", @@ -536,7 +536,7 @@ "href": "Coherence_Lab_Part_1.html#compute-the-coherence", "title": "Coherence Part 1 (Two noise signals)", "section": "Compute the coherence", - "text": "Compute the coherence\n\nXf = np.fft.fft(x - x.mean()) # Compute Fourier transform of x\nYf = np.fft.fft(y - y.mean()) # Compute Fourier transform of y\n\n# Compute the spectra\nSxx = \"SOMETHING\" # Spectrum of E1 trials\nSyy = \"SOMETHING\" # ... and E2 trials\nSxy = \"SOMETHING\" # ... and the cross spectrum\n\n# Compute the coherence.\ncohr = \"SOMETHING\"\n\n# Define a frequency axis.\nf = np.fft.fftfreq(N, dt)\n\n# Plot the result.\nplt.plot(f, cohr.real)" + "text": "Compute the coherence\n\nXf = np.fft.fft(x - x.mean()) # Compute Fourier transform of x\nYf = np.fft.fft(y - y.mean()) # Compute Fourier transform of y\n\n# Compute the spectra\nSxx = \"SOMETHING\" # Spectrum of x\nSyy = \"SOMETHING\" # ... and y\nSxy = \"SOMETHING\" # ... and the cross spectrum\n\n# Compute the coherence.\ncohr = \"SOMETHING\"\n\n# Define a frequency axis.\nf = np.fft.fftfreq(N, dt)\n\n# Plot the result.\nplt.plot(f, cohr.real)" }, { "objectID": "Analyzing_Rhythms_Lab_3.html", @@ -550,7 +550,7 @@ "href": "index.html", "title": "BU MA665 + MA666 (Fall 2024)", "section": "", - "text": "MA665\n\nIntroduction\n\nRead the syllabus\nRead: Wilson et al, Good enough practices in scientific computing, 2017\nRead: Riquelme and Gjorgjieva, Towards readable code in neuroscience, 2021\nCode: Set up Google Colab\nCode: Install Python via Anaconda\nCode: Set up ChatGPT\nPlease complete items in the Introduction to Python\nAdvanced: 100 numpy exercises\nAdvanced: Beautiful, Idiomatic Python\nAdvanced: Make a pull request to the Introduction notebook to add a new exercise. Be sure to use follow syntax in quarto with quarto-pyodide\n\n\n\nIntegrate & Fire Neuron\n\nRead: Abbott, Brain Res Bull, 1999.\nRead: Chapter 1, pages 5-12 @ C. Koch, Biophysics of computation, 1998.\nLecture Slides\nCode: Integrate & Fire Neuron in Python\n\n\n\nHodgkin-Huxley Neuron\n\nRead: Chapter 2, pages 25-42 @ E. Izhikevich, Dynamical Systems in Neuroscience, 2007.\nRead: Hodgkin-Huxley 1-page cheat sheet\nAdvanced: Hodgkin and Huxley, J Physiol, 1952.\nLecture Slides\nCode: Hodgkin-Huxley Neuron in Python\n\n\n\nPerceptron\n\nRead: Electronic Brain Teaches Itself, New York Times, 13 July 1958\nRead: Perceptron Tested for Photo Analysis, Aviation Weekly, 1961\nRead: Undercover Algorithm, O’Connor, 2022\nLecture Slides\nCode: Training a Perceptron in Python\n\n\n\nBackpropagation\n\nRead: Lee or Delusions of Artificail Intelligence, 2023\nWatch: Inside an artificial brain\nLecture Slides\nCode: Backpropagation in a Simple Neural Network in Python\n\n\n\nRegression\n\nRead: Chapter 3 of An Introduction to Statistical Learning (Free via BU Library)\nLecture Slides\nCode: Regression Example in Python\n\n\n\n\n\nMA666\n\nIntroduction to Rhythms\n\nRead: Jell-O Test Finds Lifelike Signals, New York Times, 6 March 1976\nRead: Neuronal Oscillations in Cortical Networks\nLecture 1 Slides\nLecture 2 Slides\nCode: Rhythms Introduction\n\n\n\nAnalyzing Rhythms\n\nRead: Kramer, SFN Short Course Document.\nAdvanced Read: Chapter 3 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nAdvanced Read: Chapter 4 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nVery Advanced Read: Chapter 4 @ Percival & Walden, Spectral Analysis for Physical Applications.\nLecture 1 Slides\nLecture Code 1: Analyze Rhythms Lab 1 - Practicals\nLecture 2 Slides\nLecture Code 2a: Analyze Rhythms Lab 2a - Autocovariance of noise\nLecture Code 2b: Analyze Rhythms Lab 2b - Autocovariance of data\nLecture 3 Slides\nLecture Code 3: Analyze Rhythms Lab 3 - Spikes\nHomework (Due 11/14/2024) Spectra Homework\n\n\n\nCoherence\n\nRead: Chapter 5 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nRead: Fries, A mechanism for cognitive dynamics: neuronal communication through neuronal coherence, TINS, 2005\nExtra Read: Chapter 25 @ M. X. Cohen, Analyzing neural time series data, 2014.\nExtra Read: Chapter 26 @ M. X. Cohen, Analyzing neural time series data, 2014.\nLecture 1 Slides\nLecture Code 1: Coherence Lab 1\nLecture Code 2: Coherence Lab 2\nLecture 2 Slides\nLecture Code 3: Coherence Lab 3" + "text": "MA665\n\nIntroduction\n\nRead the syllabus\nRead: Wilson et al, Good enough practices in scientific computing, 2017\nRead: Riquelme and Gjorgjieva, Towards readable code in neuroscience, 2021\nCode: Set up Google Colab\nCode: Install Python via Anaconda\nCode: Set up ChatGPT\nPlease complete items in the Introduction to Python\nAdvanced: 100 numpy exercises\nAdvanced: Beautiful, Idiomatic Python\nAdvanced: Make a pull request to the Introduction notebook to add a new exercise. Be sure to use follow syntax in quarto with quarto-pyodide\n\n\n\nIntegrate & Fire Neuron\n\nRead: Abbott, Brain Res Bull, 1999.\nRead: Chapter 1, pages 5-12 @ C. Koch, Biophysics of computation, 1998.\nLecture Slides\nCode: Integrate & Fire Neuron in Python\n\n\n\nHodgkin-Huxley Neuron\n\nRead: Chapter 2, pages 25-42 @ E. Izhikevich, Dynamical Systems in Neuroscience, 2007.\nRead: Hodgkin-Huxley 1-page cheat sheet\nAdvanced: Hodgkin and Huxley, J Physiol, 1952.\nLecture Slides\nCode: Hodgkin-Huxley Neuron in Python\n\n\n\nPerceptron\n\nRead: Electronic Brain Teaches Itself, New York Times, 13 July 1958\nRead: Perceptron Tested for Photo Analysis, Aviation Weekly, 1961\nRead: Undercover Algorithm, O’Connor, 2022\nLecture Slides\nCode: Training a Perceptron in Python\n\n\n\nBackpropagation\n\nRead: Lee or Delusions of Artificail Intelligence, 2023\nWatch: Inside an artificial brain\nLecture Slides\nCode: Backpropagation in a Simple Neural Network in Python\n\n\n\nRegression\n\nRead: Chapter 3 of An Introduction to Statistical Learning (Free via BU Library)\nLecture Slides\nCode: Regression Example in Python\n\n\n\n\n\nMA666\n\nIntroduction to Rhythms\n\nRead: Jell-O Test Finds Lifelike Signals, New York Times, 6 March 1976\nRead: Neuronal Oscillations in Cortical Networks\nLecture 1 Slides\nLecture 2 Slides\nCode: Rhythms Introduction\n\n\n\nAnalyzing Rhythms\n\nRead: Kramer, SFN Short Course Document.\nAdvanced Read: Chapter 3 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nAdvanced Read: Chapter 4 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nVery Advanced Read: Chapter 4 @ Percival & Walden, Spectral Analysis for Physical Applications.\nLecture 1 Slides\nLecture Code 1: Analyze Rhythms Lab 1 - Practicals\nLecture 2 Slides\nLecture Code 2a: Analyze Rhythms Lab 2a - Autocovariance of noise\nLecture Code 2b: Analyze Rhythms Lab 2b - Autocovariance of data\nLecture 3 Slides\nLecture Code 3: Analyze Rhythms Lab 3 - Spikes\nHomework (Due 11/14/2024) Spectra Homework\n\n\n\nCoherence\n\nRead: Chapter 5 @ Kramer & Eden, Case studies in neural data analysis, 2016.\nRead: Fries, A mechanism for cognitive dynamics: neuronal communication through neuronal coherence, TINS, 2005\nExtra Read: Chapter 25 @ M. X. Cohen, Analyzing neural time series data, 2014.\nExtra Read: Chapter 26 @ M. X. Cohen, Analyzing neural time series data, 2014.\nAdvanced Read: Lepage et al, The Dependence of Spike Field Coherence on Expected Intensity, 2011.\nLecture 1 Slides\nLecture Code 1: Coherence Lab 1\nLecture Code 2: Coherence Lab 2\nLecture 2 Slides\nLecture Code 3: Coherence Lab 3" }, { "objectID": "Backpropagation.html", diff --git a/index.qmd b/index.qmd index 32dc988..e770c4e 100644 --- a/index.qmd +++ b/index.qmd @@ -77,6 +77,7 @@ title: "BU MA665 + MA666 (Fall 2024)" - Read: [Fries, *A mechanism for cognitive dynamics: neuronal communication through neuronal coherence*, TINS, 2005](/Readings/Fries_TINS_2005.pdf) - Extra Read: [Chapter 25 @ M. X. Cohen, Analyzing neural time series data, 2014.](/Readings/Cohen_Chapter_25.pdf) - Extra Read: [Chapter 26 @ M. X. Cohen, Analyzing neural time series data, 2014.](/Readings/Cohen_Chapter_26.pdf) +- Advanced Read: [Lepage et al, *The Dependence of Spike Field Coherence on Expected Intensity*, 2011.](/Readings/Lepage_Neural_Comp_2011.pdf) - **Lecture 1** [Slides](https://github.com/Mark-Kramer/BU-MA665-MA666/blob/master/Slides/Coherence_Lecture_1.pdf) - Lecture Code 1: [Coherence Lab 1](Coherence_Lab_Part_1.html) - Lecture Code 2: [Coherence Lab 2](Coherence_Lab_Part_2.html)