clabtoolkit 0.4.4__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/CONTRIBUTING.rst +35 -24
  2. clabtoolkit-0.5.0/DOCUMENTATION.md +535 -0
  3. clabtoolkit-0.5.0/HISTORY.rst +139 -0
  4. clabtoolkit-0.5.0/MANIFEST.in +41 -0
  5. clabtoolkit-0.5.0/Makefile +84 -0
  6. clabtoolkit-0.5.0/PKG-INFO +280 -0
  7. clabtoolkit-0.5.0/README.rst +213 -0
  8. clabtoolkit-0.5.0/architecture_diagram.md +363 -0
  9. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/__init__.py +1 -1
  10. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/bidstools.py +411 -332
  11. clabtoolkit-0.5.0/clabtoolkit/bidstools_utils.py +845 -0
  12. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/build_visualization_layout.py +36 -36
  13. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/colorstools.py +657 -441
  14. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/bids.json +3 -1
  15. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/config.json +20 -2
  16. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/viz_views.json +29 -4
  17. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/connectivitytools.py +783 -339
  18. clabtoolkit-0.5.0/clabtoolkit/data/parcellationtools/sub-test2_ses-01_atlas-chimeraLFIIHISIFN_scale-1_desc-grow1mm_dseg.lut +283 -0
  19. clabtoolkit-0.5.0/clabtoolkit/data/parcellationtools/sub-test2_ses-01_atlas-chimeraLFIIHISIFN_scale-1_desc-grow1mm_dseg.nii.gz +0 -0
  20. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/dicomtools.py +204 -183
  21. clabtoolkit-0.5.0/clabtoolkit/dwitools.py +1370 -0
  22. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/dwitools_utils.py +6 -6
  23. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/freesurfertools.py +1685 -1176
  24. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/imagetools.py +565 -232
  25. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/imagetools_utils.py +4 -6
  26. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/misctools.py +554 -279
  27. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/misctools_utils.py +34 -36
  28. clabtoolkit-0.5.0/clabtoolkit/morphometrytools.py +2491 -0
  29. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/networktools.py +108 -79
  30. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/parcellationtools.py +2226 -741
  31. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/pipelinetools.py +622 -613
  32. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/plottools.py +312 -116
  33. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/pointstools.py +430 -310
  34. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/qcqatools.py +170 -153
  35. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/segmentationtools.py +58 -43
  36. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/surfacetools.py +1710 -167
  37. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/tracttools.py +1629 -269
  38. clabtoolkit-0.5.0/clabtoolkit/tracttools_utils.py +759 -0
  39. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/visualization_utils.py +311 -152
  40. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/visualizationtools.py +628 -677
  41. clabtoolkit-0.5.0/clabtoolkit.egg-info/PKG-INFO +280 -0
  42. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit.egg-info/SOURCES.txt +34 -4
  43. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit.egg-info/requires.txt +4 -0
  44. clabtoolkit-0.5.0/docs/README.md +58 -0
  45. clabtoolkit-0.5.0/docs/source/_static/clabtoolkit_ecosystem.png +0 -0
  46. clabtoolkit-0.5.0/docs/source/_static/clabtoolkit_favicon.ico +0 -0
  47. clabtoolkit-0.5.0/docs/source/api.rst +25 -0
  48. clabtoolkit-0.5.0/docs/source/changelog.rst +1 -0
  49. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/conf.py +5 -107
  50. clabtoolkit-0.5.0/docs/source/contributing.rst +1 -0
  51. clabtoolkit-0.5.0/docs/source/examples.rst +35 -0
  52. clabtoolkit-0.5.0/docs/source/index.rst +46 -0
  53. clabtoolkit-0.5.0/docs/source/installation.rst +29 -0
  54. clabtoolkit-0.5.0/docs/source/modules/bidstools.rst +86 -0
  55. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/colorstools.rst +1 -0
  56. clabtoolkit-0.5.0/docs/source/modules/connectivitytools.rst +74 -0
  57. clabtoolkit-0.5.0/docs/source/modules/dicomtools.rst +112 -0
  58. clabtoolkit-0.5.0/docs/source/modules/dwitools.rst +188 -0
  59. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/freesurfertools.rst +10 -7
  60. clabtoolkit-0.5.0/docs/source/modules/misctools.rst +100 -0
  61. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/morphometrytools.rst +1 -0
  62. clabtoolkit-0.5.0/docs/source/modules/networktools.rst +71 -0
  63. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/parcellationtools.rst +9 -2
  64. clabtoolkit-0.5.0/docs/source/modules/pipelinetools.rst +80 -0
  65. clabtoolkit-0.5.0/docs/source/modules/plottools.rst +80 -0
  66. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/pointstools.rst +7 -7
  67. clabtoolkit-0.5.0/docs/source/modules/qcqatools.rst +67 -0
  68. clabtoolkit-0.5.0/docs/source/modules/segmentationtools.rst +52 -0
  69. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/surfacetools.rst +13 -4
  70. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/tracttools.rst +20 -6
  71. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/visualizationtools.rst +30 -0
  72. clabtoolkit-0.5.0/docs/source/quickstart.rst +69 -0
  73. clabtoolkit-0.5.0/environment-mac.yaml +238 -0
  74. clabtoolkit-0.5.0/environment.yaml +300 -0
  75. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/pyproject.toml +40 -13
  76. clabtoolkit-0.5.0/requirements-docs.txt +15 -0
  77. clabtoolkit-0.5.0/requirements.txt +75 -0
  78. clabtoolkit-0.5.0/requirements_dev.txt +39 -0
  79. clabtoolkit-0.5.0/tox.ini +18 -0
  80. clabtoolkit-0.5.0/usage_examples/README.md +78 -0
  81. clabtoolkit-0.5.0/usage_examples/clabtoolkit_examples.ipynb +2244 -0
  82. clabtoolkit-0.5.0/usage_examples/examples-bidstools-methods.ipynb +1599 -0
  83. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/usage_examples/examples-colorstools-methods.ipynb +237 -85
  84. clabtoolkit-0.5.0/usage_examples/examples-connectivitytools-methods.ipynb +1006 -0
  85. clabtoolkit-0.5.0/usage_examples/examples-dicomtools-methods.ipynb +638 -0
  86. clabtoolkit-0.5.0/usage_examples/examples-dwitools-methods.ipynb +786 -0
  87. clabtoolkit-0.5.0/usage_examples/examples-freesurfertools-methods.ipynb +2964 -0
  88. clabtoolkit-0.5.0/usage_examples/examples-imagetools-methods.ipynb +2519 -0
  89. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/usage_examples/examples-misctools-methods.ipynb +303 -325
  90. clabtoolkit-0.5.0/usage_examples/examples-morphometrytools-methods.ipynb +1423 -0
  91. clabtoolkit-0.5.0/usage_examples/examples-networktools-methods.ipynb +388 -0
  92. clabtoolkit-0.5.0/usage_examples/examples-parcellationtools-methods.ipynb +2812 -0
  93. clabtoolkit-0.5.0/usage_examples/examples-pipelinetools-methods.ipynb +2116 -0
  94. clabtoolkit-0.5.0/usage_examples/examples-plottools-methods.ipynb +562 -0
  95. clabtoolkit-0.5.0/usage_examples/examples-pointstools-methods.ipynb +1151 -0
  96. clabtoolkit-0.5.0/usage_examples/examples-qcqatools-methods.ipynb +1187 -0
  97. clabtoolkit-0.5.0/usage_examples/examples-segmentationtools-methods.ipynb +185 -0
  98. clabtoolkit-0.5.0/usage_examples/examples-surfacetools-methods.ipynb +3062 -0
  99. clabtoolkit-0.5.0/usage_examples/examples-tracttools-methods.ipynb +1976 -0
  100. clabtoolkit-0.5.0/usage_examples/examples-visualizationtools-methods.ipynb +1355 -0
  101. clabtoolkit-0.4.4/HISTORY.rst +0 -81
  102. clabtoolkit-0.4.4/MANIFEST.in +0 -25
  103. clabtoolkit-0.4.4/PKG-INFO +0 -221
  104. clabtoolkit-0.4.4/README.rst +0 -156
  105. clabtoolkit-0.4.4/clabtoolkit/dwitools.py +0 -980
  106. clabtoolkit-0.4.4/clabtoolkit/morphometrytools.py +0 -3332
  107. clabtoolkit-0.4.4/clabtoolkit.egg-info/PKG-INFO +0 -221
  108. clabtoolkit-0.4.4/docs/clabtoolkit.rst +0 -141
  109. clabtoolkit-0.4.4/docs/modules.rst +0 -7
  110. clabtoolkit-0.4.4/docs/source/_static/clabtoolkit_ecosystem.png +0 -0
  111. clabtoolkit-0.4.4/docs/source/index.rst +0 -87
  112. clabtoolkit-0.4.4/docs/source/modules/bidstools.rst +0 -50
  113. clabtoolkit-0.4.4/docs/source/modules/connectivitytools.rst +0 -26
  114. clabtoolkit-0.4.4/docs/source/modules/dicomtools.rst +0 -62
  115. clabtoolkit-0.4.4/docs/source/modules/dwitools.rst +0 -115
  116. clabtoolkit-0.4.4/docs/source/modules/misctools.rst +0 -81
  117. clabtoolkit-0.4.4/docs/source/modules/networktools.rst +0 -69
  118. clabtoolkit-0.4.4/docs/source/modules/pipelinetools.rst +0 -86
  119. clabtoolkit-0.4.4/docs/source/modules/plottools.rst +0 -79
  120. clabtoolkit-0.4.4/docs/source/modules/qcqatools.rst +0 -71
  121. clabtoolkit-0.4.4/docs/source/modules/segmentationtools.rst +0 -53
  122. clabtoolkit-0.4.4/usage_examples/VisClasses4Paper.ipynb +0 -1011
  123. clabtoolkit-0.4.4/usage_examples/clabtoolkit-OHBM2026-final.ipynb +0 -2069
  124. clabtoolkit-0.4.4/usage_examples/clabtoolkit_examples.ipynb +0 -1358
  125. clabtoolkit-0.4.4/usage_examples/examples-bidstools-methods.ipynb +0 -1366
  126. clabtoolkit-0.4.4/usage_examples/examples-freesurfertools-methods.ipynb +0 -2595
  127. clabtoolkit-0.4.4/usage_examples/examples-parcellationtools-methods.ipynb +0 -2351
  128. clabtoolkit-0.4.4/usage_examples/examples-surfacetools-methods.ipynb +0 -2106
  129. clabtoolkit-0.4.4/usage_examples/examples-visualizationtools-methods.ipynb +0 -1749
  130. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/AUTHORS.rst +0 -0
  131. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/LICENSE +0 -0
  132. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/lobes.json +0 -0
  133. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/stats_mapping.json +0 -0
  134. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit/config/viz_views_test.json +0 -0
  135. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit.egg-info/dependency_links.txt +0 -0
  136. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/clabtoolkit.egg-info/top_level.txt +0 -0
  137. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/Makefile +0 -0
  138. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/make.bat +0 -0
  139. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/_static/clabtoolkit_favicon.png +0 -0
  140. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/_static/clabtoolkit_logo.png +0 -0
  141. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/_static/clabtoolkit_logo_notext.png +0 -0
  142. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/docs/source/modules/imagetools.rst +0 -0
  143. {clabtoolkit-0.4.4 → clabtoolkit-0.5.0}/setup.cfg +0 -0
