{"id":13716792,"url":"https://github.com/nitrain/nitrain","last_synced_at":"2025-05-15T14:09:10.376Z","repository":{"id":39834203,"uuid":"83503319","full_name":"nitrain/nitrain","owner":"nitrain","description":"Train AI models efficiently on medical images using any framework","archived":false,"fork":false,"pushed_at":"2024-06-13T19:43:58.000Z","size":3860,"stargazers_count":1874,"open_issues_count":4,"forks_count":301,"subscribers_count":48,"default_branch":"main","last_synced_at":"2025-04-11T22:38:08.993Z","etag":null,"topics":["deep-learning","keras","medical-imaging","neuroimaging","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitrain.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-01T02:42:12.000Z","updated_at":"2025-04-11T18:36:02.000Z","dependencies_parsed_at":"2024-01-25T18:06:26.521Z","dependency_job_id":"c4ba3f5d-9d55-48a4-ad72-d697836760e1","html_url":"https://github.com/nitrain/nitrain","commit_stats":null,"previous_names":["ncullen93/nitrain","ncullen93/torchsample"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrain%2Fnitrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrain%2Fnitrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrain%2Fnitrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrain%2Fnitrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitrain","download_url":"https://codeload.github.com/nitrain/nitrain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355332,"owners_count":22057354,"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","keras","medical-imaging","neuroimaging","pytorch"],"created_at":"2024-08-03T00:01:14.447Z","updated_at":"2025-05-15T14:09:05.345Z","avatar_url":"https://github.com/nitrain.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库"],"sub_categories":["Other libraries｜其他库:"],"readme":"# Nitrain: a medical imaging-native AI framework\n\n[![Coverage Status](https://coveralls.io/repos/github/nitrain/nitrain/badge.svg?branch=main)](https://coveralls.io/github/nitrain/nitrain?branch=main)\n[![Build](https://github.com/nitrain/nitrain/actions/workflows/test.yml/badge.svg)](https://github.com/nitrain/nitrain/actions/workflows/test.yml)\n\nNitrain (formerly \u003ci\u003etorchsample\u003c/i\u003e) is a framework-agnostic python library for sampling and augmenting medical images, training models on medical imaging datasets, and visualizing results in a medical imaging context.\n\nThe nitrain library is unique in that it makes training models as simple as possible by providing reasonable defaults and a high-level of abstraction. It also supports multiple frameworks - torch, tensorflow, and keras - with a goal to add even more.\n\nFull examples of training medical imaging AI models using nitrain can be found at the [Tutorials](https://github.com/nitrain/tutorials) page. If you are interested more generally in medical imaging AI, check out [Practical medical imaging AI techniques with Python](https://book.nitrain.dev) (expected early 2025).\n\n\u003cbr /\u003e\n\n## Quickstart\n\nHere is an example of using nitrain to a semantic segmentation model that demonstrates much of the core functionality.\n\n```python\nimport nitrain as nt\nfrom nitrain.readers import ImageReader, ColumnReader\n\n# create dataset from folder of images + participants file\ndataset = nt.Dataset(inputs=ImageReader('sub-*/anat/*_T1w.nii.gz'),\n                     outputs=ImageReader('sub-*/anat/*_aparc+aseg.nii.gz'),\n                     transforms={\n                         'inputs': tx.NormalizeIntensity(0,1),\n                         ('inputs', 'outputs'): tx.Resize((64,64,64))\n                     },\n                     base_dir='~/desktop/ds004711/')\n\n# create loader with random transforms\nloader = nt.Loader(dataset,\n                   images_per_batch=4,\n                   sampler=nt.SliceSampler(batch_size = 32, axis = 2)\n                   transforms={\n                           'inputs': tx.RandomNoise(sd=0.2)\n                   })\n\n# create model from architecture\narch_fn = nt.fetch_architecture('unet', dim=2)\nmodel = arch_fn(input_image_size=(64,64,1),\n                mode='segmentation')\n\n# create trainer and fit model\ntrainer = nt.Trainer(model, task='segmentation')\ntrainer.fit(loader, epochs=100)\n```\n\n\u003cbr /\u003e\n\n## Installation\n\nThe latest release of nitrain can be installed from pypi:\n\n```\npip install nitrain\n```\n\nOr you can install the latest development version directly from github:\n\n```\npython -m pip install git+github.com/nitrain/nitrain.git\n```\n\n### Dependencies\n\nThe [ants](https://www.github.com/antsx/antspy) python package is a key dependency that allows you to efficiently read, operate on, and visualize medical images. Additionally, you can use keras (tf.keras or keras3), tensorflow, or pytorch as backend for creating your models.\n\n\u003cbr /\u003e\n\n## Resources\n\nThe following links can be helpful in becoming more familiar with nitrain.\n\n- Introduction tutorials [[Link](https://github.com/nitrain/tutorials/tree/main/introduction)]\n- Segmentation examples [[Link](https://github.com/nitrain/tutorials/tree/main/segmentation)]\n- Classification examples [[Link](https://github.com/nitrain/tutorials/tree/main/classification)]\n- Registration examples [[Link](https://github.com/nitrain/tutorials/tree/main/registration)]\n\nYou can also visit the [ANTsPy](https://github.com/antsx/antspy) repo to learn more about handling medical images and performing traditional medical imaging analysis.\n\n\u003cbr /\u003e\n\n## Contributing\n\nIf you have a question or bug report the best way to get help is by posting an issue on the GitHub page. I would be happy to welcome any new contributors or ideas to the project. If you want to add code, the best way to get started is by posting an issue or contacting me at nickcullen31@gmail.com.\n\nYou can support this work by starring the repository or posting a feature request in the issues tab. These actions help increase the project's impact and community reach.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrain%2Fnitrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitrain%2Fnitrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrain%2Fnitrain/lists"}