Label-free biochemical imaging and time point analysis of neural organoids via deep learning-enhanced Raman microspectroscopy.
The 7 matches
- [1] § MATERIALS AND METHODS › Spectral preprocessing of Raman imaging data ↔ colab/Deep_learning_enhanced_Raman_microspectroscopy.ipynb, lines 244–291 · score 0.91 · global vector normalization, cosmic rays, baseline correction, Hayes, Whitaker, Whittaker
- [2] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ colab/Deep_learning_enhanced_Raman_microspectroscopy.ipynb, lines 513–585 · score 0.77 · Batch normalization, ReLU, dropout, rectified, filters, blocks
- [3] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ src/autoencoder.py, lines 34–111 · score 0.77 · Batch normalization, ReLU, dropout, rectified, filters, blocks
- [4] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ analyse.py, lines 11–48 · score 0.73 · training epochs, training loss, learning rate decay, Adam, MSE, SAD
- [5] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ colab/Deep_learning_enhanced_Raman_microspectroscopy.ipynb, lines 513–585 · score 0.72 · linear decoder layer, kernel constraint, activation, encoded, bias, weight
- [6] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ src/autoencoder.py, lines 34–111 · score 0.71 · linear decoder layer, kernel constraint, activation, encoded, bias, weight
- [7] § MATERIALS AND METHODS › Hyperspectral unmixing analysis ↔ src/autoencoder.py, lines 114–177 · score 0.60 · learning rate decay, exponential, Adam, epochs, SAD, optimizer
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 768 lines · 27 KB · Apache-2.0 · 3 matches
- # %% [markdown]
- # # 🔬 Deep Learning-Enhanced Raman Microspectroscopy
- #
- # ---
- #
- # ## ✨ Welcome
- #
- # This notebook provides an interactive version of the Raman imaging pipeline described in [Georgiev et al., Science Advances, 2026](https://doi.org/10.1126/sciadv.aec5080).
- #
- # ⚡ **Purpose:** Extract chemical components and their spatial maps from hyperspectral Raman imaging data.
- #
- # 💡 **How:** Using blind, unsupervised hyperspectral unmixing via physics-constrained autoencoder neural networks.
- #
- # ⚠️ **Note:** Uploading large files in Google Colab can be slow and unreliable. For large datasets (e.g. >500 MB-1 GB), we recommend running the pipeline locally using the provided GUI/CLI tools. See our [GitHub page](https://github.com/barahona-research-group/dl-raman) for more information.
- #
- # ---
- # ## ⚙️ Workflow
- #
- # This notebook guides you through the full analysis workflow:
- #
- # 1. Upload Raman imaging data
- # 2. Preprocess the spectra
- # 3. Run PCA to guide the selection of the number of endmembers
- # 4. Unmix the data into chemical components and abundance maps
- # 5. Save figures, results and metadata
- #
- # ---
- #
- # ## 📚 Related Publications
- #
- # This notebook provides an implementation of the analysis pipeline described in:
- #
- # > 📌 **Label-free biochemical imaging and timepoint analysis of neural organoids via deep learning-enhanced Raman microspectroscopy.**
- # > Dimitar Georgiev, Ruoxiao Xie, Daniel Reumann, Xiaoyu Zhao, Álvaro Fernández-Galiana, Mauricio Barahona, Molly M. Stevens.
- # > Science Advances, 12(33), eaec5080, 2026.
- # > https://doi.org/10.1126/sciadv.aec5080
- #
- # This work builds upon our previous research:
- #
- # > 📌 **Hyperspectral unmixing for Raman spectroscopy via physics-constrained autoencoders.**
- # > Dimitar Georgiev, Álvaro Fernández-Galiana, Simon Vilms Pedersen, Georgios Papadopoulos, Ruoxiao Xie, Molly M. Stevens, Mauricio Barahona.
- # > PNAS, 121(45), p.e2407439121, 2024.
- # > https://doi.org/10.1073/pnas.2407439121
- #
- # > 📌 **RamanSPy: An open-source Python package for integrative Raman spectroscopy data analysis.**
- # > Dimitar Georgiev, Simon Vilms Pedersen, Ruoxiao Xie, Álvaro Fernández-Galiana, Molly M. Stevens, Mauricio Barahona.
- # > Analytical Chemistry, 96(21), pp.8492-8500, 2024.
- # > https://doi.org/10.1021/acs.analchem.4c00383
- #
- # ⚠️ **If you use this notebook in your research, please cite our work.**
- # %%
- #@title **Install & Import Dependencies**
- #@markdown ---
- #@markdown Click the play button ▶️ to install and import relevant packages.
- import os
- import sys
- import glob
- import pickle
- import tifffile
- from google.colab import files
- import io
- from datetime import datetime
- import random
- import matplotlib.pyplot as plt
- import numpy as np
- from sklearn.decomposition import PCA
- import tensorflow as tf
- from IPython.display import clear_output
- !pip install ramanspy
- import ramanspy as rp
- os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
- os.environ['TF_DETERMINISTIC_OPS'] = '1'
- os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8'
- tf.config.experimental.enable_op_determinism()
- def set_seed(seed=None):
- # Set seeds for reproducibility
- os.environ['PYTHONHASHSEED'] = str(seed)
- random.seed(seed)
- np.random.seed(seed)
- tf.random.set_seed(seed)
- tf.keras.utils.set_random_seed(seed)
- def save_rp_object(spectral_container, caption, *, folder=None):
- if folder is not None:
- os.makedirs(folder, exist_ok=True)
- caption = os.path.join(folder, caption)
- spectral_container.save(f'{caption}_rp_spectral_container.pkl')
- np.save(f'{caption}_spectral_data.npy', spectral_container.spectral_data)
- if spectral_container.spectral_data.ndim >= 2:
- spectral_data = np.moveaxis(np.copy(spectral_container.spectral_data), -1, 0)
- spectral_data = np.moveaxis(spectral_data, -1, 0) if len(spectral_data.shape) > 3 else spectral_data # TZCYX order
- tifffile.imwrite(f'{caption}_spectral_data.tiff', spectral_data)
- np.savetxt(f'{caption}_spectral_axis.txt', spectral_container.spectral_axis)
- clear_output()
- print("✅ Packages installed successfully.")
- # %%
- #@title **Experiment setup**
- #@markdown General settings
- #@markdown ---
- experiment_name = "experiment" #@param {type:"string"}
- seed = 42 #@param {type:"number"}
- # Generate timestamp
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
- # Build folder name
- save_folder = f"{experiment_name}_{timestamp}"
- # Create directory
- os.makedirs(save_folder, exist_ok=True)
- print(f"✅ Results will be saved in: `{save_folder}/`")
- # %%
- #@title **Upload Raman imaging data and optional reference spectra** (.pkl, .mat, .wdf)
- #@markdown ---
- #@markdown Click the play button ▶️ to open the upload dialog.
- #@markdown
- #@markdown **Supported formats:**
- #@markdown - `.pkl`: `Spectrum`, `SpectralContainer`, `SpectralImage`, or `SpectralVolume` exported from RamanSPy
- #@markdown - `.mat`: WITec MATLAB export
- #@markdown - `.wdf`: Renishaw WiRE export
- #@markdown
- #@markdown At least one uploaded file must be Raman imaging data. Optional reference spectra are included in preprocessing and unmixing, but spatial abundance-map outputs are skipped for non-imaging inputs.
- #@markdown
- #@markdown ✅ Multiple files can be analyzed together in batch mode.
- #@markdown
- #@markdown ---
- #@markdown ⚠️ **Note:** Uploading large files in Google Colab can be slow and unreliable.
- #@markdown For large datasets (e.g. >500 MB-1 GB), we recommend running the pipeline locally using the local GUI or command-line interface provided on our [GitHub page](https://github.com/barahona-research-group/dl-raman).
- def _is_imaging_object(spectral_obj):
- return len(spectral_obj.spectral_data.shape) in [3, 4]
- def _as_2d_spectral_data(data):
- data = np.asarray(data)
- if data.ndim == 1:
- return data.reshape(1, -1)
- return data
- def _validate_raman_object(spectral_obj, filename):
- data_shape = spectral_obj.spectral_data.shape
- if len(data_shape) not in [1, 2, 3, 4]:
- raise ValueError(
- f"{filename} is not a supported Raman dataset. Expected shape "
- "(wavenumbers), (spectra, wavenumbers), "
- "(x, y, wavenumbers), or (x, y, z, wavenumbers), "
- f"but found {data_shape}."
- )
- uploaded = files.upload()
- assert uploaded, "No file uploaded."
- uploaded_filenames = list(uploaded.keys())
- print(f"✅ {len(uploaded_filenames)} file(s) uploaded.")
- spectral_objects = []
- spectral_object_names = []
- raw_data_folder = os.path.join(save_folder, 'Raw data')
- os.makedirs(raw_data_folder, exist_ok=True)
- for filename in uploaded_filenames:
- print(f"\n📁 Parsing: {filename}")
- ext = os.path.splitext(filename)[1].lower()
- # Save file to disk
- scan_folder = os.path.join(raw_data_folder, os.path.splitext(filename)[0])
- os.makedirs(scan_folder, exist_ok=True)
- with open(os.path.join(scan_folder, filename), 'wb') as f:
- f.write(uploaded[filename])
- # Load depending on extension
- if ext == ".pkl":
- spectral_obj = rp.SpectralContainer.load(filename)
- elif ext == ".mat":
- spectral_obj = rp.load.witec(filename)
- elif ext == ".wdf":
- if hasattr(rp.load, 'renishaw'):
- spectral_obj = rp.load.renishaw(filename)
- elif hasattr(rp.load, 'wdf'):
- spectral_obj = rp.load.wdf(filename)
- else:
- raise RuntimeError("Loading .wdf files requires a RamanSPy version with a Renishaw/WDF loader.")
- else:
- print(f"⚠️ Skipping unsupported file: {filename}")
- continue
- _validate_raman_object(spectral_obj, filename)
- # Store object
- spectral_objects.append(spectral_obj)
- spectral_object_names.append(filename)
- input_type = "imaging" if _is_imaging_object(spectral_obj) else "reference/non-imaging"
- # Display info
- print(f" ✅ Shape: {spectral_obj.shape}")
- print(f" Type: {input_type}")
- print(f" Wavenumber axis length: {len(spectral_obj.spectral_axis)}")
- # Save parsed object
- save_rp_object(
- spectral_obj,
- caption='raw',
- folder=scan_folder
- )
- assert spectral_objects, "No supported Raman datasets were loaded."
- assert any(_is_imaging_object(obj) for obj in spectral_objects), "At least one Raman image or volume is required. Reference spectra can be included alongside imaging data, but cannot be the only inputs."
- print(f"\n💾 All parsed spectral objects saved in: `{raw_data_folder}/`")
- print(f"📦 Total spectral datasets loaded: {len(spectral_objects)}")
- print(f"🖼️ Imaging datasets: {sum(_is_imaging_object(obj) for obj in spectral_objects)}")
- print(f"📈 Reference/non-imaging datasets: {sum(not _is_imaging_object(obj) for obj in spectral_objects)}")
- print("ℹ️ Run the preprocessing cell before PCA and unmixing.")
- # %%
- #@title **Spectral preprocessing**
- #@title 🧹 **Spectral preprocessing**
- #@markdown ---
- #@markdown This cell performs a standard Raman spectral preprocessing pipeline consisting of the following steps:
- #@markdown
- #@markdown 1. **Cropping** – trims the spectral axis to remove low-wavenumber noise (starting from 300 cm⁻¹).
- #@markdown 2. **Despiking** – removes cosmic ray spikes using the Whitaker-Hayes filter.
- #@markdown 3. **Denoising** – smooths the spectra using Whittaker smoothing (λ=1e3, d=3).
- #@markdown 4. **Baseline Correction** – removes fluorescence/background using ASLS (λ=1e5).
- #@markdown 5. **Normalization** – normalizes spectra using vector normalization (global, not pixelwise).
- #@markdown
- #@markdown ✏️ *To customize preprocessing, click on `Show code` and modify the `PREPROCESSING_PIPELINE` object below.*
- #@markdown
- #@markdown ℹ️ The processed data will be saved in the `Preprocessed data/` subfolder of your run directory.
- PREPROCESSING_PIPELINE = rp.preprocessing.Pipeline([
- rp.preprocessing.misc.Cropper(region=(300, None)), # 1. Crop low-wavenumber region
- rp.preprocessing.despike.WhitakerHayes(kernel_size=3, threshold=6), # 2. Despike
- rp.preprocessing.denoise.Whittaker(lam=1e3, d=3), # 3. Denoise
- rp.preprocessing.baseline.ASLS(lam=1e5), # 4. Baseline correction
- rp.preprocessing.normalise.Vector(pixelwise=False) # 5. Global vector normalization
- ])
- print("🧹 Preprocessing starting...")
- set_seed(seed) # Ensures reproducibility
- preprocessed_spectral_objs = PREPROCESSING_PIPELINE.apply(spectral_objects)
- preprocessed_spectral_axis = preprocessed_spectral_objs[0].spectral_axis
- print("✅ Preprocessing complete.")
- # Save results
- preprocessed_data_folder = os.path.join(save_folder, 'Preprocessed data')
- os.makedirs(preprocessed_data_folder, exist_ok=True)
- # Save updated objects
- for filename, spectral_obj in zip(spectral_object_names, preprocessed_spectral_objs):
- save_rp_object(
- spectral_obj,
- caption=f'preprocessed',
- folder=os.path.join(preprocessed_data_folder, os.path.splitext(filename)[0])
- )
- print(f"💾 Preprocessed data saved in: `{preprocessed_data_folder}/`")
- # %%
- #@title **PCA plot**
- def pca_explained_variance_plot(data, n_components=None, save_path=None, show_plot=True):
- """
- Performs PCA on a 2D data matrix and produces an explained variance plot.
- Parameters
- ----------
- data : array-like, shape (n_samples, n_features)
- Input data matrix where rows correspond to samples and columns to features.
- n_components : int or None, optional (default=None)
- Number of principal components to compute. If None or larger than the number of features,
- all components are computed.
- save_path : str or None, optional (default=None)
- File path where the plot image will be saved (e.g., 'fig1.png'). If None, the plot is not saved.
- show_plot : bool, optional (default=True)
- If True, displays the plot. If False, the figure is closed after saving.
- Returns
- -------
- pca : sklearn.decomposition.PCA object
- The fitted PCA object.
- explained_variance_ratio : ndarray, shape (n_components,)
- Percentage of variance explained by each selected principal component.
- """
- # Determine the number of components to use
- n_samples, n_features = data.shape
- max_components = min(n_samples, n_features)
- if n_components is None or n_components > max_components:
- n_components = max_components
- # Perform PCA (assuming the data is already centered/scaled as needed)
- pca = PCA(n_components=n_components)
- pca.fit(data)
- explained_variance_ratio = pca.explained_variance_ratio_
- # Create the plot
- fig, ax = plt.subplots(figsize=(12, 6))
- components = np.arange(1, n_components + 1)
- variance_percentage = explained_variance_ratio * 100 # Convert to percentage
- # Create a bar plot for the explained variance
- bars = ax.bar(components, variance_percentage, color='skyblue', edgecolor='black')
- # Set axes labels and title with appropriate font sizes and padding
- ax.set_xlabel('Principal Component', fontsize=16)
- ax.set_ylabel('Explained Variance (%)', fontsize=16)
- ax.set_title('Explained Variance by Principal Component', fontsize=18, pad=15)
- ax.set_xticks(components)
- ax.set_ylim(0, variance_percentage.max() * 1.1) # Add some headroom above the highest bar
- # Optionally annotate each bar with its percentage value
- for comp, var in zip(components, variance_percentage):
- ax.text(comp, var + variance_percentage.max() * 0.01, f"{var:.2f}%",
- ha='center', va='bottom', fontsize=8)
- plt.tight_layout()
- # Save the plot if a save path is provided
- if save_path:
- plt.savefig(save_path, dpi=300, bbox_inches='tight')
- # Show or close the plot based on the user's preference
- if show_plot:
- plt.show()
- else:
- plt.close(fig)
- return pca, explained_variance_ratio
- analysis_data_folder = os.path.join(save_folder, 'Analysis data')
- os.makedirs(analysis_data_folder, exist_ok=True)
- assert 'preprocessed_spectral_objs' in globals(), "Run the spectral preprocessing cell before PCA."
- spectral_data = np.vstack([_as_2d_spectral_data(s.flat.spectral_data) for s in preprocessed_spectral_objs])
- _ = pca_explained_variance_plot(spectral_data, n_components=20, save_path=os.path.join(analysis_data_folder, 'pca_plot.png'))
- # %%
- #@title **Hyperspectral unmixing analysis**
- #@markdown ---
- #@markdown Unmixing settings
- #@markdown ---
- num_endmembers = 10 #@param {type:"number"}
- vca_init = True #@param {type:"boolean"}
- #@markdown ---
- #@markdown Model training settings
- #@markdown ---
- loss = "MSE_SAD" # @param ["MSE", "SAD", "MSE_SAD"]
- epochs = 5 #@param {type:"number"}
- learning_rate = 0.001 #@param {type:"number"}
- batch_size = 32 #@param {type:"number"}
- #@markdown ---
- #@markdown Advanced settings
- #@markdown ---
- verbose = 1 #@param {type:"number"}
- use_bias = False #@param {type:"boolean"}
- learning_rate_decay = True #@param {type:"boolean"}
- assert 'preprocessed_spectral_objs' in globals(), "Run the spectral preprocessing cell before unmixing."
- analysis_data_folder = os.path.join(save_folder, 'Analysis data')
- os.makedirs(analysis_data_folder, exist_ok=True)
- # Pack into a dictionary
- experiment_params = {
- "num_endmembers": num_endmembers,
- "vca_init": vca_init,
- "loss": loss,
- "epochs": epochs,
- "learning_rate": learning_rate,
- "batch_size": batch_size,
- "verbose": verbose,
- "use_bias": use_bias,
- "learning_rate_decay": learning_rate_decay,
- "seed": seed
- }
- # Save to JSON inside the timestamped save folder
- import json
- params_path = os.path.join(analysis_data_folder, "params.json")
- with open(params_path, 'w') as f:
- json.dump(experiment_params, f, indent=2)
- print(f"✅ Parameters saved to: `{params_path}`")
- def save_results(abundance_maps, endmembers, x_axis, *, save_to):
- os.makedirs(save_to, exist_ok=True)
- # save x-axis
- np.savetxt(os.path.join(save_to, 'wavenumber_axis.txt'), x_axis)
- # save endmembers
- np.savetxt(os.path.join(save_to, 'endmembers.txt'), endmembers)
- # save abundances
- abundance_array = np.array(abundance_maps)
- abundance_array = np.moveaxis(abundance_array, -1, 0) if len(abundance_array.shape) > 3 else abundance_array # TZCYX order
- tifffile.imwrite(os.path.join(save_to, 'abundances.tiff'), abundance_array)
- def save_plots(abundance_maps, endmembers, spectral_axis, *, cmap='gray', save_to=None, plot=True):
- endmember_array = [rp.Spectrum(endmember, spectral_axis) for endmember in endmembers]
- # Plot the endmembers
- plt.figure(figsize=(8, 4))
- ax = rp.plot.spectra(endmember_array, title='Endmembers', color='gray', plot_type='single stacked')
- if save_to is not None:
- ax.get_figure().savefig(os.path.join(save_to, 'endmembers.png'), dpi=600)
- if plot is True:
- plt.show()
- else:
- plt.close()
- abundance_array = np.array(abundance_maps)
- if len(abundance_array.shape) == 3:
- abundance_array = abundance_array[..., np.newaxis]
- # Plot the abundance maps
- fig, axs = plt.subplots(abundance_array.shape[-1], len(endmember_array), figsize=(1.75 * len(endmember_array), 2*abundance_array.shape[-1]), sharey=True)
- for j in range(abundance_array.shape[-1]):
- if abundance_array.shape[-1] == 1:
- axs = [axs]
- for i, ax in enumerate(axs[j]):
- ax.imshow(abundance_array[i, :, :, j], cmap=cmap)
- ax.set_axis_off()
- if save_to is not None:
- os.makedirs(save_to, exist_ok=True)
- fig.savefig(os.path.join(save_to, 'abundances.png'), dpi=600)
- plt.show()
- def _soft_rectified_tanh(x, gamma=10.0):
- return (1 / gamma) * tf.math.log(1 + tf.math.exp(gamma * tf.keras.activations.tanh(x)))
- cos = tf.losses.CosineSimilarity()
- mse = tf.losses.MeanSquaredError()
- def SAD(y_true, y_pred):
- sad_loss = tf.math.acos(-1*cos(y_true, y_pred))
- return sad_loss
- def MSE_SAD(beta1=0.5, beta2=1):
- def mse_sad(y_true, y_pred):
- mse_loss = mse(y_true, y_pred)
- sad_loss = tf.math.acos(-1*cos(y_true, y_pred))
- return beta1*mse_loss + beta2*sad_loss
- return mse_sad
- loss_dict = {
- 'MSE': mse,
- 'SAD': SAD,
- 'MSE_SAD': MSE_SAD(beta1=1e4, beta2=1)
- }
- loss = loss_dict[loss]
- class ConvUnmixingAEModel(tf.keras.Model):
- def __init__(self, input_dim, bottleneck_dim, use_bias):
- super(ConvUnmixingAEModel, self).__init__()
- kernel_sizes=[5, 10, 15, 20]
- num_filters=[32, 32, 32, 32]
- encoder_hidden_dims=[256, 128, 64, 32]
- # ENCODER
- self.conv_layers = []
- for kernel_size, num_filter in zip(kernel_sizes, num_filters):
- conv_block = tf.keras.models.Sequential([
- tf.keras.layers.Conv1D(num_filter, kernel_size=kernel_size, padding='same', activation='relu', kernel_initializer=tf.keras.initializers.HeNormal()),
- tf.keras.layers.BatchNormalization(),
- tf.keras.layers.Dropout(0.2)
- ])
- self.conv_layers.append(conv_block)
- self.concat = tf.keras.layers.Concatenate(axis=-1)
- self.linear_dim_reduce = tf.keras.layers.Dense(1)
- # ENCODER
- self.ffn_layers = tf.keras.models.Sequential()
- for dim in encoder_hidden_dims:
- self.ffn_layers.add(tf.keras.layers.Dense(dim, activation='relu', kernel_initializer=tf.keras.initializers.HeNormal()))
- self.ffn_layers.add(tf.keras.layers.BatchNormalization())
- self.ffn_layers.add(tf.keras.layers.Dropout(0.5))
- self.bottleneck_layer = tf.keras.layers.Dense(bottleneck_dim, activation=_soft_rectified_tanh)
- # DECODER
- self.linear_decoder_layer = tf.keras.layers.Dense(input_dim, activation='linear', kernel_constraint=tf.keras.constraints.NonNeg(), use_bias=use_bias)
- def _encode(self, input_x):
- x = tf.expand_dims(input_x, axis=-1)
- conv_outputs = []
- for conv_layer in self.conv_layers:
- conv_outputs.append(conv_layer(x))
- x = self.concat(conv_outputs)
- x = self.linear_dim_reduce(x)
- x = tf.squeeze(x, axis=-1)
- x = self.ffn_layers(x)
- x = self.bottleneck_layer(x)
- return x
- def predict_abundances(self, data):
- return self._encode(data)
- def _initialize_endmembers(self, endmembers):
- endmembers = np.array(endmembers)
- self.linear_decoder_layer.build(input_shape=(None, endmembers.shape[0]))
- weigths = [endmembers, self.linear_decoder_layer.get_weights()[1]] if len(self.linear_decoder_layer.get_weights())>1 else [endmembers]
- self.linear_decoder_layer.set_weights(weigths)
- def predict_endmembers(self):
- return self.linear_decoder_layer.trainable_variables[0].numpy()
- def _decode(self, x):
- return self.linear_decoder_layer(x)
- def call(self, x):
- z = self._encode(x)
- x_hat = self._decode(z)
- return x_hat
- class ConvUnmixingAE:
- def apply(self, raman_objects, *, num_endmembers, use_bias=False, loss=SAD, batch_size=32, epochs=5, vca_init=False, seed=None, learning_rate=0.001, learning_rate_decay=False, verbose=0, return_endmember_init=False):
- if not isinstance(raman_objects, list):
- raman_objects = [raman_objects]
- flat_spectral_data = [_as_2d_spectral_data(v.flat.spectral_data) for v in raman_objects]
- spectral_data_concat = np.concatenate(flat_spectral_data)
- input_dim = len(raman_objects[0].spectral_axis)
- set_seed(seed)
- # create the model
- model = ConvUnmixingAEModel(input_dim, num_endmembers, use_bias=use_bias)
- if learning_rate_decay:
- steps_per_epoch = len(spectral_data_concat) / batch_size
- decay_epochs = 1
- learning_rate = tf.keras.optimizers.schedules.ExponentialDecay(
- initial_learning_rate=learning_rate,
- decay_steps=steps_per_epoch * decay_epochs,
- decay_rate=0.9,
- staircase=True
- )
- model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=learning_rate), loss=loss)
- if vca_init:
- endmember_init = _vca(spectral_data_concat, num_endmembers)
- model._initialize_endmembers(endmember_init)
- # fit the model
- model.fit(spectral_data_concat, spectral_data_concat, epochs=epochs, verbose=verbose, batch_size=batch_size, shuffle=True)
- # model.summary()
- # get endmembers
- endmembers = model.predict_endmembers()
- # get abundances
- abundance_maps = []
- for scan, flat_data in zip(raman_objects, flat_spectral_data):
- spectral_dataset = tf.data.Dataset.from_tensor_slices(flat_data).batch(batch_size)
- predictions = []
- for batch in spectral_dataset:
- batch_predictions = model.predict_abundances(batch)
- predictions.append(batch_predictions)
- # If needed, concatenate the predictions into one array
- predictions = np.concatenate(predictions, axis=0)
- abundances = predictions.reshape(list(scan.shape) + [-1])
- # move channels to the last axis to comply with ramanspy unmixing
- abundances = np.moveaxis(abundances, -1, 0)
- abundance_maps.append(abundances)
- if return_endmember_init:
- return abundance_maps, endmembers, endmember_init
- return abundance_maps, endmembers
- def _vca(data, n_endmembers, *, snr_input=0):
- """
- Copyright 2018 Adrien Lagrange
- Licensed under the Apache License, Version 2.0.
- Source code available at: https://github.com/Laadr/VCA
- Changes:
- - sp -> np;
- - removed comments;
- - removed semicolons at the end of lines;
- - removed verbose option and print statements;
- - renamed some variables;
- - only return endmembers;
- """
- import scipy.linalg as splin
- # Transpose data to comply with code
- data = data.T
- N = data.shape[1]
- # Estimate SNR
- # ------------
- if snr_input == 0:
- data_mean = np.mean(data, axis=1, keepdims=True)
- data_centered = data - data_mean # data with zero-mean
- Ud = splin.svd(np.dot(data_centered, data_centered.T) / float(N))[0][:, :n_endmembers]
- x_p = np.dot(Ud.T, data_centered)
- P_y = np.sum(data ** 2) / float(N)
- P_x = np.sum(x_p ** 2) / float(N) + np.sum(data_mean ** 2)
- SNR = 10 * np.log10((P_x - n_endmembers / data.shape[0] * P_y) / (P_y - P_x))
- else:
- SNR = snr_input
- SNR_th = 15 + 10 * np.log10(n_endmembers)
- # Projection to n_endmembers-1 subspace if SNR < SNR_th; else, no projective projection
- # -------------------------------------------------------------------------------------
- if SNR < SNR_th:
- d = n_endmembers - 1
- if snr_input == 0:
- Ud = Ud[:, :d]
- else:
- data_mean = np.mean(data, axis=1, keepdims=True)
- data_centered = data - data_mean
- Ud = splin.svd(np.dot(data_centered, data_centered.T) / float(N))[0][:, :d] # computes the p-projection matrix
- x_p = np.dot(Ud.T, data_centered)
- Yp = np.dot(Ud, x_p[:d, :]) + data_mean
- x = x_p[:d, :]
- c = np.amax(np.sum(x ** 2, axis=0)) ** 0.5
- y = np.vstack((x, c * np.ones((1, N))))
- else:
- d = n_endmembers
- Ud = splin.svd(np.dot(data, data.T) / float(N))[0][:, :d]
- x_p = np.dot(Ud.T, data)
- Yp = np.dot(Ud, x_p[:d, :])
- x = np.dot(Ud.T, data)
- u = np.mean(x, axis=1, keepdims=True)
- y = x / np.dot(u.T, x)
- # VCA algorithm
- # -------------
- indice = np.zeros((n_endmembers), dtype=int)
- A = np.zeros((n_endmembers, n_endmembers))
- A[-1, 0] = 1
- for i in range(n_endmembers):
- w = np.random.rand(n_endmembers, 1)
- f = w - np.dot(A, np.dot(splin.pinv(A), w))
- f = f / splin.norm(f)
- v = np.dot(f.T, y)
- indice[i] = np.argmax(np.absolute(v))
- A[:, i] = y[:, indice[i]]
- Ae = Yp[:, indice]
- return Ae.T
- print("🔧 Initializing model with selected parameters...")
- conv_ae_unmixer = ConvUnmixingAE()
- print("📊 Starting the unmixing process. This may take a few moments...")
- abundances, endmembers = conv_ae_unmixer.apply(preprocessed_spectral_objs, num_endmembers=num_endmembers, epochs=epochs, seed=seed, use_bias=use_bias, loss=loss, batch_size=batch_size, verbose=verbose, learning_rate=learning_rate, learning_rate_decay=learning_rate_decay, vca_init=vca_init)
- print("✅ Unmixing complete. Extracted endmembers and abundances are ready.")
- # Save results
- for i, (filename, spectral_obj, amaps) in enumerate(zip(spectral_object_names, preprocessed_spectral_objs, abundances)):
- save_to = os.path.join(analysis_data_folder, os.path.splitext(filename)[0])
- if _is_imaging_object(spectral_obj):
- save_results(amaps, endmembers, preprocessed_spectral_axis, save_to=save_to)
- to_plot = True if i < 1 else False
- save_plots(amaps, endmembers, preprocessed_spectral_axis, save_to=save_to, plot=to_plot)
- else:
- os.makedirs(save_to, exist_ok=True)
- np.savetxt(os.path.join(save_to, 'wavenumber_axis.txt'), preprocessed_spectral_axis)
- np.savetxt(os.path.join(save_to, 'endmembers.txt'), endmembers)
- np.savetxt(os.path.join(save_to, 'reference_abundances.txt'), np.asarray(amaps))
- print(f"ℹ️ Skipped spatial abundance map plotting for non-imaging input: {filename}")
- print(f"✅ Unmixing data saved in {analysis_data_folder}/")
Deep_learning_enhanced_Raman_microspectroscopy.ipynb at commit 5eaa744, under Apache-2.0 · at the source
Overview
- Department of Computing, and UKRI Centre for Doctoral Training in AI for Healthcare, Imperial College London, London, UK SW7 2AZ
- Department of Materials, Department of Bioengineering, and Institute of Biomedical Engineering, Imperial College London, London, UK SW7 2AZ
- Department of Physiology, Anatomy and Genetics, Department of Engineering Science, and Kavli Institute for Nanoscience Discovery, University of Oxford, Oxford, UK OX1 3QU
- Department of Engineering Science, University of Oxford, Oxford, UK OX1 3PJ
- Department of Mathematics, Imperial College London, London, UK SW7 2AZ
Abstract
Three-dimensional (3D) organoids have emerged as powerful models for studying human development, disease, and drug response in vitro. Yet, their analysis remains constrained by standard imaging and characterization techniques, which are invasive, require exogenous labeling, and offer limited multiplexing. Here, we present a noninvasive, label-free imaging platform that integrates Raman microspectroscopy with deep learning–based hyperspectral unmixing for unsupervised, spatially resolved biochemical analysis of neural organoids. Our approach enables 2D and 3D mapping of cellular and subcellular structures in both cryosectioned and intact organoids, achieving improved imaging accuracy and robustness compared to conventional methods for hyperspectral analysis. Using our platform, we demonstrate volumetric imaging of a neural rosette within a neural organoid and interrogate changes in biochemical composition during early developmental stages in intact neural organoids, revealing spatiotemporal variations in lipids, proteins, and nucleic acids. This work establishes a versatile framework for high-content, label-free (bio)chemical phenotyping with broad applications in organoid research and beyond.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above, with 7 matches between paragraphs and lines of code.
Zenodo 18661874
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
barahona-research-group/dl-raman
5eaa7445ad4243646de9c31c1912c662fcbdb499, 13 August 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
9 files
- analyse.py — Python, 364 lines, 1 match
- colab/
Deep_learning_enhanced_R — Jupyter, 768 lines, 3 matchesaman_microspectroscopy.i pynb - gui.py — Python, 1,402 lines
- src/
__init__.py — Python, 1 line - src/
autoencoder.py — Python, 271 lines, 3 matches - src/
preprocessing.py — Python, 20 lines - src/
utils.py — Python, 168 lines - LICENSE — License, 201 lines
- README.md — Text, 238 lines
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 7 scripts, each with its path and the digest of its content;
- 7 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data, code, and materials availability
The datasets and source code generated in this study are archived on Zenodo at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 3, 28 September 2026
- Funding: added Advanced Research and Invention Agency: SCNI-PR01-P11; UK Research and Innovation: 10145749; Royal Academy of Engineering: CiET2021∖94; Norges Forskningsråd: #262613; HORIZON EUROPE Framework Programme: 101071203; Engineering and Physical Sciences Research Council: EP/T027258/1, EP/N014529/1, EP/P00114/1, EP/T020792/1, EP/Z534870/1
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 7 MeSH terms, 68 references, 1 RRID.
Cite
This paper
Georgiev, D., Xie, R., Reumann, D., Zhao, X., Fernández-Galiana, Á., Barahona, M., & Stevens, M. M. (2026). Label-free biochemical imaging and time point analysis of neural organoids via deep learning-enhanced Raman microspectroscopy. Science advances, 12(33), eaec5080. https://
BibTeX
@article{georgiev2026lab
author = {Georgiev, Dimitar and Xie, Ruoxiao and Reumann, Daniel and Zhao, Xiaoyu and Fernández-Galiana, Álvaro and Barahona, Mauricio and Stevens, Molly M},
title = {{Label-free biochemical imaging and time point analysis of neural organoids via deep learning-enhanced Raman microspectroscopy}},
journal = {Science advances},
year = {2026},
month = aug,
volume = {12},
number = {33},
pages = {eaec5080},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
doi = {10.1126/
url = {https://
pmid = {42585326},
pmcid = {PMC13464642}
}
RIS
TY - JOUR
AU - Georgiev, Dimitar
AU - Xie, Ruoxiao
AU - Reumann, Daniel
AU - Zhao, Xiaoyu
AU - Fernández-Galiana, Álvaro
AU - Barahona, Mauricio
AU - Stevens, Molly M
TI - Label-free biochemical imaging and time point analysis of neural organoids via deep learning-enhanced Raman microspectroscopy
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/
VL - 12
IS - 33
SP - eaec5080
SN - 2375-2548
PB - American Association for the Advancement of Science
DO - 10.1126/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1126/
"type": "article-journal",
"title": "Label-free biochemical imaging and time point analysis of neural organoids via deep learning-enhanced Raman microspectroscopy",
"container-title": "Science advances",
"author": [
{
"family": "Georgiev",
"given": "Dimitar"
},
{
"family": "Xie",
"given": "Ruoxiao"
},
{
"family": "Reumann",
"given": "Daniel"
},
{
"family": "Zhao",
"given": "Xiaoyu"
},
{
"family": "Fernández-Galiana",
"given": "Álvaro"
},
{
"family": "Barahona",
"given": "Mauricio"
},
{
"family": "Stevens",
"given": "Molly M"
}
],
"container-title-short":
"volume": "12",
"issue": "33",
"page": "eaec5080",
"DOI": "10.1126/
"PMID": "42585326",
"PMCID": "PMC13464642",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
12
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41467-026-74320-5 [code]
- Spatial architecture of autism pathogenesis reveals mosaic structural disarray during early development.Journal: Nature communicationsIn common: tifffile, SciPy, Matplotlib, 1 other tool, developmental, 3 references
- [2] doi:10.7554/elife.98340 [code]
- Human adherent cortical organoids in a multi-well format.Journal: eLifeIn common: Matplotlib, NumPy, 5 references
- [3] doi:10.64898/2026.03.30.715222 [code]
- Synthetic lumen rounding directs neural progenitor division modeJournal: bioRxiv (preprint)In common: tifffile, scikit-learn, SciPy, 2 other tools, developmental, 2 references
- [4] doi:10.1002/advs.202519893 [code]
- NeuroSuite for Long-Term Functional and Structural Studies of Air-Liquid Interface Cerebral Organoids.Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)In common: SciPy, Matplotlib, NumPy, developmental, 4 references
- [5] doi:10.1016/j.cell.2026.07.023
- Metabolic atlas of early human cortex reveals glycolytic remodeling and pentose phosphate pathway control of cell fate transitions.Journal: CellIn common: 5 references
- [6] doi:10.1038/s41467-026-71458-0 [code]
- Early differential impact of MeCP2 mutations on functional networks in Rett syndrome patient-derived human cortical organoids.Journal: Nature communicationsIn common: tifffile, scikit-learn, SciPy, 2 other tools, 2 references
- [7] doi:10.1371/journal.pbio.3003757 [code]
- Cell type-agnostic transcriptomic signatures enable uniform comparisons of neural maturation.Journal: PLoS biologyIn common: SciPy, Matplotlib, NumPy, 4 references
- [8] doi:10.1093/stcltm/szag071
- Temporal mapping of radiation-induced neural injury and mitigation in human cortical organoids.Journal: Stem cells translational medicineIn common: 5 references
- [9] doi:10.1038/s41467-026-76956-9 [code]
- Innervated human cardiac muscle model reveals sympathetic drivers of KCNH2-associated arrhythmias.Journal: Nature communicationsIn common: tifffile, SciPy, Matplotlib, 1 other tool, 2 references
- [10] doi:10.1371/journal.pcbi.1014571 [code]
- SynAPSeg: A novel dataset and image analysis framework for deep learning-based synapse detection and quantification.Journal: PLoS computational biologyIn common: tifffile, TensorFlow, scikit-learn, 3 other tools
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 7 scripts, and 7 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:3578e3b3c6b4c1eb…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