@@ -15,7 +15,7 @@ Types of Contributions
15
15
  Report Bugs
16
16
  ~~~~~~~~~~~
17
17
 
18
- Report bugs at https://github.com/yasseraleman/clabtoolkit/issues.
18
+ Report bugs at https://github.com/connectomicslab/clabtoolkit/issues.
19
19
 
20
20
  If you are reporting a bug, please include:
21
21
 
@@ -45,7 +45,7 @@ articles, and such.
45
45
  Submit Feedback
46
46
  ~~~~~~~~~~~~~~~
47
47
 
48
- The best way to send feedback is to file an issue at https://github.com/yasseraleman/clabtoolkit/issues.
48
+ The best way to send feedback is to file an issue at https://github.com/connectomicslab/clabtoolkit/issues.
49
49
 
50
50
  If you are proposing a feature:
51
51
 
@@ -64,11 +64,15 @@ Ready to contribute? Here's how to set up `clabtoolkit` for local development.
64
64
 
65
65
  $ git clone git@github.com:your_name_here/clabtoolkit.git
66
66
 
67
- 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
67
+ 3. Install your local copy, with the development tools, into a virtual environment::
68
68
 
69
- $ mkvirtualenv clabtoolkit
70
69
  $ cd clabtoolkit/
71
- $ python setup.py develop
70
+ $ python -m venv .venv
71
+ $ source .venv/bin/activate
72
+ $ pip install -e .[dev,test]
73
+
74
+ A conda environment with the dependencies is also available in
75
+ ``environment.yaml``.
72
76
 
