OSCR

fMRI-based prediction of eye gaze during naturalistic movie viewing reveals eye-movement-related brain activity.

Code ↔ Paper

2 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 2 matches
  1. [1] § Materials and methods › Gaze prediction from pretrained DeepMReye ↔ 02_prediction_extraction.R, lines 1–34 · score 0.73 · zero shot, fine tuning, DeepMReye, 1to6, official, pretrained
  2. [2] § Materials and methods › Eye-tracking preprocessing ↔ 01_tracking_preprocessing.R, lines 43–152 · score 0.51 · volume triggers, fMRI, preprocessed, tracking, gaze

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

R · 216 lines · 5.4 KB · no license · 1 match

  1. ## ============================================================
  2. ## Format DeepMReye zero-shot prediction outputs
  3. ## Zero-shot gaze prediction was performed using the official
  4. ## DeepMReye implementation with the pretrained
  5. ## datasets_1to6.h5 model, without fine-tuning.
  6. ## https://github.com/DeepMReye/DeepMReye/blob/main/notebooks/deepmreye_example_usage_pretrained_weights.ipynb
  7. ## ============================================================
  8. library(reticulate)
  9. library(stringr)
  10. library(dplyr)
  11. library(reshape2)
  12. np <- import("numpy")
  13. clinical_path <- "data/clinical/Clinical_all.csv"
  14. prediction_dir <- "data/prediction"
  15. output_dir <- file.path("processed_data", "hbn")
  16. dir.create(output_dir, recursive = TRUE, showWarnings = FALSE)
  17. TR <- 0.8
  18. subTR_per_TR <- 10
  19. dataset_name <- "HBN"
  20. clinical_df <- read.csv(clinical_path)
  21. clinical_hbn <- clinical_df %>%
  22. filter(Dataset == dataset_name)
  23. hbn_ids <- as.character(clinical_hbn$EID)
  24. message("Number of HBN subjects in clinical table: ", length(hbn_ids))
  25. extract_subject_id <- function(run_name, task_lower) {
  26. prefix <- paste0("./processed_data_", task_lower, "/")
  27. subject_id <- run_name %>%
  28. str_remove_all(fixed(prefix)) %>%
  29. str_remove("\\.npz$")
  30. return(subject_id)
  31. }
  32. format_prediction_one_run <- function(data_df, subject_id, task_lower) {
  33. pred_x <- data_df$pred_y[, , 1]
  34. pred_y <- data_df$pred_y[, , 2]
  35. euc <- data_df$euc_pred
  36. if (!all(dim(pred_x) == dim(pred_y)) || !all(dim(pred_x) == dim(euc))) {
  37. stop("Dimension mismatch in prediction arrays for subject: ", subject_id)
  38. }
  39. n_tr <- nrow(pred_x)
  40. n_subtr <- ncol(pred_x)
  41. if (n_subtr != subTR_per_TR) {
  42. warning(
  43. "Unexpected number of subTR samples for subject ",
  44. subject_id,
  45. ": expected ", subTR_per_TR,
  46. ", got ", n_subtr
  47. )
  48. }
  49. ## -----------------------------
  50. ## subTR-level output
  51. ## -----------------------------
  52. df_x <- reshape2::melt(pred_x)
  53. df_y <- reshape2::melt(pred_y)
  54. df_euc <- reshape2::melt(euc)
  55. colnames(df_x) <- c("TR_index", "subTR_index", "x")
  56. colnames(df_y) <- c("TR_index", "subTR_index", "y")
  57. colnames(df_euc) <- c("TR_index", "subTR_index", "euc")
  58. df_sub <- df_x %>%
  59. left_join(df_y, by = c("TR_index", "subTR_index")) %>%
  60. left_join(df_euc, by = c("TR_index", "subTR_index")) %>%
  61. mutate(
  62. subject = subject_id,
  63. task = task_lower,
  64. time = ((TR_index - 1) + (subTR_index - 1) / subTR_per_TR) * TR
  65. ) %>%
  66. arrange(time) %>%
  67. select(subject, task, TR_index, subTR_index, time, x, y, euc)
  68. ## -----------------------------
  69. ## TR-averaged output
  70. ## -----------------------------
  71. df_mean <- data.frame(
  72. subject = subject_id,
  73. task = task_lower,
  74. TR_index = seq_len(n_tr),
  75. time = seq_len(n_tr) * TR,
  76. x = rowMeans(pred_x, na.rm = TRUE),
  77. y = rowMeans(pred_y, na.rm = TRUE),
  78. euc = rowMeans(euc, na.rm = TRUE)
  79. )
  80. ## -----------------------------
  81. ## Write files
  82. ## -----------------------------
  83. subtr_file <- file.path(
  84. output_dir,
  85. paste0(subject_id, "_", task_lower, "_subTR.csv")
  86. )
  87. mean_file <- file.path(
  88. output_dir,
  89. paste0(subject_id, "_", task_lower, "_mean.csv")
  90. )
  91. write.csv(df_sub, subtr_file, row.names = FALSE, quote = FALSE)
  92. write.csv(df_mean, mean_file, row.names = FALSE, quote = FALSE)
  93. return(
  94. data.frame(
  95. subject = subject_id,
  96. task = task_lower,
  97. n_TR = n_tr,
  98. n_subTR_per_TR = n_subtr,
  99. subTR_file = subtr_file,
  100. mean_file = mean_file
  101. )
  102. )
  103. }
  104. process_prediction_files <- function(task_upper, task_lower) {
  105. prediction_files <- dir(
  106. path = prediction_dir,
  107. pattern = paste0(".*", task_upper, ".*\\.npz$"),
  108. full.names = TRUE
  109. )
  110. if (length(prediction_files) == 0) {
  111. warning("No prediction files found for task: ", task_upper)
  112. return(data.frame())
  113. }
  114. message("Processing task: ", task_upper)
  115. message("Number of prediction files: ", length(prediction_files))
  116. summary_all <- data.frame()
  117. for (file_i in prediction_files) {
  118. message("Reading: ", file_i)
  119. data_npz <- np$load(file = file_i, allow_pickle = TRUE)
  120. prediction_dict <- data_npz[[1]]
  121. runs <- names(prediction_dict)
  122. subject_ids <- sapply(runs, extract_subject_id, task_lower = task_lower)
  123. keep_idx <- subject_ids %in% hbn_ids
  124. runs_keep <- runs[keep_idx]
  125. subject_ids_keep <- subject_ids[keep_idx]
  126. message("Matched HBN runs in this file: ", length(runs_keep))
  127. for (j in seq_along(runs_keep)) {
  128. run_name <- runs_keep[j]
  129. subject_id <- subject_ids_keep[j]
  130. data_df <- prediction_dict[[which(names(prediction_dict) == run_name)]]
  131. run_summary <- format_prediction_one_run(
  132. data_df = data_df,
  133. subject_id = subject_id,
  134. task_lower = task_lower
  135. )
  136. summary_all <- bind_rows(summary_all, run_summary)
  137. }
  138. }
  139. return(summary_all)
  140. }
  141. ## ============================================================
  142. ## Run DM and TP
  143. ## ============================================================
  144. summary_dm <- process_prediction_files(
  145. task_upper = "DM",
  146. task_lower = "dm"
  147. )
  148. summary_tp <- process_prediction_files(
  149. task_upper = "TP",
  150. task_lower = "tp"
  151. )
  152. summary_all <- bind_rows(summary_dm, summary_tp)
  153. summary_file <- file.path(output_dir, "HBN_prediction_formatting_summary.csv")
  154. write.csv(
  155. summary_all,
  156. summary_file,
  157. row.names = FALSE
  158. )

