|
1 | | -# ants_bidsapp |
| 1 | +# ANTs BIDS App |
| 2 | + |
| 3 | +A BIDS App for ANTs-based brain segmentation with NIDM outputs. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This BIDS App provides a standardized way to run ANTs-based brain segmentation on BIDS-formatted datasets. It includes preprocessing steps, segmentation, and generates NIDM-compatible outputs for better reproducibility and sharing of results. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- BIDS-compliant input/output |
| 12 | +- ANTs-based brain segmentation |
| 13 | +- N4 bias field correction |
| 14 | +- Brain extraction |
| 15 | +- Tissue segmentation |
| 16 | +- NIDM-compatible outputs |
| 17 | +- Docker and Singularity support |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +### Container Images |
| 22 | + |
| 23 | +Pre-built images will be available once the app is published to Docker Hub. For now, please build from source (see below). |
| 24 | + |
| 25 | +### From Source |
| 26 | + |
| 27 | +```bash |
| 28 | +git clone https://github.com/ReproNim/ants-bidsapp.git |
| 29 | +cd ants-bidsapp |
| 30 | +pip install -e . |
| 31 | +``` |
| 32 | + |
| 33 | +### Building Containers from Source |
| 34 | + |
| 35 | +This BIDS App follows standard BIDS Apps practices with a Dockerfile as the primary container definition. For HPC environments without Docker, we also provide a native Singularity definition file. |
| 36 | + |
| 37 | +#### Building with Docker (on systems with Docker installed) |
| 38 | + |
| 39 | +```bash |
| 40 | +# Using the setup.py helper script |
| 41 | +python setup.py docker |
| 42 | + |
| 43 | +# Or directly with Docker |
| 44 | +docker build -t ants-bidsapp:latest . |
| 45 | + |
| 46 | +# Save for transfer to HPC (if needed) |
| 47 | +docker save ants-bidsapp:latest -o ants-bidsapp.tar |
| 48 | +``` |
| 49 | + |
| 50 | +#### Building with Singularity/Apptainer (for HPC environments) |
| 51 | + |
| 52 | +```bash |
| 53 | +# Direct build from Singularity definition file |
| 54 | +# The --fakeroot flag is required on HPC systems without root access |
| 55 | +apptainer build --fakeroot ants-bidsapp.sif Singularity |
| 56 | + |
| 57 | +# Or using the setup.py helper |
| 58 | +python setup.py singularity |
| 59 | +``` |
| 60 | + |
| 61 | +#### Converting Docker to Singularity |
| 62 | + |
| 63 | +If you have a Docker image (either built locally or from a tar file): |
| 64 | + |
| 65 | +```bash |
| 66 | +# From a saved Docker tar file |
| 67 | +singularity build ants-bidsapp.sif docker-archive://ants-bidsapp.tar |
| 68 | + |
| 69 | +# From local Docker daemon (requires Docker) |
| 70 | +singularity build ants-bidsapp.sif docker-daemon://ants-bidsapp:latest |
| 71 | +``` |
| 72 | + |
| 73 | +## Usage |
| 74 | + |
| 75 | +### Basic Usage |
| 76 | + |
| 77 | +```bash |
| 78 | +ants-bidsapp bids_dir output_dir participant --participant-label 01 |
| 79 | +``` |
| 80 | + |
| 81 | +### Advanced Options |
| 82 | + |
| 83 | +```bash |
| 84 | +ants-bidsapp bids_dir output_dir participant \ |
| 85 | + --participant-label 01 \ |
| 86 | + --session-label pre \ |
| 87 | + --modality T1w \ |
| 88 | + --prob-threshold 0.5 \ |
| 89 | + --num-threads 4 \ |
| 90 | + --verbose |
| 91 | +``` |
| 92 | + |
| 93 | +### Command-line Arguments |
| 94 | + |
| 95 | +- `bids_dir`: Path to the BIDS dataset |
| 96 | +- `output_dir`: Path where outputs will be stored |
| 97 | +- `analysis_level`: Level of the analysis (participant) |
| 98 | +- `--participant-label`: Label(s) of the participant(s) to analyze |
| 99 | +- `--session-label`: Label(s) of the session(s) to analyze |
| 100 | +- `--modality`: Imaging modality to process (default: T1w) |
| 101 | +- `--prob-threshold`: Probability threshold for binary mask creation (default: 0.5) |
| 102 | +- `--priors`: Paths to prior probability maps for segmentation |
| 103 | +- `--skip-nidm`: Skip NIDM conversion step |
| 104 | +- `--num-threads`: Number of threads to use for processing (default: 1) |
| 105 | +- `--verbose`: Print detailed logs |
| 106 | + |
| 107 | +## Outputs |
| 108 | + |
| 109 | +The app generates the following outputs: |
| 110 | + |
| 111 | +- Segmentation results in BIDS-compatible format |
| 112 | +- Probability maps for each tissue class |
| 113 | +- Binary masks for each tissue class |
| 114 | +- NIDM-compatible outputs for reproducibility |
| 115 | + |
| 116 | +## NIDM Outputs |
| 117 | + |
| 118 | +The app generates NIDM-compatible outputs that can be used with NIDM tools for visualization and sharing of results. The NIDM outputs include: |
| 119 | + |
| 120 | +- Segmentation statistics |
| 121 | +- Brain volumes |
| 122 | +- Tissue volumes |
| 123 | + |
| 124 | +## Contributing |
| 125 | + |
| 126 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +This project is licensed under the MIT License - see the LICENSE file for details. |
| 131 | + |
| 132 | +## Citation |
| 133 | + |
| 134 | +If you use this BIDS App in your research, please cite: |
| 135 | + |
| 136 | +``` |
| 137 | +ANTs BIDS App. ReproNim. https://github.com/ReproNim/ants-bidsapp |
| 138 | +``` |
0 commit comments