https://github.com/berenslab/medical-t-simcne

This repository contains the codes to train a t-SimCNE model. This model has been shown to produce good representations on natural and medical images.

https://github.com/berenslab/medical-t-simcne

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary

Keywords

medical-imaging representation-learning visualisation
Last synced: 5 months ago · JSON representation

Repository

This repository contains the codes to train a t-SimCNE model. This model has been shown to produce good representations on natural and medical images.

Basic Info
  • Host: GitHub
  • Owner: berenslab
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 23.6 MB
Statistics
  • Stars: 3
  • Watchers: 5
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
medical-imaging representation-learning visualisation
Created about 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme

readme.md

Unsupervised Visualisation of Medical Image Datasets

This repository contains the codes to train a $t$-SimCNE model for medical images. You can find our paper here: Unsupervised Visualisation of Medical Image Datasets

Citation

If you use this code, kindly cite our paper:

@misc{nwabufo2024selfsupervised, title={Self-supervised Visualisation of Medical Image Datasets}, author={Ifeoma Veronica Nwabufo and Jan Niklas Böhm and Philipp Berens and Dmitry Kobak}, year={2024}, eprint={2402.14566}, archivePrefix={arXiv}, primaryClass={cs.CV} }

Installation

$t$-SimCNE is available as a package. You could install it by running python pip install tsimcne or you can clone this repository. git clone https://github.com/berenslab/medical-t-simcne cd medical-t-simcne pip install .

Training a $t$-SimCNE model on MedMNIST dataset

```python

import libraries

import numpy as np import medmnist.dataset from tsimcne.imagedistortions import * from tsimcne.tsimcne import TSimCNE from evaluation.eval import knnacc,silhouettescore_ from torch.utils.data import ConcatDataset

load the data

root='datasets' datasettrain = medmnist.dataset.BloodMNIST(root=root, split='train', transform=None,targettransform=None, download=True) datasettest = medmnist.dataset.BloodMNIST(root=root, split='test', transform=None, targettransform=None, download=True) datasetval = medmnist.dataset.BloodMNIST(root=root, split='val', transform=None, targettransform=None, download=True) datasetfull = [datasettrain, datasettest,datasetval]

for dataset in datasetfull: dataset.labels = dataset.labels.squeeze() datasetfull_ = ConcatDataset(dataset_full)

labels = np.array([lbl for img, lbl in datasetfull])

batchsize=1024 totalepochs=[1000,50,450]

You can also define your custom augmentations by passing a 'data_transform' parameter.

For more details check scripts/mnist.py or

read the documentation here [https://t-simcne.readthedocs.io/]

tsimcne = TSimCNE(batchsize=batchsize, totalepochs=totalepochs) Y = tsimcne.fittransform(datasetfull_)

get the metrics

kNNscore=knnacc(Y,labels) silscore=silhouettescore_(Y,labels)

visualise the results

fig, ax = plt.subplots() ax.scatter(*Y.T, c=labels) ax.settitle(f"$k$NN acc. = {kNNscore}% sil score = {sil_score}") fig.savefig("tsimcne.png")

```

Figures

To reproduce the figures, you can run the respective python files in the plot folder at the root of this directory.

Embeddings

To get the embeddings run the respective python files in the scripts folder at the root of the directory.

Owner

  • Name: Berens Lab @ University of Tübingen
  • Login: berenslab
  • Kind: organization
  • Email: philipp.berens@uni-tuebingen.de
  • Location: Tübingen, Germany

Department of Data Science at the Hertie Institute for AI in Brain Health, University of Tübingen

GitHub Events

Total
Last Year

Dependencies

pyproject.toml pypi
  • annoy *
  • ffmpeg-python *
  • hdbscan *
  • matplotlib *
  • medmnist *
  • numpy *
  • pandas *
  • pillow *
  • python-telegram-bot *
  • pytorch-lightning *
  • scikit-learn *
  • scipy *
  • torch *
  • torchvision *
  • tqdm *