OSCR

Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning.

Code ↔ Paper

1 match 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 1 match
  1. [1] § 4. Experiments and Results › 4.5. Implementation Details › 4.5.1. Brain Cortex and Vessels Segmentation Training Details ↔ main_supcon.py, lines 131–176 · score 0.53 · random resized cropping, jittering, horizontal, flips, composed, transformations

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 · 296 lines · 10 KB · BSD-2-Clause · 1 match

  1. from __future__ import print_function
  2. import os
  3. import sys
  4. import argparse
  5. import time
  6. import math
  7. import tensorboard_logger as tb_logger
  8. import torch
  9. import torch.backends.cudnn as cudnn
  10. from torchvision import transforms, datasets
  11. from util import TwoCropTransform, AverageMeter
  12. from util import adjust_learning_rate, warmup_learning_rate
  13. from util import set_optimizer, save_model
  14. from networks.resnet_big import SupConResNet
  15. from losses import SupConLoss
  16. try:
  17. import apex
  18. from apex import amp, optimizers
  19. except ImportError:
  20. pass
  21. def parse_option():
  22. parser = argparse.ArgumentParser('argument for training')
  23. parser.add_argument('--print_freq', type=int, default=10,
  24. help='print frequency')
  25. parser.add_argument('--save_freq', type=int, default=50,
  26. help='save frequency')
  27. parser.add_argument('--batch_size', type=int, default=256,
  28. help='batch_size')
  29. parser.add_argument('--num_workers', type=int, default=16,
  30. help='num of workers to use')
  31. parser.add_argument('--epochs', type=int, default=1000,
  32. help='number of training epochs')
  33. # optimization
  34. parser.add_argument('--learning_rate', type=float, default=0.05,
  35. help='learning rate')
  36. parser.add_argument('--lr_decay_epochs', type=str, default='700,800,900',
  37. help='where to decay lr, can be a list')
  38. parser.add_argument('--lr_decay_rate', type=float, default=0.1,
  39. help='decay rate for learning rate')
  40. parser.add_argument('--weight_decay', type=float, default=1e-4,
  41. help='weight decay')
  42. parser.add_argument('--momentum', type=float, default=0.9,
  43. help='momentum')
  44. # model dataset
  45. parser.add_argument('--model', type=str, default='resnet50')
  46. parser.add_argument('--dataset', type=str, default='cifar10',
  47. choices=['cifar10', 'cifar100', 'path'], help='dataset')
  48. parser.add_argument('--mean', type=str, help='mean of dataset in path in form of str tuple')
  49. parser.add_argument('--std', type=str, help='std of dataset in path in form of str tuple')
  50. parser.add_argument('--data_folder', type=str, default=None, help='path to custom dataset')
  51. parser.add_argument('--size', type=int, default=32, help='parameter for RandomResizedCrop')
  52. # method
  53. parser.add_argument('--method', type=str, default='SupCon',
  54. choices=['SupCon', 'SimCLR'], help='choose method')
  55. # temperature
  56. parser.add_argument('--temp', type=float, default=0.07,
  57. help='temperature for loss function')
  58. # other setting
  59. parser.add_argument('--cosine', action='store_true',
  60. help='using cosine annealing')
  61. parser.add_argument('--syncBN', action='store_true',
  62. help='using synchronized batch normalization')
  63. parser.add_argument('--warm', action='store_true',
  64. help='warm-up for large batch training')
  65. parser.add_argument('--trial', type=str, default='0',
  66. help='id for recording multiple runs')
  67. opt = parser.parse_args()
  68. # check if dataset is path that passed required arguments
  69. if opt.dataset == 'path':
  70. assert opt.data_folder is not None \
  71. and opt.mean is not None \
  72. and opt.std is not None
  73. # set the path according to the environment
  74. if opt.data_folder is None:
  75. opt.data_folder = './datasets/'
  76. opt.model_path = './save/SupCon/{}_models'.format(opt.dataset)
  77. opt.tb_path = './save/SupCon/{}_tensorboard'.format(opt.dataset)
  78. iterations = opt.lr_decay_epochs.split(',')
  79. opt.lr_decay_epochs = list([])
  80. for it in iterations:
  81. opt.lr_decay_epochs.append(int(it))
  82. opt.model_name = '{}_{}_{}_lr_{}_decay_{}_bsz_{}_temp_{}_trial_{}'.\
  83. format(opt.method, opt.dataset, opt.model, opt.learning_rate,
  84. opt.weight_decay, opt.batch_size, opt.temp, opt.trial)
  85. if opt.cosine:
  86. opt.model_name = '{}_cosine'.format(opt.model_name)
  87. # warm-up for large-batch training,
  88. if opt.batch_size > 256:
  89. opt.warm = True
  90. if opt.warm:
  91. opt.model_name = '{}_warm'.format(opt.model_name)
  92. opt.warmup_from = 0.01
  93. opt.warm_epochs = 10
  94. if opt.cosine:
  95. eta_min = opt.learning_rate * (opt.lr_decay_rate ** 3)
  96. opt.warmup_to = eta_min + (opt.learning_rate - eta_min) * (
  97. 1 + math.cos(math.pi * opt.warm_epochs / opt.epochs)) / 2
  98. else:
  99. opt.warmup_to = opt.learning_rate
  100. opt.tb_folder = os.path.join(opt.tb_path, opt.model_name)
  101. if not os.path.isdir(opt.tb_folder):
  102. os.makedirs(opt.tb_folder)
  103. opt.save_folder = os.path.join(opt.model_path, opt.model_name)
  104. if not os.path.isdir(opt.save_folder):
  105. os.makedirs(opt.save_folder)
  106. return opt
  107. def set_loader(opt):
  108. # construct data loader
  109. if opt.dataset == 'cifar10':
  110. mean = (0.4914, 0.4822, 0.4465)
  111. std = (0.2023, 0.1994, 0.2010)
  112. elif opt.dataset == 'cifar100':
  113. mean = (0.5071, 0.4867, 0.4408)
  114. std = (0.2675, 0.2565, 0.2761)
  115. elif opt.dataset == 'path':
  116. mean = eval(opt.mean)
  117. std = eval(opt.std)
  118. else:
  119. raise ValueError('dataset not supported: {}'.format(opt.dataset))
  120. normalize = transforms.Normalize(mean=mean, std=std)
  121. train_transform = transforms.Compose([
  122. transforms.RandomResizedCrop(size=opt.size, scale=(0.2, 1.)),
  123. transforms.RandomHorizontalFlip(),
  124. transforms.RandomApply([
  125. transforms.ColorJitter(0.4, 0.4, 0.4, 0.1)
  126. ], p=0.8),
  127. transforms.RandomGrayscale(p=0.2),
  128. transforms.ToTensor(),
  129. normalize,
  130. ])
  131. if opt.dataset == 'cifar10':
  132. train_dataset = datasets.CIFAR10(root=opt.data_folder,
  133. transform=TwoCropTransform(train_transform),
  134. download=True)
  135. elif opt.dataset == 'cifar100':
  136. train_dataset = datasets.CIFAR100(root=opt.data_folder,
  137. transform=TwoCropTransform(train_transform),
  138. download=True)
  139. elif opt.dataset == 'path':
  140. train_dataset = datasets.ImageFolder(root=opt.data_folder,
  141. transform=TwoCropTransform(train_transform))
  142. else:
  143. raise ValueError(opt.dataset)
  144. train_sampler = None
  145. train_loader = torch.utils.data.DataLoader(
  146. train_dataset, batch_size=opt.batch_size, shuffle=(train_sampler is None),
  147. num_workers=opt.num_workers, pin_memory=True, sampler=train_sampler)
  148. return train_loader
  149. def set_model(opt):
  150. model = SupConResNet(name=opt.model)
  151. criterion = SupConLoss(temperature=opt.temp)
  152. # enable synchronized Batch Normalization
  153. if opt.syncBN:
  154. model = apex.parallel.convert_syncbn_model(model)
  155. if torch.cuda.is_available():
  156. if torch.cuda.device_count() > 1:
  157. model.encoder = torch.nn.DataParallel(model.encoder)
  158. model = model.cuda()
  159. criterion = criterion.cuda()
  160. cudnn.benchmark = True
  161. return model, criterion
  162. def train(train_loader, model, criterion, optimizer, epoch, opt):
  163. """one epoch training"""
  164. model.train()
  165. batch_time = AverageMeter()
  166. data_time = AverageMeter()
  167. losses = AverageMeter()
  168. end = time.time()
  169. for idx, (images, labels) in enumerate(train_loader):
  170. data_time.update(time.time() - end)
  171. images = torch.cat([images[0], images[1]], dim=0)
  172. if torch.cuda.is_available():
  173. images = images.cuda(non_blocking=True)
  174. labels = labels.cuda(non_blocking=True)
  175. bsz = labels.shape[0]
  176. # warm-up learning rate
  177. warmup_learning_rate(opt, epoch, idx, len(train_loader), optimizer)
  178. # compute loss
  179. features = model(images)
  180. f1, f2 = torch.split(features, [bsz, bsz], dim=0)
  181. features = torch.cat([f1.unsqueeze(1), f2.unsqueeze(1)], dim=1)
  182. if opt.method == 'SupCon':
  183. loss = criterion(features, labels)
  184. elif opt.method == 'SimCLR':
  185. loss = criterion(features)
  186. else:
  187. raise ValueError('contrastive method not supported: {}'.
  188. format(opt.method))
  189. # update metric
  190. losses.update(loss.item(), bsz)
  191. # SGD
  192. optimizer.zero_grad()
  193. loss.backward()
  194. optimizer.step()
  195. # measure elapsed time
  196. batch_time.update(time.time() - end)
  197. end = time.time()
  198. # print info
  199. if (idx + 1) % opt.print_freq == 0:
  200. print('Train: [{0}][{1}/{2}]\t'
  201. 'BT {batch_time.val:.3f} ({batch_time.avg:.3f})\t'
  202. 'DT {data_time.val:.3f} ({data_time.avg:.3f})\t'
  203. 'loss {loss.val:.3f} ({loss.avg:.3f})'.format(
  204. epoch, idx + 1, len(train_loader), batch_time=batch_time,
  205. data_time=data_time, loss=losses))
  206. sys.stdout.flush()
  207. return losses.avg
  208. def main():
  209. opt = parse_option()
  210. # build data loader
  211. train_loader = set_loader(opt)
  212. # build model and criterion
  213. model, criterion = set_model(opt)
  214. # build optimizer
  215. optimizer = set_optimizer(opt, model)
  216. # tensorboard
  217. logger = tb_logger.Logger(logdir=opt.tb_folder, flush_secs=2)
  218. # training routine
  219. for epoch in range(1, opt.epochs + 1):
  220. adjust_learning_rate(opt, optimizer, epoch)
  221. # train for one epoch
  222. time1 = time.time()
  223. loss = train(train_loader, model, criterion, optimizer, epoch, opt)
  224. time2 = time.time()
  225. print('epoch {}, total time {:.2f}'.format(epoch, time2 - time1))
  226. # tensorboard logger
  227. logger.log_value('loss', loss, epoch)
  228. logger.log_value('learning_rate', optimizer.param_groups[0]['lr'], epoch)
  229. if epoch % opt.save_freq == 0:
  230. save_file = os.path.join(
  231. opt.save_folder, 'ckpt_epoch_{epoch}.pth'.format(epoch=epoch))
  232. save_model(model, optimizer, opt, epoch, save_file)
  233. # save the last model
  234. save_file = os.path.join(
  235. opt.save_folder, 'last.pth')
  236. save_model(model, optimizer, opt, opt.epochs, save_file)
  237. if __name__ == '__main__':
  238. main()

