Difference between revisions of "Spring 2020 Assignment 10"

From Course Wiki
Jump to: navigation, search
(Created page with "# Start by loading the data structure called <tt>fall2019_StudentData_Responses.mat</tt> into matlab. This file contains two variables: #* <tt>allClassResponseData</tt> is a ...")
 
Line 1: Line 1:
 +
In this assignment, you will find the amplitude and phase response of Hog1 to osmotic shock using student data from last semester. Note that this assignment is OPTIONAL, and completing it will give you +2 points of extra credit on a previous assignment.
 +
 
# Start by loading the data structure called <tt>fall2019_StudentData_Responses.mat</tt> into matlab. This file contains two variables:  
 
# Start by loading the data structure called <tt>fall2019_StudentData_Responses.mat</tt> into matlab. This file contains two variables:  
 
#* <tt>allClassResponseData</tt> is a cell array containing the analyzed response data from each group. Each element of the cell array is a 3-column matrix containing the response data. The columns represent (in order): the time (in seconds), the mean response (the average correlation between GFP and RFP in each cell), and the standard error of the response. To access the matrix of the <tt>ii</tt>th group, you can use curly braces: <tt>allClassResponseData{ii}</tt>.
 
#* <tt>allClassResponseData</tt> is a cell array containing the analyzed response data from each group. Each element of the cell array is a 3-column matrix containing the response data. The columns represent (in order): the time (in seconds), the mean response (the average correlation between GFP and RFP in each cell), and the standard error of the response. To access the matrix of the <tt>ii</tt>th group, you can use curly braces: <tt>allClassResponseData{ii}</tt>.
 
#* <tt>allClassOscillationPeriods</tt> is a vector containing the oscillation period (in seconds) for each of the elements in <tt>allClassResponseData</tt>.
 
#* <tt>allClassOscillationPeriods</tt> is a vector containing the oscillation period (in seconds) for each of the elements in <tt>allClassResponseData</tt>.
# For each set of data, fit a sine function to extract the amplitude and phase of the response at that input frequency.
+
# For each set of data, use <tt>nlinfit</tt> to fit a sine function to extract the amplitude and phase of the response at that input frequency.
#* There are a few important, but subtle points here.  
+
#* Remember that <tt>nlinfit</tt> requires four inputs in this order: the independent variable (time), the dependent variable (hog1 response), a model function (more about this below), and a vector containing initial guesses for each parameter.
#** Since the response data is not centered around zero, you must include a constant offset in your model function.  
+
#* Your model function should be a sine wave with an amplitude, phase, and offset (since the response data is not centered around zero) as fit parameters. The frequency of oscillations that we are interested in is determined by our experiment (given by <tt>1./allClassOscillationPeriods</tt>), and should not be left as a fit parameter.
#** The frequency of oscillations that we are interested in is determined by our experiment, and should not be left as a fit parameter.  
+
# Plot the best-fit amplitude and phase in a Bode plot.
 +
 
 +
''Tip #1:'' Test your code for a single data set before looping through the entire cell array.
 +
 
 +
''Tip #2:'' The model function used by <tt>nlinfit</tt> needs to have the vector of parameters as its first argument, and the independent variable as its second argument. You may find the following template useful for the model function:
  
 +
<pre>
 +
exampleModelFunction = @(p,t) p(1) * t.^2 + p(2) * t + p(3) t^3;
 +
bestFitParameters = nlinfit( time, response, exampleModelFunction, [1 2 3]);
 +
</pre>
  
 +
