clabtoolkit 0.0.1__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 (36) hide show
  1. clabtoolkit-0.0.1/AUTHORS.rst +13 -0
  2. clabtoolkit-0.0.1/CONTRIBUTING.rst +128 -0
  3. clabtoolkit-0.0.1/HISTORY.rst +8 -0
  4. clabtoolkit-0.0.1/LICENSE +16 -0
  5. clabtoolkit-0.0.1/MANIFEST.in +11 -0
  6. clabtoolkit-0.0.1/PKG-INFO +68 -0
  7. clabtoolkit-0.0.1/README.rst +37 -0
  8. clabtoolkit-0.0.1/clabtoolkit/__init__.py +5 -0
  9. clabtoolkit-0.0.1/clabtoolkit/bidstools.py +141 -0
  10. clabtoolkit-0.0.1/clabtoolkit/connect_lab_toolkit.py +724 -0
  11. clabtoolkit-0.0.1/clabtoolkit/dicomtools.py +161 -0
  12. clabtoolkit-0.0.1/clabtoolkit/dwitools.py +68 -0
  13. clabtoolkit-0.0.1/clabtoolkit/examples.py +27 -0
  14. clabtoolkit-0.0.1/clabtoolkit/freesurfertools.py +147 -0
  15. clabtoolkit-0.0.1/clabtoolkit/misctools.py +72 -0
  16. clabtoolkit-0.0.1/clabtoolkit/parcellationtools.py +91 -0
  17. clabtoolkit-0.0.1/clabtoolkit/surfacetools.py +724 -0
  18. clabtoolkit-0.0.1/clabtoolkit.egg-info/PKG-INFO +68 -0
  19. clabtoolkit-0.0.1/clabtoolkit.egg-info/SOURCES.txt +35 -0
  20. clabtoolkit-0.0.1/clabtoolkit.egg-info/dependency_links.txt +1 -0
  21. clabtoolkit-0.0.1/clabtoolkit.egg-info/not-zip-safe +1 -0
  22. clabtoolkit-0.0.1/clabtoolkit.egg-info/top_level.txt +1 -0
  23. clabtoolkit-0.0.1/docs/Makefile +20 -0
  24. clabtoolkit-0.0.1/docs/authors.rst +1 -0
  25. clabtoolkit-0.0.1/docs/conf.py +162 -0
  26. clabtoolkit-0.0.1/docs/contributing.rst +1 -0
  27. clabtoolkit-0.0.1/docs/history.rst +1 -0
  28. clabtoolkit-0.0.1/docs/index.rst +20 -0
  29. clabtoolkit-0.0.1/docs/installation.rst +51 -0
  30. clabtoolkit-0.0.1/docs/make.bat +36 -0
  31. clabtoolkit-0.0.1/docs/readme.rst +1 -0
  32. clabtoolkit-0.0.1/docs/usage.rst +7 -0
  33. clabtoolkit-0.0.1/setup.cfg +23 -0
  34. clabtoolkit-0.0.1/setup.py +44 -0
  35. clabtoolkit-0.0.1/tests/__init__.py +1 -0
  36. clabtoolkit-0.0.1/tests/test_clabtoolkit.py +21 -0