main_supcon.py at commit 66a8fe5, under BSD-2-Clause · at the source

Overview

  1. Research Center on Software Technologies and Multimedia Systems, Universidad Politécnica de Madrid (UPM), 28031 Madrid, Spain; (A.M.-P.)
  2. Neurosurgery Department, Hospital Universitario 12 de Octubre, 28041 Madrid, Spain
  3. Medicine Faculty, Universidad Complutense de Madrid (UCM), 28040 Madrid, Spain
  4. Instituto de Investigación Sanitaria Hospital 12 de Octubre (Imas12), 28041 Madrid, Spain
Journal: Cancers, volume 18, issue 5, article 857
Dates: received 21 January 2026; accepted 2 March 2026; published online 6 March 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3390/cancers18050857 · PMID 41827790 · PMCID PMC12984245 · OpenAlex W7134107051
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: other condition (population), methods / tools (subfield)
Methods: Connectivity, Machine learning
Keywords: hyperspectral, segmentation, transfer learning, vessel segmentation, cortical segmentation
Topic: Optical Imaging and Spectroscopy Techniques (Radiology, Nuclear Medicine and Imaging, Medicine), according to OpenAlex
Funding: the European project STRATUM (no. 101137416)
Citations: not cited yet (Europe PMC); 68 references in the paper