02_prediction_extraction.R, no license · at the source

Overview

Authors: Le Gao1, Zhi Wei1, Bharat B Biswal2, Xin Di2
ORCID iDs: Xin Di
  1. Department of Computer Science, New Jersey Institute of Technology, University Heights, Newark, NJ 07102, United States
  2. Department of Biomedical Engineering, New Jersey Institute of Technology, University Heights, Newark, NJ 07102, United States
Institutions: New Jersey Institute of Technology (United States)
Journal: Psychoradiology, volume 6, article kkag026
Dates: received 14 January 2026; accepted 8 June 2026; published online 26 June 2026
Type: Review · Language: English
License: CC BY
Identifiers: DOI 10.1093/psyrad/kkag026 · PMID 42534530 · PMCID PMC13421079 · OpenAlex W7166183128
Open access: diamond, a free copy (OpenAlex)
Status: code verified
Categories: fMRI (modality)
Methods: Connectivity, Statistics, fMRI & imaging, Physiology & signal measures, Machine learning
Keywords: convolutional neural network, frontal eye field, gaze prediction, inter-individual correlation, naturalistic condition
Journal subjects: Special issue: Naturalistic Neuroimaging: A New Perspective on Psychiatric Disorders
Topic: Visual Attention and Saliency Detection (Computer Vision and Pattern Recognition, Computer Science), according to OpenAlex
Funding: NIH (R15MH125332, 5R01MH131335, 5R01AG085665, 4R01NS124778); Governor’s Council for Medical Research and Treatment of Autism (CAUT25BRP005)
Citations: not cited yet (Europe PMC); 35 references in the paper

