Learnable Diffusion Framework for Mouse V1 Neural Decoding.
The 17 matches
- [1] § Methods › Devices and Settings for Training the Models ↔ train.py, lines 193–248 · score 0.89 · default Adam betas, AdamW, weight decay, training steps, DDP, optimized
- [2] § Methods › Model Architecture › The Diffusion Transformer (DiT) ↔ models.py, lines 147–168 · score 0.76 · adaptive layer norm, adaLN, MSA, MLP, head, blocks
- [3] § Methods › Model Architecture › The AutoEncoder ↔ gen_eval.py, lines 19–128 · score 0.76 · sd vae ft, AutoencoderKL, ema, decoded, model
- [4] § Methods › Model Architecture › The AutoEncoder ↔ gen_eval_aggTest.py, lines 19–116 · score 0.76 · sd vae ft, AutoencoderKL, ema, decoded, model
- [5] § Methods › The Classifier‐Free Guidance (CFG) ↔ models.py, lines 191–316 · score 0.65 · classifier free guidance, diffusion models, unconditioned, embedded, training
- [6] § Methods › Model Architecture › The Diffusion Transformer (DiT) ↔ models.py, lines 191–316 · score 0.63 · sin cos, unpatchifies, embedder, blocks, latent, timesteps
- [7] § Results › Sensorium‐Viz Reconstructs Stimuli via DiT With Spatially Embedded Neuron Responses ↔ models.py, lines 147–168 · score 0.59 · Adaptive Layer Norm, adaLN, blocks, Zero, model
- [8] § Methods › Devices and Settings for Training the Models ↔ train.py, lines 250–323 · score 0.58 · exponential moving, monitored, explode, EMA, loss, Devices
- [9] § Methods › The Training Losses ↔ diffusion/gaussian_diffusion.py, lines 682–713 · score 0.55 · log likelihood, log variance, discretizing, Gaussian, model
- [10] § Methods › Model Architecture › The Response Projector Network ↔ sensorium/neuralpredictors_cp/layers/cores/conv2d.py, lines 34–169 · score 0.54 · convolution layer, feature map, connection, nonlinearity, channel
- [11] § Methods › Model Architecture › The Response Projector Network ↔ sensorium/cores/conv2d.py, lines 28–165 · score 0.54 · convolution layer, feature map, connection, nonlinearity, channel
- [12] § Methods › Evaluation ↔ res_23656_idw32_all/metrics_full.py, lines 124–137 · score 0.54 · learned perceptual image, LPIPS, metrics, patch
- [13] § Methods › Process the Input Data for Model Training and Inference ↔ dataloaders/sensorium_synthetic.py, lines 19–39 · score 0.52 · Inverse Distance Weighting, PyInterp, neighbors, IDW
- [14] § Methods › Process the Input Data for Model Training and Inference ↔ dataloaders/sensorium_test_agg.py, lines 14–34 · score 0.52 · Inverse Distance Weighting, PyInterp, neighbors, IDW
- [15] § Methods › The Training Losses ↔ diffusion/diffusion_utils.py, lines 62–88 · score 0.52 · log likelihood, Gaussian distribution, discretizing
- [16] § Methods › The Classifier‐Free Guidance (CFG) ↔ train.py, lines 193–248 · score 0.52 · classifier free guidance, embedded, diffusion, training, models
- [17] § Methods › The Training Losses ↔ diffusion/gaussian_diffusion.py, lines 682–713 · score 0.51 · variational lower bound, posterior, KL, model
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
Python · 420 lines · 17 KB · MIT · 4 matches
- # Copyright (c) Meta Platforms, Inc. and affiliates.
- # All rights reserved.
- # This source code is licensed under the license found in the
- # LICENSE file in the root directory of this source tree.
- # --------------------------------------------------------
- # References:
- # GLIDE: https://github.com/openai/glide-text2im
- # MAE: https://github.com/facebookresearch/mae/blob/main/models_mae.py
- # --------------------------------------------------------
- import torch
- import torch.nn as nn
- import numpy as np
- import math
- from timm.models.vision_transformer import PatchEmbed, Attention, Mlp
- def modulate(x, shift, scale):
- return x * (1 + scale.unsqueeze(1)) + shift.unsqueeze(1)
- #################################################################################
- # Embedding Layers for Timesteps and Class Labels #
- #################################################################################
- class TimestepEmbedder(nn.Module):
- """
- Embeds scalar timesteps into vector representations.
- """
- def __init__(self, hidden_size, frequency_embedding_size=256):
- super().__init__()
- self.mlp = nn.Sequential(
- nn.Linear(frequency_embedding_size, hidden_size, bias=True),
- nn.SiLU(),
- nn.Linear(hidden_size, hidden_size, bias=True),
- )
- self.frequency_embedding_size = frequency_embedding_size
- @staticmethod
- def timestep_embedding(t, dim, max_period=10000):
- """
- Create sinusoidal timestep embeddings.
- :param t: a 1-D Tensor of N indices, one per batch element.
- These may be fractional.
- :param dim: the dimension of the output.
- :param max_period: controls the minimum frequency of the embeddings.
- :return: an (N, D) Tensor of positional embeddings.
- """
- # https://github.com/openai/glide-text2im/blob/main/glide_text2im/nn.py
- half = dim // 2
- freqs = torch.exp(
- -math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32) / half
- ).to(device=t.device)
- args = t[:, None].float() * freqs[None]
- embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
- if dim % 2:
- embedding = torch.cat([embedding, torch.zeros_like(embedding[:, :1])], dim=-1)
- return embedding
- def forward(self, t):
- t_freq = self.timestep_embedding(t, self.frequency_embedding_size)
- t_emb = self.mlp(t_freq)
- return t_emb
- class GridResponseEncoder(nn.Module):
- """
- Encode the response grids into vector representations utilize some structures of
- DownBlock of DDPM Unet
- """
- def __init__(self, num_grids, in_channels, hidden_size, drop_prob=0):
- super().__init__()
- self.num_grids = num_grids
- self.in_channels = in_channels
- self.drop_prob = drop_prob
- self.conv_in = nn.Conv2d(in_channels, 32, kernel_size=3, padding=1)
- self.resnet_conv_first = nn.Sequential(
- nn.GroupNorm(8, 32),
- nn.SiLU(),
- nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
- )
- self.residual_input_conv = nn.Conv2d(32, 64, kernel_size=1)
- self.attn_norm = nn.GroupNorm(8, 64)
- self.attn = nn.MultiheadAttention(64, num_heads=16, batch_first=True)
- self.norm_out = nn.GroupNorm(8, 64)
- self.conv_out = nn.Conv2d(64, 1, kernel_size=1)
- self.linear = nn.Linear(num_grids ** 2, hidden_size, bias=False)
- def drop_response(self, grid_responses):
- """
- Simulate the classifier-free guidance with 0 matrix
- """
- # create null response
- # null_response = torch.zeros_like(grid_responses[:, :1, :, :]) # Zero out only the first channel
- # null_response = torch.cat([null_response, grid_responses[:, 1:3, :, :].detach()], dim=1)
- null_response = torch.clone(grid_responses)
- null_response[:, :1, :, :] = 0
- drop_ids = torch.rand(grid_responses.shape[0], device=grid_responses.device) < self.drop_prob
- drop_ids = drop_ids.view(-1, 1, 1, 1) # Reshape for broadcasting across all dimensions
- # Use broadcasting to apply drop_ids across all channels and spatial dimensions
- grid_responses = torch.where(drop_ids, null_response, grid_responses)
- return grid_responses
- def forward(self, x, train):
- use_dropout = self.drop_prob > 0
- if train and use_dropout:
- # print(f"Dropout is {self.drop_prob}. Use CFG")
- x = self.drop_response(x)
- # else:
- # print(f"Dropout is {self.drop_prob}. No CFG")
- out = self.conv_in(x)
- resnet_input = out
- out = self.resnet_conv_first(out)
- out = out + self.residual_input_conv(resnet_input)
- batch_size, channels, h, w = out.shape
- in_attn = out.reshape(batch_size, channels, h * w).contiguous()
- in_attn = self.attn_norm(in_attn)
- in_attn = in_attn.transpose(1, 2).contiguous()
- out_attn, _ = self.attn(in_attn, in_attn, in_attn)
- out_attn = out_attn.transpose(1, 2).reshape(batch_size, channels, h, w).contiguous()
- out = out + out_attn
- out = self.norm_out(out)
- out = nn.SiLU()(out)
- out = self.conv_out(out)
- out = out.reshape(batch_size, -1).contiguous()
- out = self.linear(out)
- return out
- #################################################################################
- # Core DiT Model #
- #################################################################################
- class DiTBlock(nn.Module):
- """
- A DiT block with adaptive layer norm zero (adaLN-Zero) conditioning.
- """
- def __init__(self, hidden_size, num_heads, mlp_ratio=4.0, **block_kwargs):
- super().__init__()
- self.norm1 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)
- self.attn = Attention(hidden_size, num_heads=num_heads, qkv_bias=True, **block_kwargs)
- self.norm2 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)
- mlp_hidden_dim = int(hidden_size * mlp_ratio)
- approx_gelu = lambda: nn.GELU(approximate="tanh")
- self.mlp = Mlp(in_features=hidden_size, hidden_features=mlp_hidden_dim, act_layer=approx_gelu, drop=0)
- self.adaLN_modulation = nn.Sequential(
- nn.SiLU(),
- nn.Linear(hidden_size, 6 * hidden_size, bias=True)
- )
- def forward(self, x, c):
- shift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp = self.adaLN_modulation(c).chunk(6, dim=1)
- x = x + gate_msa.unsqueeze(1) * self.attn(modulate(self.norm1(x), shift_msa, scale_msa))
- x = x + gate_mlp.unsqueeze(1) * self.mlp(modulate(self.norm2(x), shift_mlp, scale_mlp))
- return x
- class FinalLayer(nn.Module):
- """
- The final layer of DiT.
- """
- def __init__(self, hidden_size, patch_size, out_channels):
- super().__init__()
- self.norm_final = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)
- self.linear = nn.Linear(hidden_size, patch_size * patch_size * out_channels, bias=True)
- self.adaLN_modulation = nn.Sequential(
- nn.SiLU(),
- nn.Linear(hidden_size, 2 * hidden_size, bias=True)
- )
- def forward(self, x, c):
- shift, scale = self.adaLN_modulation(c).chunk(2, dim=1)
- x = modulate(self.norm_final(x), shift, scale)
- x = self.linear(x)
- return x
- class DiT(nn.Module):
- """
- Diffusion model with a Transformer backbone.
- """
- def __init__(
- self,
- input_size=32,
- patch_size=2,
- in_channels=4,
- hidden_size=1152,
- depth=28,
- num_heads=16,
- mlp_ratio=4.0,
- response_grid=32,
- response_grid_channels=3,
- response_dropout_prob=0.1,
- # num_classes=1000,
- learn_sigma=True,
- ):
- super().__init__()
- self.learn_sigma = learn_sigma
- self.in_channels = in_channels
- self.out_channels = in_channels * 2 if learn_sigma else in_channels
- self.patch_size = patch_size
- self.num_heads = num_heads
- self.x_embedder = PatchEmbed(input_size, patch_size, in_channels, hidden_size, bias=True)
- self.t_embedder = TimestepEmbedder(hidden_size)
- # self.y_embedder = LabelEmbedder(num_classes, hidden_size, class_dropout_prob)
- self.y_embedder = GridResponseEncoder(response_grid, response_grid_channels, hidden_size, response_dropout_prob)
- num_patches = self.x_embedder.num_patches
- # Will use fixed sin-cos embedding:
- self.pos_embed = nn.Parameter(torch.zeros(1, num_patches, hidden_size), requires_grad=False)
- self.blocks = nn.ModuleList([
- DiTBlock(hidden_size, num_heads, mlp_ratio=mlp_ratio) for _ in range(depth)
- ])
- self.final_layer = FinalLayer(hidden_size, patch_size, self.out_channels)
- self.initialize_weights()
- def initialize_weights(self):
- # Initialize transformer layers:
- def _basic_init(module):
- if isinstance(module, nn.Linear):
- torch.nn.init.xavier_uniform_(module.weight)
- if module.bias is not None:
- nn.init.constant_(module.bias, 0)
- self.apply(_basic_init)
- # Initialize (and freeze) pos_embed by sin-cos embedding:
- pos_embed = get_2d_sincos_pos_embed(self.pos_embed.shape[-1], int(self.x_embedder.num_patches ** 0.5))
- self.pos_embed.data.copy_(torch.from_numpy(pos_embed).float().unsqueeze(0))
- # Initialize patch_embed like nn.Linear (instead of nn.Conv2d):
- w = self.x_embedder.proj.weight.data
- nn.init.xavier_uniform_(w.view([w.shape[0], -1]))
- nn.init.constant_(self.x_embedder.proj.bias, 0)
- # Initialize label embedding table:
- # nn.init.normal_(self.y_embedder.embedding_table.weight, std=0.02)
- nn.init.normal_(self.y_embedder.linear.weight, std=0.02)
- # Initialize timestep embedding MLP:
- nn.init.normal_(self.t_embedder.mlp[0].weight, std=0.02)
- nn.init.normal_(self.t_embedder.mlp[2].weight, std=0.02)
- # Zero-out adaLN modulation layers in DiT blocks:
- for block in self.blocks:
- nn.init.constant_(block.adaLN_modulation[-1].weight, 0)
- nn.init.constant_(block.adaLN_modulation[-1].bias, 0)
- # Zero-out output layers:
- nn.init.constant_(self.final_layer.adaLN_modulation[-1].weight, 0)
- nn.init.constant_(self.final_layer.adaLN_modulation[-1].bias, 0)
- nn.init.constant_(self.final_layer.linear.weight, 0)
- nn.init.constant_(self.final_layer.linear.bias, 0)
- def unpatchify(self, x):
- """
- x: (N, T, patch_size**2 * C)
- imgs: (N, H, W, C)
- """
- c = self.out_channels
- p = self.x_embedder.patch_size[0]
- h = w = int(x.shape[1] ** 0.5)
- assert h * w == x.shape[1]
- x = x.reshape(shape=(x.shape[0], h, w, p, p, c))
- x = torch.einsum('nhwpqc->nchpwq', x)
- imgs = x.reshape(shape=(x.shape[0], c, h * p, h * p))
- return imgs
- def forward(self, x, t, y):
- """
- Forward pass of DiT.
- x: (N, C, H, W) tensor of spatial inputs (images or latent representations of images)
- t: (N,) tensor of diffusion timesteps
- y: (N, CofG, G, G) tensor of grid responses
- """
- x = self.x_embedder(x) + self.pos_embed # (N, T, D), where T = H * W / patch_size ** 2
- t = self.t_embedder(t) # (N, D)
- y = self.y_embedder(y, self.training) # (N, D)
- c = t + y # (N, D)
- for block in self.blocks:
- x = block(x, c) # (N, T, D)
- x = self.final_layer(x, c) # (N, T, patch_size ** 2 * out_channels)
- x = self.unpatchify(x) # (N, out_channels, H, W)
- return x
- def forward_with_cfg(self, x, t, y, cfg_scale):
- """
- Forward pass of DiT, but also batches the unconditional forward pass for classifier-free guidance.
- """
- # https://github.com/openai/glide-text2im/blob/main/notebooks/text2im.ipynb
- half = x[: len(x) // 2]
- combined = torch.cat([half, half], dim=0)
- model_out = self.forward(combined, t, y)
- # For exact reproducibility reasons, we apply classifier-free guidance on only
- # three channels by default. The standard approach to cfg applies it to all channels.
- # This can be done by uncommenting the following line and commenting-out the line following that.
- eps, rest = model_out[:, :self.in_channels], model_out[:, self.in_channels:]
- # eps, rest = model_out[:, :3], model_out[:, 3:]
- cond_eps, uncond_eps = torch.split(eps, len(eps) // 2, dim=0)
- half_eps = uncond_eps + cfg_scale * (cond_eps - uncond_eps)
- eps = torch.cat([half_eps, half_eps], dim=0)
- return torch.cat([eps, rest], dim=1)
- #################################################################################
- # Sine/Cosine Positional Embedding Functions #
- #################################################################################
- # https://github.com/facebookresearch/mae/blob/main/util/pos_embed.py
- def get_2d_sincos_pos_embed(embed_dim, grid_size, cls_token=False, extra_tokens=0):
- """
- grid_size: int of the grid height and width
- return:
- pos_embed: [grid_size*grid_size, embed_dim] or [1+grid_size*grid_size, embed_dim] (w/ or w/o cls_token)
- """
- grid_h = np.arange(grid_size, dtype=np.float32)
- grid_w = np.arange(grid_size, dtype=np.float32)
- grid = np.meshgrid(grid_w, grid_h) # here w goes first
- grid = np.stack(grid, axis=0)
- grid = grid.reshape([2, 1, grid_size, grid_size])
- pos_embed = get_2d_sincos_pos_embed_from_grid(embed_dim, grid)
- if cls_token and extra_tokens > 0:
- pos_embed = np.concatenate([np.zeros([extra_tokens, embed_dim]), pos_embed], axis=0)
- return pos_embed
- def get_2d_sincos_pos_embed_from_grid(embed_dim, grid):
- assert embed_dim % 2 == 0
- # use half of dimensions to encode grid_h
- emb_h = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[0]) # (H*W, D/2)
- emb_w = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[1]) # (H*W, D/2)
- emb = np.concatenate([emb_h, emb_w], axis=1) # (H*W, D)
- return emb
- def get_1d_sincos_pos_embed_from_grid(embed_dim, pos):
- """
- embed_dim: output dimension for each position
- pos: a list of positions to be encoded: size (M,)
- out: (M, D)
- """
- assert embed_dim % 2 == 0
- omega = np.arange(embed_dim // 2, dtype=np.float64)
- omega /= embed_dim / 2.
- omega = 1. / 10000**omega # (D/2,)
- pos = pos.reshape(-1) # (M,)
- out = np.einsum('m,d->md', pos, omega) # (M, D/2), outer product
- emb_sin = np.sin(out) # (M, D/2)
- emb_cos = np.cos(out) # (M, D/2)
- emb = np.concatenate([emb_sin, emb_cos], axis=1) # (M, D)
- return emb
- #################################################################################
- # DiT Configs #
- #################################################################################
- def DiT_XL_2(**kwargs):
- return DiT(depth=28, hidden_size=1152, patch_size=2, num_heads=16, **kwargs)
- def DiT_XL_4(**kwargs):
- return DiT(depth=28, hidden_size=1152, patch_size=4, num_heads=16, **kwargs)
- def DiT_XL_8(**kwargs):
- return DiT(depth=28, hidden_size=1152, patch_size=8, num_heads=16, **kwargs)
- def DiT_L_2(**kwargs):
- return DiT(depth=24, hidden_size=1024, patch_size=2, num_heads=16, **kwargs)
- def DiT_L_4(**kwargs):
- return DiT(depth=24, hidden_size=1024, patch_size=4, num_heads=16, **kwargs)
- def DiT_L_8(**kwargs):
- return DiT(depth=24, hidden_size=1024, patch_size=8, num_heads=16, **kwargs)
- def DiT_B_2(**kwargs):
- return DiT(depth=12, hidden_size=768, patch_size=2, num_heads=12, **kwargs)
- def DiT_B_4(**kwargs):
- return DiT(depth=12, hidden_size=768, patch_size=4, num_heads=12, **kwargs)
- def DiT_B_8(**kwargs):
- return DiT(depth=12, hidden_size=768, patch_size=8, num_heads=12, **kwargs)
- def DiT_S_2(**kwargs):
- return DiT(depth=12, hidden_size=384, patch_size=2, num_heads=6, **kwargs)
- def DiT_S_4(**kwargs):
- return DiT(depth=12, hidden_size=384, patch_size=4, num_heads=6, **kwargs)
- def DiT_S_8(**kwargs):
- return DiT(depth=12, hidden_size=384, patch_size=8, num_heads=6, **kwargs)
- DiT_models = {
- 'DiT-XL/2': DiT_XL_2, 'DiT-XL/4': DiT_XL_4, 'DiT-XL/8': DiT_XL_8,
- 'DiT-L/2': DiT_L_2, 'DiT-L/4': DiT_L_4, 'DiT-L/8': DiT_L_8,
- 'DiT-B/2': DiT_B_2, 'DiT-B/4': DiT_B_4, 'DiT-B/8': DiT_B_8,
- 'DiT-S/2': DiT_S_2, 'DiT-S/4': DiT_S_4, 'DiT-S/8': DiT_S_8,
- }
models.py at commit bb27c89, under MIT · at the source
Overview
- Department of Computational Medicine and Bioinformatics University of Michigan Ann Arbor Michigan USA
- Department of Electrical Engineering and Computer Science University of Michigan Ann Arbor Michigan USA
- Department of Internal Medicine University of Michigan Ann Arbor Michigan USA
Abstract
Decoding visual stimuli from neural signals is an essential step toward understanding how sensory information is represented in the brain. While most existing approaches reconstruct visual stimuli from human functional magnetic resonance imaging (fMRI), utilizing calcium imaging in mice opens the door to single‐neuron‐level insights into non‐primate visual systems with distinct spectral sensitivities. Here, we present Sensorium‐Viz, a diffusion‐based framework specifically designed for decoding activity in the mouse primary visual cortex. The model is among the first to reliably reconstruct complex, high‐resolution images from previously unseen single‐neuron responses. At its core, Sensorium‐Viz introduces two key advances for neuron‐to‐image decoding: a synthetic‐response augmentation strategy that improves reconstruction performance by more than 30% while enabling cross‐mouse generalization through fine‐tuning, and an architectural design that integrates a Diffusion Transformer (DiT) with a spatial neuron‐embedding module, thereby achieving up to a 10.65% performance gain over leading fMRI‐based reconstruction methods across pixel‐ and content‐level benchmarks. Analysis of the neural responses and corresponding reconstructions reveals that neurons sensitive to low‐level visual features form the primary basis of V1's representation of external stimuli. These findings establish Sensorium‐Viz as a biologically grounded and technically robust tool for vision decoding.
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 17 matches between paragraphs and lines of code.
GuanLab/Sensorium2022_Challenge
def478db9e7ae519430acc4688614c49c6b07a05, 3 January 2024Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
104 files
- 0_process_data.ipynb, Jupyter, 23 lines
- analyze/
estimate_aRF.py , Python, 233 lines - analyze/
grid_experiments.ipynb , Jupyter, 681 lines - analyze/
inspect_model_with_image , Jupyter, 485 lines.ipynb - analyze/
plot_aRF.ipynb , Jupyter, 475 lines - analyze/
retinotopic_map.ipynb , Jupyter, 392 lines - analyze/
run_estimate_aRF.sh , Shell, 16 lines - analyze/
utils.py , Python, 271 lines - autolabel.py, Python, 72 lines
- sensorium/
1_train_evaluate_submit. , Jupyter, 23 linesipynb - sensorium/
MyDataloader.py , Python, 410 lines - sensorium/
MyScores.py , Python, 213 lines - sensorium/
MySubmission.py , Python, 209 lines - sensorium/
cores/ , Python, 14 lines__init__.py - sensorium/
cores/ , Python, 53 linesbase.py - sensorium/
cores/ , Python, 287 lines, 1 matchconv2d.py - sensorium/
encoders/ , Python, 1 line__init__.py - sensorium/
encoders/ , Python, 61 linesfiring_rate.py - sensorium/
models.py , Python, 213 lines - sensorium/
neuralpredictors_cp/ , Python, 1 line__init__.py - sensorium/
neuralpredictors_cp/ , Python, 1 linedata/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 2 linesdata/ datasets/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 575 linesdata/ datasets/ base.py - sensorium/
neuralpredictors_cp/ , Python, 235 linesdata/ datasets/ movies.py - sensorium/
neuralpredictors_cp/ , Python, 988 linesdata/ datasets/ old_datasets.py - sensorium/
neuralpredictors_cp/ , Python, 2 linesdata/ datasets/ statics/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 134 linesdata/ datasets/ statics/ base.py - sensorium/
neuralpredictors_cp/ , Python, 66 linesdata/ datasets/ statics/ filetree.py - sensorium/
neuralpredictors_cp/ , Python, 10 linesdata/ exceptions.py - sensorium/
neuralpredictors_cp/ , Python, 143 linesdata/ samplers.py - sensorium/
neuralpredictors_cp/ , Python, 586 linesdata/ transforms.py - sensorium/
neuralpredictors_cp/ , Python, 217 linesdata/ utils.py - sensorium/
neuralpredictors_cp/ , Python, 31 linesdistributions.py - sensorium/
neuralpredictors_cp/ , Python, 13 lineslayers/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 188 lineslayers/ activations.py - sensorium/
neuralpredictors_cp/ , Python, 40 lineslayers/ affine.py - sensorium/
neuralpredictors_cp/ , Python, 85 lineslayers/ attention.py - sensorium/
neuralpredictors_cp/ , Python, 30 lineslayers/ conv.py - sensorium/
neuralpredictors_cp/ , Python, 18 lineslayers/ cores/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 53 lineslayers/ cores/ base.py - sensorium/
neuralpredictors_cp/ , Python, 600 lines, 1 matchlayers/ cores/ conv2d.py - sensorium/
neuralpredictors_cp/ , Python, 1 linelayers/ encoders/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 61 lineslayers/ encoders/ firing_rate.py - sensorium/
neuralpredictors_cp/ , Python, 257 lineslayers/ hermite.py - sensorium/
neuralpredictors_cp/ , Python, 1 linelayers/ modulators/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 24 lineslayers/ readouts/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 92 lineslayers/ readouts/ attention.py - sensorium/
neuralpredictors_cp/ , Python, 124 lineslayers/ readouts/ base.py - sensorium/
neuralpredictors_cp/ , Python, 189 lineslayers/ readouts/ factorized.py - sensorium/
neuralpredictors_cp/ , Python, 1,303 lineslayers/ readouts/ gaussian.py - sensorium/
neuralpredictors_cp/ , Python, 133 lineslayers/ readouts/ multi_readout.py - sensorium/
neuralpredictors_cp/ , Python, 1,878 lineslayers/ readouts/ old_readouts.py - sensorium/
neuralpredictors_cp/ , Python, 336 lineslayers/ readouts/ point_pooled.py - sensorium/
neuralpredictors_cp/ , Python, 176 lineslayers/ readouts/ pyramid.py - sensorium/
neuralpredictors_cp/ , Python, 10 lineslayers/ shifters/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 27 lineslayers/ shifters/ base.py - sensorium/
neuralpredictors_cp/ , Python, 74 lineslayers/ shifters/ mlp.py - sensorium/
neuralpredictors_cp/ , Python, 67 lineslayers/ shifters/ static_affine.py - sensorium/
neuralpredictors_cp/ , Python, 34 lineslayers/ squeeze_excitation.py - sensorium/
neuralpredictors_cp/ , Python, 1 linemeasures/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 21 linesmeasures/ functions.py - sensorium/
neuralpredictors_cp/ , Python, 144 linesmeasures/ modules.py - sensorium/
neuralpredictors_cp/ , Python, 178 linesmeasures/ np_functions.py - sensorium/
neuralpredictors_cp/ , Python, 57 linesold_constraints.py - sensorium/
neuralpredictors_cp/ , Python, 293 linesregularizers.py - sensorium/
neuralpredictors_cp/ , Python, 14 linestraining/ __init__.py - sensorium/
neuralpredictors_cp/ , Python, 60 linestraining/ context_managers.py - sensorium/
neuralpredictors_cp/ , Python, 111 linestraining/ cyclers.py - sensorium/
neuralpredictors_cp/ , Python, 143 linestraining/ early_stopping.py - sensorium/
neuralpredictors_cp/ , Python, 554 linestraining/ tracking.py - sensorium/
neuralpredictors_cp/ , Python, 22 linestraining/ utils.py - sensorium/
neuralpredictors_cp/ , Python, 55 linesutils.py - sensorium/
predict.py , Python, 88 lines - sensorium/
predict_per_neuron.py , Python, 83 lines - sensorium/
readouts/ , Python, 17 lines__init__.py - sensorium/
readouts/ , Python, 124 linesbase.py - sensorium/
readouts/ , Python, 488 linesgaussian.py - sensorium/
readouts/ , Python, 120 linesmulti_readout.py - sensorium/
run.sh , Shell, 14 lines - sensorium/
sensorium/ , Python, 1 line__init__.py - sensorium/
sensorium/ , Python, 1 linedatasets/ __init__.py - sensorium/
sensorium/ , Python, 398 linesdatasets/ mouse_loaders.py - sensorium/
sensorium/ , Python, 1 linemodels/ __init__.py - sensorium/
sensorium/ , Python, 171 linesmodels/ models.py - sensorium/
sensorium/ , Python, 5 linesmodels/ readouts.py - sensorium/
sensorium/ , Python, 39 linesmodels/ utility.py - sensorium/
sensorium/ , Python, 1 linetraining/ __init__.py - sensorium/
sensorium/ , Python, 219 linestraining/ trainers.py - sensorium/
sensorium/ , Python, 3 linesutility/ __init__.py - sensorium/
sensorium/ , Python, 92 linesutility/ eval.py - sensorium/
sensorium/ , Python, 119 linesutility/ measure_helpers.py - sensorium/
sensorium/ , Python, 205 linesutility/ metrics.py - sensorium/
sensorium/ , Python, 220 linesutility/ scores.py - sensorium/
sensorium/ , Python, 203 linesutility/ submission.py - sensorium/
shifters/ , Python, 10 lines__init__.py - sensorium/
shifters/ , Python, 27 linesbase.py - sensorium/
shifters/ , Python, 74 linesmlp.py - sensorium/
shifters/ , Python, 67 linesstatic_affine.py - sensorium/
submit.py , Python, 82 lines - sensorium/
summary.py , Python, 13 lines - sensorium/
train.py , Python, 76 lines - setup_environment.sh, Shell, 11 lines
- split_train_validation.p
y , Python, 36 lines - README.md, Text, 76 lines
GuanLab/sensorium-viz
bb27c89057998be71f49c0aa6c06a7637c1b5617, 1 July 2025Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
19 files
- data/
create_agg_test.py , Python, 43 lines - dataloaders/
sensorium_synthetic.py , Python, 199 lines, 1 match - dataloaders/
sensorium_test.py , Python, 230 lines - dataloaders/
sensorium_test_agg.py , Python, 171 lines, 1 match - diffusion/
__init__.py , Python, 46 lines - diffusion/
diffusion_utils.py , Python, 88 lines, 1 match - diffusion/
gaussian_diffusion.py , Python, 873 lines, 2 matches - diffusion/
plms.py , Python, 285 lines - diffusion/
respace.py , Python, 129 lines - diffusion/
timestep_sampler.py , Python, 150 lines - download.py, Python, 50 lines
- gen_eval.py, Python, 149 lines, 1 match
- gen_eval_aggTest.py, Python, 134 lines, 1 match
- models.py, Python, 420 lines, 4 matches
- res_23656_idw32_all/
metrics_full.py , Python, 286 lines, 1 match - res_23656_idw32_all/
summary.py , Python, 89 lines - train.py, Python, 346 lines, 3 matches
- LICENSE, License, 21 lines
- README.md, Text, 131 lines
Code Availability
The codes of this work are available at: https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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;
- 120 scripts, each with its path and the digest of its content;
- 17 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
Datasets cited
- gin.g-node.org/
cajal/ , at gin.g-node.org; found in “Data Availability Statement”sensorium2022 - kaggle.com/
datasets/ , at Kaggle; found in the text, “Collect Images and Generate Synthetic Neuronal…”jeffaudi
Data Availability Statement
Datasets of the mice can be retrieved from 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 1, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 4 keywords, 9 MeSH terms, 1 funder, 22 references.
Cite
This paper
Deng, K., Schwendeman, P. S., & Guan, Y. (2026). Learnable Diffusion Framework for Mouse V1 Neural Decoding. Advanced science (Weinheim, Baden-Wurttemberg, Germany), 13(30), e20220. https://
BibTeX
@article{deng2026learnab
author = {Deng, Kaiwen and Schwendeman, Peter S. and Guan, Yuanfang},
title = {{Learnable Diffusion Framework for Mouse V1 Neural Decoding}},
journal = {Advanced science (Weinheim, Baden-Wurttemberg, Germany)},
year = {2026},
month = mar,
volume = {13},
number = {30},
pages = {e20220},
publisher = {Wiley},
issn = {2198-3844},
doi = {10.1002/
url = {https://
pmid = {41787846},
pmcid = {PMC13248838}
}
RIS
TY - JOUR
AU - Deng, Kaiwen
AU - Schwendeman, Peter S.
AU - Guan, Yuanfang
TI - Learnable Diffusion Framework for Mouse V1 Neural Decoding
T2 - Advanced science (Weinheim, Baden-Wurttemberg, Germany)
J2 - Adv Sci (Weinh)
PY - 2026
DA - 2026/
VL - 13
IS - 30
SP - e20220
SN - 2198-3844
PB - Wiley
DO - 10.1002/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1002/
"type": "article-journal",
"title": "Learnable Diffusion Framework for Mouse V1 Neural Decoding",
"container-title": "Advanced science (Weinheim, Baden-Wurttemberg, Germany)",
"author": [
{
"family": "Deng",
"given": "Kaiwen"
},
{
"family": "Schwendeman",
"given": "Peter S."
},
{
"family": "Guan",
"given": "Yuanfang"
}
],
"container-title-short":
"volume": "13",
"issue": "30",
"page": "e20220",
"DOI": "10.1002/
"PMID": "41787846",
"PMCID": "PMC13248838",
"ISSN": "2198-3844",
"publisher": "Wiley",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
5
]
]
}
}
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.7554/elife.105081 [code]
- Movie reconstruction from mouse visual cortex activity.Journal: eLifeIn common: OpenCV, Pillow, PyTorch, 4 other tools, systems, mouse, 6 references
- [2] doi:10.1371/journal.pcbi.1014263 [code]
- MIRAGE: Robust multi-modal architectures translate fMRI-to-image models from vision to mental imagery.Journal: PLoS computational biologyIn common: UMAP, OpenCV, scikit-image, 8 other tools, 2 references
- [3] doi:10.1038/s41467-026-72057-9 [code]
- Sex-specific behavioral feedback modulates sensorimotor processing and drives flexible social behavior.Journal: Nature communicationsIn common: UMAP, OpenCV, scikit-image, 9 other tools, systems, 1 reference
- [4] doi:10.1016/j.isci.2026.116825 [code]
- Social hierarchy shapes behavioral and transcriptional responses to chronic stress and ketamine in male mice.Journal: iScienceIn common: UMAP, OpenCV, scikit-image, 9 other tools, systems, mouse
- [5] doi:10.1371/journal.pbio.3003915 [code]
- Noise-invariant representations of sound emerge along the canonical cortical hierarchy.Journal: PLoS biologyIn common: UMAP, OpenCV, scikit-image, 9 other tools, mouse
- [6] doi:10.21203/rs.3.rs-9676637/v1 [code]
- A Comprehensive Benchmarking of Spatial Deconvolution and Domain Detection Methods across Diverse Tissues and Spatial Transcriptomic TechnologiesJournal: Research Square (preprint)In common: UMAP, OpenCV, scikit-image, 9 other tools
- [7] doi:10.1162/imag.a.1299 [code]
- A modular semantic-structural pipeline for visual decoding from primate spiking data via selective temporal integration.Journal: Imaging neuroscience (Cambridge, Mass.)In common: scikit-image, h5py, Pillow, 7 other tools, 2 references
- [8] doi:10.7554/elife.107933 [code]
- Modality-agnostic decoding of vision and language from fMRI.Journal: eLifeIn common: OpenCV, scikit-image, h5py, 8 other tools, 1 reference
- [9] doi:10.7554/elife.109717 [code]
- Retrosplenial cortex enables context-dependent goal-directed sensorimotor transformation.Journal: eLifeIn common: OpenCV, scikit-image, h5py, 7 other tools, systems, mouse, 1 reference
- [10] doi:10.1038/s41467-026-74823-1 [code]
- Cerebellar activity is triggered by reach endpoint during learning of a complex locomotor task.Journal: Nature communicationsIn common: UMAP, OpenCV, scikit-image, 7 other tools, mouse, 1 reference
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, 120 scripts, and 17 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:101967ee64d151b6…
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.
