The development of FEDUPP: feeding experimentation device users processing package to assess learning and cognitive flexibility.
The 2 matches
- [1] § Methods › CNN-based model ↔ scripts/meal_classifiers.py, lines 63–98 · score 0.68 · ReLU, feature map, convolutional, kernel, CNN, classes
- [2] § Results › Comparison of FEDUPP metrics with win-stay/lose-shift ↔ scripts/direction_transition.py, lines 1623–1667 · score 0.58 · way ANOVA, Win Stay, Lose shift, interaction, CASK
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 · 250 lines · 9.8 KB · MIT · 1 match
- """
- This script defines and implements neural network models (RNN and CNN) for classifying
- meal-related time-series data. It includes classes for datasets, the classifiers
- themselves, and functions for training, evaluation, and prediction.
- """
- import numpy as np
- from sklearn.metrics import f1_score
- import torch
- import torch.nn as nn
- import torch.optim as optim
- from torch.utils.data import DataLoader, Dataset
- # Detect best available device including MPS for Mac
- device = torch.device('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
- class TimeSeriesDataset(Dataset):
- """A custom PyTorch Dataset for time-series data."""
- def __init__(self, X, y):
- """
- Args:
- X (torch.Tensor): The input features, with shape (num_samples, seq_len).
- y (torch.Tensor): The corresponding labels, with shape (num_samples,).
- """
- self.X = X # Tensor of shape (num_samples, seq_len)
- self.y = y # Tensor of shape (num_samples,)
- def __len__(self):
- """Returns the total number of samples."""
- return len(self.y)
- def __getitem__(self, idx):
- """Returns a single sample and its label."""
- return self.X[idx], self.y[idx]
- class RNNClassifier(nn.Module):
- """A Recurrent Neural Network (RNN) classifier using LSTM layers."""
- def __init__(self, input_size=1, hidden_size=16, num_layers=1, num_classes=2):
- """
- Args:
- input_size (int): The number of features in the input.
- hidden_size (int): The number of features in the hidden state.
- num_layers (int): The number of recurrent layers.
- num_classes (int): The number of output classes.
- """
- super(RNNClassifier, self).__init__()
- self.hidden_size = hidden_size
- self.num_layers = num_layers
- self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True)
- self.fc = nn.Linear(hidden_size, num_classes)
- def forward(self, x):
- # x: [batch_size, seq_len]
- x = x.unsqueeze(-1) # Now x is [batch_size, seq_len, 1]
- h0 = torch.zeros(self.num_layers, x.size(0), self.hidden_size, device=x.device)
- c0 = torch.zeros(self.num_layers, x.size(0), self.hidden_size, device=x.device)
- out, _ = self.lstm(x, (h0, c0))
- out = out[:, -1, :]
- out = self.fc(out)
- return out
- class CNNClassifier(nn.Module):
- """A 1D Convolutional Neural Network (CNN) for time-series classification."""
- def __init__(self, num_classes=2, maxlen=4):
- """
- Args:
- num_classes (int): The number of output classes.
- maxlen (int): The maximum length of the input sequences.
- """
- super(CNNClassifier, self).__init__()
- self.conv1 = nn.Conv1d(in_channels=1, out_channels=16, kernel_size=2)
- self.relu = nn.ReLU()
- self.conv2 = nn.Conv1d(in_channels=16, out_channels=32, kernel_size=2)
- self.pool = nn.MaxPool1d(kernel_size=2)
- self.maxlen = maxlen
- # Calculate the size of the feature map after convolution and pooling
- self.feature_size = self._get_feature_size()
- self.fc = nn.Linear(self.feature_size, num_classes)
- def _get_feature_size(self):
- # Replace 'maxlen' with your actual maximum sequence length
- dummy_input = torch.zeros(1, 1, self.maxlen) # Shape: [batch_size, channels, seq_len]
- x = self.relu(self.conv1(dummy_input))
- x = self.relu(self.conv2(x))
- x = self.pool(x)
- feature_size = x.view(1, -1).size(1)
- return feature_size
- def forward(self, x):
- # x shape: [batch_size, seq_len]
- x = x.unsqueeze(1) # Shape: [batch_size, channels=1, seq_len]
- x = self.relu(self.conv1(x))
- x = self.relu(self.conv2(x))
- x = self.pool(x)
- x = x.view(x.size(0), -1) # Flatten the tensor
- x = self.fc(x)
- return x
- def train(model:nn.Module, lr:float, num_epochs:int, train_loader:DataLoader,
- X_test_tensor:torch.tensor, y_test_tensor:torch.tensor):
- """
- Trains a given neural network model.
- Args:
- model (nn.Module): The model to be trained.
- lr (float): The learning rate for the optimizer.
- num_epochs (int): The number of training epochs.
- train_loader (DataLoader): The DataLoader for the training data.
- X_test_tensor (torch.Tensor): The test features.
- y_test_tensor (torch.Tensor): The test labels.
- Returns:
- nn.Module: The trained model.
- """
- criterion = nn.CrossEntropyLoss()
- optimizer = optim.Adam(model.parameters(), lr=lr)
- print(f"Model Parameters: {sum(p.numel() for p in model.parameters())}")
- for epoch in range(num_epochs):
- model.train()
- total_loss = 0
- correct_train = 0
- total_train = 0
- for X_batch, y_batch in train_loader:
- X_batch, y_batch = X_batch.to(device), y_batch.to(device)
- optimizer.zero_grad()
- outputs = model(X_batch)
- loss = criterion(outputs, y_batch)
- loss.backward()
- optimizer.step()
- total_loss += loss.item() * X_batch.size(0)
- _, predicted = torch.max(outputs.data, 1)
- total_train += y_batch.size(0)
- predicted, y_batch = predicted.cpu().numpy(), y_batch.cpu().numpy()
- correct_train += (predicted == y_batch).sum().item()
- avg_loss = total_loss / total_train
- train_accuracy = correct_train / total_train
- model.eval()
- with torch.no_grad():
- outputs_test = model(X_test_tensor)
- _, predicted_test = torch.max(outputs_test.data, 1)
- correct_test = (predicted_test.cpu() == y_test_tensor).sum().item()
- test_accuracy = correct_test / y_test_tensor.size(0)
- if (epoch+1) % 10 == 0 or epoch == num_epochs-1:
- print(f'Ep {epoch+1}, Loss: {avg_loss:.4f}, Train Acc: {train_accuracy:.4f}, Test Acc: {test_accuracy:.4f}')
- return model
- def evaluate_meals_by_groups(model:nn.Module, ctrl_input:torch.Tensor, ctrl_y:torch.Tensor,
- exp_input:torch.Tensor, exp_y:torch.Tensor):
- """
- Evaluates the model's performance on control and experimental groups.
- Args:
- model (nn.Module): The trained model.
- ctrl_input (torch.Tensor): Input data for the control group.
- ctrl_y (torch.Tensor): Labels for the control group.
- exp_input (torch.Tensor): Input data for the experimental group.
- exp_y (torch.Tensor): Labels for the experimental group.
- """
- model.eval()
- with torch.no_grad():
- outputs_ctrl = model(ctrl_input)
- _, predicted_ctrl = torch.max(outputs_ctrl.data, 1)
- correct_test = (predicted_ctrl.cpu().numpy() == ctrl_y).sum().item()
- ctrl_accuracy = correct_test / len(ctrl_y)
- outputs_exp = model(exp_input)
- _, predicted_exp = torch.max(outputs_exp.data, 1)
- correct_test = (predicted_exp.cpu().numpy() == exp_y).sum().item()
- exp_accuracy = correct_test / len(exp_y)
- print(f'Control Accuracy: {ctrl_accuracy:.3f}, Exp Accuracy: {exp_accuracy:.3f}')
- predicted_ctrl, predicted_exp = predicted_ctrl.cpu().numpy(), predicted_exp.cpu().numpy()
- ctrl_good, ctrl_total = np.sum(predicted_ctrl), np.size(predicted_ctrl)
- exp_good, exp_total = np.sum(predicted_exp), np.size(predicted_exp)
- # calculate F1 score
- f1_ctrl = f1_score(ctrl_y, predicted_ctrl)
- f1_exp = f1_score(exp_y, predicted_exp)
- print(f'Control Group: {ctrl_total-ctrl_good}/{ctrl_total} good meals with proportion of {1-ctrl_good/ctrl_total}; F1 Score: {f1_ctrl:.3f}')
- print(f'Experiment Group: {exp_total-exp_good}/{exp_total} good meals with proportion of {1-exp_good/exp_total}; F1 Score: {f1_exp:.3f}')
- def evaluate_meals_on_new_data(model:nn.Module, ctrl_input:torch.Tensor, exp_input:torch.Tensor):
- """
- Evaluates the model on new, unlabeled data from control and experimental groups.
- Args:
- model (nn.Module): The trained model.
- ctrl_input (torch.Tensor): New input data for the control group.
- exp_input (torch.Tensor): New input data for the experimental group.
- """
- ctrl_input, exp_input = ctrl_input.to(device), exp_input.to(device)
- model.eval()
- with torch.no_grad():
- outputs_ctrl = model(ctrl_input)
- _, predicted_ctrl = torch.max(outputs_ctrl.data, 1)
- outputs_exp = model(exp_input)
- _, predicted_exp = torch.max(outputs_exp.data, 1)
- predicted_ctrl, predicted_exp = predicted_ctrl.cpu().numpy(), predicted_exp.cpu().numpy()
- ctrl_good, ctrl_total = np.sum(predicted_ctrl), np.size(predicted_ctrl)
- exp_good, exp_total = np.sum(predicted_exp), np.size(predicted_exp)
- print(f'Control Group: {ctrl_total-ctrl_good}/{ctrl_total} good meals with proportion of {1-ctrl_good/ctrl_total}')
- print(f'Experiment Group: {exp_total-exp_good}/{exp_total} good meals with proportion of {1-exp_good/exp_total}')
- def predict(model:nn.Module, input):
- """
- Makes predictions on new data using the trained model.
- Args:
- model (nn.Module): The trained model.
- input (array-like or torch.Tensor): The input data for prediction.
- Returns:
- np.ndarray: The predicted class labels.
- """
- if not isinstance(input, torch.Tensor):
- input = torch.tensor(input, dtype=torch.float32)
- else:
- input = input.float()
- # Ensure input is on the same device as the model
- try:
- model_device = next(model.parameters()).device
- except StopIteration:
- model_device = device
- input = input.to(model_device)
- model.eval()
- with torch.no_grad():
- outputs_ctrl = model(input)
- _, predicted_ctrl = torch.max(outputs_ctrl.data, 1)
- return predicted_ctrl.cpu().numpy()
meal_classifiers.py at commit 783c7f7, under MIT · at the source
Overview
- Department of Mathematics, School of Physical Sciences, University of California,San Diego, CA USA
- Department of Psychiatry, School of Medicine, University of California,San Diego, CA USA
- School of Biological Sciences, University of California,San Diego, CA USA
Abstract
Cognitive flexibility, the ability to adapt behavior in response to changing contingencies, is a key component of adaptive decision-making and is impaired in multiple neuropsychiatric disorders. Traditional rodent assays of cognitive flexibility are conducted in experimenter-controlled sessions in restrictive environments, limiting ecological validity and temporal resolution. Here, we developed a fully automated, home-cage paradigm using the Feeding Experimentation Device 3 (FED3) and a companion open-source analysis pipeline, the Feeding Experimentation Device Users Processing Package (FEDUPP), to assess learning and cognitive flexibility with minimal experimenter intervention. The paradigm combines a single-day fixed-ratio 1 (FR1) task with a multi-day, reversal learning task in which active port assignment switches every 25 pellets collected. FEDUPP implements multi-scale learning metrics, including overall accuracy, an 80% accuracy milestone, and a machine learning-based classification of meal accuracy to capture motivated, goal-directed feeding. In wild-type mice, the paradigm detected rapid FR1 acquisition and progressive within-block adaptation during reversal. Application to mice with dorsal hippocampal knockdown of the scaffolding protein CASK revealed faster FR1 acquisition and higher accuracy. In addition, a faster onset of the first accurate meal after reversal suggests an improvement in updating goal-directed feeding behavior. These findings demonstrate that FEDUPP enables high-resolution, continuous assessment of learning and cognitive flexibility in ethologically relevant settings, and that meal-based accuracy provides a sensitive metric for detecting subtle changes in flexibility not captured by traditional measures.
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 2 matches between paragraphs and lines of code.
ftlabucsd/FEDUPP
783c7f7d665a4a2def670cf69b0c92c2f6d9f041, 19 May 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
13 files
- Accurate Meal Model.ipynb, Jupyter, 485 lines
- pipeline.ipynb, Jupyter, 1,021 lines
- scripts/
accuracy.py , Python, 225 lines - scripts/
advanced_analysis.py , Python, 914 lines - scripts/
direction_transition.py , Python, 2,553 lines - scripts/
meal_classifiers.py , Python, 250 lines - scripts/
meals.py , Python, 1,621 lines - scripts/
preprocessing.py , Python, 347 lines - scripts/
unsupervised_helpers.py , Python, 206 lines - scripts/
utils.py , Python, 499 lines - scripts/
zenodo_deposit.py , Python, 295 lines - LICENSE, License, 21 lines
- README.md, Text, 173 lines
Zenodo 20277475
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
- 28 September 2026: the link answers (HTTP 200)
13 files
- Accurate Meal Model.ipynb, Jupyter, 485 lines
- pipeline.ipynb, Jupyter, 1,021 lines
- scripts/
accuracy.py , Python, 225 lines - scripts/
advanced_analysis.py , Python, 914 lines - scripts/
direction_transition.py , Python, 2,553 lines - scripts/
meal_classifiers.py , Python, 250 lines - scripts/
meals.py , Python, 1,621 lines - scripts/
preprocessing.py , Python, 347 lines - scripts/
unsupervised_helpers.py , Python, 206 lines - scripts/
utils.py , Python, 499 lines - scripts/
zenodo_deposit.py , Python, 257 lines - LICENSE, License, 21 lines
- README.md, Text, 170 lines
ftlabucsd/FED3-data
783c7f7d665a4a2def670cf69b0c92c2f6d9f041, 19 May 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
13 files
- Accurate Meal Model.ipynb, Jupyter, 485 lines
- pipeline.ipynb, Jupyter, 1,021 lines
- scripts/
accuracy.py , Python, 225 lines - scripts/
advanced_analysis.py , Python, 914 lines - scripts/
direction_transition.py , Python, 2,553 lines, 1 match - scripts/
meal_classifiers.py , Python, 250 lines, 1 match - scripts/
meals.py , Python, 1,621 lines - scripts/
preprocessing.py , Python, 347 lines - scripts/
unsupervised_helpers.py , Python, 206 lines - scripts/
utils.py , Python, 499 lines - scripts/
zenodo_deposit.py , Python, 295 lines - LICENSE, License, 21 lines
- README.md, Text, 173 lines
Zenodo 20277476
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
- 28 September 2026: the link answers (HTTP 200)
13 files
- Accurate Meal Model.ipynb, Jupyter, 485 lines
- pipeline.ipynb, Jupyter, 1,021 lines
- scripts/
accuracy.py , Python, 225 lines - scripts/
advanced_analysis.py , Python, 914 lines - scripts/
direction_transition.py , Python, 2,553 lines - scripts/
meal_classifiers.py , Python, 250 lines - scripts/
meals.py , Python, 1,621 lines - scripts/
preprocessing.py , Python, 347 lines - scripts/
unsupervised_helpers.py , Python, 206 lines - scripts/
utils.py , Python, 499 lines - scripts/
zenodo_deposit.py , Python, 257 lines - LICENSE, License, 21 lines
- README.md, Text, 170 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:
- 4 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 44 scripts, each with its path and the digest of its content;
- 2 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 availability
FED3 behavioral data is available on 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, 28 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 2 keywords, 9 MeSH terms, 5 funders, 49 references.
Cite
This paper
Yao, M., Libster, A. M., Desfor, S., Malhotra, F., Castorena, N., Montilla-Perez, P., & Telese, F. (2026). The development of FEDUPP: feeding experimentation device users processing package to assess learning and cognitive flexibility. Translational psychiatry, 16(1), 348. https://
BibTeX
@article{yao2026developm
author = {Yao, Mingyang and Libster, Avraham M. and Desfor, Shane and Malhotra, Freiya and Castorena, Nathalia and Montilla-Perez, Patricia and Telese, Francesca},
title = {{The development of FEDUPP: feeding experimentation device users processing package to assess learning and cognitive flexibility}},
journal = {Translational psychiatry},
year = {2026},
month = may,
volume = {16},
number = {1},
pages = {348},
publisher = {Nature Publishing Group},
issn = {2158-3188},
doi = {10.1038/
url = {https://
pmid = {42140909},
pmcid = {PMC13346605}
}
RIS
TY - JOUR
AU - Yao, Mingyang
AU - Libster, Avraham M.
AU - Desfor, Shane
AU - Malhotra, Freiya
AU - Castorena, Nathalia
AU - Montilla-Perez, Patricia
AU - Telese, Francesca
TI - The development of FEDUPP: feeding experimentation device users processing package to assess learning and cognitive flexibility
T2 - Translational psychiatry
J2 - Transl Psychiatry
PY - 2026
DA - 2026/
VL - 16
IS - 1
SP - 348
SN - 2158-3188
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "The development of FEDUPP: feeding experimentation device users processing package to assess learning and cognitive flexibility",
"container-title": "Translational psychiatry",
"author": [
{
"family": "Yao",
"given": "Mingyang"
},
{
"family": "Libster",
"given": "Avraham M."
},
{
"family": "Desfor",
"given": "Shane"
},
{
"family": "Malhotra",
"given": "Freiya"
},
{
"family": "Castorena",
"given": "Nathalia"
},
{
"family": "Montilla-Perez",
"given": "Patricia"
},
{
"family": "Telese",
"given": "Francesca"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "348",
"DOI": "10.1038/
"PMID": "42140909",
"PMCID": "PMC13346605",
"ISSN": "2158-3188",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
16
]
]
}
}
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.1073/pnas.2536535123 [code]
- Orbitofrontal noradrenaline supports adaptive learning-rate adjustment in probabilistic reversal learning.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: pandas, SciPy, Matplotlib, 1 other tool, cognitive, 3 references
- [2] doi:10.1038/s41593-026-02362-5 [code]
- Replay of procedural memory is independent of the hippocampus.Journal: Nature neuroscienceIn common: seaborn, scikit-learn, pandas, 3 other tools, cognitive, mouse, 1 reference
- [3] doi:10.3389/fnsys.2026.1822122 [code]
- Convergence-divergence circuits for multimodal integration of innate and learned opponent valences.Journal: Frontiers in systems neuroscienceIn common: PyTorch, seaborn, scikit-learn, 4 other tools, 1 reference
- [4] doi:10.1038/s41593-026-02253-9 [code]
- Genoarchitecture and input-output organization of the mouse basal ganglia and thalamic parafascicular nucleus.Journal: Nature neuroscienceIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 1 reference
- [5] doi:10.7554/elife.109717 [code]
- Retrosplenial cortex enables context-dependent goal-directed sensorimotor transformation.Journal: eLifeIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 1 reference
- [6] doi:10.1038/s41593-026-02262-8 [code]
- Cheese3D enables sensitive detection and analysis of whole-face movement in mice.Journal: Nature neuroscienceIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 1 reference
- [7] doi:10.1016/j.crmeth.2026.101421 [code]
- EthoPy provides an accessible platform for reproducible behavioral neuroscience.Journal: Cell reports methodsIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 1 reference
- [8] doi:10.1038/s41467-026-71404-0 [code]
- Nonergodicity and Simpson's paradox in neurocognitive dynamics of cognitive control.Journal: Nature communicationsIn common: seaborn, scikit-learn, pandas, 3 other tools, cognitive, 1 reference
- [9] doi:10.1371/journal.pcbi.1014585 [code]
- Decoding behavior with minimal and interpretable agent models.Journal: PLoS computational biologyIn common: PyTorch, pandas, SciPy, 2 other tools, cognitive, mouse, 1 reference
- [10] doi:10.7554/elife.108673 [code]
- Adaptive behavior is guided by integrated representations of controlled and non-controlled information.Journal: eLifeIn common: seaborn, scikit-learn, pandas, 3 other tools, 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: 4 repositories of the authors' code, each at its verified commit and with its license, 44 scripts, and 2 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:de7632457b76ef6e…
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.