This is an example of the model function <math>y = a t^2 + b t +c</math>, where ''a, b,'' and ''c'' are fit parameters with initial guesses a = 1, b = 2, and c =3.
  
 
{{Template:Assignment Turn In|message =  
 
{{Template:Assignment Turn In|message =  
  
For each set of response data:
+
# Write a function to fit the Hog1 response to a sinusoid and extract the estimated amplitude and phase shift of the response signal. For each set of response data, make a plot showing the Hog1 response vs time and the best fit model function.  
# Plot the response vs time in one subplot, and the pinch valve state (1 for high salt, 0 for low salt) in a second subplot.
+
# Make a Bode plot (i.e. plot the amplitude and phase) of the Hog1-response as a function of frequency. Use log-log axes for the magnitude, and semi-log x axes for the phase. Since some frequencies have several measurements, you may either plot each fit result as a single point on the plot, or average the results together. For the phase plot, use <tt>wrapTo180</tt> or <tt>wrapToPi</tt> to make sure your phase is in the appropriate range of angles.  
# Write a function to fit the response to a sinusoid and extract the predicted amplitude and phase shift of the response signal. Plot the best fit function on the same plot as your data.
+
# Qualitatively compare your Bode plot to the amplitude and phase found in the Mettetal paper. What aspects of the results are expected or unexpected? If your measurements do not agree, describe two or three reasons why they might differ.
# On one set of axes, plot the Hog1-response vs. time and the best fit sinusoid.
+
# Make a Bode Plot (amplitude and phase) of the Hog1-response as a function of frequency.
+
# How does your data compare to the amplitude and phase found in the paper? If your measurements do not agree, describe two or three reasons why they might differ.
+
 
}}
 
}}
  
 
{{Template:Assignment Turn In|message = Turn in all your MATLAB code in pdf format. No need to include functions that you used but did not modify.}}
 
{{Template:Assignment Turn In|message = Turn in all your MATLAB code in pdf format. No need to include functions that you used but did not modify.}}

Revision as of 14:49, 5 May 2020

In this assignment, you will find the amplitude and phase response of Hog1 to osmotic shock using student data from last semester. Note that this assignment is OPTIONAL, and completing it will give you +2 points of extra credit on a previous assignment.

  1. Start by loading the data structure called fall2019_StudentData_Responses.mat into matlab. This file contains two variables:
    • allClassResponseData is a cell array containing the analyzed response data from each group. Each element of the cell array is a 3-column matrix containing the response data. The columns represent (in order): the time (in seconds), the mean response (the average correlation between GFP and RFP in each cell), and the standard error of the response. To access the matrix of the iith group, you can use curly braces: allClassResponseData{ii}.
    • allClassOscillationPeriods is a vector containing the oscillation period (in seconds) for each of the elements in allClassResponseData.
  2. For each set of data, use nlinfit to fit a sine function to extract the amplitude and phase of the response at that input frequency.
    • Remember that nlinfit requires four inputs in this order: the independent variable (time), the dependent variable (hog1 response), a model function (more about this below), and a vector containing initial guesses for each parameter.
    • Your model function should be a sine wave with an amplitude, phase, and offset (since the response data is not centered around zero) as fit parameters. The frequency of oscillations that we are interested in is determined by our experiment (given by 1./allClassOscillationPeriods), and should not be left as a fit parameter.
  3. Plot the best-fit amplitude and phase in a Bode plot.

Tip #1: Test your code for a single data set before looping through the entire cell array.

Tip #2: The model function used by nlinfit needs to have the vector of parameters as its first argument, and the independent variable as its second argument. You may find the following template useful for the model function:

exampleModelFunction = @(p,t) p(1) * t.^2 + p(2) * t + p(3) t^3;
bestFitParameters = nlinfit( time, response, exampleModelFunction, [1 2 3]);

This is an example of the model function $ y = a t^2 + b t +c $, where a, b, and c are fit parameters with initial guesses a = 1, b = 2, and c =3.


Pencil.png
  1. Write a function to fit the Hog1 response to a sinusoid and extract the estimated amplitude and phase shift of the response signal. For each set of response data, make a plot showing the Hog1 response vs time and the best fit model function.
  2. Make a Bode plot (i.e. plot the amplitude and phase) of the Hog1-response as a function of frequency. Use log-log axes for the magnitude, and semi-log x axes for the phase. Since some frequencies have several measurements, you may either plot each fit result as a single point on the plot, or average the results together. For the phase plot, use wrapTo180 or wrapToPi to make sure your phase is in the appropriate range of angles.
  3. Qualitatively compare your Bode plot to the amplitude and phase found in the Mettetal paper. What aspects of the results are expected or unexpected? If your measurements do not agree, describe two or three reasons why they might differ.



Pencil.png

Turn in all your MATLAB code in pdf format. No need to include functions that you used but did not modify.