{"id":22731563,"url":"https://github.com/fahimfba/organize-adni","last_synced_at":"2025-09-04T10:46:16.669Z","repository":{"id":220477409,"uuid":"751743283","full_name":"FahimFBA/organize-ADNI","owner":"FahimFBA","description":"Organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally","archived":false,"fork":false,"pushed_at":"2024-06-20T07:41:26.000Z","size":552,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T16:48:15.963Z","etag":null,"topics":["ad","adni","adni-1","adni-script","brain","brain-mri","cn","mci","script"],"latest_commit_sha":null,"homepage":"https://fahimfba.github.io/organize-ADNI","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FahimFBA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-02T08:25:21.000Z","updated_at":"2025-02-24T15:50:26.000Z","dependencies_parsed_at":"2024-02-02T09:38:59.362Z","dependency_job_id":"56a657c1-c6e8-4d69-b314-0e747d45ea14","html_url":"https://github.com/FahimFBA/organize-ADNI","commit_stats":null,"previous_names":["fahimfba/adni-dataset-folder-group-based-on-class"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/FahimFBA/organize-ADNI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FahimFBA%2Forganize-ADNI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FahimFBA%2Forganize-ADNI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FahimFBA%2Forganize-ADNI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FahimFBA%2Forganize-ADNI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FahimFBA","download_url":"https://codeload.github.com/FahimFBA/organize-ADNI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FahimFBA%2Forganize-ADNI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270191415,"owners_count":24542268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ad","adni","adni-1","adni-script","brain","brain-mri","cn","mci","script"],"created_at":"2024-12-10T19:28:59.820Z","updated_at":"2025-08-13T06:06:34.668Z","avatar_url":"https://github.com/FahimFBA.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Cover](/img/og_cover.png)\n\nAlzheimer's Disease Neuroimaging Initiative (ADNI) dataset organization based on the group name (AD, MCI, CN)\nOrganize the entire ADNI dataset based on the group name (AD, MCI, CN) locally. Then, remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name. Lastly, rewrite the `.nii` files' filenames to the subject's ID. \n\nTherefore, I have created 3 separate scripts to perform these tasks. The first script will organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally. The second script will remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name. The third script will rewrite the `.nii` files' filenames to the subject's ID. The reason for creating three separate scripts is to make the process more modular and to make it easier to understand and maintain. One cruicial thing behind creating 3 separate scripts is that, it might be possible that the user may not want to perform all the tasks. Therefore, the user can choose to perform only the tasks that are required. However, the tasks should be performed sequentially. The order of the scripts and tasks are as follows:\n\n1. `script.py` - Organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally.\n2. `remove_subdir_script.py` - Remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name.\n3. `rename_file_script.py` - Rewrite the `.nii` files' filenames to the subject's ID.\n\n\n⭐ the repository if you found it helpful. 😊\n\nIf you use this repository, please cite it as below.\n\n```markdown\n@software{Amin_organize-ADNI_2024,\nauthor = {Amin, Md. Fahim},\nmonth = feb,\ntitle = {organize-ADNI},\nurl = {https://github.com/FahimFBA/organize-ADNI},\nversion = {2.0.4},\nyear = {2024}\n}\n```\n\n## Table of Contents\n- [Table of Contents](#table-of-contents)\n- [Introduction](#introduction)\n- [Screenshot](#screenshot)\n- [Prerequisites](#prerequisites)\n- [How to use](#how-to-use)\n- [Experiment](#experiment)\n- [License](#license)\n- [Additional](#additional)\n\n\n\n🎁 The entire project is live at [fahimfba.github.io/organize-ADNI](https://fahimfba.github.io/organize-ADNI/)\n\n## Introduction\nThe Alzheimer's Disease Neuroimaging Initiative (ADNI) dataset is a large dataset that contains the data of subjects with Alzheimer's disease (AD), Mild Cognitive Impairment (MCI), and Cognitively Normal (CN). The dataset is organized into different directories based on the subject's ID. This script will organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally. \n\nThe first script ([script.py](https://github.com/FahimFBA/organize-ADNI/blob/main/script.py)) will create 3 directories: `AD`, `MCI`, and `CN`. Each directory will contain the subjects' data based on the group name. The script will read the csv file that contains the list of the subjects and organize the dataset based on the group name. \n\nThe second script ([remove_subdir_script.py](https://github.com/FahimFBA/organize-ADNI/blob/main/remove_subdir_script.py)) will remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name. \n\nThe third script ([rename_file_script.py](https://github.com/FahimFBA/organize-ADNI/blob/main/rename_file_script.py)) will rewrite the `.nii` files' filenames to the subject's ID. The script will rename the `.nii` files' filenames to the subject's ID. Suppose, a file name is `ADNI_002_S_0619_MR_MPR-R__GradWarp__N3__Scaled_2_Br_20081001115218896_S15145_I118678.nii`. It will be renamed to `I118678.nii`. \n\nThis script can be used to organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally. This script works successfully on Windows, Linux, and macOS.\n\n## Screenshot\n\n1. After running first script [`script.py`](https://github.com/FahimFBA/organize-ADNI/blob/main/script.py):\n![Script 1](./img/cover.png)\n\n1. After running second script [`remove_subdir_script.py`](https://github.com/FahimFBA/organize-ADNI/blob/main/remove_subdir_script.py):\n![Script 2](./img/After_Script_2.png)\n\n1. After running third script [`rename_file_script.py`](https://github.com/FahimFBA/organize-ADNI/blob/main/rename_file_script.py):\n![Script 3](./img/After_Script_3.png)\n\nLastly, I have analyzed the dataset and found that the dataset is organized successfully. \n\nHere, you can check the After \u0026 Before files and folders count side by side (Left Side = After, Right Side = Before).\n\n![Comparison](./img/After_Before.png)\n\n## Prerequisites\n- Python 3.9 or later\n\n## How to use\n1. Clone the repository to your local machine.\n```bash\ngit clone https://github.com/FahimFBA/organize-ADNI.git\n```\n2. Copy the `script.py`, `remove_subdir_script.py`, and `rename_file_script.py` to the root directory of the ADNI dataset.\n3. Copy the csv file that contains the list of the subjects to the root directory of the ADNI dataset.\n4. Change the csv file name in the `script.py` to the name of the csv file that contains the list of the subjects.\n5. Create 3 empty directories in the root directory of the ADNI dataset and name them `AD`, `MCI`, and `CN`.\n6. Run the `script.py` using the following command, **if you want to organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally**:\n```bash\npython script.py\n```\nor,\n```bash\npython3 script.py\n```\n7. The script will organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally.\n8. Run the `remove_subdir_script.py` using the following command, **if you want to remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name**:\n```bash\npython remove_subdir_script.py\n```\nor,\n```bash\npython3 remove_subdir_script.py\n```\n9. The script will remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name.\n10. Run the `rename_file_script.py` using the following command, **if you want to rewrite the `.nii` files' filenames to the subject's ID**:\n```bash\npython rename_file_script.py\n```\nor,\n```bash\npython3 rename_file_script.py\n```\n11. The script will rewrite the `.nii` files' filenames to the subject's ID. Suppose, a file name is `ADNI_002_S_0619_MR_MPR-R__GradWarp__N3__Scaled_2_Br_20081001115218896_S15145_I118678.nii`. It will be renamed to `I118678.nii`.\n\n\n*Note: Here the root directory implies that directory which contains all the subject folders.*\n\n## Experiment\nThe script was tested on the ADNI dataset - ADNI1: Screening 1.5T having 1075 subjects. The dataset contains 3 groups of subjects: AD, MCI, and CN. The script was able to organize the dataset based on the group name. The dataset was organized into 3 directories: `AD`, `MCI`, and `CN`. Each directory contains the subjects' data based on the group name. The dataset was organized successfully. This script can be used to organize the entire ADNI dataset based on the group name (AD, MCI, CN) locally. Then, another script was used to remove all the subdirectories of the individual subjects and keep only the data of the subjects based on the group name. Lastly, another script was used to rewrite the `.nii` files' filenames to the subject's ID. The script was able to rewrite the `.nii` files' filenames to the subject's ID. The dataset was organized successfully.\n\n## License\nThis project is licensed under the Apache License - see the [LICENSE](https://github.com/FahimFBA/organize-ADNI/blob/main/LICENSE) file for details.\n\n## Additional\nIf you want to compress the `.nii` files to `.gzip` files, you can use the following command:\n```bash\ngzip * -r\n```\nThis command will compress all the `.nii` files to `.gzip` files. But make sure that you go to the root directory of the ADNI dataset before running the command. Also, keep in mind that it will replace the original `.nii` files with the `.gzip` files. Therefore, it is recommended to keep a backup of the original `.nii` files before running the command.\n\nAlso, if you are a Windows user, you can install the `gzip` using chocolatey. You can install `gzip` via chocolatey using the following command:\n```bash\nchoco install gzip\n```\nThen, you can use the `gzip` command to compress the `.nii` files to `.gzip` files.\n\nIf you haven't installed chocolatey yet, you can install chocolatey by following the instructions on the [chocolatey website](https://chocolatey.org/install).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffahimfba%2Forganize-adni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffahimfba%2Forganize-adni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffahimfba%2Forganize-adni/lists"}