@@ -0,0 +1,13 @@
1
+ =======
2
+ Credits
3
+ =======
4
+
5
+ Development Lead
6
+ ----------------
7
+
8
+ * Yasser Alemán-Gómez <yasseraleman@protonmail.com>
9
+
10
+ Contributors
11
+ ------------
12
+
13
+ None yet. Why not be the first?
@@ -0,0 +1,128 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every little bit
8
+ helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs at https://github.com/yasseraleman/clabtoolkit/issues.
19
+
20
+ If you are reporting a bug, please include:
21
+
22
+ * Your operating system name and version.
23
+ * Any details about your local setup that might be helpful in troubleshooting.
24
+ * Detailed steps to reproduce the bug.
25
+
26
+ Fix Bugs
27
+ ~~~~~~~~
28
+
29
+ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
30
+ wanted" is open to whoever wants to implement it.
31
+
32
+ Implement Features
33
+ ~~~~~~~~~~~~~~~~~~
34
+
35
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
36
+ and "help wanted" is open to whoever wants to implement it.
37
+
38
+ Write Documentation
39
+ ~~~~~~~~~~~~~~~~~~~
40
+
41
+ Connectomics Lab Toolkit could always use more documentation, whether as part of the
42
+ official Connectomics Lab Toolkit docs, in docstrings, or even on the web in blog posts,
43
+ articles, and such.
44
+
45
+ Submit Feedback
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ The best way to send feedback is to file an issue at https://github.com/yasseraleman/clabtoolkit/issues.
49
+
50
+ If you are proposing a feature:
51
+
52
+ * Explain in detail how it would work.
53
+ * Keep the scope as narrow as possible, to make it easier to implement.
54
+ * Remember that this is a volunteer-driven project, and that contributions
55
+ are welcome :)
56
+
57
+ Get Started!
58
+ ------------
59
+
60
+ Ready to contribute? Here's how to set up `clabtoolkit` for local development.
61
+
62
+ 1. Fork the `clabtoolkit` repo on GitHub.
63
+ 2. Clone your fork locally::
64
+
65
+ $ git clone git@github.com:your_name_here/clabtoolkit.git
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::
68
+
69
+ $ mkvirtualenv clabtoolkit
70
+ $ cd clabtoolkit/
71
+ $ python setup.py develop
72
+
73
+ 4. Create a branch for local development::
74
+
75
+ $ git checkout -b name-of-your-bugfix-or-feature
76
+
77
+ Now you can make your changes locally.
78
+
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::
81
+
82
+ $ flake8 clabtoolkit tests
83
+ $ python setup.py test or pytest
84
+ $ tox
85
+
86
+ To get flake8 and tox, just pip install them into your virtualenv.
87
+
88
+ 6. Commit your changes and push your branch to GitHub::
89
+
90
+ $ git add .
91
+ $ git commit -m "Your detailed description of your changes."
92
+ $ git push origin name-of-your-bugfix-or-feature
93
+
94
+ 7. Submit a pull request through the GitHub website.
95
+
96
+ Pull Request Guidelines
97
+ -----------------------
98
+
99
+ Before you submit a pull request, check that it meets these guidelines:
100
+
101
+ 1. The pull request should include tests.
102
+ 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.5, 3.6, 3.7 and 3.8, 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
+
109
+ Tips
110
+ ----
111
+
112
+ To run a subset of tests::
113
+
114
+
115
+ $ python -m unittest tests.test_clabtoolkit
116
+
117
+ Deploying
118
+ ---------
119
+
120
+ 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
+
124
+ $ bump2version patch # possible: major / minor / patch
125
+ $ git push
126
+ $ git push --tags
127
+
128
+ Travis will then deploy to PyPI if tests pass.
@@ -0,0 +1,8 @@
1
+ =======
2
+ History
3
+ =======
4
+
5
+ 0.0.1 (2024-03-06)
6
+ ------------------
7
+
8
+ * First release on PyPI.
@@ -0,0 +1,16 @@
1
+ Apache Software License 2.0
2
+
3
+ Copyright (c) 2024, Yasser Alemán-Gómez
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
@@ -0,0 +1,11 @@
1
+ include AUTHORS.rst
2
+ include CONTRIBUTING.rst
3
+ include HISTORY.rst
4
+ include LICENSE
5
+ include README.rst
6
+
7
+ recursive-include tests *
8
+ recursive-exclude * __pycache__
9
+ recursive-exclude * *.py[co]
10
+
11
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.1
2
+ Name: clabtoolkit
3
+ Version: 0.0.1
4
+ Summary: This package contains a set of useful tools for image processing
5
+ Home-page: https://github.com/connectomicslab/clabtoolkit
6
+ Author: Yasser Alemán-Gómez
7
+ Author-email: yasseraleman@protonmail.com
8
+ License: Apache Software License 2.0
9
+ Keywords: clabtoolkit
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Requires-Python: >=3.6
19
+ License-File: LICENSE
20
+ License-File: AUTHORS.rst
21
+
22
+ ========================
23
+ Connectomics Lab Toolkit
24
+ ========================
25
+
26
+
27
+ .. image:: https://img.shields.io/pypi/v/clabtoolkit.svg
28
+ :target: https://pypi.python.org/pypi/clabtoolkit
29
+
30
+ .. image:: https://img.shields.io/travis/yasseraleman/clabtoolkit.svg
31
+ :target: https://travis-ci.com/yasseraleman/clabtoolkit
32
+
33
+ .. image:: https://readthedocs.org/projects/clabtoolkit/badge/?version=latest
34
+ :target: https://clabtoolkit.readthedocs.io/en/latest/?version=latest
35
+ :alt: Documentation Status
36
+
37
+
38
+
39
+
40
+ This package contains a set of useful tools for image processing
41
+
42
+
43
+ * Free software: Apache Software License 2.0
44
+ * Documentation: https://clabtoolkit.readthedocs.io.
45
+
46
+
47
+ Features
48
+ --------
49
+
50
+ * TODO
51
+
52
+ Credits
53
+ -------
54
+
55
+ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
56
+
57
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
58
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
59
+
60
+
61
+ =======
62
+ History
63
+ =======
64
+
65
+ 0.0.1 (2024-03-06)
66
+ ------------------
67
+
68
+ * First release on PyPI.
@@ -0,0 +1,37 @@
1
+ ========================
2
+ Connectomics Lab Toolkit
3
+ ========================
4
+
5
+
6
+ .. image:: https://img.shields.io/pypi/v/clabtoolkit.svg
7
+ :target: https://pypi.python.org/pypi/clabtoolkit
8
+
9
+ .. image:: https://img.shields.io/travis/yasseraleman/clabtoolkit.svg
10
+ :target: https://travis-ci.com/yasseraleman/clabtoolkit
11
+
12
+ .. image:: https://readthedocs.org/projects/clabtoolkit/badge/?version=latest
13
+ :target: https://clabtoolkit.readthedocs.io/en/latest/?version=latest
14
+ :alt: Documentation Status
15
+
16
+
17
+
18
+
19
+ This package contains a set of useful tools for image processing
20
+
21
+
22
+ * Free software: Apache Software License 2.0
23
+ * Documentation: https://clabtoolkit.readthedocs.io.
24
+
25
+
26
+ Features
27
+ --------
28
+
29
+ * TODO
30
+
31
+ Credits
32
+ -------
33
+
34
+ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
35
+
36
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
37
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
@@ -0,0 +1,5 @@
1
+ """Top-level package for Connectomics Lab Toolkit."""
2
+
3
+ __author__ = """Yasser Alemán-Gómez"""
4
+ __email__ = 'yasseraleman@protonmail.com'
5
+ __version__ = '0.0.1'
@@ -0,0 +1,141 @@
1
+ import os
2
+ import shutil
3
+ import clabtoolkit as clt
4
+
5
+
6
+ # This function copies the BIDs folder and its derivatives for e given subjects to a new location
7
+ def _copy_bids_folder(
8
+ bids_dir: str, out_dir: str, fold2copy: list = ["anat"], subjs2copy: str = None, deriv_dir: str = None,
9
+ include_derivatives: bool = False):
10
+ """
11
+ Copy full bids folders
12
+ @params:
13
+ bids_dir - Required : BIDs dataset directory:
14
+ out_dir - Required : Output directory:
15
+ fold2copy - Optional : List of folders to copy: default = ['anat']
16
+ subjs2copy - Optional : List of subjects to copy:
17
+ deriv_dir - Optional : Derivatives directory: default = None
18
+ include_derivatives - Optional : Include derivatives folder: default = False
19
+ """
20
+
21
+ # Listing the subject ids inside the dicom folder
22
+ if subjs2copy is None:
23
+ my_list = os.listdir(bids_dir)
24
+ subj_ids = []
25
+ for it in my_list:
26
+ if "sub-" in it:
27
+ subj_ids.append(it)
28
+ subj_ids.sort()
29
+ else:
30
+ subj_ids = subjs2copy
31
+
32
+ # Selecting the derivatives folder
33
+ if include_derivatives:
34
+ if deriv_dir is None:
35
+ deriv_dir = os.path.join(bids_dir, "derivatives")
36
+
37
+ if not os.path.isdir(deriv_dir):
38
+ # Lunch a warning message if the derivatives folder does not exist
39
+ print("WARNING: The derivatives folder does not exist.")
40
+ print("WARNING: The derivatives folder will not be copied.")
41
+ include_derivatives = False
42
+
43
+ # Selecting all the derivatives folders
44
+ der_pipe_folders = []
45
+ directories = os.listdir(deriv_dir)
46
+ der_pipe_folders = []
47
+ for directory in directories:
48
+ pipe_dir = os.path.join(deriv_dir, directory)
49
+ if not directory.startswith(".") and os.path.isdir(pipe_dir):
50
+ der_pipe_folders.append(pipe_dir)
51
+
52
+ # Failed sessions and derivatives
53
+ fail_sess = []
54
+ fail_deriv = []
55
+
56
+ # Loop around all the subjects
57
+ nsubj = len(subj_ids)
58
+ for i, subj_id in enumerate(subj_ids): # Loop along the IDs
59
+ subj_dir = os.path.join(bids_dir, subj_id)
60
+ out_subj_dir = os.path.join(out_dir, subj_id)
61
+
62
+ clt._printprogressbar(
63
+ i + 1,
64
+ nsubj,
65
+ "Processing subject "
66
+ + subj_id
67
+ + ": "
68
+ + "("
69
+ + str(i + 1)
70
+ + "/"
71
+ + str(nsubj)
72
+ + ")",
73
+ )
74
+
75
+ # Loop along all the sessions inside the subject directory
76
+ for ses_id in os.listdir(subj_dir): # Loop along the session
77
+ ses_dir = os.path.join(subj_dir, ses_id)
78
+ out_ses_dir = os.path.join(out_subj_dir, ses_id)
79
+
80
+ # print('Copying SubjectId: ' + subjId + ' ======> Session: ' + sesId)
81
+
82
+ if fold2copy[0] == "all":
83
+ directories = os.listdir(ses_dir)
84
+ fold2copy = []
85
+ for directory in directories:
86
+ if not directory.startswith(".") and os.path.isdir(os.path.join(ses_dir, directory)):
87
+ print(directory)
88
+ fold2copy.append(directory)
89
+
90
+ for fc in fold2copy:
91
+ # Copying the anat folder
92
+ if os.path.isdir(ses_dir):
93
+ fold_to_copy = os.path.join(ses_dir, fc)
94
+
95
+ try:
96
+ # Creating destination directory using make directory
97
+ dest_dir = os.path.join(out_ses_dir, fc)
98
+ os.makedirs(dest_dir, exist_ok=True)
99
+
100
+ shutil.copytree(fold_to_copy, dest_dir, dirs_exist_ok=True)
101
+
102
+ except:
103
+ fail_sess.append(fold_to_copy)
104
+
105
+ if include_derivatives:
106
+ # Copying the derivatives folder
107
+
108
+ for pipe_dir in der_pipe_folders:
109
+ if os.path.isdir(pipe_dir):
110
+
111
+ out_pipe_dir = os.path.join(out_dir, "derivatives", os.path.basename(pipe_dir))
112
+
113
+ pipe_indiv_subj_in = os.path.join(pipe_dir, subj_id, ses_id)
114
+ pipe_indiv_subj_out = os.path.join(out_pipe_dir, subj_id, ses_id)
115
+
116
+ if os.path.isdir(pipe_indiv_subj_in):
117
+ try:
118
+ # Creating destination directory using make directory
119
+ os.makedirs(pipe_indiv_subj_out, exist_ok=True)
120
+
121
+ # Copying the folder
122
+ shutil.copytree(pipe_indiv_subj_in, pipe_indiv_subj_out, dirs_exist_ok=True)
123
+
124
+ except:
125
+ fail_deriv.append(pipe_indiv_subj_in)
126
+
127
+ # Print the failed sessions and derivatives
128
+ print(" ")
129
+ if fail_sess:
130
+ print("THE PROCESS FAILED COPYING THE FOLLOWING SESSIONS:")
131
+ for i in fail_sess:
132
+ print(i)
133
+ print(" ")
134
+
135
+ if fail_deriv:
136
+ print("THE PROCESS FAILED COPYING THE FOLLOWING DERIVATIVES:")
137
+ for i in fail_deriv:
138
+ print(i)
139
+ print(" ")
140
+
141
+ print("End of copying the files.")