THERM-D uncovers distinct neural mechanisms separating morning and evening body temperature rhythms in Drosophila
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 211 lines · 6.7 KB · CC-BY-4.0
- """Entry point for running the fly detection package on a data set.
- """
- from argparse import ArgumentParser
- from pathlib import Path
- import cv2
- import matplotlib.pyplot as plt
- import numpy as np
- from . import cli
- from . import detect
- from . import io
- from . import match
- from . import ops
- from . import registration as reg
- from . import train
- from . import viz
- def register_arenas(config):
- """Register the fly arenas.
- """
- # TODO:
- # + Expose mask_hsv parameters
- config = config["register"]
- # Read the data set.
- data_dir = Path(config["data_path"])
- print(f"Data set directory: '{data_dir}'")
- if not data_dir.is_dir():
- raise IOError(f"'{data_dir}' is not a directory.")
- dset = io.FlyDatasetReader(data_dir)
- print(f" Found {len(dset)} images.\n")
- # Make sure the output directory exists.
- output_dir = config.get("output_path", data_dir / "arenas")
- cli.prompt_overwrite(output_dir, "Output directory", mkdir = True)
- debug_dir = None
- is_debug = config.get("debug", False)
- if is_debug:
- debug_dir = data_dir / "debug/arenas"
- cli.prompt_overwrite(debug_dir, "Debug directory", mkdir = True)
- print()
- image_set = dset.iter_read()
- if "arena" in config:
- # Arena coordinates are specified in config.
- arena_set = reg.get_arenas(image_set, config)
- else:
- # Detect arena coordinates.
- arena_set = reg.detect_arenas(image_set, config, debug_dir)
- # Rotate images and arenas by specified/detected rotation.
- arena_set = reg.rotate_images_with_arenas(arena_set)
- image_set, arenas = zip(*arena_set)
- # Compute median arena position. No need to convert to int since the
- # perspective transformation requires float inputs.
- print("Computing median arena boundary...\n")
- arenas = np.stack(arenas)
- arena = np.median(arenas, axis = 0).reshape(-1, 2)
- print(f"{arena=}")
- transform, width, height = ops.get_perspective_transform(arena)
- print(f"{width=}, {height=}\n")
- # Extract and save the arenas.
- print("Cropping, gamma-adjusting, and saving arenas...\n")
- for path, img in image_set:
- img = cv2.warpPerspective(
- img, transform, (width, height), flags = cv2.INTER_CUBIC)
- img = ops.adaptive_gamma_correction(img)
- # Save the cropped, gamma-adjusted image.
- output_path = output_dir / path.name
- img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
- cv2.imwrite(str(output_path), img)
- print(f"Wrote '{output_path}'.")
- def match_flies(config):
- """Apply template matching to fly images.
- """
- # TODO:
- # + Scale templates according to size of image
- # + Expose match.extract parameters
- apparatuses = config["apparatuses"]
- config = config["register"]
- # Read the data set.
- data_dir = Path(config["data_path"])
- print(f"Data set directory: '{data_dir}'")
- if not data_dir.is_dir():
- raise IOError(f"'{data_dir}' is not a directory.")
- dset = io.FlyDatasetReader(data_dir)
- print(f" Found {len(dset)} images.\n")
- # Make sure the output directory exists.
- output_dir = config.get("output_path", data_dir / "match_labels")
- cli.prompt_overwrite(output_dir, "Output directory", mkdir = True)
- is_debug = config.get("debug", False)
- if is_debug:
- debug_dir = data_dir / "debug/match_labels"
- cli.prompt_overwrite(debug_dir, "Debug directory", mkdir = True)
- print()
- # Load the templates.
- template_path = Path("outputs/fly_template.npz")
- #template_path = Path("outputs/test_rotations.npz")
- print(f"Template path: '{template_path}'")
- templates, template_shape = io.read_fly_template(template_path)
- print(f" Found {len(templates)} template images.\n")
- # Resize templates based on relative arena size.
- arena_w_cm = apparatuses[dset.apparatus]["horizontal"]
- # FIXME:
- arena_w_px = cv2.imread(str(dset[0])).shape[1]
- arena_scale = arena_w_px / arena_w_cm
- template_scale = 4280 / 28.6
- scale = arena_scale / template_scale
- width = int(round(templates[0].shape[1] * scale))
- height = int(round(templates[0].shape[0] * scale))
- dim = (width, height)
- c = 0
- for i in templates:
- templates[c] = cv2.resize(i, dim, interpolation = cv2.INTER_AREA)
- c += 1
- # Process each image.
- print("Processing images...\n")
- for path, img in dset.iter_read_arenas():
- print(f"Processing '{path}'.")
- # Run template matching.
- boxes, scores = match.concatenate(
- [match.extract(img, t, verbose = is_debug) for t in templates])
- boxes = match.suppress_nonmax(boxes, scores)
- print(f" Found {boxes.shape[0]} boxes.")
- if is_debug:
- # Output a diagnostic image.
- ax = viz.plot_image(img, figsize = (15, 15))
- for i in range(boxes.shape[0]):
- viz.plot_box(boxes[i, :], ax)
- debug_path = debug_dir / path.name
- plt.savefig(debug_path, bbox_inches = "tight")
- print(f" Wrote '{debug_path}'.")
- # Save to a YOLO file.
- output_path = output_dir / (str(path.stem) + ".txt")
- io.write_yolo(output_path, boxes, None, img.shape)
- print(f" Wrote '{output_path}'.\n")
- fly_label = f"{output_dir}/labels.txt"
- with open(fly_label, mode = "wt") as file:
- file.write("fly")
- def main():
- # Parse command line arguments.
- parser = ArgumentParser()
- parser.add_argument(
- "--debug", action = "store_true"
- , help = "output diagnostic information")
- subparsers = parser.add_subparsers(title = "subcommands")
- register_parser = subparsers.add_parser(
- "register", help = "(step 1) register arenas in data set")
- register_parser.set_defaults(func = register_arenas)
- detect_parser = subparsers.add_parser(
- "detect", help = "apply a fly detection model to a dataset")
- detect_parser.set_defaults(func = detect.main)
- match_parser = subparsers.add_parser(
- "match", help = "apply template matching to data set")
- match_parser.set_defaults(func = match_flies)
- assemble_parser = subparsers.add_parser(
- "assemble", help = "assemble a YOLO object detection training set "
- "from multiple annotated data sets")
- assemble_parser.set_defaults(func = train.assemble_training_set)
- # Add `config` argument to all subparsers.
- for name, subparser in subparsers.choices.items():
- subparser.add_argument(
- "config", type = Path, help ="path to config file")
- args = parser.parse_args()
- # Read the config file.
- print(f"Config path: '{args.config}'")
- config = io.read_config(args.config)
- args.func(config)
- if __name__ == "__main__":
- main()
__main__.py, under CC-BY-4.0 · at the source
Overview
- Department of Neurobiology, Physiology and Behavior, University of California, Davis, Davis, CA 95616, USA
- Neurobiology and Genetics, Theodor-Boveri-Institute, Biocenter, Julius-Maximilians-University of Würzburg, Am Hubland, 97074 Würzburg, Germany
- DataLab: Data Science and Informatics, University of California, Davis, One Shields Avenue, Davis CA 95616, USA
- Graduate School of Environmental, Life, Natural Science and Technology, Okayama University, Okayama 700-8530, Japan
- University of California, Berkeley School of Public Health, Berkeley, CA 94720, USA
Abstract
Animal body temperature rises throughout the day and peaks in the evening, a pattern conserved across diurnal endotherms and ectotherms. However, the mechanisms driving the robust body temperature rhythms (BTRs) remain largely unclear. Here, we developed a machine learning–based platform, Temperature Homeostasis Evaluation of Rhythmicity in Model Drosophila (THERM-D), enabling continuous, high-throughput analyses of BTR. Using THERM-D, we identified robust BTR patterns reflecting flies’ morning and evening behaviors and revealed the function of CRYPTOCHROME (CRY)–negative clock neurons. About half of all clock neurons lack CRY, yet their functions are only partially understood. Gal4 drivers targeting CRY-negative neurons demonstrated that these neurons control the morning temperature rise. We further show that separate clock circuits regulate morning and evening BTRs. Thus, THERM-D elucidated the role of CRY-negative clock neurons in BTR and provides a powerful platform for uncovering mechanisms underlying circadian temperature homeostasis.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above.
Zenodo 21184934
Availability: 1 check, the latest on 21 November 2026: the link answers (HTTP 200)
- 21 November 2026: the link answers (HTTP 200)
12 files
- src/
__main__.py , Python, 211 lines - src/
cli.py , Python, 53 lines - src/
detect.py , Python, 303 lines - src/
io.py , Python, 356 lines - src/
match.py , Python, 166 lines - src/
ops.py , Python, 202 lines - src/
registration.py , Python, 339 lines - src/
temperature.py , Python, 52 lines - src/
train.py , Python, 161 lines - src/
tsops.py , Python, 59 lines - src/
viz.py , Python, 120 lines - README.md, Text, 466 lines
ucdavisdatalab/therm-d_fly_detection
38149aa097a6a7e06acffa5c7a6f090f83cc4db5, 24 October 2023Availability: 1 check, the latest on 21 November 2026: the link answers
- 21 November 2026: the link answers
12 files
- src/
__main__.py , Python, 211 lines - src/
cli.py , Python, 53 lines - src/
detect.py , Python, 303 lines - src/
io.py , Python, 356 lines - src/
match.py , Python, 166 lines - src/
ops.py , Python, 202 lines - src/
registration.py , Python, 339 lines - src/
temperature.py , Python, 52 lines - src/
train.py , Python, 161 lines - src/
tsops.py , Python, 59 lines - src/
viz.py , Python, 120 lines - README.md, Text, 466 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;
- 22 scripts, each with its path and the digest of its content;
- no match between paragraphs and code yet;
- 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
All data and code needed to evaluate and reproduce the results in the paper are present in the paper and/
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, 21 November 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 19 authors, 65 references, 4 RRIDs.
Cite
This paper
Goda, T., Lopez, O. M., Ramolete, R., Reinhard, N., Ulle, N., Fukuda, A., Umezaki, Y., Rizvi, K., Aikawa, M. G., Catiis, R., Marquez, V. Z., Ngo, R., Raj, N. C., Fisher, C., Bui, G. T., Lee, J., Helfrich-Förster, C., Yoshii, T., & Hamada, F. N. (2026). THERM-D uncovers distinct neural mechanisms separating morning and evening body temperature rhythms in Drosophila. Science advances, 12(47), eaed8055.
BibTeX
@article{goda2026therm,
author = {Goda, Tadahiro and Lopez, Olivia M and Ramolete, Richard and Reinhard, Nils and Ulle, Nick and Fukuda, Ayumi and Umezaki, Yujiro and Rizvi, Kazim and Aikawa, Madison G and Catiis, Roslyn and Marquez, Victoria Z and Ngo, Richard and Raj, Nikita C and Fisher, Cora and Bui, Gregory T and Lee, Jalen and Helfrich-Förster, Charlotte and Yoshii, Taishi and Hamada, Fumika N},
title = {{THERM-D uncovers distinct neural mechanisms separating morning and evening body temperature rhythms in Drosophila}},
journal = {Science advances},
year = {2026},
month = nov,
volume = {12},
number = {47},
pages = {eaed8055},
publisher = {American Association for the Advancement of Science},
issn = {2375-2548},
pmcid = {PMC13787506}
}
RIS
TY - JOUR
AU - Goda, Tadahiro
AU - Lopez, Olivia M
AU - Ramolete, Richard
AU - Reinhard, Nils
AU - Ulle, Nick
AU - Fukuda, Ayumi
AU - Umezaki, Yujiro
AU - Rizvi, Kazim
AU - Aikawa, Madison G
AU - Catiis, Roslyn
AU - Marquez, Victoria Z
AU - Ngo, Richard
AU - Raj, Nikita C
AU - Fisher, Cora
AU - Bui, Gregory T
AU - Lee, Jalen
AU - Helfrich-Förster, Charlotte
AU - Yoshii, Taishi
AU - Hamada, Fumika N
TI - THERM-D uncovers distinct neural mechanisms separating morning and evening body temperature rhythms in Drosophila
T2 - Science advances
J2 - Sci Adv
PY - 2026
DA - 2026/
VL - 12
IS - 47
SP - eaed8055
SN - 2375-2548
PB - American Association for the Advancement of Science
LA - en
ER -
CSL-JSON
{
"id": "pmcid:PMC13787506",
"type": "article-journal",
"title": "THERM-D uncovers distinct neural mechanisms separating morning and evening body temperature rhythms in Drosophila",
"container-title": "Science advances",
"author": [
{
"family": "Goda",
"given": "Tadahiro"
},
{
"family": "Lopez",
"given": "Olivia M"
},
{
"family": "Ramolete",
"given": "Richard"
},
{
"family": "Reinhard",
"given": "Nils"
},
{
"family": "Ulle",
"given": "Nick"
},
{
"family": "Fukuda",
"given": "Ayumi"
},
{
"family": "Umezaki",
"given": "Yujiro"
},
{
"family": "Rizvi",
"given": "Kazim"
},
{
"family": "Aikawa",
"given": "Madison G"
},
{
"family": "Catiis",
"given": "Roslyn"
},
{
"family": "Marquez",
"given": "Victoria Z"
},
{
"family": "Ngo",
"given": "Richard"
},
{
"family": "Raj",
"given": "Nikita C"
},
{
"family": "Fisher",
"given": "Cora"
},
{
"family": "Bui",
"given": "Gregory T"
},
{
"family": "Lee",
"given": "Jalen"
},
{
"family": "Helfrich-Förster",
"given": "Charlotte"
},
{
"family": "Yoshii",
"given": "Taishi"
},
{
"family": "Hamada",
"given": "Fumika N"
}
],
"container-title-short":
"volume": "12",
"issue": "47",
"page": "eaed8055",
"PMCID": "PMC13787506",
"ISSN": "2375-2548",
"publisher": "American Association for the Advancement of Science",
"language": "en",
"issued": {
"date-parts": [
[
2026,
11,
20
]
]
}
}
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.1016/j.celrep.2022.110668
- Dorsal clock networks drive temperature preference rhythms in Drosophila.Journal: Cell reportsIn common: drosophila, 28 references
- [2] doi:10.7554/elife.79139 [code]
- Connectomic analysis of the &
lt;i& gt;Drosophila& lt;/ i& gt; lateral neuron clock cells reveals the synaptic basis of functional pacemaker classes. Journal: eLifeIn common: pandas, Matplotlib, NumPy, drosophila, 13 references - [3] doi:10.1073/pnas.2506164122 [code]
- A functional clock in only two dorsal clock neurons is sufficient to restore the basal circadian activity pattern of &
lt;i& gt;Drosophila melanogaster& lt;/ i& gt;. Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: drosophila, 11 references - [4] doi:10.1371/journal.pbio.3002918
- Temperature cues are integrated in a flexible circadian neuropeptidergic feedback circuit to remodel sleep-wake patterns in flies.Journal: PLoS biologyIn common: drosophila, 10 references
- [5] doi:10.7554/elife.85410 [code]
- Neural mechanisms of parasite-induced summiting behavior in 'zombie' <i>Drosophila</
i>. Journal: eLifeIn common: drosophila, 9 references - [6] doi:10.1073/pnas.2206066119
- Dopamine and GPCR-mediated modulation of DN1 clock neurons gates the circadian timing of sleep.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: drosophila, 9 references
- [7] doi:10.1126/sciadv.adr4580
- Transcriptomic DN3 clock neuron subtypes regulate <i>Drosophila</
i> sleep. Journal: Science advancesIn common: drosophila, 9 references - [8] doi:10.7554/elife.103359
- Circadian control of a sex-specific behavior in &
lt;i& gt;Drosophila& lt;/ i& gt;. Journal: eLifeIn common: drosophila, 9 references - [9] doi:10.1126/sciadv.adw4666
- Synaptic targets of circadian clock neurons influence core clock parameters.Journal: Science advancesIn common: drosophila, 9 references
- [10] doi:10.7554/elife.91927 [code]
- Conditional chemoconnectomics (cCCTomics) as a strategy for efficient and conditional targeting of chemical transmission.Journal: eLifeIn common: drosophila, 8 references
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, 22 scripts, and 0 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:82f4a31999cf8e11…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/repo/zenodo:21184934)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/repo/zenodo:21184934.svg
:target: https://openscicode.org/badge/repo/zenodo:21184934
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/repo/zenodo:21184934"><img src="https://openscicode.org/badge/repo/zenodo:21184934.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge 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: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
