Based on finetuned BioBERT, for visualising different brain regions from text description.
Different NLP approaches are stored in the helpers/experiments directory.
Setup to run the full visualisation (Node.js, conda/mamba required, cuda for faster execution)
- Clone or download the project.
- Start with this command in the root directory.
This will install the necessary libraries, depending on the existing version of node installed some errors need to be resoled.
npm install
- Create a file
local.config.jsonbased ontemplate_local.config.json. This defines which model will be used to predict the brain regions. Updateconfig.jsonif the typically usedlocalhost:3000is not available. - Create conda env for running the model.
conda env create -f environment.yml
- Update
local.config.jsonwith the exactconda_modelandbert_modelpaths. - Start the server with visualisations.
This will start the visualisation server at
npm start
http://localhost:3000in your browser.
The available functionalities are listed below.
- Uploading pdf/html file.
- Opening the file in a browser.
- Highlighting the text connects to the model, that read the text, and generates the image. The image is also saved in the
outputdirectory.
The uploaded data includes the following elements.
trainfolder with the dataset used to train the modeltestfolder with the dataset used to test the modelvalidationdataset folder with the dataset used to validate the model- AAL3v1 files (
.nii|.txt) with the data extracted from the AAL brain atlas - AAL3v1 structured dictionary (
AAL3v1.json) with the data extracted from the AAL brain atlas - AAL dictionary from the relevant paper (
paper_ALL3.json) with the data extracted from the AAL brain atlas - Uberon anatomy ontology, filtered for brain entities (
brain-view.json) - Structured Uberon brain regions with names and definitions (
brain_uberon_structured.json) - Downloaded PubMED abstracts (
abstracts.csv) - Annotated PubMED abstracts, with either B-Brain or O annotations (
annotated_abstracts.csv) - Annotated brain regions connl file for NER finetuning with either B-Brain or O annotations (
annotated_brain_regions.connl)
The main question is what brain regions should be used for text extraction and later visualisation. There are the major parts (cerebrum, brainstem, cerebellum), lobes (frontal, temporal, parietal, occipital), individual structures (hippocampus, amygdala). Each region can be subdivided into smaller parts, there are different networks (DMN) and systems.
Each atlas for visualisations has a different naming system and split, with AAL3v1 and schaeffer being the most commonly used for brain regions. Most of the experiments in the repository have focues on either structures of the brain or aal atlas regions.
During the data preprocessing part, new dictionaries and connections were generated, and stored in the data folder.
The helper\experiments folder contains Jupyter notebooks with experiments and different approaches to the given problem.
The brain regions used in the notebook are the most common ones, they do not come from any atlas or dictionary. First, the model was trained to recognize whether the text is brain related or not, based on PubMED abstracts fetched for the list of regions.
| Epoch | Training Loss | Validation Loss | Precision | Recall | F1 |
|---|---|---|---|---|---|
| 1 | No log | 0.282965 | 0.201717 | 0.256831 | 0.225962 |
| 2 | No log | 0.154976 | 0.426724 | 0.540984 | 0.477108 |
| 3 | No log | 0.122615 | 0.542373 | 0.699454 | 0.610979 |
| 4 | No log | 0.100538 | 0.666667 | 0.765027 | 0.712468 |
| 5 | No log | 0.095848 | 0.669725 | 0.797814 | 0.728180 |
Normally the embeddings and safetensors would not be uploaded, and ignored, but they were uploaded using LFS for convenience.
The simple version of biobert, with embeddings based on AAL3v1 regions of the brain but with no extra pre-training works well only when the text is closely related to the name of the region. The probability of each region is listed in the brackets.
The more complex version of biobert, trained on annotated PubMed abstracts. The dictionary comes from the AAL3v1 atlas with 170 unique brain regions.
The most complex model was trained on hierarchical embeddings. AAL atlas has brain regions that are extremely common (hippocampus) and others that are quite rare. The goal is to highlight the most relevant regions.
- Medium NER tutorial link
- BioBERT-CRF paper link
- How to choose tools for unique BioNER need link
- BioSERPBERT repository of neuroscience representation of brain region text mining link
- Connectivity search engine with different connected embeddings link
- Data fetching tutorial link
- Token classification link
- Brain2Qwerty link
- Noninvasive decoding of typed sentences from human brain activity link