Improving Brain Tumor Detection by Cortical Surface and Vessels Segmentation Through RGB-to-HSI Transfer Learning.
The 1 match
- [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
- from __future__ import print_function
- import os
- import sys
- import argparse
- import time
- import math
- import tensorboard_logger as tb_logger
- import torch
- import torch.backends.cudnn as cudnn
- from torchvision import transforms, datasets
- from util import TwoCropTransform, AverageMeter
- from util import adjust_learning_rate, warmup_learning_rate
- from util import set_optimizer, save_model
- from networks.resnet_big import SupConResNet
- from losses import SupConLoss
- try:
- import apex
- from apex import amp, optimizers
- except ImportError:
- pass
- def parse_option():
- parser = argparse.ArgumentParser('argument for training')
- parser.add_argument('--print_freq', type=int, default=10,
- help='print frequency')
- parser.add_argument('--save_freq', type=int, default=50,
- help='save frequency')
- parser.add_argument('--batch_size', type=int, default=256,
- help='batch_size')
- parser.add_argument('--num_workers', type=int, default=16,
- help='num of workers to use')
- parser.add_argument('--epochs', type=int, default=1000,
- help='number of training epochs')
- # optimization
- parser.add_argument('--learning_rate', type=float, default=0.05,
- help='learning rate')
- parser.add_argument('--lr_decay_epochs', type=str, default='700,800,900',
- help='where to decay lr, can be a list')
- parser.add_argument('--lr_decay_rate', type=float, default=0.1,
- help='decay rate for learning rate')
- parser.add_argument('--weight_decay', type=float, default=1e-4,
- help='weight decay')
- parser.add_argument('--momentum', type=float, default=0.9,
- help='momentum')
- # model dataset
- parser.add_argument('--model', type=str, default='resnet50')
- parser.add_argument('--dataset', type=str, default='cifar10',
- choices=['cifar10', 'cifar100', 'path'], help='dataset')
- parser.add_argument('--mean', type=str, help='mean of dataset in path in form of str tuple')
- parser.add_argument('--std', type=str, help='std of dataset in path in form of str tuple')
- parser.add_argument('--data_folder', type=str, default=None, help='path to custom dataset')
- parser.add_argument('--size', type=int, default=32, help='parameter for RandomResizedCrop')
- # method
- parser.add_argument('--method', type=str, default='SupCon',
- choices=['SupCon', 'SimCLR'], help='choose method')
- # temperature
- parser.add_argument('--temp', type=float, default=0.07,
- help='temperature for loss function')
- # other setting
- parser.add_argument('--cosine', action='store_true',
- help='using cosine annealing')
- parser.add_argument('--syncBN', action='store_true',
- help='using synchronized batch normalization')
- parser.add_argument('--warm', action='store_true',
- help='warm-up for large batch training')
- parser.add_argument('--trial', type=str, default='0',
- help='id for recording multiple runs')
- opt = parser.parse_args()
- # check if dataset is path that passed required arguments
- if opt.dataset == 'path':
- assert opt.data_folder is not None \
- and opt.mean is not None \
- and opt.std is not None
- # set the path according to the environment
- if opt.data_folder is None:
- opt.data_folder = './datasets/'
- opt.model_path = './save/SupCon/{}_models'.format(opt.dataset)
- opt.tb_path = './save/SupCon/{}_tensorboard'.format(opt.dataset)
- iterations = opt.lr_decay_epochs.split(',')
- opt.lr_decay_epochs = list([])
- for it in iterations:
- opt.lr_decay_epochs.append(int(it))
- opt.model_name = '{}_{}_{}_lr_{}_decay_{}_bsz_{}_temp_{}_trial_{}'.\
- format(opt.method, opt.dataset, opt.model, opt.learning_rate,
- opt.weight_decay, opt.batch_size, opt.temp, opt.trial)
- if opt.cosine:
- opt.model_name = '{}_cosine'.format(opt.model_name)
- # warm-up for large-batch training,
- if opt.batch_size > 256:
- opt.warm = True
- if opt.warm:
- opt.model_name = '{}_warm'.format(opt.model_name)
- opt.warmup_from = 0.01
- opt.warm_epochs = 10
- if opt.cosine:
- eta_min = opt.learning_rate * (opt.lr_decay_rate ** 3)
- opt.warmup_to = eta_min + (opt.learning_rate - eta_min) * (
- 1 + math.cos(math.pi * opt.warm_epochs / opt.epochs)) / 2
- else:
- opt.warmup_to = opt.learning_rate
- opt.tb_folder = os.path.join(opt.tb_path, opt.model_name)
- if not os.path.isdir(opt.tb_folder):
- os.makedirs(opt.tb_folder)
- opt.save_folder = os.path.join(opt.model_path, opt.model_name)
- if not os.path.isdir(opt.save_folder):
- os.makedirs(opt.save_folder)
- return opt
- def set_loader(opt):
- # construct data loader
- if opt.dataset == 'cifar10':
- mean = (0.4914, 0.4822, 0.4465)
- std = (0.2023, 0.1994, 0.2010)
- elif opt.dataset == 'cifar100':
- mean = (0.5071, 0.4867, 0.4408)
- std = (0.2675, 0.2565, 0.2761)
- elif opt.dataset == 'path':
- mean = eval(opt.mean)
- std = eval(opt.std)
- else:
- raise ValueError('dataset not supported: {}'.format(opt.dataset))
- normalize = transforms.Normalize(mean=mean, std=std)
- train_transform = transforms.Compose([
- transforms.RandomResizedCrop(size=opt.size, scale=(0.2, 1.)),
- transforms.RandomHorizontalFlip(),
- transforms.RandomApply([
- transforms.ColorJitter(0.4, 0.4, 0.4, 0.1)
- ], p=0.8),
- transforms.RandomGrayscale(p=0.2),
- transforms.ToTensor(),
- normalize,
- ])
- if opt.dataset == 'cifar10':
- train_dataset = datasets.CIFAR10(root=opt.data_folder,
- transform=TwoCropTransform(train_transform),
- download=True)
- elif opt.dataset == 'cifar100':
- train_dataset = datasets.CIFAR100(root=opt.data_folder,
- transform=TwoCropTransform(train_transform),
- download=True)
- elif opt.dataset == 'path':
- train_dataset = datasets.ImageFolder(root=opt.data_folder,
- transform=TwoCropTransform(train_transform))
- else:
- raise ValueError(opt.dataset)
- train_sampler = None
- train_loader = torch.utils.data.DataLoader(
- train_dataset, batch_size=opt.batch_size, shuffle=(train_sampler is None),
- num_workers=opt.num_workers, pin_memory=True, sampler=train_sampler)
- return train_loader
- def set_model(opt):
- model = SupConResNet(name=opt.model)
- criterion = SupConLoss(temperature=opt.temp)
- # enable synchronized Batch Normalization
- if opt.syncBN:
- model = apex.parallel.convert_syncbn_model(model)
- if torch.cuda.is_available():
- if torch.cuda.device_count() > 1:
- model.encoder = torch.nn.DataParallel(model.encoder)
- model = model.cuda()
- criterion = criterion.cuda()
- cudnn.benchmark = True
- return model, criterion
- def train(train_loader, model, criterion, optimizer, epoch, opt):
- """one epoch training"""
- model.train()
- batch_time = AverageMeter()
- data_time = AverageMeter()
- losses = AverageMeter()
- end = time.time()
- for idx, (images, labels) in enumerate(train_loader):
- data_time.update(time.time() - end)
- images = torch.cat([images[0], images[1]], dim=0)
- if torch.cuda.is_available():
- images = images.cuda(non_blocking=True)
- labels = labels.cuda(non_blocking=True)
- bsz = labels.shape[0]
- # warm-up learning rate
- warmup_learning_rate(opt, epoch, idx, len(train_loader), optimizer)
- # compute loss
- features = model(images)
- f1, f2 = torch.split(features, [bsz, bsz], dim=0)
- features = torch.cat([f1.unsqueeze(1), f2.unsqueeze(1)], dim=1)
- if opt.method == 'SupCon':
- loss = criterion(features, labels)
- elif opt.method == 'SimCLR':
- loss = criterion(features)
- else:
- raise ValueError('contrastive method not supported: {}'.
- format(opt.method))
- # update metric
- losses.update(loss.item(), bsz)
- # SGD
- optimizer.zero_grad()
- loss.backward()
- optimizer.step()
- # measure elapsed time
- batch_time.update(time.time() - end)
- end = time.time()
- # print info
- if (idx + 1) % opt.print_freq == 0:
- print('Train: [{0}][{1}/{2}]\t'
- 'BT {batch_time.val:.3f} ({batch_time.avg:.3f})\t'
- 'DT {data_time.val:.3f} ({data_time.avg:.3f})\t'
- 'loss {loss.val:.3f} ({loss.avg:.3f})'.format(
- epoch, idx + 1, len(train_loader), batch_time=batch_time,
- data_time=data_time, loss=losses))
- sys.stdout.flush()
- return losses.avg
- def main():
- opt = parse_option()
- # build data loader
- train_loader = set_loader(opt)
- # build model and criterion
- model, criterion = set_model(opt)
- # build optimizer
- optimizer = set_optimizer(opt, model)
- # tensorboard
- logger = tb_logger.Logger(logdir=opt.tb_folder, flush_secs=2)
- # training routine
- for epoch in range(1, opt.epochs + 1):
- adjust_learning_rate(opt, optimizer, epoch)
- # train for one epoch
- time1 = time.time()
- loss = train(train_loader, model, criterion, optimizer, epoch, opt)
- time2 = time.time()
- print('epoch {}, total time {:.2f}'.format(epoch, time2 - time1))
- # tensorboard logger
- logger.log_value('loss', loss, epoch)
- logger.log_value('learning_rate', optimizer.param_groups[0]['lr'], epoch)
- if epoch % opt.save_freq == 0:
- save_file = os.path.join(
- opt.save_folder, 'ckpt_epoch_{epoch}.pth'.format(epoch=epoch))
- save_model(model, optimizer, opt, epoch, save_file)
- # save the last model
- save_file = os.path.join(
- opt.save_folder, 'last.pth')
- save_model(model, optimizer, opt, opt.epochs, save_file)
- if __name__ == '__main__':
- main()
main_supcon.py at commit 66a8fe5, under BSD-2-Clause · at the source
Overview
- Research Center on Software Technologies and Multimedia Systems, Universidad Politécnica de Madrid (UPM), 28031 Madrid, Spain; (A.M.-P.)
- Neurosurgery Department, Hospital Universitario 12 de Octubre, 28041 Madrid, Spain
- Medicine Faculty, Universidad Complutense de Madrid (UCM), 28040 Madrid, Spain
- Instituto de Investigación Sanitaria Hospital 12 de Octubre (Imas12), 28041 Madrid, Spain
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
66a8fe53880d6a1084b2e4e0db0a019024d6d41a, 26 December 2023Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
8 files
- losses.py, Python, 106 lines
- main_ce.py, Python, 333 lines
- main_linear.py, Python, 263 lines
- main_supcon.py, Python, 296 lines, 1 match
- networks/
resnet_big.py , Python, 209 lines - util.py, Python, 95 lines
- LICENSE, License, 25 lines
- README.md, Text, 146 lines
gitlab.citsem.upm.es/public-projects/hyperspectral/cortical_segmentation
4968d2685d0aafe273f34e904e546d04ed7ebf21, 5 March 2026Availability: 1 check, the latest on 30 September 2026: the link answers
- 30 September 2026: the link answers
1 file
- README.md, Text, 93 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;
- 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://
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://
BibTeX
@article{vazquez2026impr
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/
url = {https://
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/
VL - 18
IS - 5
SP - 857
SN - 2072-6694
PB - Multidisciplinary Digital Publishing Institute (MDPI)
DO - 10.3390/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.3390/
"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":
"volume": "18",
"issue": "5",
"page": "857",
"DOI": "10.3390/
"PMID": "41827790",
"PMCID": "PMC12984245",
"ISSN": "2072-6694",
"publisher": "Multidisciplinary Digital Publishing Institute (MDPI)",
"URL": "https://
"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 surgeryIn 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 reportsIn 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 medicineIn 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 intelligenceIn 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 biologyIn common: PyTorch, NumPy, methods / tools, 1 reference
- [7] doi:10.1364/boe.600665 [code]
- NeuroSeg-MF: robust neuron segmentation in two-photon Ca&
lt;sup& gt;2+& lt;/ sup& gt; imaging using multi-feature fusion and detection-guided SAM. Journal: Biomedical optics expressIn 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 medicineIn 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 oneIn 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 healthIn 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.
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, 6 scripts, and 1 match 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:62a5c890d62abed6…
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.
