{"id":20653353,"url":"https://github.com/ad12/dosma","last_synced_at":"2025-10-31T00:30:47.459Z","repository":{"id":33802435,"uuid":"147602033","full_name":"ad12/DOSMA","owner":"ad12","description":"An AI-powered open-source medical image analysis toolbox","archived":false,"fork":false,"pushed_at":"2024-08-19T23:18:04.000Z","size":11421,"stargazers_count":61,"open_issues_count":12,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-16T02:51:43.522Z","etag":null,"topics":["deep-learning","medical-image-analysis","mri","musculoskeletal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ad12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-06T01:45:40.000Z","updated_at":"2025-02-10T10:47:23.000Z","dependencies_parsed_at":"2024-06-21T02:14:25.014Z","dependency_job_id":"7ceefc5c-21be-4896-9306-71f94679dc57","html_url":"https://github.com/ad12/DOSMA","commit_stats":{"total_commits":450,"total_committers":9,"mean_commits":50.0,"dds":0.3866666666666667,"last_synced_commit":"bd5efecbb944263c9a5d7853f154d9071c72ba62"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad12%2FDOSMA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad12%2FDOSMA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad12%2FDOSMA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad12%2FDOSMA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ad12","download_url":"https://codeload.github.com/ad12/DOSMA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239080900,"owners_count":19578233,"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":["deep-learning","medical-image-analysis","mri","musculoskeletal"],"created_at":"2024-11-16T17:43:38.606Z","updated_at":"2025-10-31T00:30:46.997Z","avatar_url":"https://github.com/ad12.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DOSMA: Deep Open-Source Medical Image Analysis\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ad12/DOSMA/CI)\n[![codecov](https://codecov.io/gh/ad12/DOSMA/branch/master/graph/badge.svg?token=X2FRQJHV2M)](https://codecov.io/gh/ad12/DOSMA)\n[![Documentation Status](https://readthedocs.org/projects/dosma/badge/?version=latest)](https://dosma.readthedocs.io/en/latest/?badge=latest)\n\n[Documentation](http://dosma.readthedocs.io/) | [Questionnaire](https://forms.gle/sprthTC2swyt8dDb6) | [DOSMA Basics Tutorial](https://colab.research.google.com/drive/1zY5-3ZyTBrn7hoGE5lH0IoQqBzumzP1i?usp=sharing)\n\nDOSMA is an AI-powered Python library for medical image analysis. This includes, but is not limited to:\n- image processing (denoising, super-resolution, registration, segmentation, etc.)\n- quantitative fitting and image analysis\n- anatomical visualization and analysis (patellar tilt, femoral cartilage thickness, etc.)\n\nWe hope that this open-source pipeline will be useful for quick anatomy/pathology analysis and will serve as a hub for adding support for analyzing different anatomies and scan sequences.\n\n## Installation\nDOSMA requires Python 3.6+. The core module depends on numpy, nibabel, nipype,\npandas, pydicom, scikit-image, scipy, PyYAML, and tqdm.\n\nAdditional AI features can be unlocked by installing tensorflow and keras. To\nenable built-in registration functionality, download [elastix](https://elastix.lumc.nl/download.php).\nDetails can be found in the [setup documentation](https://dosma.readthedocs.io/en/latest/general/installation.html#setup).\n\nTo install DOSMA, run:\n\n```bash\npip install dosma\n\n# To install with AI support\npip install dosma[ai]\n```\n\nIf you would like to contribute to DOSMA, we recommend you clone the repository and\ninstall DOSMA with `pip` in editable mode.\n\n```bash\ngit clone git@github.com:ad12/DOSMA.git\ncd DOSMA\npip install -e '.[dev,docs]'\nmake dev\n```\n\nTo run tests, build documentation and contribute, run\n```bash\nmake autoformat test build-docs\n```\n\n## Features\n### Simplified, Efficient I/O\nDOSMA provides efficient readers for DICOM and NIfTI formats built on nibabel and pydicom. Multi-slice DICOM data can be loaded in\nparallel with multiple workers and structured into the appropriate 3D volume(s). For example, multi-echo and dynamic contrast-enhanced (DCE) MRI scans have multiple volumes acquired at different echo times and trigger times, respectively. These can be loaded into multiple volumes with ease:\n\n```python\nimport dosma as dm\n\nmulti_echo_scan = dm.load(\"/path/to/multi-echo/scan\", group_by=\"EchoNumbers\", num_workers=8, verbose=True)\ndce_scan = dm.load(\"/path/to/dce/scan\", group_by=\"TriggerTime\")\n```\n\n### Data-Embedded Medical Images\nDOSMA's [MedicalVolume](https://dosma.readthedocs.io/en/latest/generated/dosma.MedicalVolume.html#dosma.MedicalVolume) data structure supports array-like operations (arithmetic, slicing, etc.) on medical images while preserving spatial attributes and accompanying metadata. This structure supports NumPy interoperability, intelligent reformatting, fast low-level computations, and native GPU support. For example, given MedicalVolumes `mvA` and `mvB` we can do the following:\n\n```python\n# Reformat image into Superior-\u003eInferior, Anterior-\u003ePosterior, Left-\u003eRight directions.\nmvA = mvA.reformat((\"SI\", \"AP\", \"LR\"))\n\n# Get and set metadata\nstudy_description = mvA.get_metadata(\"StudyDescription\")\nmvA.set_metadata(\"StudyDescription\", \"A sample study\")\n\n# Perform NumPy operations like you would on image data.\nrss = np.sqrt(mvA**2 + mvB**2)\n\n# Move to GPU 0 for CuPy operations\nmv_gpu = mvA.to(dosma.Device(0))\n\n# Take slices. Metadata will be sliced appropriately.\nmv_subvolume = mvA[10:20, 10:20, 4:6]\n```\n\n### Built-in AI Models\nDOSMA is built to be a hub for machine/deep learning models. A complete list of models and corresponding publications can be found [here](https://dosma.readthedocs.io/en/latest/models.html).\nWe can use one of the knee segmentation models to segment a MedicalVolume `mv` and model\n`weights` [downloaded locally](https://dosma.readthedocs.io/en/latest/installation.html#segmentation):\n\n```python\nfrom dosma.models import IWOAIOAIUnet2DNormalized\n\n# Reformat such that sagittal plane is last dimension.\nmv = mv.reformat((\"SI\", \"AP\", \"LR\"))\n\n# Do segmentation\nmodel = IWOAIOAIUnet2DNormalized(input_shape=mv.shape[:2] + (1,), weights_path=weights)\nmasks = model.generate_mask(mv)\n```\n\n### Parallelizable Operations\nDOSMA supports parallelization for compute-heavy operations, like curve fitting and image registration.\nImage registration is supported thru the [elastix/transformix](https://elastix.lumc.nl/download.php) libraries. For example we can use multiple workers to register volumes to a target, and use the registered outputs for per-voxel monoexponential fitting:\n\n```python\n# Register images mvA, mvB, mvC to target image mv_tgt in parallel\n_, (mvA_reg, mvB_reg, mvC_reg) = dosma.register(\n   mv_tgt,\n   moving=[mvA, mvB, mvC],\n   parameters=\"/path/to/elastix/registration/file\",\n   num_workers=3,\n   return_volumes=True,\n   show_pbar=True,\n)\n\n# Perform monoexponential fitting.\ndef monoexponential(x, a, b):\n   return a * np.exp(b*x)\n\nfitter = dosma.CurveFitter(\n   monoexponential,\n   num_workers=4,\n   p0={\"a\": 1.0, \"b\": -1/30},\n)\npopt, r2 = fitter.fit(x=[1, 2, 3, 4], [mv_tgt, mvA_reg, mvB_reg, mvC_reg])\na_fit, b_fit = popt[..., 0], popt[..., 1]\n```\n\n## Citation\n```\n@inproceedings{desai2019dosma,\n  title={DOSMA: A deep-learning, open-source framework for musculoskeletal MRI analysis},\n  author={Desai, Arjun D and Barbieri, Marco and Mazzoli, Valentina and Rubin, Elka and Black, Marianne S and Watkins, Lauren E and Gold, Garry E and Hargreaves, Brian A and Chaudhari, Akshay S},\n  booktitle={Proc 27th Annual Meeting ISMRM, Montreal},\n  pages={1135},\n  year={2019}\n}\n```\n\nIn addition to DOSMA, please also consider citing the work that introduced the method used for analysis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad12%2Fdosma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fad12%2Fdosma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad12%2Fdosma/lists"}