Abstract

Background: Accurate in vivo brain tumor detection using hyperspectral imaging (HSI), a non-invasive technique that captures spectral information beyond the visible range, is challenging due to the complexity of biological tissues and the difficulty in distinguishing malignant from healthy areas. Conventional neural-network-based methods often misclassify tumor tissue as blood vessels, largely due to high vascularization and the scarcity of annotated data. Method: To address this issue, this work proposes an underexplored approach that decomposes the problem into two tasks: (1) segmentation of the brain cortical surface and its blood vessels, and (2) segmentation of biological tissues within the segmented craniotomy site. The cortical segmentation task is addressed independently of the segmentation model used in the second stage. To achieve this, a set of pseudo-labels is generated from RGB and HSI captures acquired during in vivo brain surgeries. These pseudo-labels support a multimodal training strategy that leverages both imaging domains, yielding a model capable of segmenting the craniotomy site and the blood vessels contained in it. The model is further refined on HSI using weakly supervised fine-tuning with sparse ground truth annotations. Results: The final segmentation map combines cortical and tissue segmentation outputs, considering only cortex pixels not overlapped by vessels as potential tumor regions. This simplifies the HSI tissue segmentation task, reframing it as a binary segmentation of healthy vs. other tissues, while still enabling a comprehensive multiclass output. Conclusions: The proposed method achieves up to a 15.48% increase in F1 score for the tumor class, while segmenting the brain cortex with a mean Dice similarity coefficient (DSC) of 92.08% and accurately detecting 95.42% of labeled blood vessel samples in the HSI dataset.

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 1 match between paragraphs and lines of code.

