{"id":21587626,"url":"https://github.com/firstmover/cr-seg","last_synced_at":"2025-03-18T09:23:27.205Z","repository":{"id":199367655,"uuid":"701007832","full_name":"firstmover/cr-seg","owner":"firstmover","description":"Source code for \"Consistency Regularization Improves Placenta Segmentation in Fetal EPI MRI Time Series\" paper.","archived":false,"fork":false,"pushed_at":"2023-10-16T03:12:36.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T15:43:12.390Z","etag":null,"topics":["consistency-regularization","mri","registration","segmentation","semi-supervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firstmover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-05T18:10:34.000Z","updated_at":"2023-10-07T18:40:28.000Z","dependencies_parsed_at":"2023-12-12T21:30:52.421Z","dependency_job_id":null,"html_url":"https://github.com/firstmover/cr-seg","commit_stats":null,"previous_names":["firstmover/cr-seg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstmover%2Fcr-seg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstmover%2Fcr-seg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstmover%2Fcr-seg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstmover%2Fcr-seg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstmover","download_url":"https://codeload.github.com/firstmover/cr-seg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244190239,"owners_count":20413084,"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","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":["consistency-regularization","mri","registration","segmentation","semi-supervised-learning"],"created_at":"2024-11-24T15:17:14.105Z","updated_at":"2025-03-18T09:23:27.184Z","avatar_url":"https://github.com/firstmover.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Consistency Regularization Improves Placenta Segmentation in Fetal EPI MRI Time Series\n\nThis repo includes the code for the paper [Liu et al. 2023](https://arxiv.org/pdf/2310.03870.pdf).\n\n![Python 3.9](https://img.shields.io/badge/Python-3.9%2B-brightgreen.svg)\n[![GitHub Repo Stars](https://img.shields.io/github/stars/firstmover/cr-seg?label=Stars\u0026logo=github\u0026color=red)](https://github.com/firstmover/cr-seg)\n\n\u003cbr\u003e\n\u003cimg src=\"https://people.csail.mit.edu/liuyingcheng/data/projects/fetal/cr_seg/overview_method.png\"\u003e\n\u003chr/\u003e\n\n### Environment and dependency\n\nCreate a conda environment with: \n```bash \nconda create --name cr_seg --file requirements.txt\n```\n\nSpecify your paths to data, cache, and results directories in: \n1. `./envs/default`\n2. `./configs/segm_release/spatial_temporal_cr.py`\n\n### Results\n\n#### Pre-process of data \n\n```bash \nsrun --partition=gpu \\\n--job-name=segm \\\n--gres=gpu:1 \\\n--ntasks=1 \\\n--ntasks-per-node=1 \\\n--cpus-per-task=16 \\\n--time=24:00:00 \\\npython scripts/pre_compute_data.py\n```\n\n#### Training \n\npretrain registration models for all cross-validation folds \n```bash \npython ./scripts/submit_job_registraion.py \\\n--exp-name regi_release \\\n--config-name voxelmorph \\\n--job-name=regi \\\n--num-gpus-per-node=1 \\\n--cpus-per-task=20 \\\n--num-nodes=1 \\\n--array-parallelism=5\n```\n\nTrain UNet with spatial and temporal consistency regularization for all cross-validation folds\n```bash \npython ./scripts/submit_job_segmentation.py \\\n--task-mode train \\\n--exp-name segm_release \\\n--config-name spatial_temporal_cr \\\n--lambda-list '0.001' \\\n--lambda-t-list '0.001' \\\n--job-name segm_regi \\\n--num-gpus-per-node 4 \\\n--cpus-per-task 8 \\\n--array-parallelism 5\n```\n\n#### Inference and evaluation \n\nRun inference for labeled data for all cross-validation folds \n```bash \npython ./scripts/submit_job_segmentation.py \\\n--task-mode inference_labeled \\\n--exp-name segm_release \\\n--config-name spatial_temporal_cr \\\n--lambda-list '0.001' \\\n--lambda-t-list '0.001' \\\n--tta \\\n--tta-cfg-path ./configs/segm_release/_base_/tta_all_crop.py \\\n--save-data-name-list 'img,pred_seg_map,gt_seg_map' \\\n--job-name inference \\\n--partition gpu \\\n--num-gpus-per-node 1 \\\n--cpus-per-task 16 \\\n--array-parallelism 5\n```\n\nRun inference for time series data (unlabeled and labeled data) for all cross-validation folds\n```bash \npython ./scripts/submit_job_segmentation.py \\\n--task-mode inference_time_series \\\n--exp-name segm_release \\\n--config-name spatial_temporal_cr \\\n--lambda-list '0.001' \\\n--lambda-t-list '0.001' \\\n--tta \\\n--tta-cfg-path ./configs/segm_release/_base_/tta_all_crop.py \\\n--save-data-name-list 'pred_seg_map' \\\n--job-name inference \\\n--partition gpu \\\n--num-gpus-per-node 1 \\\n--cpus-per-task 16 \\\n--array-parallelism 5\n```\n\n#### Visualization \n\nPre-compute and evulate time series data \n```bash\npython scripts/visualization/pre_compute_time_series.py \\\n--result_root ./results/segm_release \\\n--job-name eval \\\n--partition gpu \\\n--num-gpus-per-node 1 \\\n--cpus-per-task 24 \\\n--array-parallelism 8\n```\n\nVisualize labeled results\n```bash\nstreamlit run scripts/visualization/labeled.py -- --result_root ./results/segm_release --model_name epoch_100_all\n```\n\nVisualize time series results\n```bash\nstreamlit run scripts/visualization/time_series.py -- --result_root ./results/segm_release --model_name epoch_100_all\n```\n\n### todos \n- [ ] Add commands for non-slurm users \n- [ ] Add more details for data set structures \n- [x] Update citation\n\n### Acknowledgement\n- [mabulnaga/automatic-placenta-segmentation](https://github.com/mabulnaga/automatic-placenta-segmentation)\n- [voxelmorph/voxelmorph](https://github.com/voxelmorph/voxelmorph)\n\n### License\n\nThis repo is licensed under the MIT License and the copyright belongs to all authors - see the [LICENSE](https://github.com/firstmover/cr-seg/blob/master/LICENSE) file for details.\n\n### Citation\n\n```\n@inproceedings{liu2023consistency,\n  title={Consistency Regularization Improves Placenta Segmentation in Fetal EPI MRI Time Series},\n  author={Liu, Yingcheng and Karani, Neerav and Abulnaga, S Mazdak and Xu, Junshen and Grant, P Ellen and Abaci Turk, Esra and Golland, Polina},\n  booktitle={International Workshop on Preterm, Perinatal and Paediatric Image Analysis},\n  pages={77--87},\n  year={2023},\n  organization={Springer}\n}\n```\n\n### Contact\n\nEmail: liuyc@mit.edu\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstmover%2Fcr-seg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstmover%2Fcr-seg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstmover%2Fcr-seg/lists"}