Abstract

Background: Eye gaze provides crucial insights into perceptual and cognitive processes during naturalistic movie viewing, yet concurrent eye tracking is often unavailable in functional MRI (fMRI) research. While deep learning models can estimate gaze directly from fMRI eyeball signals, their out-of-the-box generalizability across heterogeneous datasets requires empirical evaluation.

Methods: We applied a specific pre-trained model from the DeepMReye framework in a zero-shot setting (without dataset-specific fine-tuning) to estimate gaze during movie watching across three independent fMRI datasets. Model accuracy was evaluated against camera-based eye-tracking data and via inter-subject correlations. Furthermore, we derived eye-movement-related time series from the predicted gaze signals to map their associated brain activation.

Results: At the individual level, predicted gaze showed modest correspondence with measured ground-truth data (r ≈ 0.24–0.37), yielding brain activation maps largely restricted to the visual cortex. In contrast, group-averaged gaze predictions exhibited substantially higher reliability (r ≈ 0.73–0.84). First-level general linear models (GLMs) derived from group-averaged predictions successfully revealed widespread activation across established oculomotor control regions, including the frontal and parietal eye fields. Exploratory analyses of age-related effects on gaze prediction and brain activity yielded inconsistent results across datasets.

Conclusions: Under a zero-shot implementation, the pre-trained model exhibits limitations for individual-level inference, likely reflecting the absence of dataset-specific training. However, group-averaged fMRI-based gaze estimates successfully capture shared viewing behaviors and robustly support the investigation of eye-movement-related brain activity. These findings inform the appropriate use of fMRI-based gaze decoding for naturalistic neuroimaging datasets lacking ground-truth eye-tracking logs.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 2 matches between paragraphs and lines of code.

