This repository contains a Python script (run_lst_ai.py) for applying LST-AI lesion segmentation and performing the necessary steps to convert the output to BIDS standards. The script processes a list of subjects, checks for the availability of required images, and runs the segmentation pipeline, producing outputs that comply with BIDS (Brain Imaging Data Structure) conventions. This is a framework to automatically apply LST-AI on all images in a BIDS compliant database.
To use this pipeline, ensure you have Python installed on your system along with the required dependencies. In addition, the pipeline requires LST-AI to be installed (https://github.com/CompImg/LST-AI).
To run the LST-AI pipeline, use the following command:
python run_lst_ai.py -i /path/to/bids/dataset -n 4 --cpu --remove_temp --clipping 0.5 99.5
- -i, --input_directory: (Required) Path to the derivatives folder in the BIDS database.
- -n, --number_of_workers: Number of parallel processing cores to use (default: os.cpu_count()-1).
- --cpu: Use this flag to process using CPU only (default: GPU if available).
- --remove_temp: Use this flag to remove the temporary folder containing auxiliary files after processing.
- --clipping: Clipping for standardization of image intensities (default: (0.5, 99.5)).
The script performs the following steps:
- Check availability: The scripts checks availability of T1w and FLAIR images and whether the lesion mask generated by LST-AI already exists.
- Segmentation: Runs the LST-AI lesion segmentation on the images where the lesion mask does not exist.
- Output Handling: Checks if the segmentation was successful, renames output files to comply with BIDS conventions, and optionally removes temporary files.