{"id":19417367,"url":"https://github.com/neuronets/kwyk","last_synced_at":"2025-07-03T23:33:38.899Z","repository":{"id":36045653,"uuid":"201010051","full_name":"neuronets/kwyk","owner":"neuronets","description":"Knowing what you know - Bayesian brain parcellation","archived":false,"fork":false,"pushed_at":"2022-09-03T13:52:08.000Z","size":25689,"stargazers_count":20,"open_issues_count":9,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-09T10:04:52.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://doi.org/10.3389/fninf.2019.00067","language":"Python","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/neuronets.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}},"created_at":"2019-08-07T08:44:34.000Z","updated_at":"2023-06-22T07:34:05.000Z","dependencies_parsed_at":"2022-09-06T03:20:14.242Z","dependency_job_id":null,"html_url":"https://github.com/neuronets/kwyk","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/neuronets/kwyk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuronets%2Fkwyk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuronets%2Fkwyk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuronets%2Fkwyk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuronets%2Fkwyk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuronets","download_url":"https://codeload.github.com/neuronets/kwyk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuronets%2Fkwyk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421460,"owners_count":23464012,"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":[],"created_at":"2024-11-10T13:09:09.492Z","updated_at":"2025-07-03T23:33:38.854Z","avatar_url":"https://github.com/neuronets.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kwyk\nKnowing what you know - Bayesian Neural Network for brain parcellation and uncertainty estimation\n\nPaper, code, and model corresponding to [preprint](https://arxiv.org/abs/1812.01719), which is now published.\n\nCite: [McClure P, Rho N, Lee JA, Kaczmarzyk JR, Zheng CY, Ghosh SS, Nielson DM, Thomas AG, Bandettini P and Pereira F (2019) Knowing What You Know in Brain Segmentation Using Bayesian Deep Neural Networks. Front. Neuroinform. 13:67. doi:10.3389/fninf.2019.00067](https://www.frontiersin.org/articles/10.3389/fninf.2019.00067/full)\n\n![In-site segmentation results](figure4.png) \u003csub\u003e__Figure__: In-site segmentation results for the spike-and-slab dropout (SSD) network for a test subject with average Dice performance. The columns show, respectively, the structural image used as input, the FreeSurfer segmentation used as a prediction target, the prediction made by our network, the voxels where there was a mismatch between prediction and target, and the prediction uncertainty at each voxel.\u003c/sub\u003e\n\nTo run using singularity, first pull the image:\n\n```\nsingularity pull docker://neuronets/kwyk:latest-gpu\n```\n\nYou have a few options when running the image. To see them call help.\n```\nsingularity run -B $(pwd):/data -W /data --nv kwyk_latest-gpu.sif --help\n```\n\nThe models correspond to:\n1. Spike-and-slab dropout (bvwn_multi_prior)\n2. MC Bernoulli dropout (bwn_multi)\n3. MAP (bwn)\n\nHere is an example with the spike and slab dropout.\n```\nsingularity run -B $(pwd):/data -W /data --nv kwyk_latest-gpu.sif -m bvwn_multi_prior -n 2 \\\n  --save-variance --save-entropy T1_001.nii.gz output\n```\n\nNote: If you already have `FREESURFER` environment variables in your shell, these may interfere with the ones inside the container. To isolate the container further please add the `-e` flag at the beginning (`singularity run -e ...`) to suppress any environment variables from being pulled into the container.\n\nThis will generate two sets of files `outputT1_001_*.nii.gz` and `outputT1_001_*_orig.nii.gz`. The first set consists of results in conformed FreeSurfer space. The second set will correspond to the original input space.\n\n1. `output_means`: This file contains the labels\n2. `output_variance`: This file contains the variance in labeling over multiple samplings.\n3. `output_entropy`: This file contains the estimated entropy at each voxel.\n4. `output_uncertainty`: A json file that contains the average uncertainty of the input.\n\nIf output files exist, the program will overwrite them only if the option `--overwrite yes` is given. \n\nYou can pass more than one input file to the container. the output will be saved with `prefix` added to input filename.\n\n```\nsingularity run -B $(pwd):/data -W /data --nv kwyk_latest-gpu.sif -m bvwn_multi_prior -n 2 \\\n  --save-variance --save-entropy path/to/T1_001.nii.gz path/to/T2_001.nii.gz output\n```\n\nIf the input files share the same file path pattern such as bids format, the `--base` option removes parts of infile path and creates a new folder to save all outputs there.\n\n```\nsingularity run -B $(pwd):/data -W /data --nv kwyk_latest-gpu.sif -m bvwn_multi_prior -n 2 \\\n  --save-variance --save-entropy --base /path/to/location/bidsdataset/ /path/to/location/bidsdataset/sub-1/anat/T1.nii.gz output\n```\n\nIn case of multiple input files\n\n```\nsingularity run -B $(pwd):/data -W /data --nv kwyk_latest-gpu.sif -m bvwn_multi_prior -n 2 \\\n  --save-variance --save-entropy --base /path/to/location/bidsdataset/ /path/to/location/bidsdataset/sub-1/anat/T1.nii.gz /path/to/location/bidsdataset/sub-2/anat/T1.nii.gz output\n```\n\n\n### Docker usage example\n\nInstead of singularity with GPU, once can also use docker directly. This is an example with a CPU. Note that the CPU-based run is significantly slower.\n\n```\ndocker run -it --rm -v $(pwd):/data neuronets/kwyk:latest-cpu -m bvwn_multi_prior \\\n  --save-entropy T1_001.nii.gz output\n```\n\nThe above examples assume there is a file named `T1_001.nii.gz` in `$(pwd)`.\n\n### Docker hub tags\n\nThe docker hub tags follow the following naming scheme:\n\n- `master-gpu`: gpu version of current github master\n- `latest-gpu`: gpu version of latest release\n- `SEMVER-gpu`: gpu version of semantically versioned release\n\nfor `cpu` versions replace `gpu` with `cpu`\n\n# nobrainer\n\nThis model is based on an earlier version of the nobrainer framework. This repository will be updated when the code is transitioned to the new model.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuronets%2Fkwyk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuronets%2Fkwyk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuronets%2Fkwyk/lists"}