crashs 0.2.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 (41) hide show
  1. crashs-0.2.0/.github/workflows/python-publish.yml +38 -0
  2. crashs-0.2.0/.gitignore +166 -0
  3. crashs-0.2.0/Dockerfile +67 -0
  4. crashs-0.2.0/LICENSE +21 -0
  5. crashs-0.2.0/PKG-INFO +55 -0
  6. crashs-0.2.0/README.md +39 -0
  7. crashs-0.2.0/misc/test.ipynb +4219 -0
  8. crashs-0.2.0/misc/test_refactor.ipynb +5387 -0
  9. crashs-0.2.0/pyproject.toml +24 -0
  10. crashs-0.2.0/requirements.txt +12 -0
  11. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/affine_t1_to_template/t1_to_template_affine.mat +4 -0
  12. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_000.nii.gz +0 -0
  13. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_001.nii.gz +0 -0
  14. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_002.nii.gz +0 -0
  15. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_007.nii.gz +0 -0
  16. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_009.nii.gz +0 -0
  17. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_010.nii.gz +0 -0
  18. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_011.nii.gz +0 -0
  19. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_012.nii.gz +0 -0
  20. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_013.nii.gz +0 -0
  21. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_014.nii.gz +0 -0
  22. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_016.nii.gz +0 -0
  23. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_017.nii.gz +0 -0
  24. crashs-0.2.0/sample_data/035_S_4082_2011-06-28/bootstrap/fusion/posterior_corr_usegray_right_020.nii.gz +0 -0
  25. crashs-0.2.0/scripts/run_sample.sh +2 -0
  26. crashs-0.2.0/src/crashs/__init__.py +0 -0
  27. crashs-0.2.0/src/crashs/__main__.py +2 -0
  28. crashs-0.2.0/src/crashs/build_template.py +714 -0
  29. crashs-0.2.0/src/crashs/crashs.py +871 -0
  30. crashs-0.2.0/src/crashs/lddmm.py +374 -0
  31. crashs-0.2.0/src/crashs/omt.py +265 -0
  32. crashs-0.2.0/src/crashs/preprocess_t2.py +310 -0
  33. crashs-0.2.0/src/crashs/profile_sampling.py +214 -0
  34. crashs-0.2.0/src/crashs/roi_integrate.py +73 -0
  35. crashs-0.2.0/src/crashs/upsample/upsample_net.py +496 -0
  36. crashs-0.2.0/src/crashs/util.py +300 -0
  37. crashs-0.2.0/src/crashs/vtkutil.py +352 -0
  38. crashs-0.2.0/templates/crashs_template_01/ashs_template_flip.mat +4 -0
  39. crashs-0.2.0/templates/crashs_template_01/template.json +23 -0
  40. crashs-0.2.0/templates/crashs_template_01/template_shoot_left.vtk +32278 -0
  41. crashs-0.2.0/templates/crashs_template_01/template_shoot_right.vtk +32278 -0
