crikit.cri package

Subpackages

Submodules

crikit.cri.error_correction module

Created on Mon Jun 6 11:20:35 2016

@author: chc

class crikit.cri.error_correction.PhaseErrCorrectALS(wavenumber_increasing=True, smoothness_param=1, asym_param=0.01, redux=10, order=2, rng=None, fix_end_points=False, fix_rng=None, fix_const=1, max_iter=100, min_diff=1e-05, verbose=True, **kwargs)[source]

Bases: object

Phase error correction (PEC) using asymmetric least squares (ALS).

Parameters
  • wavenumber_increasing (bool, optional (default=True)) – Are the wavenumbers increasing from left-to-right? This setting should match the conjugate setting of the previously performed KramersKronig.

  • smoothness_param (float, optional (default=1.0)) – ALS smoothness parameter. See Ref [2].

  • asym_param (float, optional (default=1e-2)) – ALS asymmetry parameter. See Ref [2].

  • redux (int, optional (default=10)) – Factor to sub-sample each spectrum. This reduces computational burnden. Sub-sample phase error is then interpolated to match input signal length.

  • order (int, optional (default=2)) – ALS derivative order number. See Ref [2].

  • rng (array-like, optional (default=None)) – Only perform PEC on specific pixel range.

  • fix_end_points (bool, optional (default=False)) – Phase error at extrema points is equal to input phase extrema points.

  • fix_rng (array-like, optional (default=None)) – Phase error over given range is pushed to be equal to input phase. To prevent discontinuities, it is not enforced in an exact manner, but rather the algorithm is weighted to try to match.

  • fix_const (float, optional (default=1.)) – For fix_rng, this is the weighting term. Higher value will force the phase error to be more equal to the input.

  • max_iter (int, optional (default=100)) – Maximum number of ALS iterations

  • min_diff (float, optional (default=1e-5)) – Minimum difference between ALS phase error values. If difference is less than min_diff, considered static and iterations are ceased.

  • verbose (bool, optional (default=True)) – Verbose PEC output

Returns

Phase-error corrected signal from CARS.

Return type

ndarray

Notes

  • This module assumes the spectra are oriented as such that the frequency

    (wavenumber) increases with increasing index. If this is not the case for your spectra(um), set wavenumber_increasing=False.

  • The wavenumber_increasing setting should match that of the conjugate setting for the previously-performed KramersKronig.

References

[1] C. H. Camp Jr, Y. J. Lee, and M. T. Cicerone, “Quantitative, Comparable Coherent Anti-Stokes Raman Scattering (CARS) Spectroscopy: Correcting Errors in Phase Retrieval,” Journal of Raman Spectroscopy 47, 408-415 (2016). arXiv:1507.06543.

[2] P. H. C. Eilers and H. F. M. Boelens, “Baseline Correction with Asymmetric Least Squares Smoothing,” (2005).

calculate(data, **kwargs)[source]
transform(data, **kwargs)[source]
class crikit.cri.error_correction.ScaleErrCorrectSG(win_size=601, order=2, rng=None)[source]

Bases: object

Scale error correction using Savitky-Golay

References

  • C H Camp Jr, Y J Lee, and M T Cicerone, JRS (2016).

calculate(data)[source]
transform(data)[source]

crikit.cri.kk module

Kramers-Kronig relation phase retrieval.

References

[1] Y. Liu, Y. J. Lee, and M. T. Cicerone, “Broadband CARS spectral phase retrieval using a time-domain Kramers-Kronig transform,” Opt. Lett. 34, 1363-1365 (2009).

[2] C. H. Camp Jr, Y. J. Lee, and M. T. Cicerone, “Quantitative, Comparable Coherent Anti-Stokes Raman Scattering (CARS) Spectroscopy: Correcting Errors in Phase Retrieval,” Journal of Raman Spectroscopy 47, 408-415 (2016). arXiv:1507.06543.

class crikit.cri.kk.KramersKronig(cars_amp_offset=0.0, nrb_amp_offset=0.0, conjugate=False, phase_offset=0.0, norm_to_nrb=True, pad_factor=1, rng=None, n_edge=1, axis=- 1, bad_value=1e-08, min_value=None, hilb_kwargs={}, **kwargs)[source]

Bases: object

Retrieve the real and imaginary components of coherent Raman data via the Kramers-Kronig (KK) relation. See References.

Parameters
  • cars_amp_offset (float, optional (default=0.0)) – DC offset applied to CARS spectrum(a) prior to KK relation. See Notes and Ref. [2].

  • nrb_amp_offset (float, optional (default=0.0)) – DC offset applied to NRB spectrum(a) prior to KK relation. See Notes and Ref. [2].

  • conjugate (bool) – If spectra go from high-to-low-wavenumber (left-to-right), you should conjugate the KK output.

  • phase_offset (float or ndarray, optional (default=0.0)) – Phase constant or ndarray applied to retrieved phase prior to separating the real and imaginary components. See Notes and Ref. [2].

  • norm_to_nrb (bool, optional (default=True)) – Normalize the amplitude by sqrt(NRB). This effectively removes several system reponse functions. Highly recommended. See Ref. [2]

  • pad_factor (int, optional (default=1)) – Multiple size of spectral-length to pad the ends of each spectra with. Padded with a constant value corresponding to the value at that end of the spectrum. See Ref. [1].

  • rng (ndarray (1D), optional (default=None)) – Range of pixels/frequencies (if freq provided) to perform over

  • n_edge (int, optional) – For edge values, take a mean of n_edge neighbors

  • axis (int, optional) – Axis to perform over

  • min_value (float, optional) – Applies to cars/nrb (the ratio). Values below min_value set to min_value

  • bad_value (float, optional) – Applies to cars/nrb (the ratio). Inf’s and NaN’s set to bad_value

  • hilb_kwargs (dict) – kwargs sent to the hilbert transform. Only pad_factor, n_edge, and axis are automatically sent – these will overwrite anything in hilb_kwargs.

Returns

KK of cars

Return type

ndarray

Notes

  • This function does NOT overwrite input data

  • The imaginary components provides the sponatenous Raman-like spectra(um).

  • This module assumes the spectra are oriented as such that the frequency

    (wavenumber) increases with increasing index. If this is not the case for your spectra(um), apply a phase_offset of pi.

References

[1] Y. Liu, Y. J. Lee, and M. T. Cicerone, “Broadband CARS spectral phase retrieval using a time-domain Kramers-Kronig transform,” Opt. Lett. 34, 1363-1365 (2009).

[2] C. H. Camp Jr, Y. J. Lee, and M. T. Cicerone, “Quantitative, Comparable Coherent Anti-Stokes Raman Scattering (CARS) Spectroscopy: Correcting Errors in Phase Retrieval,” Journal of Raman Spectroscopy 47, 408-415 (2016). arXiv:1507.06543.

calculate(cars, nrb)[source]

cars : ndarray Coherent Raman signal.

nrbndarray

Nonresonant background (NRB)

property norm_to_nrb
property pad_factor
property phase_offset

Phase offset

crikit.cri.merge_nrbs module

Created on Wed Nov 2 11:04:43 2016

@author: chc

class crikit.cri.merge_nrbs.MergeNRBs(nrb_left, nrb_right, pix, left_side_scale=True)[source]

Bases: object

Merge two NRBs: a left-side and a right-side

calculate()[source]

Module contents