73
77
  4. Create a branch for local development::
74
78
 
@@ -76,14 +80,15 @@ Ready to contribute? Here's how to set up `clabtoolkit` for local development.
76
80
 
77
81
  Now you can make your changes locally.
78
82
 
79
- 5. When you're done making changes, check that your changes pass flake8 and the
80
- tests, including testing other Python versions with tox::
83
+ 5. When you're done making changes, check that your changes pass the linter, the
84
+ formatting check and the tests. These are the same checks that run in CI::
81
85
 
82
- $ flake8 clabtoolkit tests
83
- $ python setup.py test or pytest
84
- $ tox
86
+ $ ruff check clabtoolkit tests
87
+ $ black --check clabtoolkit tests
88
+ $ pytest
85
89
 
86
- To get flake8 and tox, just pip install them into your virtualenv.
90
+ CI installs the latest ``black``, whose formatting can differ slightly from older
91
+ releases, so keep it up to date (``pip install -U black``) before running the check.
87
92
 
88
93
  6. Commit your changes and push your branch to GitHub::
89
94
 
@@ -100,29 +105,35 @@ Before you submit a pull request, check that it meets these guidelines:
100
105
 
101
106
  1. The pull request should include tests.
102
107
  2. If the pull request adds functionality, the docs should be updated. Put