hobbitlong/supcontrast

License: BSD-2-Clause
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 66a8fe53880d6a1084b2e4e0db0a019024d6d41a, 26 December 2023
Languages: Python (6)
Size: 14 files, 6 scripts
Software Heritage: not archived
Found in: the text, “3.4.1. Encoder Pre-Training”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: PyTorch (6 files), NumPy (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
8 files

gitlab.citsem.upm.es/public-projects/hyperspectral/cortical_segmentation

License: none: the authors keep all their rights
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 4968d2685d0aafe273f34e904e546d04ed7ebf21, 5 March 2026
Size: 1 file, 0 scripts
Software Heritage: not archived
Found in: “Data Availability Statement”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
1 file

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;
  • 6 scripts, each with its path and the digest of its content;
  • 1 match 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 Statement

All the in vivo hyperspectral human brain data used in this study is present in the SLIMBRAIN database, which is available at https://slimbrain.citsem.upm.es/ (accessed on 10 December 2025). Note that access must be granted, under reasonable request, before downloading the data. The source code can be found at: https://gitlab.citsem.upm.es/public-projects/hyperspectral/cortical_segmentation (accessed on 26 February 2026).

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, 6 authors, 5 keywords, 1 funder, 43 references.

Cite

This paper

Vazquez, G., Martín-Pérez, A., Perez-Nuñez, A., Lagares, A., Juarez, E., & Sanz, C. (2026). Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning. Cancers, 18(5), 857. https://doi.org/10.3390/cancers18050857

BibTeX

@article{vazquez2026improving,
author = {Vazquez, Guillermo and Martín-Pérez, Alberto and Perez-Nuñez, Angel and Lagares, Alfonso and Juarez, Eduardo and Sanz, Cesar},
title = {{Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning}},
journal = {Cancers},
year = {2026},
month = mar,
volume = {18},
number = {5},
pages = {857},
publisher = {Multidisciplinary Digital Publishing Institute (MDPI)},
issn = {2072-6694},
doi = {10.3390/cancers18050857},
url = {https://doi.org/10.3390/cancers18050857},
pmid = {41827790},
pmcid = {PMC12984245}
}

RIS

TY - JOUR
AU - Vazquez, Guillermo
AU - Martín-Pérez, Alberto
AU - Perez-Nuñez, Angel
AU - Lagares, Alfonso
AU - Juarez, Eduardo
AU - Sanz, Cesar
TI - Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning
T2 - Cancers
J2 - Cancers (Basel)
PY - 2026
DA - 2026/03/06
VL - 18
IS - 5
SP - 857
SN - 2072-6694
PB - Multidisciplinary Digital Publishing Institute (MDPI)
DO - 10.3390/cancers18050857
UR - https://doi.org/10.3390/cancers18050857
LA - en
ER -

CSL-JSON

{
"id": "10.3390/cancers18050857",
"type": "article-journal",
"title": "Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning",
"container-title": "Cancers",
"author": [
{
"family": "Vazquez",
"given": "Guillermo"
},
{
"family": "Martín-Pérez",
"given": "Alberto"
},
{
"family": "Perez-Nuñez",
"given": "Angel"
},
{
"family": "Lagares",
"given": "Alfonso"
},
{
"family": "Juarez",
"given": "Eduardo"
},
{
"family": "Sanz",
"given": "Cesar"
}
],
"container-title-short": "Cancers (Basel)",
"volume": "18",
"issue": "5",
"page": "857",
"DOI": "10.3390/cancers18050857",
"PMID": "41827790",
"PMCID": "PMC12984245",
"ISSN": "2072-6694",
"publisher": "Multidisciplinary Digital Publishing Institute (MDPI)",
"URL": "https://doi.org/10.3390/cancers18050857",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
6
]
]
}
}

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.3390/bioengineering13050549 [code]
High-to-Low Spectral Mapping for Cross-System Feature Adaptation in Medical Hyperspectral Imaging.
Journal: Bioengineering (Basel, Switzerland)
In common: methods / tools, other condition, 5 references, author Alfonso Lagares
[2] doi:10.21037/qims-2026-0792 [code]
An nnU-Net-based framework with adaptive feature representation for 3D brain tumor segmentation.
Journal: Quantitative imaging in medicine and surgery
In common: PyTorch, NumPy, methods / tools, other condition, 1 reference
[3] doi:10.1038/s41598-026-35627-x [code]
Distilling population specific expertise into a unified model for generalizable brain tumor segmentation.
Journal: Scientific reports
In common: PyTorch, NumPy, methods / tools, other condition, 1 reference
[4] doi:10.3390/jcm15176501 [code]
Saliency-Curated Deep Learning for Predicting Receptor Status in Breast Cancer Brain Metastases.
Journal: Journal of clinical medicine
In common: PyTorch, NumPy, other condition, 1 reference
[5] doi:10.3389/frai.2026.1785867 [code]
A generalized logistic-logit function and its application to multi-layer perceptron and neuron segmentation.
Journal: Frontiers in artificial intelligence
In common: PyTorch, NumPy, methods / tools, 1 reference
[6] doi:10.1371/journal.pcbi.1013441 [code]
Large vision model framework for automated C. elegans analysis: From static morphometry to dynamic neural activity.
Journal: PLoS computational biology
In common: PyTorch, NumPy, methods / tools, 1 reference
[7] doi:10.1364/boe.600665 [code]
NeuroSeg-MF: robust neuron segmentation in two-photon Ca<sup>2+</sup> imaging using multi-feature fusion and detection-guided SAM.
Journal: Biomedical optics express
In common: PyTorch, NumPy, methods / tools, 1 reference
[8] doi:10.1038/s43856-026-01695-3 [code]
Predict neuromuscular performance in human epidural electrical stimulation: phase 1 trial interim results.
Journal: Communications medicine
In common: PyTorch, NumPy, other condition, 1 reference
[9] doi:10.1371/journal.pone.0344600 [code]
Robust disease prognosis via diagnostic knowledge preservation: A sequential learning approach.
Journal: PloS one
In common: PyTorch, NumPy, other condition, 1 reference
[10] doi:10.1371/journal.pdig.0001316 [code]
Reliability of a convolutional neural network in segmenting multiple sclerosis lesions from MRI: Impact of data augmentation, image modality and tolerance with U-Net architecture.
Journal: PLOS digital health
In common: PyTorch, NumPy, methods / 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.

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.