This project processes standard MRI scan using FreeSurfer and extracts specific regions of interest (ROIs) from the MRI data. The extracted data includes volumes and centroids of various brain structures, which are then aggregated and normalized.
- FreeSurfer
- Python 3.x
- Required Python packages (see requirements.txt)
Follow the installation instructions on the FreeSurfer website: https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall.
Install the required Python packages:
pip install -r requirements.txtTo run the script, you need to provide the path to the MRI file, study ID, and age of the patient. The output will be saved in the studies_output directory and a summary CSV file will be generated.
python workflow.py --mri "/path/to/mri/file.nii" --id "study123" --age 60 --sex "M"- --mri: Path to the MRI file (.nii format).
- --id: Study ID (any string).
- --age: Age of the patient (integer).
- --sex: Sex of the patient (M or F).
The script generates three output files:
- Raw results CSV: Contains volumes and centroids of various ROIs.
- Summary CSV: Aggregated and normalized results.
- 3d visualization HTML: Presents cloud points and their respective centroids.
- Ensure FreeSurfer is correctly installed and the FREESURFER_HOME environment variable is set.
- The script will run FreeSurfer's recon-all command, which might take several hours to complete depending on the MRI file size and system performance.
If you don't have a .nii file, install FreeSurfer and then run the command:
dcm2niix -o "/path/to/mri/" "/path/to/mri/"
You can install FreeSurfer on Linux, macOS, and Windows (using WSL: https://learn.microsoft.com/en-us/windows/wsl/about).
This project is licensed under the MIT License.
The repository's MIT LICENSE covers the original Python workflow code. FreeSurfer, dcm2niix, and their dependencies have their own licenses and installation conditions; this repository does not relicense them.
MRI scans, participant identifiers, age/sex metadata, segmentation results, CSV summaries, and 3D visualizations may contain participant-level information. Keep real study input and generated outputs in access-controlled storage, and check study consent, ethics approval, and data-sharing agreements before publication. The existing studies_input/, studies_output/, and processed_data/ ignore rules are intended to keep generated data out of version control. This is a research workflow, not a clinical diagnostic tool.