103
- your new functionality into a function with a docstring, and add the
104
- feature to the list in README.rst.
105
- 3. The pull request should work for Python >3.10, and for PyPy. Check
106
- https://travis-ci.com/yasseraleman/clabtoolkit/pull_requests
107
- and make sure that the tests pass for all supported Python versions.
108
+ your new functionality into a function with a docstring, add the feature to
109
+ the list in README.rst, and add an entry to the "Unreleased" section of
110
+ HISTORY.rst.
111
+ 3. The pull request should work for Python 3.11 and newer. The tests run in CI on
112
+ Linux, Windows and macOS, so check that they pass on all of them.
108
113
 
109
114
  Tips
110
115
  ----
111
116
 
112
- To run a subset of tests::
117
+ The tests are in the ``tests`` folder, with one ``test_<module>.py`` file per module.
118
+ To run a subset of them::
113
119
 
120
+ $ pytest tests/test_dicomtools.py
121
+ $ pytest tests/test_imagetools.py -k morphology
114
122
 
115
- $ python -m unittest tests.test_clabtoolkit
123
+ The tests do not need a display, ANTs, FreeSurfer or any data. They use small synthetic
124
+ files and replace the external tools with fakes, so keep new tests self-contained.
116
125
 
117
126
  Deploying
118
127
  ---------
119
128
 
120
129
  A reminder for the maintainers on how to deploy.
121
- Make sure all your changes are committed (including an entry in HISTORY.rst).
122
- Then run::
123
130
 
124
- $ bump2version patch # possible: major / minor / patch
125
- $ git push
126
- $ git push --tags
131
+ 1. Update the version in ``pyproject.toml``, ``clabtoolkit/__init__.py`` and ``release`` in
132
+ ``docs/source/conf.py``. The three must match.
133
+ 2. Move the "Unreleased" entries of ``HISTORY.rst`` under the new version and date.
134
+ 3. Commit the changes, make sure the CI is green, and push to ``main``. The distribution is
135
+ built and published to TestPyPI.
136
+ 4. Tag the release and push the tag. Tags starting with ``v`` publish the distribution to PyPI::
127
137
 
