Synthetic data
Synthetic spectra
- ramanspy.synth.generate_spectra(num_spectra, n_bands, *, realistic=False, spectral_axis=None, seed=None)[source]
Generate synthetic spectra.
- Parameters:
num_spectra (int) – The number of spectra to generate.
n_bands (int) – The number of bands to generate.
realistic (bool, optional) – Whether to generate ‘more realistic’ spectra by adding smaller noise peaks.
spectral_axis (array_like, optional) – The spectral axis to use for the spectra. Should match the number of bands.
seed (int, optional) – The seed to use for the random number generator.
- Returns:
spectra – The generated spectra.
- Return type:
list[ramanspy.Spectrum]
Examples
import ramanspy as rp # Generate synthetic spectra spectra = rp.synth.generate_spectra(5, 100, realistic=True) rp.plot.spectra(spectra) rp.plot.show()
References
Georgiev, D., Fernández-Galiana, A., Pedersen, S.V., Papadopoulos, G., Xie, R., Stevens, M.M. and Barahona, M., 2024. Hyperspectral unmixing for Raman spectroscopy via physics-constrained autoencoders. arXiv preprint arXiv:2403.04526.
Synthetic fractional abundance scenes
- ramanspy.synth.generate_abundance_scene(size, num_endmembers, scene_type, *, seed=None)[source]
- Parameters:
size (int) – The size of the abundance scene. Assumes a square scene (i.e. size x size).
num_endmembers (int) – The number of endmembers to use.
scene_type ({'chessboard', 'gaussian', 'dirichlet'}) – The type of scene to generate.
seed (int, optional) – The seed to use for the random number generator.
- Returns:
image – The generated abundance image.
- Return type:
array_like, shape (size, size, num_endmembers)
References
Georgiev, D., Fernández-Galiana, A., Pedersen, S.V., Papadopoulos, G., Xie, R., Stevens, M.M. and Barahona, M., 2024. Hyperspectral unmixing for Raman spectroscopy via physics-constrained autoencoders. arXiv preprint arXiv:2403.04526.
Synthetic mixtures
- ramanspy.synth.mix(endmembers, abundances, *, mixture_mode='linear', noise=False, noise_amplitude=0.1, baseline=False, baseline_amplitude=2, baseline_probability=0.25, cosmic_spikes=False, cosmic_spike_amplitude=5, cosmic_spikes_probability=0.1, seed=None)[source]
Create mixtures based on the given endmembers and abundances.
- Parameters:
endmembers (list[Spectrum]) – The underlying endmembers to mix.
abundances (array_like) – The underlying fractional abundance scene.
mixture_mode ({'linear', 'nonlinear'}, optional) – The mixing mode to use. Default is ‘linear’.
noise (bool, optional) – Whether to add noise to the image. Default is False.
noise_amplitude (float, optional) – The amplitude of the noise to add. Default is 0.1.
baseline (bool, optional) – Whether to add a baseline to the image. Default is False.
baseline_amplitude (float, optional) – The amplitude of the baseline to add. Default is 2.
baseline_probability (float, optional) – The probability of adding a baseline to a pixel. Default is 0.25.
cosmic_spikes (bool, optional) – Whether to add cosmic spikes to the image. Default is False.
cosmic_spike_amplitude (float, optional) – The amplitude of the cosmic spikes to add. Default is 5.
cosmic_spikes_probability (float, optional) – The probability of adding a cosmic spike to a pixel. Default is 0.1.
seed (int, optional) – The seed to use for the random number generator.
- Returns:
mixtures – The mixed spectra.
- Return type:
array_like
References
Georgiev, D., Fernández-Galiana, A., Pedersen, S.V., Papadopoulos, G., Xie, R., Stevens, M.M. and Barahona, M., 2024. Hyperspectral unmixing for Raman spectroscopy via physics-constrained autoencoders. arXiv preprint arXiv:2403.04526.
Synthetic mixture datasets
- ramanspy.synth.generate_mixture_image(num_endmembers, num_spectral_bands, image_size, image_type, *, mixture_mode='linear', realistic_endmembers=False, noise=False, noise_amplitude=0.1, baseline=False, baseline_amplitude=2, baseline_probability=0.25, cosmic_spikes=False, cosmic_spike_amplitude=5, cosmic_spikes_probability=0.1, seed=None)[source]
Generate a synthetic image dataset.
- Parameters:
num_endmembers (int) – The number of endmembers to use.
num_spectral_bands (int) – The number of spectral bands to use.
image_size (int) – The size of the image to generate. Assumes a square image.
image_type ({'chessboard', 'gaussian', 'dirichlet'}) – The type of image to generate.
mixture_mode ({'linear', 'bilinear'}, optional) – The type of mixture to generate. Default is ‘linear’.
realistic_endmembers (bool, optional) – Whether to use realistic endmembers. Default is False.
noise (bool, optional) – Whether to add noise to the image. Default is False.
noise_amplitude (float, optional) – The amplitude of the noise to add. Default is 0.1.
baseline (bool, optional) – Whether to add a baseline to the image. Default is False.
baseline_amplitude (float, optional) – The amplitude of the baseline to add. Default is 2.
baseline_probability (float, optional) – The probability of adding a baseline to a pixel. Default is 0.25.
cosmic_spikes (bool, optional) – Whether to add cosmic spikes to the image. Default is False.
cosmic_spike_amplitude (float, optional) – The amplitude of the cosmic spikes to add. Default is 5.
cosmic_spikes_probability (float, optional) – The probability of adding a cosmic spike to a pixel. Default is 0.1.
seed (int, optional) – The seed to use for the random number generator.
- Returns:
mixture (SpectralImage) – The generated mixture.
endmembers (list[Spectrum]) – The generated endmembers.
abundance_image (array_like, shape (image_size, image_size, num_endmembers)) – The generated abundance image.
Examples
import ramanspy as rp # Generate synthetic data mixture, endmebers, abundance_image = rp.synth.generate_image_dataset(5, 1000, 100, 'chessboard', mixture_mode='linear')
References
Georgiev, D., Fernández-Galiana, A., Pedersen, S.V., Papadopoulos, G., Xie, R., Stevens, M.M. and Barahona, M., 2024. Hyperspectral unmixing for Raman spectroscopy via physics-constrained autoencoders. arXiv preprint arXiv:2403.04526.