Download a Template on GitHub:
lab1_uv-vis_template.ipynb
and nothing else. If there is a .txt shown delete it.Insert your introduction here.
Write a short paragraph about the purpose of the lab, the technique(s) you're using, the samples you're analyzing, and any additional background information you can think of that will help frame the purpose of the lab. At minimum you should include and overview (not detail) of:
Fill in all of the exact details necessary for you to repeat the study without any additional resources.
Much of this section should be filled in during lab!
Standard and QC concentrations are shown below to following chunk.
In [112]:
###### Load function #################################################################
## Leave the function alone
function concentrations = serialDilution(stock, pipettes, flasks)
concentrations =[];
for i = 1:length(pipettes)
if i == 1
concentrations(i) = stock * pipettes(i)/flasks(i); # calculate first dilution
else
concentrations(i) = concentrations(i-1) * pipettes(i)/flasks(i); # calculate all other dilutions
end
end
concentrations = flip(concentrations)'; # reverse the vector from lowest to highest and transpose to column vector
end
########################################################################################
In [113]:
####### Use function - insert standard info here #######################################
concentrations = serialDilution(104.9, [20 10 10], [25 25 25]); # conc in ppm, volume of pipettes in ml, vol of flasks in ml
disp("Standard Concentrations (in ppm) = ");
output_precision(4); # only display 4 significant digits
disp(concentrations);
######## Insert QC Info Here ############################################################
qc_stock = 100.6; # units: ppm, insert concentration of the stock soln. used for QC
qc_pipette = 10; # units: ml
qc_flask = 50; # units: ml (must be same length and units as 'qc_pipette')
########################################################################################
qc_conc = qc_pipette / qc_flask * qc_stock;
disp("QC Concentration (in ppm) = ");
output_precision(4); # only display 4 significant digits
disp(qc_conc);
Samples were analyzed with a Vernier SpectroVis in fluorescence mode. Table 2 shows complete instrument parameters.
Students: Fill in the instrument settings table. Look up the values on the Vernier website.
Parameter | Value |
---|---|
Make & Model | Vernier SpectroVis |
Source (fluorescence) | |
Optical Resolution | |
Wavelength Range | |
Data Acquisition Software |
In [114]:
#### Import the data
X = csvread('data/20200102_tonic_fluorescence.csv'); ## import data
X(1:2, :) ## print to screen to make sure data imported OK (optional)
The data imported correctly, but could use some cleaning up. The first step will be to remove the duplicate wavelength columns.
In [115]:
wavelengths = X(:, 1); ## extract wavelength column to it's own vector
X = X(:, 2:2:end); ## extract even columns (intensity columns) and discard wavelength columns
X(1:2, :) ## print to screen to make sure clean up worked as expected (optional)
Looks better. The columns are:
In [116]:
##### Plot the emission spectrum
plot(wavelengths, X(:, 5), 'DisplayName', 'Medium Standard');
xlabel('Wavelength (nm)');
ylabel('Intensity (arbitrary)');
xlim([380 700]); ylim([0 0.25]);
hold on
plot(wavelengths, X(:, 9), 'DisplayName', 'Tonic Water');
legend();
hold off
##### find max emission wavelength #######################
[max_values indices] = max(X(:, 5));
lambda_max = wavelengths(indices);
disp("Wavelength of maximum emission (in nm) = ");
output_precision(0); # only display to nearest nm
disp(lambda_max);
The peak emission, $\lambda_{e-max}$, for quinine occurs at 461 nm, so only this wavelength will be used for analysis. The expected maximum wavelength is 450 nm; the difference might indicate a significant miscalibration of the spectrophotometer. A wavelength standard will be needed to verify this.
In [117]:
disp("The intensities at the analytical wavelength are:")
intensity_values = X(wavelengths == (lambda_max), :)
In [118]:
##### Define function to calculate linear fit and R2 ###############################
##### Leave this section alone
function [fit_params, r2, fitline] = fitlm(x, y)
X = [ones(length(x), 1) x];
fit_params = (pinv(X'*X))*X'*y;
# watch this video to understand this code: https://www.youtube.com/watch?v=w2FKXOa0HGA
ss_tot = sum((y - mean(y)).^2);
ss_reg = sum(((X*fit_params) - mean(y)).^2);
r2 = ss_reg/ss_tot;
fitline = [x, X*fit_params];
end
#####################################################################################
In [119]:
standards = intensity_values(4:6) .- intensity_values(1); ## subtract blank reading
##### Plot Data
plot(concentrations', standards', '*', 'DisplayName', 'Experimental Data');
xlabel('Concentration (ppm)');
ylabel('Intensity (arbitrary)');
##### Calculate linear model / cal curve
[fit_params, r2, fitline] = fitlm(concentrations, standards');
##### Plot cal curve
hold on; % this keeps our previous plot of the training data visible
plot(fitline(:, 1), fitline(:, 2), 'b--', 'DisplayName', 'Linear regression')
legend('location', 'northwest')
hold off % Don't put any more plots on this figure
##### print values to screen
output_precision(4); # only display to 4 sf
disp("Slope =")
disp(fit_params(2))
disp("Intercept =")
disp(fit_params(1))
disp("R2 =")
disp(r2)
In [120]:
###### Calculate concentration of samples & QC
samples_qc = intensity_values(7:12) .- mean(intensity_values(1:3)); ## subtract blank reading
concs = (samples_qc - fit_params(1))/fit_params(2);
In [121]:
###### Calculate mean QC value
mean_qc = mean(concs(1:3));
sd_qc = std(concs(1:3));
qc_percent_diff = (mean_qc - qc_conc)/qc_conc*100;
disp("Avearge [Quinine] in QC (in ppm) = ");
disp(mean_qc);
disp("Expected [Quinine] in QC (in ppm) = ");
disp(qc_conc);
disp("QC Difference in percent = ");
disp(qc_percent_diff);
if qc_percent_diff < 5
disp("QC PASS!")
else
disp("QC FAIL!")
end
The QC Passed at -3.525% difference.
Now, moving on to calculate sample concentrations.
In [122]:
###### Calculate mean sample values
mean_samples = mean(concs(4:6));
sd_samples = std(concs(4:6));
disp("Avearge [Quinine] in sample (in ppm) = ");
disp(mean_samples);
disp("SD [Quinine] in sample(in ppm) = ");
disp(sd_samples);
disp("RSD [Quinine] in sample (in %) = ");
disp(sd_samples/mean_samples*100);
In [123]:
mean_blank = mean(intensity_values(1:3));
sd_blank = std(intensity_values(1:3));
disp("Limits of Detection and Quantitation (in ppm) = ")
LOD = (3*sd_blank)/fit_params(2)
LOQ = (10*sd_blank)/fit_params(2)
[1] Lawson-Wood, Kathryn, and Kieran Evans. “Determination of Quinine in Tonic Water Using Fluorescence Spectroscopy,” (Application Note: Fluorescence Spectroscopy) Link