128
- Travis will then deploy to PyPI if tests pass.
138
+ $ git tag v0.4.6
139
+ $ git push origin v0.4.6
@@ -0,0 +1,535 @@
1
+ # Connectomics Lab Toolkit (clabtoolkit)
2
+
3
+ ## Overview
4
+
5
+ **clabtoolkit** is a comprehensive Python toolkit designed for neuroimaging data processing and analysis, with specialized focus on brain connectivity data, BIDS datasets, and various neuroimaging formats. Developed by Yasser Alemán-Gómez, this toolkit provides an end-to-end solution for connectomics research and surface-based brain analysis.
6
+
7
+ **Version**: 0.5.0
8
+ **License**: Apache Software License 2.0
9
+ **Python Support**: 3.11+
10
+ **Documentation**: https://clabtoolkit.readthedocs.io
11
+ **Repository**: https://github.com/connectomicslab/clabtoolkit
12
+
13
+ ## Installation
14
+
15
+ ### From PyPI
16
+
17
+ ```bash
18
+ pip install clabtoolkit
19
+ ```
20
+
21
+ ### Development Installation with Conda
22
+
23
+ ```bash
24
+ git clone https://github.com/connectomicslab/clabtoolkit.git
25
+ cd clabtoolkit
26
+ conda env create -f environment.yaml
27
+ conda activate clabtoolkit-env
28
+ pip install -e .[dev]
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ import clabtoolkit.bidstools as cltbids
35
+ import clabtoolkit.surfacetools as cltsurf
36
+
37
+ # Extract entities from BIDS filename
38
+ entities = cltbids.str2entity("sub-01_ses-M00_T1w.nii.gz")
39
+ print(entities) # {'sub': '01', 'ses': 'M00', 'suffix': 'T1w', 'extension': 'nii.gz'}
40
+
41
+ # Load and visualize a brain surface
42
+ surface = cltsurf.Surface("/path/to/surface.pial")
43
+ surface.plot()
44
+ ```
45
+
46
+ ## Package Architecture
47
+
48
+ The toolkit follows a modular, layered architecture designed for scalability and ease of use:
49
+
50
+ - **Foundation Layer**: Core utilities and plotting infrastructure
51
+ - **Data Layer**: BIDS compliance and image processing
52
+ - **Analysis Layer**: Specialized neuroimaging analysis tools
53
+ - **Workflow Layer**: Pipeline management and quality control
54
+
55
+ ## Module Reference
56
+
57
+ ### Core Data Management
58
+
59
+ #### bidstools - BIDS Dataset Management
60
+
61
+ **Purpose**: Comprehensive BIDS (Brain Imaging Data Structure) compliance and dataset management
62
+
63
+ **Key Features**:
64
+
65
+ - BIDS entity manipulation and validation
66
+ - Dataset organization and structure analysis
67
+ - Batch processing utilities
68
+ - Automated database table generation from BIDS datasets
69
+
70
+ **Key Functions**:
71
+
72
+ ```python
73
+ # Convert BIDS filename to entity dictionary
74
+ entities = cltbids.str2entity("sub-01_ses-M00_acq-3T_T1w.nii.gz")
75
+
76
+ # Manipulate BIDS entities
77
+ cltbids.replace_entity_value(filename, 'ses', 'new_session')
78
+ cltbids.insert_entity(filename, 'run', '01', prev_entity='acq')
79
+
80
+ # Generate and display BIDS dataset structure
81
+ tree = cltbids.generate_bids_tree("/path/to/bids/dataset")
82
+ print(tree)
83
+
84
+ # Get all subjects from a BIDS dataset
85
+ subjects = cltbids.get_subjects("/path/to/bids/dataset")
86
+
87
+ # Generate comprehensive dataset overview
88
+ database = cltbids.get_bids_database_table("/path/to/bids/dataset")
89
+ print(database.head())
90
+ ```
91
+
92
+ #### imagetools - Image Processing Engine
93
+
94
+ **Purpose**: Neuroimaging operations and morphological processing
95
+
96
+ **Key Classes**:
97
+
98
+ - `MorphologicalOperations`: Binary image morphology (erosion, dilation, opening, closing)
99
+
100
+ **Key Features**:
101
+
102
+ - 2D/3D morphological operations
103
+ - Volume filtering and hole filling
104
+ - Image resampling and transformation
105
+ - Quality control utilities
106
+
107
+ **Usage Example**:
108
+
109
+ ```python
110
+ from clabtoolkit.imagetools import MorphologicalOperations
111
+
112
+ morph = MorphologicalOperations()
113
+ # Perform morphological closing on binary image
114
+ filled = morph.closing(image_with_holes, iterations=1)
115
+ ```
116
+
117
+ ### FreeSurfer Integration
118
+
119
+ #### freesurfertools - FreeSurfer Ecosystem Interface
120
+
121
+ **Purpose**: Complete interface with FreeSurfer outputs and cortical surface analysis
122
+
123
+ **Key Classes**:
124
+
125
+ - `AnnotParcellation`: Advanced annotation file management
126
+ - Load/save annotation files (.annot, .gcs formats)
127
+ - Parcellation correction and validation
128
+ - Format conversion between annotation types
129
+
130
+ **Key Features**:
131
+
132
+ - FreeSurfer stats file parsing
133
+ - Surface-based morphometry computation
134
+ - Container technology integration
135
+ - Annotation file correction and processing
136
+
137
+ **Usage Example**:
138
+
139
+ ```python
140
+ import clabtoolkit.freesurfertools as cltfree
141
+ import os
142
+
143
+ # Get FreeSurfer environment variables
144
+ freesurfer_home = os.environ.get('FREESURFER_HOME')
145
+ fs_subject_dir = os.path.join(freesurfer_home, 'subjects')
146
+ fs_fullid = 'bert'
147
+
148
+ # Load the Subject object
149
+ subject = cltfree.FreeSurferSubject(fs_fullid, fs_subject_dir)
150
+
151
+ # Obtain dictionaries containing hemisphere-specific FreeSurfer file paths
152
+ surf, maps, parc, stats = subject.get_hemi_dicts(fs_subject_dir, 'lh')
153
+
154
+ # Get the processing status
155
+ print(f"Processing status for subject {fs_fullid}:")
156
+ subject.get_proc_status()
157
+ print(subject.pstatus)
158
+
159
+ # Load and process annotation file
160
+ annot = cltfree.AnnotParcellation("lh.aparc.a2009s.annot")
161
+ annot.correct_parcellation() # Fix unlabeled vertices
162
+ ```
163
+
164
+ ### Analysis and Processing
165
+
166
+ #### parcellationtools - Brain Parcellation Management
167
+
168
+ **Purpose**: Comprehensive brain parcellation handling and regional analysis
169
+
170
+ **Key Classes**:
171
+
172
+ - `Parcellation`: Complete parcellation ecosystem
173
+ - Load parcellations with lookup tables
174
+ - Regional filtering and grouping
175
+ - Volume calculations and statistics
176
+ - Multi-format export capabilities
177
+
178
+ **Key Features**:
179
+
180
+ - Flexible parcellation filtering and modification
181
+ - Regional statistics computation
182
+ - Atlas integration and validation
183
+ - BIDS-compliant output generation
184
+
185
+ **Usage Example**:
186
+
187
+ ```python
188
+ import clabtoolkit.parcellationtools as cltparc
189
+
190
+ # Load parcellation (automatically detects and loads lookup table if available)
191
+ vol_parc = cltparc.Parcellation("/path/to/parcellation/parcellation.nii.gz")
192
+ ```
193
+
194
+ If a lookup table with the same filename and extension (.lut or .tsv) exists, it will be loaded automatically. Otherwise, load it manually:
195
+
196
+ ```python
197
+ # Load the LUT file manually
198
+ vol_parc.load_colortable("/path/to/lookuptable/lookuptable.lut", lut_type="lut")
199
+ ```
200
+
201
+ Compute regional volumes for all structures in the parcellation:
202
+
203
+ ```python
204
+ # Compute regional volumes
205
+ volumes = vol_parc.compute_regional_volumes()
206
+ ```
207
+
208
+ Filter structures by name or code if only specific regions are of interest:
209
+
210
+ ```python
211
+ # Select structures to keep by their name
212
+ names_to_keep = ["thalamus", "cerebellum"]
213
+
214
+ # Keep only the specified structures
215
+ vol_parc.keep_by_name(names2keep=names_to_keep)
216
+
217
+ # Save the modified parcellation
218
+ out_parc_path = "/tmp/sub-test_desc-tha+cer_dseg.nii.gz"
219
+ vol_parc.save_parcellation(out_parc_path, save_lut=True)
220
+ ```
221
+
222
+ #### surfacetools - Surface Geometry Processing
223
+
224
+ **Purpose**: Brain surface mesh processing and advanced visualization
225
+
226
+ **Key Classes**:
227
+
228
+ - `Surface`: Comprehensive surface management
229
+ - FreeSurfer surface file support (.pial, .white, .inflated)
230
+ - Scalar data overlay and visualization
231
+ - Parcellation integration
232
+ - PyVista-powered 3D rendering
233
+
234
+ **Key Features**:
235
+
236
+ - Multi-format surface loading
237
+ - Scalar map management and visualization
238
+ - Interactive 3D plotting
239
+ - Surface-based analysis tools
240
+
241
+ **Usage Example**:
242
+
243
+ ```python
244
+ from clabtoolkit.surfacetools import Surface
245
+
246
+ # Load surface with scalar data
247
+ surface = Surface("/path/to/lh.pial")
248
+ surface.load_scalar_data("/path/to/thickness.mgh", maps_names="Thickness")
249
+ surface.plot(maps="Thickness", cmap='viridis', views=["lateral", "medial"])
250
+
251
+ # Load annotations
252
+ surface.load_annotation("/path/to/lh.aparc.annot", 'aparc')
253
+ surface.plot(maps="Thickness", cmap='viridis', views="8_views")
254
+ ```
255
+
256
+ #### morphometrytools - Morphometric Analysis
257
+
258
+ **Purpose**: Surface-based morphometric computations and statistics
259
+
260
+ **Key Features**:
261
+
262
+ - Regional value extraction from surface annotations
263
+ - Multi-hemisphere morphometric analysis
264
+ - Statistical summary generation
265
+ - Integration with parcellation workflows
266
+
267
+ **Usage Examples**:
268
+
269
+ Extract regional values by combining vertex-wise surface metrics with anatomical parcellation data:
270
+
271
+ ```python
272
+ import clabtoolkit.morphometrytools as morpho
273
+
274
+ metric_file = '/path/to/metric/lh.thickness'
275
+ parc_file = '/path/to/annotation/lh.atlas.annot'
276
+
277
+ df_region, metric_values, _ = morpho.compute_reg_val_fromannot(
278
+ metric_file, parc_file, hemi, metric=metric_name, include_global=False
279
+ )
280
+ ```
281
+
282
+ Compute regional statistics from a volumetric metric map and a parcellation:
283
+
284
+ ```python
285
+ import clabtoolkit.morphometrytools as morpho
286
+
287
+ metric_file = '/path/to/metric/fa.nii.gz'
288
+ parc_file = '/path/to/parcellation/parc.nii.gz'
289
+
290
+ # Compute regional statistics
291
+ df, metric_values, _ = morpho.compute_reg_val_fromparcellation(
292
+ metric_file, parc_file, metric='intensity'
293
+ )
294
+ ```
295
+
296
+ ### Specialized Analysis
297
+
298
+ #### dwitools - Diffusion MRI Analysis
299
+
300
+ **Purpose**: Diffusion-weighted imaging volume handling, acquisition schemes and tensor-derived maps (tractograms are handled by `tracttools`)
301
+
302
+ **Key Features**:
303
+
304
+ - DWI volume removal by index or b-value, keeping the bvec/bval files in sync
305
+ - B0 volume extraction
306
+ - Acquisition scheme handling from bvec/bval files or b-matrices (shelled and cartesian/DSI schemes)
307
+ - q-space visualization of the scheme, displayed or saved as an image, a vector graphic or an interactive HTML file
308
+ - Scalar maps from the tensor eigenvalues (AD, RD, MD, FA, CL, CP, CS, VF, GA, RA)
309
+
310
+ **Usage Example**:
311
+
312
+ ```python
313
+ from clabtoolkit.dwitools import DiffusionScheme, delete_dwi_volumes, get_b0s
314
+
315
+ # Remove specific DWI volumes (the bvec/bval files are updated as well)
316
+ out_image, out_bvec, out_bval, removed = delete_dwi_volumes(
317
+ in_image="dwi.nii.gz",
318
+ bvec_file="dwi.bvec",
319
+ bval_file="dwi.bval",
320
+ vols_to_delete=[0, 5, 10],
321
+ out_image="dwi_clean.nii.gz",
322
+ )
323
+
324
+ # Extract the B0 volumes
325
+ b0s_img, b0_vols = get_b0s("dwi.nii.gz", "dwi_b0s.nii.gz", bval_thresh=50)
326
+
327
+ # Plot the acquisition scheme, or save it as an image or an interactive HTML file
328
+ scheme = DiffusionScheme.from_bvec_bval_files("dwi.bvec", "dwi.bval")
329
+ scheme.plot()
330
+ scheme.plot(save_path="scheme.html")
331
+ scheme.plot(use_notebook=True) # Inside a Jupyter notebook
332
+ ```
333
+
334
+ #### networktools - Graph Analysis
335
+
336
+ **Purpose**: Network analysis and graph theory applications for brain connectivity
337
+
338
+ **Key Features**:
339
+
340
+ - Graph representation creation from brain meshes
341
+ - Sparse matrix operations for large-scale networks
342
+ - Connectivity analysis utilities
343
+
344
+ **Usage Example**:
345
+
346
+ ```python
347
+ from clabtoolkit.networktools import triangulated_mesh_to_csr
348
+
349
+ # Convert mesh to graph representation
350
+ graph = triangulated_mesh_to_csr(vertices, faces)
351
+ ```
352
+
353
+ #### segmentationtools - Image Segmentation
354
+
355
+ **Purpose**: Atlas-based and automated image segmentation
356
+
357
+ **Key Features**:
358
+
359
+ - Atlas-based parcellation using ANTs
360
+ - Template registration workflows
361
+ - Multi-atlas segmentation support
362
+
363
+ **Usage Example**:
364
+
365
+ ```python
366
+ from clabtoolkit.segmentationtools import abased_parcellation
367
+
368
+ # Perform atlas-based segmentation
369
+ abased_parcellation(
370
+ moving_image="T1w.nii.gz",
371
+ atlas_image="template.nii.gz",
372
+ atlas_labels="template_labels.nii.gz"
373
+ )
374
+ ```
375
+
376
+ ### Quality Control and Visualization
377
+
378
+ #### qcqatools - Quality Control Framework
379
+
380
+ **Purpose**: Comprehensive quality assessment for neuroimaging data
381
+
382
+ **Key Features**:
383
+
384
+ - Automated slice selection for quality control
385
+ - Multi-modal data validation
386
+ - Visual quality assessment tools
387
+ - Report generation capabilities
388
+
389
+ #### visualizationtools - Advanced Brain Visualization
390
+
391
+ **Purpose**: Publication-quality brain visualization system
392
+
393
+ **Key Classes**:
394
+
395
+ - `BrainPlotter`: Multi-view brain surface visualization
396
+ - Configurable view layouts
397
+ - Custom colormap support
398
+ - Publication-ready output
399
+ - Multi-hemisphere rendering
400
+
401
+ **Key Features**:
402
+
403
+ - JSON-based view configuration system
404
+ - Flexible layout management
405
+ - High-quality rendering for publications
406
+ - Interactive visualization capabilities
407
+ - Figures saved with `save_path` as screenshots (`.png`, `.jpg`), vector graphics (`.svg`, `.pdf`, `.eps`) or interactive HTML (`.html`)
408
+ - Notebook-friendly figure size: `window_size` sets the figure size; by default notebook figures are 1024 x 768 so they fit in the cell output, while windows and saved figures use the monitor size
409
+
410
+ **Usage Example**:
411
+
412
+ ```python
413
+ from clabtoolkit.visualizationtools import BrainPlotter
414
+
415
+ plotter = BrainPlotter()
416
+ plotter.plot(surf_lh, views="lateral", notebook=True) # Fits the cell output
417
+ plotter.plot(surf_lh, views="lateral", notebook=True, window_size=(800, 500))
418
+ plotter.plot(surf_lh, views=["lateral", "medial"], save_path="figure.png") # Saved, not displayed
419
+ ```
420
+
421
+ ### Utilities and Infrastructure
422
+
423
+ #### misctools - Core Utilities
424
+
425
+ **Purpose**: Foundation utility functions supporting all modules
426
+
427
+ **Key Features**:
428
+
429
+ - Enhanced command-line argument parsing
430
+ - File system operations
431
+ - Color processing utilities
432
+ - Documentation generation helpers
433
+
434
+ #### pipelinetools - Workflow Management
435
+
436
+ **Purpose**: Pipeline orchestration and batch processing
437
+
438
+ **Key Features**:
439
+
440
+ - Subject ID management for batch workflows
441
+ - Parallel processing utilities
442
+ - Progress tracking and monitoring
443
+
444
+ #### plottools - Plotting Infrastructure
445
+
446
+ **Purpose**: Low-level plotting support and layout calculations
447
+
448
+ **Key Features**:
449
+
450
+ - Dynamic subplot grid calculation
451
+ - Screen size detection
452
+ - Multi-monitor support
453
+
454
+ #### dicomtools - DICOM Processing
455
+
456
+ **Purpose**: Organization of raw DICOM files into subject/session/series folders (conversion to NIfTI is left to tools such as dcm2niix)
457
+
458
+ **Key Features**:
459
+
460
+ - Multi-threaded DICOM organization, with subjects taken from the `sub-*` folders or from the `PatientID` tag
461
+ - Session (`ses-YYYYMMDDHHMMSS`) and series (`0001-T1w-MPRAGE`) names built from the DICOM headers
462
+ - Visit IDs from a demographics table, subject selection and fixed session labels
463
+ - Compression and extraction of the session folders (`tar.gz`)
464
+ - DICOM metadata extraction
465
+
466
+ **Usage Example**:
467
+
468
+ ```python
469
+ from clabtoolkit.dicomtools import org_conv_dicoms, get_dicom_info
470
+
471
+ # /raw/sub-01, /raw/sub-02, ... -> /organized/<subject>/<session>/<series>
472
+ org_conv_dicoms("/raw", "/organized", demog_file="demographics.csv", nthreads=4)
473
+
474
+ info = get_dicom_info("/raw/sub-01/IM_0001.dcm", tags=["PatientID", "StudyDate"])
475
+ ```
476
+
477
+ ## Configuration System
478
+
479
+ clabtoolkit uses a sophisticated JSON-based configuration system located in `clabtoolkit/config/`:
480
+
481
+ - **bids.json**: BIDS entity definitions and validation rules
482
+ - **viz_views.json**: Visualization layout configurations
483
+ - **lobes.json**: Anatomical lobe definitions for parcellation
484
+ - **stats_mapping.json**: Statistical measure mappings and metadata
485
+
486
+ ## Dependencies
487
+
488
+ ### Core Dependencies
489
+
490
+ - **nibabel**: Neuroimaging file I/O
491
+ - **numpy**: Numerical computing
492
+ - **pandas**: Data manipulation
493
+ - **scipy**: Scientific computing
494
+ - **matplotlib**: Basic plotting
495
+
496
+ ### Specialized Dependencies
497
+
498
+ - **pyvista**: 3D visualization and mesh processing
499
+ - **rich**: Enhanced console output
500
+ - **dipy**: Diffusion MRI processing
501
+ - **h5py**: HDF5 file support
502
+
503
+ ### Environment
504
+
505
+ All dependencies are specified in the **environment.yaml** file for reproducible conda environments.
506
+
507
+ ## Contributing
508
+
509
+ 1. Fork the repository
510
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
511
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
512
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
513
+ 5. Open a Pull Request
514
+
515
+ ## Support and Documentation
516
+
517
+ - **GitHub Issues**: Report bugs and request features
518
+ - **Documentation**: Comprehensive API documentation with examples
519
+ - **Test Suite**: Extensive test coverage with example data
520
+ - **Jupyter Notebooks**: Interactive examples and tutorials
521
+
522
+ ## Research Applications
523
+
524
+ clabtoolkit is particularly well-suited for:
525
+
526
+ - **Connectomics Research**: Brain connectivity analysis and visualization
527
+ - **Surface-based Analysis**: Cortical thickness, area, and curvature studies
528
+ - **BIDS Data Management**: Large-scale neuroimaging dataset organization
529
+ - **Multi-modal Integration**: Combined structural and diffusion MRI analysis
530
+ - **Quality Control**: Automated quality assessment for neuroimaging data
531
+ - **Publication Visualization**: High-quality brain visualizations for research papers
532
+
533
+ ---
534
+
535
+ _This toolkit represents a comprehensive solution for modern neuroimaging research, combining robust data management with advanced analysis capabilities and publication-quality visualization tools._