@@ -0,0 +1,38 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ workflow_dispatch:
13
+ release:
14
+ types: [published]
15
+
16
+ permissions:
17
+ contents: read
18
+ id-token: write
19
+
20
+ jobs:
21
+ deploy:
22
+
23
+ runs-on: ubuntu-latest
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v3
29
+ with:
30
+ python-version: '3.x'
31
+ - name: Install dependencies
32
+ run: |
33
+ python -m pip install --upgrade pip
34
+ pip install build
35
+ - name: Build package
36
+ run: python -m build
37
+ - name: Publish package
38
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,166 @@
1
+ # For this project
2
+ tmp
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105
+ #poetry.lock
106
+
107
+ # pdm
108
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109
+ #pdm.lock
110
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111
+ # in version control.
112
+ # https://pdm.fming.dev/#use-with-ide
113
+ .pdm.toml
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+
165
+ .*~
166
+ .DS_Store
@@ -0,0 +1,67 @@
1
+ # THE FIRST PART OF THIS Dockerfile is taken from https://github.com/nighres/nighres/blob/master/Dockerfile
2
+ # Start from the official Debian image
3
+ FROM debian:bullseye
4
+
5
+ <<<<<<< Updated upstream
6
+ # Install nighres prerequisites
7
+ RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic main universe" >> /etc/apt/sources.list
8
+ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
9
+ RUN apt-get update
10
+ RUN apt-get install -y openjdk-11-jdk python3-jcc
11
+
12
+ # Install nighres
13
+ RUN git clone https://github.com/nighres/nighres /tk/nighres && cd /tk/nighres && git checkout 7293c368476a015708b3a89c43409fdfdef9e19c
14
+ RUN ln -s /usr/lib/jvm/java-11-openjdk-amd64 /usr/lib/jvm/default-java
15
+ RUN apt-get install -y wget
16
+ WORKDIR /tk/nighres
17
+ RUN ./build.sh || ./build.sh
18
+ RUN python3 -m pip install .
19
+ RUN pip3 install nibabel==3.2.2
20
+ =======
21
+ # Install necessary tools and dependencies
22
+ RUN apt-get update && apt-get install -y --no-install-recommends \
23
+ ca-certificates \
24
+ git \
25
+ build-essential \
26
+ python3 \
27
+ python3-pip \
28
+ python3-dev \
29
+ libffi-dev \
30
+ openjdk-17-jdk \
31
+ wget \
32
+ && rm -rf /var/lib/apt/lists/*
33
+
34
+ # Adjust JAVA_HOME if necessary and create a symbolic link to match JCC's expected JDK path
35
+ # RUN ls -l /usr/lib/jvm && exit 255
36
+ ENV JAVA_HOME=/usr/lib/jvm/openjdk-17
37
+ RUN ln -s $JAVA_HOME /usr/lib/jvm/temurin-17-jdk-amd64
38
+
39
+ # Install JCC
40
+ RUN python3 -m pip install --upgrade pip && \
41
+ python3 -m pip install jcc
42
+
43
+ # Clone the nighres repository
44
+ RUN git clone https://github.com/nighres/nighres
45
+
46
+ # Change directory into the cloned repository, run the build script, and install nighres
47
+ WORKDIR /nighres
48
+ RUN ./build.sh && \
49
+ python3 -m pip install .
50
+
51
+ # Install nighres
52
+ #RUN git clone https://github.com/nighres/nighres /tk/nighres && cd /tk/nighres && git checkout master
53
+ #RUN ln -s /usr/lib/jvm/java-11-openjdk-amd64 /usr/lib/jvm/default-java
54
+ #RUN apt-get install -y wget
55
+ #WORKDIR /tk/nighres
56
+ #RUN ./build.sh || ./build.sh
57
+ #RUN python3 -m pip install .
58
+ #RUN pip3 install nibabel==3.2.2
59
+ >>>>>>> Stashed changes
60
+
61
+ # Install python packages
62
+ COPY ./requirements.txt /tmp/
63
+ RUN pip install -r /tmp/requirements.txt
64
+
65
+ # Copy the contents
66
+ COPY . /tk/crashs
67
+ WORKDIR /tk/crashs
crashs-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Paul Yushkevich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
crashs-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.3
2
+ Name: crashs
3
+ Version: 0.2.0
4
+ Summary: CRASHS: Cortical Reconstruction for Automated Segmentation of Hippocampal Subfields (ASHS)
5
+ Project-URL: Homepage, https://github.com/pyushkevich/crashs
6
+ Author-email: Paul Yushkevich <pyushkevich@gmail.com>
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+
17
+ # crashs=Cruise+ASHS
18
+ CRASHS is a surface-based modeling and groupwise registration pipeline for the human medial temporal lobe (MTL). It is used to postprocess the results of [ASHS](https://github.com/pyushkevich/ashs) segmentation with ASHS atlases that contain a white matter label. CRASHS uses the [CRUISE](https://doi.org/10.1016/j.neuroimage.2004.06.043) technique implemented in the [NighRes software](https://nighres.readthedocs.io/en/latest/) to fit the white matter segmentation with a surface of spherical topology, and find a series of surfaces spanning between the gray/white boundary and the pial surface. The middle surface is inflated and registered to a population template, allowing surface-based analysis of MTL cortical thickness and other measures such as functional MRI and diffusion MRI.
19
+
20
+ ## Inputs
21
+ The main input to the package is the ASHS-T1 output folder. ASHS should be run using the new [ASHS-T1 atlas with the white matter label](https://www.nitrc.org/frs/downloadlink.php/13554).
22
+
23
+ ## Outputs
24
+ The program generates many outputs, but the most useful ones are:
25
+ * `fitting/[ID]_fitted_omt_hw_target.vtk`: the grey/white and grey/csf boundaries estimated by the `cruise_cortex_extraction` module of NighRes. These meshes are in physical (RAS) coordinate space, not in voxel (IJK) space output by Nighres. *If you extract meshes from the T1-ASHS segmentation in ITK-SNAP, those should like up with these meshes.*
26
+
27
+ * `fitting/[ID]_fitted_omt_hw_target.vtk`: the mid-surface of the gray matter estimated by the `volumetric_layering` module of NighRes. Also in RAS space.
28
+
29
+ * `fitting/[ID]_fitted_omt_match_to_hw.vtk`: the template mesh projected onto the mid-surface surface, also in RAS space. This should have the same geometry as the mid-surface, but the same number of vertices/faces as the template. This mesh will also have scalar arrays for the anatomical label and other features from the template, such as template curvature (useful for visualization). **This mesh can be used to map data from subject space (thickness, fMRI, NODDI, etc) into template space for group analysis**
30
+
31
+ The following files can be used to check how well the fitting between the inflated template mid-surface and the inflated subject mid-surface worked.
32
+
33
+ * `fitting/[ID]_fit_target_reduced`: this is the inflated and sub-sampled mid-surface mesh of the subject, affine transformed into the space of the inflated template. Each triangle is associated with an anatomical label.
34
+
35
+ * `fitting/[ID]_fitted_lddmm_template`: this is the inflated template warped to optimally match the mesh above. The fit is not perfect but should be close.
36
+
37
+ * `fitting/[ID]_fitted_dist_stat.json`: distance statistics of the fitting, including average, max, and 95th percentile of the distance. Useful to check for poor fitting results.
38
+
39
+
40
+ ## Docker
41
+ This repository includes the CRASHS scripts and a `Dockerfile`. The official container on DockerHub is labeled `pyushkevich/crashs:latest`
42
+
43
+ docker run -v your_data_directory:/data -it pyushkevich/crashs:latest /bin/bash
44
+ ./crashs.py --help
45
+
46
+ A sample dataset is also provided and can be processed as follows (also see `run_sample.sh`)
47
+
48
+ docker run -v your_data_directory:/data -it pyushkevich/crashs:latest /bin/bash
49
+ ./crashs.py -s right -r 0.1 sample_data/035_S_4082_2011-06-28 templates/crashs_template_01 /data/test
50
+
51
+ ## Citation
52
+ * PA Yushkevich, L Xie, LEM Wisse, M Dong, S Ravikumar, R Ittyerah, R de Flores, SR Das, DA Wolk for the Alzheimer’s Disease Neuroimaging Initiative (ADNI), Mapping Medial Temporal Lobe Longitudinal Change in Preclinical Alzheimer’s Disease, 2023 Alzheimer's Association International Conference (AAIC 2023).
53
+
54
+
55
+
crashs-0.2.0/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # crashs=Cruise+ASHS
2
+ CRASHS is a surface-based modeling and groupwise registration pipeline for the human medial temporal lobe (MTL). It is used to postprocess the results of [ASHS](https://github.com/pyushkevich/ashs) segmentation with ASHS atlases that contain a white matter label. CRASHS uses the [CRUISE](https://doi.org/10.1016/j.neuroimage.2004.06.043) technique implemented in the [NighRes software](https://nighres.readthedocs.io/en/latest/) to fit the white matter segmentation with a surface of spherical topology, and find a series of surfaces spanning between the gray/white boundary and the pial surface. The middle surface is inflated and registered to a population template, allowing surface-based analysis of MTL cortical thickness and other measures such as functional MRI and diffusion MRI.
3
+
4
+ ## Inputs
5
+ The main input to the package is the ASHS-T1 output folder. ASHS should be run using the new [ASHS-T1 atlas with the white matter label](https://www.nitrc.org/frs/downloadlink.php/13554).
6
+
7
+ ## Outputs
8
+ The program generates many outputs, but the most useful ones are:
9
+ * `fitting/[ID]_fitted_omt_hw_target.vtk`: the grey/white and grey/csf boundaries estimated by the `cruise_cortex_extraction` module of NighRes. These meshes are in physical (RAS) coordinate space, not in voxel (IJK) space output by Nighres. *If you extract meshes from the T1-ASHS segmentation in ITK-SNAP, those should like up with these meshes.*
10
+
11
+ * `fitting/[ID]_fitted_omt_hw_target.vtk`: the mid-surface of the gray matter estimated by the `volumetric_layering` module of NighRes. Also in RAS space.
12
+
13
+ * `fitting/[ID]_fitted_omt_match_to_hw.vtk`: the template mesh projected onto the mid-surface surface, also in RAS space. This should have the same geometry as the mid-surface, but the same number of vertices/faces as the template. This mesh will also have scalar arrays for the anatomical label and other features from the template, such as template curvature (useful for visualization). **This mesh can be used to map data from subject space (thickness, fMRI, NODDI, etc) into template space for group analysis**
14
+
15
+ The following files can be used to check how well the fitting between the inflated template mid-surface and the inflated subject mid-surface worked.
16
+
17
+ * `fitting/[ID]_fit_target_reduced`: this is the inflated and sub-sampled mid-surface mesh of the subject, affine transformed into the space of the inflated template. Each triangle is associated with an anatomical label.
18
+
19
+ * `fitting/[ID]_fitted_lddmm_template`: this is the inflated template warped to optimally match the mesh above. The fit is not perfect but should be close.
20
+
21
+ * `fitting/[ID]_fitted_dist_stat.json`: distance statistics of the fitting, including average, max, and 95th percentile of the distance. Useful to check for poor fitting results.
22
+
23
+
24
+ ## Docker
25
+ This repository includes the CRASHS scripts and a `Dockerfile`. The official container on DockerHub is labeled `pyushkevich/crashs:latest`
26
+
27
+ docker run -v your_data_directory:/data -it pyushkevich/crashs:latest /bin/bash
28
+ ./crashs.py --help
29
+
30
+ A sample dataset is also provided and can be processed as follows (also see `run_sample.sh`)
31
+
32
+ docker run -v your_data_directory:/data -it pyushkevich/crashs:latest /bin/bash
33
+ ./crashs.py -s right -r 0.1 sample_data/035_S_4082_2011-06-28 templates/crashs_template_01 /data/test
34
+
35
+ ## Citation
36
+ * PA Yushkevich, L Xie, LEM Wisse, M Dong, S Ravikumar, R Ittyerah, R de Flores, SR Das, DA Wolk for the Alzheimer’s Disease Neuroimaging Initiative (ADNI), Mapping Medial Temporal Lobe Longitudinal Change in Preclinical Alzheimer’s Disease, 2023 Alzheimer's Association International Conference (AAIC 2023).
37
+
38
+
39
+