Brain MRI Anomaly Detection
BrainMRIAD generates unsupervised anomaly detection maps from brain ADC and T2 FLAIR MRI nifti files. This was built with stroke lesions in mind, but since it is unsupervised it can be used to detect any abnormality. At the core two DDPM models are used, trained on both ADC and FLAIR healthy brains.
Specify the requirements and the steps to install the project.
git clone https://github.com/theotime/BrainMRIAD.git
cd BrainMRIAD
# Install dependencies
# Use python 3.12
python3.12 -m venv brainmriad_env
source brainmriad_env/bin/activate
pip install -r requirements.txtProvide examples and instructions on how to use the project. Settings are specified inside the sample_config.json file.
python brainmriad -c sample_config.jsoninput_folder: the folder with nifti files to processoutput_folder: the folder where the output files will be savedsequence: input MRI type. either 'ADC' or 'FLAIR'save_segmentation_masks: true if a threshold should be applied to the anomaly map, resulting in an additional segmentation nifti file.segmentation_threshold: the theshold used to turn the anomaly map into a binary segmentation mapalready_preprocessed: true if the input nifti files have already been skullstriped registered to a 128x128x128 MNI template. If false the preprocessing will be performedsave_preprocessed_image: true if the preprocessing step should be saveduse_post_processing: true if a median filter should be apply to smooth the anomaly maps (the post-processed anomaly map will be saved). If save_segmentation_masks is true, additional post-processing (erosion-dilation and binary fill holes) steps will be applied to the segmentation mask and be saved.replace_files: true if the program should skip files which already have an anomaly map in the output foldernb_inference: number of averaged inference for the anomaly mapspost_processing: post processing parameters used if use_post_processing = true
State the license under which the project is distributed.
Uses HD-BET for skullstripping MRI preprocessing https://github.com/MIC-DKFZ/hd-bet