OSF chgpx

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: MATLAB (4), R (3)
Size: 7 files, 7 scripts
Software Heritage: not checked
Found in: “Data and code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: SPM (3 files), tidyverse (3 files), reshape2 (2 files), cowplot (1 file), ggplot2 (1 file), Image Processing Toolbox (1 file), Statistics and Machine Learning Toolbox (1 file), patchwork (1 file), reticulate (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
7 files
At the source: osf.io/chgpx/

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:

  • 1 repository 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;
  • 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

Datasets cited

Data and code availability

MRI and eye-tracking data were obtained from publicly available sources: the NV dataset (https://fcon_1000.projects.nitrc.org/indi/retro/nat_view.html), the HBN dataset (http://fcon_1000.projects.nitrc.org/indi/cmi_healthy_brain_network/), and the OpenNeuro repository (https://openneuro.org/datasets/ds000228). Analysis scripts are available at: https://osf.io/chgpx/.

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, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 4 authors, 5 keywords, 2 funders, 29 references.

Cite

This paper

Gao, L., Wei, Z., Biswal, B. B., & Di, X. (2026). fMRI-based prediction of eye gaze during naturalistic movie viewing reveals eye-movement-related brain activity. Psychoradiology, 6, kkag026. https://doi.org/10.1093/psyrad/kkag026

BibTeX

@article{gao2026fmri,
author = {Gao, Le and Wei, Zhi and Biswal, Bharat B and Di, Xin},
title = {{fMRI-based prediction of eye gaze during naturalistic movie viewing reveals eye-movement-related brain activity}},
journal = {Psychoradiology},
year = {2026},
month = jun,
volume = {6},
pages = {kkag026},
publisher = {Oxford University Press},
issn = {2634-4416},
doi = {10.1093/psyrad/kkag026},
url = {https://doi.org/10.1093/psyrad/kkag026},
pmid = {42534530},
pmcid = {PMC13421079}
}

RIS

TY - JOUR
AU - Gao, Le
AU - Wei, Zhi
AU - Biswal, Bharat B
AU - Di, Xin
TI - fMRI-based prediction of eye gaze during naturalistic movie viewing reveals eye-movement-related brain activity
T2 - Psychoradiology
J2 - Psychoradiology
PY - 2026
DA - 2026/06/26
VL - 6
SP - kkag026
SN - 2634-4416
PB - Oxford University Press
DO - 10.1093/psyrad/kkag026
UR - https://doi.org/10.1093/psyrad/kkag026
LA - en
ER -

CSL-JSON

{
"id": "10.1093/psyrad/kkag026",
"type": "article-journal",
"title": "fMRI-based prediction of eye gaze during naturalistic movie viewing reveals eye-movement-related brain activity",
"container-title": "Psychoradiology",
"author": [
{
"family": "Gao",
"given": "Le"
},
{
"family": "Wei",
"given": "Zhi"
},
{
"family": "Biswal",
"given": "Bharat B"
},
{
"family": "Di",
"given": "Xin"
}
],
"container-title-short": "Psychoradiology",
"volume": "6",
"page": "kkag026",
"DOI": "10.1093/psyrad/kkag026",
"PMID": "42534530",
"PMCID": "PMC13421079",
"ISSN": "2634-4416",
"publisher": "Oxford University Press",
"URL": "https://doi.org/10.1093/psyrad/kkag026",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
26
]
]
}
}

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.1162/imag.a.1331 [code]
Beyond the canonical HRF: Flexible temporal modeling reveals unconstrained BOLD profiles during naturalistic viewing.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: OpenNeuro ds000228, fMRI, 4 references, author Xin Di
[2] doi:10.1162/imag.a.1347 [code]
Neural and behavioural correlates of theory of mind reasoning in five-year-old children born preterm.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: reshape2, patchwork, ggplot2, 1 other tool, OpenNeuro ds000228, fMRI, 3 references
[3] doi:10.1002/hbm.70605 [code]
BrainEnrich: Revealing Biological Insights for Imaging-Derived Phenotypes Through Transcriptomic Enrichment.
Journal: Human brain mapping
In common: reticulate, SPM, cowplot, 5 other tools
[4] doi:10.1038/s41467-026-74331-2 [code]
Trial-by-trial fMRI-neurofeedback dissociates fusiform and occipital contributions to face detection and recognition.
Journal: Nature communications
In common: SPM, cowplot, Image Processing Toolbox, 4 other tools, fMRI
[5] doi:10.1016/j.dcn.2026.101765 [code]
Fusiform face area development correlates with development in higher-order social brain regions.
Journal: Developmental cognitive neuroscience
In common: reshape2, patchwork, tidyverse, OpenNeuro ds000228, fMRI
[6] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: reticulate, SPM, reshape2, 4 other tools
[7] doi:10.1038/s41467-026-74565-0 [code]
The functional neurobiology of dispositions towards negative emotions.
Journal: Nature communications
In common: SPM, cowplot, reshape2, 4 other tools
[8] doi:10.1038/s41586-026-10490-y [code]
Lineage and organ signals sequentially build organ intrinsic nervous systems.
Journal: Nature
In common: cowplot, reshape2, Image Processing Toolbox, 4 other tools
[9] doi:10.1162/imag.a.1330 [code]
Human risk taking and metabolic state: No credible evidence for desacyl-ghrelin modulation of neural or behavioural effects.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: SPM, cowplot, reshape2, 3 other tools, fMRI
[10] doi:10.1038/s41467-026-76939-w [code]
HIPPIE: a generative model for electrophysiological analysis across species, technologies, and modalities.
Journal: Nature communications
In common: reticulate, cowplot, reshape2, 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.

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.