temporal-models

Trains LSTM, GRU, TCN, and Transformer encoders on longitudinal neuroimaging sequences.

89|5|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill temporal-models-cuhk-aim-group
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: temporal-models
Source: https://github.com/CUHK-AIM-Group/NeuroDiscovery/tree/main/skills/temporal-models
Command: npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill temporal-models-cuhk-aim-group

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, torch, scikit-learn, pandas, and includes scripts (resource) components.

What problem does it solve? Modeling ordered repeated measurements such as longitudinal visits, ROI time series, and dynamic connectivity requires sequence encoders that handle variable-length inputs without leaking information across subjects. This Skill trains temporal deep learning models on neuroimaging sequence data with subject-level cross-validation and training-only normalization. ## Core Features & Use Cases - Four Sequence Encoders: Supports LSTM, GRU, temporal convolutional networks (TCN), and masked temporal Transformers for both classification and regression tasks. - Variable-Length Handling: Uses an optional lengths array for sequence masking, with normalization statistics estimated from valid training frames only. - Subject-Level Cross-Validation: Produces fold assignments, per-fold checkpoints, predictions, metrics, and provenance manifests while keeping all visits from one subject in the same fold. - Use Case: Given an NPZ bundle of ROI time series from patients scanned at multiple visits, train a GRU classifier to predict diagnosis while ensuring no subject's visits are split across training and test sets. ## Quick Start Train a GRU classification model on my sequences.npz file with 5-fold subject-level cross-validation and save the outputs to a run directory.

Frequently Asked Questions about temporal-models

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train an LSTM or GRU on longitudinal neuroimaging data?

Prepare an NPZ file containing X (subjects by time by features), y labels, and optional lengths and subject_id arrays, then run the train_reference.py script with --model lstm or gru and --task classification or regression. The script runs cross-validated training and writes predictions, metrics, and checkpoints.

What input format do temporal sequence models expect?

The models expect a single .npz bundle with a float32 array X of shape [subjects, time, features], a label array y, and optional lengths and subject_id arrays. Padded frames must come after each valid sequence, and if lengths is absent every sequence is treated as fully valid.

LSTM vs TCN vs temporal Transformer for time series classification?

LSTM suits longitudinal visit data, GRU serves as a compact recurrent baseline, TCN captures local temporal patterns, and the masked temporal Transformer handles longer dependencies. All four encoders are available through the --model flag with the same training pipeline.

Does the training pipeline prevent data leakage across subjects?

Yes, cross-validation uses subject-level folds so frames or visits from one subject never appear in both training and test sets. Normalization statistics are also estimated from training subjects only, and each fold checkpoint stores its own feature mean and standard deviation.

Can I run temporal model training on a GPU?

Yes, pass --device cuda to the training script to run on a GPU. You can verify CUDA availability with python -c "import torch; print(torch.cuda.is_available())" after installing torch.