/// <summary> /// Constructor to create the chromophore spectrum /// </summary> /// <param name="wavelengths">A list of wavelengths</param> /// <param name="spectrum">A list of spectral values</param> /// <param name="name">The name of the chromophore absorber</param> /// <param name="coeffType">The chromophore coefficient type</param> /// <param name="absUnits">The absorption coefficient units</param> /// <param name="molarUnit">The molar units</param> /// <param name="wavelengthUnit">The wavelength units</param> public ChromophoreSpectrum(List <double> wavelengths, List <double> spectrum, string name, ChromophoreCoefficientType coeffType, AbsorptionCoefficientUnit absUnits, MolarUnit molarUnit, WavelengthUnit wavelengthUnit) { ChromophoreCoefficientType = coeffType; AbsorptionCoefficientUnit = absUnits; WavelengthUnit = wavelengthUnit; MolarUnit = molarUnit; Name = name; Spectrum = spectrum; Wavelengths = wavelengths; }
private ChromophoreSpectrum CreateChromophoreSpectrum() { string name = "Melanin"; AbsorptionCoefficientUnit muaUnit = AbsorptionCoefficientUnit.InverseMillimeters; MolarUnit molarUnit = MolarUnit.None; ChromophoreCoefficientType coeffType = ChromophoreCoefficientType.FractionalAbsorptionCoefficient; // populate list of wavelengths List <double> wavelengths = new List <double>(); wavelengths.Add(0.0); wavelengths.Add(1.0); wavelengths.Add(2.0); // populate list of values List <double> values = new List <double>(); values.Add(0.1); values.Add(1.1); values.Add(2.1); return(new ChromophoreSpectrum(wavelengths, values, name, coeffType, muaUnit, molarUnit, WavelengthUnit.Nanometers)); }
private ChromophoreSpectrumDictionary CreateDictionary() { string name = "Melanin"; AbsorptionCoefficientUnit muaUnit = AbsorptionCoefficientUnit.InverseMillimeters; MolarUnit molarUnit = MolarUnit.MicroMolar; ChromophoreCoefficientType coeffType = ChromophoreCoefficientType.FractionalAbsorptionCoefficient; // populate list of wavelengths List <double> wavelengths = new List <double>(); wavelengths.Add(0.0); wavelengths.Add(1.0); wavelengths.Add(2.0); // populate list of values List <double> values = new List <double>(); values.Add(0.1); values.Add(1.1); values.Add(2.1); ChromophoreSpectrum chromophoreSpectrum = new ChromophoreSpectrum(wavelengths, values, name, coeffType, muaUnit, molarUnit, WavelengthUnit.Nanometers); var testDictionary = new ChromophoreSpectrumDictionary(); testDictionary.Add(chromophoreSpectrum.Name, chromophoreSpectrum); name = "HbO2"; muaUnit = AbsorptionCoefficientUnit.InverseMillimeters; molarUnit = MolarUnit.MicroMolar; coeffType = ChromophoreCoefficientType.MolarAbsorptionCoefficient; chromophoreSpectrum = new ChromophoreSpectrum(wavelengths, values, name, coeffType, muaUnit, molarUnit, WavelengthUnit.Nanometers); testDictionary.Add(chromophoreSpectrum.Name, chromophoreSpectrum); return(testDictionary); }
/// <summary> /// Method to convert coefficient values /// </summary> /// <param name="CoefficientValue">The coefficient value to convert</param> /// <param name="Unit">An enum representing the units of the value to convert</param> /// <param name="MolarUnit">An enum to represent a molar based coefficient</param> /// <returns>The converted value as a double</returns> public static double ConvertCoefficient(this double CoefficientValue, AbsorptionCoefficientUnit Unit, MolarUnit MolarUnit) { double coeff; switch (Unit) { case AbsorptionCoefficientUnit.InverseMillimeters: default: coeff = CoefficientValue; break; case AbsorptionCoefficientUnit.InverseMeters: coeff = CoefficientValue / 1000; //10^3 break; case AbsorptionCoefficientUnit.InverseCentimeters: coeff = CoefficientValue / 10; break; case AbsorptionCoefficientUnit.InverseMicrometers: coeff = CoefficientValue * 1000; //10^3 break; } //molar coefficient applied switch (MolarUnit) { case MolarUnit.MicroMolar: default: return(coeff); case MolarUnit.MilliMolar: return(coeff / 1000); //10^3 case MolarUnit.Molar: return(coeff / 1000000); //10^6 case MolarUnit.NanoMolar: return(coeff * 1000); } }
/// <summary> /// Passes the molar unit enum and the absorption coefficient unit enum and returns it as a string /// </summary> /// <param name="molarUnit">The molar unit enum</param> /// <param name="absorptionCoefficientUnit">an absorption coefficient enum</param> /// <returns>A string representing the molar units</returns> public static string getSpectralUnit(MolarUnit molarUnit, AbsorptionCoefficientUnit absorptionCoefficientUnit) { string mU; string aCU; string sU; switch (molarUnit) { case MolarUnit.None: mU = ""; break; case MolarUnit.Molar: mU = "M"; break; case MolarUnit.MilliMolar: mU = "mM"; break; case MolarUnit.MicroMolar: mU = "uM"; break; case MolarUnit.NanoMolar: mU = "nM"; break; default: throw new Exception("Unknown molar unit"); } switch (absorptionCoefficientUnit) { case AbsorptionCoefficientUnit.InverseCentimeters: aCU = "cm"; break; case AbsorptionCoefficientUnit.InverseMeters: aCU = "m"; break; case AbsorptionCoefficientUnit.InverseMicrometers: aCU = "um"; break; case AbsorptionCoefficientUnit.InverseMillimeters: aCU = "mm"; break; default: throw new Exception("Unknown absorption coefficient unit"); } if (molarUnit == MolarUnit.None) { sU = "1/" + aCU; } else { sU = "1/(" + aCU + "*" + mU + ")"; } return(sU); }
/// <summary> /// Constructor to create the chromophore spectrum starting with empty lists /// </summary> /// <param name="name">The name of the chromophore absorber</param> /// <param name="coeffType">The chromophore coefficient type</param> /// <param name="absUnits">The absorption coefficient units</param> /// <param name="molarUnit">The molar units</param> /// <param name="wavelengthUnit">The wavelength units</param> public ChromophoreSpectrum(string name, ChromophoreCoefficientType coeffType, AbsorptionCoefficientUnit absUnits, MolarUnit molarUnit, WavelengthUnit wavelengthUnit) : this(new List <double>(), new List <double>(), name, coeffType, absUnits, molarUnit, wavelengthUnit) { }