som-multimodal-datareduction 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 (47) hide show
  1. som_multimodal_datareduction-0.2.0/LICENSE +201 -0
  2. som_multimodal_datareduction-0.2.0/NOTICE +46 -0
  3. som_multimodal_datareduction-0.2.0/PKG-INFO +150 -0
  4. som_multimodal_datareduction-0.2.0/README.md +111 -0
  5. som_multimodal_datareduction-0.2.0/pyproject.toml +112 -0
  6. som_multimodal_datareduction-0.2.0/setup.cfg +4 -0
  7. som_multimodal_datareduction-0.2.0/som_multimodal/__init__.py +30 -0
  8. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/__init__.py +0 -0
  9. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/LICENSE +201 -0
  10. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/__init__.py +31 -0
  11. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/codebook.py +190 -0
  12. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/decorators.py +21 -0
  13. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/neighborhood.py +48 -0
  14. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/normalization.py +93 -0
  15. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/sompy.py +718 -0
  16. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/__init__.py +1 -0
  17. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/bmuhits.py +71 -0
  18. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/dotmap.py +68 -0
  19. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/histogram.py +59 -0
  20. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/hitmap.py +60 -0
  21. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/mapview.py +193 -0
  22. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/plot_tools.py +82 -0
  23. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/plot_tools2.py +80 -0
  24. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/umatrix.py +163 -0
  25. som_multimodal_datareduction-0.2.0/som_multimodal/_vendor/sompy/visualization/view.py +55 -0
  26. som_multimodal_datareduction-0.2.0/som_multimodal/analysis.py +101 -0
  27. som_multimodal_datareduction-0.2.0/som_multimodal/config.py +121 -0
  28. som_multimodal_datareduction-0.2.0/som_multimodal/engine/__init__.py +42 -0
  29. som_multimodal_datareduction-0.2.0/som_multimodal/engine/strings.py +37 -0
  30. som_multimodal_datareduction-0.2.0/som_multimodal/engine/tfprop_vis.py +584 -0
  31. som_multimodal_datareduction-0.2.0/som_multimodal/io.py +84 -0
  32. som_multimodal_datareduction-0.2.0/som_multimodal/pipeline.py +46 -0
  33. som_multimodal_datareduction-0.2.0/som_multimodal/train.py +85 -0
  34. som_multimodal_datareduction-0.2.0/som_multimodal/visualize.py +138 -0
  35. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/PKG-INFO +150 -0
  36. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/SOURCES.txt +45 -0
  37. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/dependency_links.txt +1 -0
  38. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/entry_points.txt +5 -0
  39. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/requires.txt +16 -0
  40. som_multimodal_datareduction-0.2.0/som_multimodal_datareduction.egg-info/top_level.txt +1 -0
  41. som_multimodal_datareduction-0.2.0/tests/test_config.py +40 -0
  42. som_multimodal_datareduction-0.2.0/tests/test_data.py +35 -0
  43. som_multimodal_datareduction-0.2.0/tests/test_engine.py +31 -0
  44. som_multimodal_datareduction-0.2.0/tests/test_io.py +41 -0
  45. som_multimodal_datareduction-0.2.0/tests/test_pipeline.py +32 -0
  46. som_multimodal_datareduction-0.2.0/tests/test_train.py +21 -0
  47. som_multimodal_datareduction-0.2.0/tests/test_version.py +7 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,46 @@
1
+ som-multimodal-datareduction
2
+ Copyright 2026 Cameron B. Renteria
3
+
4
+ This product includes software developed by third parties, redistributed here in
5
+ original or MODIFIED form under their respective licenses. The overall pipeline,
6
+ the HDF5 codebook schema, the de-widgetized command-line interface, the enamel
7
+ feature set, and the dataset are original to this project; the SOM core and its
8
+ visualization layer are not (see below).
9
+
10
+ --------------------------------------------------------------------------------
11
+ 1. SOMPY (vendored verbatim, except 3 imports - som_multimodal/_vendor/sompy/)
12
+ --------------------------------------------------------------------------------
13
+ "SOMPY: A Python Library for Self Organizing Map (SOM)"
14
+ Copyright (c) Vahid Moosavi (@sevamoo) and contributors.
15
+ Licensed under the Apache License, Version 2.0.
16
+ https://github.com/sevamoo/SOMPY
17
+ Original license retained at som_multimodal/_vendor/sompy/LICENSE.
18
+
19
+ --------------------------------------------------------------------------------
20
+ 2. tfprop_sompy (MODIFIED - som_multimodal/engine/tfprop_vis.py, strings.py)
21
+ --------------------------------------------------------------------------------
22
+ "tfprop_sompy: Self-Organizing Map Data-Mining for Thermo-Fluid Properties"
23
+ Developed by Gota Kikugawa and Yuta Nishimura (Tohoku University, Japan),
24
+ built on SOMPY. The files in som_multimodal/engine/ are MODIFIED versions of
25
+ that work; modifications Copyright 2026 Cameron B. Renteria, Apache-2.0.
26
+ Each modified file documents its changes in a header; see also
27
+ som_multimodal/engine/ACKNOWLEDGMENTS.md.
28
+
29
+ --------------------------------------------------------------------------------
30
+ 3. Notebook / template lineage
31
+ --------------------------------------------------------------------------------
32
+ The original Jupyter notebooks descend from SOM-lab teaching templates by
33
+ Tim Letz (University of Washington,
34
+ https://github.com/timletz/materials_datascience_uw_somlab) and the MSESOM
35
+ consolidation in the Huang group at the University of Washington.
36
+
37
+ --------------------------------------------------------------------------------
38
+ Dataset
39
+ --------------------------------------------------------------------------------
40
+ data/general_main.csv accompanies, and should be cited as:
41
+ C. Renteria, W. Yan, Y. L. Huang, D. D. Arola, "Contributions to enamel
42
+ durability with aging: An application of data science tools," Journal of the
43
+ Mechanical Behavior of Biomedical Materials, vol. 129, 105147, 2022.
44
+ doi:10.1016/j.jmbbm.2022.105147
45
+
46
+ This NOTICE file is provided for attribution and does not modify the License.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: som-multimodal-datareduction
3
+ Version: 0.2.0
4
+ Summary: Self-Organizing-Map data reduction for multimodal materials data (nanomechanics + Raman + fracture), applied to tooth enamel.
5
+ Author-email: "Cameron B. Renteria" <crentb@uw.edu>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/crentb/som-multimodal-datareduction
8
+ Project-URL: Issues, https://github.com/crentb/som-multimodal-datareduction/issues
9
+ Keywords: self-organizing map,SOM,unsupervised learning,multimodal,data reduction,clustering,materials science,tooth enamel,Raman,nanoindentation
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Visualization
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: numpy>=1.24
24
+ Requires-Dist: scipy>=1.10
25
+ Requires-Dist: scikit-learn>=1.3
26
+ Requires-Dist: scikit-image>=0.20
27
+ Requires-Dist: joblib>=1.2
28
+ Requires-Dist: pandas>=1.5
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: tables>=3.8
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=8.0; extra == "dev"
33
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
34
+ Requires-Dist: ruff==0.14.10; extra == "dev"
35
+ Requires-Dist: black==26.3.1; extra == "dev"
36
+ Requires-Dist: mypy==1.17.1; extra == "dev"
37
+ Requires-Dist: pre-commit>=3.7; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # som-multimodal-datareduction
41
+
42
+ > **Dataset & method paper - please cite:**
43
+ > C. Renteria, W. Yan, Y. L. Huang, D. D. Arola, *"Contributions to enamel durability
44
+ > with aging: An application of data science tools,"* **Journal of the Mechanical
45
+ > Behavior of Biomedical Materials** 129, 105147 (2022).
46
+ > doi:[10.1016/j.jmbbm.2022.105147](https://doi.org/10.1016/j.jmbbm.2022.105147)
47
+
48
+ A reproducible, command-line pipeline that applies **Self-Organizing Maps (SOMs)** plus
49
+ **k-means** to *multimodal* materials data - reducing high-dimensional, mixed-source
50
+ measurements to interpretable maps. It is the de-widgetized, packaged version of the
51
+ analysis behind the paper above, in which nanomechanical, Raman, and fracture
52
+ measurements of tooth enamel are fused to map structure-property relationships with
53
+ aging across species.
54
+
55
+ The shipped dataset (`data/general_main.csv`, 138 measurements) carries eight features -
56
+ modulus, hardness, carbonate, crystallinity, fluorescence, depth, fracture toughness
57
+ (`kc`), and a crack-resistance parameter (`b`) - plus tooth/mammal/position metadata.
58
+
59
+ ## What it produces
60
+
61
+ | Figure | Description |
62
+ |--------|-------------|
63
+ | `component_planes.png` | One heat map per feature over the trained SOM grid, k-means cluster borders overlaid - shows how each property varies and which co-vary. |
64
+ | `cluster_map_by_<label>.png` | SOM nodes colored by k-means cluster, data points colored by a metadata column (e.g. `mammal`) - shows how groups distribute across the map. |
65
+ | `umatrix.png` | Unified distance matrix (inter-node distances) with projected samples - reveals cluster boundaries. |
66
+ | `cluster_diagnostics.png` | Elbow + silhouette vs. *k* to choose the cluster count. |
67
+
68
+ ## Install
69
+
70
+ ```bash
71
+ git clone https://github.com/crentb/som-multimodal-datareduction.git
72
+ cd som-multimodal-datareduction
73
+ pip install -e ".[dev]" # core + test/lint tools; or drop [dev] for runtime only
74
+ ```
75
+
76
+ No GPU or deep-learning stack is required - only the standard scientific-Python
77
+ libraries. The SOM core (SOMPY) is **vendored**, so nothing extra is fetched at install.
78
+
79
+ ## Quickstart
80
+
81
+ End-to-end (train -> figures) on the bundled data:
82
+
83
+ ```bash
84
+ som-pipeline --data-csv data/general_main.csv --n-clusters 6 --output-dir outputs
85
+ ```
86
+
87
+ Or step by step:
88
+
89
+ ```bash
90
+ som-train --data-csv data/general_main.csv --mapsize 25 25 --output-dir outputs
91
+ som-analysis --output-dir outputs --k-min 2 --k-max 12 # pick k (elbow/silhouette)
92
+ som-visualize --output-dir outputs --n-clusters 6 --label-column mammal
93
+ ```
94
+
95
+ Every entry point shares the same flags (`--features`, `--mapsize`, `--normalization`,
96
+ `--n-clusters`, `--label-column`, ...); run any with `-h` for the full list. Use
97
+ `--features` to point the same pipeline at a different column set or dataset.
98
+
99
+ ## How it works
100
+
101
+ ```
102
+ CSV --> train --> som_codebook.h5 --> visualize --> PNG figures
103
+ (SOMPY build+train, (rebuild SOM, k-means
104
+ topographic/quantization over codebook, render)
105
+ error, save codebook)
106
+ ```
107
+
108
+ - **`config.RunConfig`** - one dataclass holding every parameter; shared by all CLIs.
109
+ - **`train.py`** - builds a SOMPY map (`var` normalization, PCA init), trains it,
110
+ reports topographic + quantization error, and writes the codebook + data to HDF5.
111
+ - **`io.py`** - the HDF5 schema (codebook / data / mapsize / feature names / specimen
112
+ ids), interchangeable with the original notebooks.
113
+ - **`visualize.py`** - reloads the codebook, clusters it with k-means, and renders the
114
+ figures via the engine.
115
+ - **`analysis.py`** - elbow + silhouette diagnostics for choosing *k*.
116
+
117
+ ## Repository layout
118
+
119
+ ```
120
+ som_multimodal/
121
+ config.py train.py visualize.py analysis.py pipeline.py io.py
122
+ engine/ MODIFIED tfprop_sompy visualization layer (credited)
123
+ _vendor/sompy/ vendored SOMPY core (Apache-2.0, verbatim)
124
+ data/ general_main.csv + data dictionary
125
+ tests/ fast, synthetic, CPU tests
126
+ ```
127
+
128
+ ## Attribution
129
+
130
+ This project **builds on, and contains modified copies of, prior open-source work**;
131
+ only the overall pipeline, the HDF5 schema, the CLI, the enamel feature set, and the
132
+ dataset are original here.
133
+
134
+ - **SOMPY** - Vahid Moosavi (@sevamoo) et al., Apache-2.0 - the SOM core, vendored.
135
+ - **tfprop_sompy** - Gota Kikugawa & Yuta Nishimura (Tohoku University) - the
136
+ visualization layer, used here in **modified** form.
137
+ - Notebook/template lineage: Tim Letz (UW SOM lab) and the Huang group (UW) MSESOM.
138
+
139
+ Full details and per-file modification notes: [`NOTICE`](NOTICE) and
140
+ [`som_multimodal/engine/ACKNOWLEDGMENTS.md`](som_multimodal/engine/ACKNOWLEDGMENTS.md).
141
+
142
+ ## Citing
143
+
144
+ Please cite the **JMBBM 2022 paper** above (the dataset and method) and, optionally, this
145
+ software via [`CITATION.cff`](CITATION.cff).
146
+
147
+ ## License
148
+
149
+ [Apache-2.0](LICENSE). Vendored/modified upstream code is redistributed under its
150
+ original Apache-2.0 terms with attribution preserved.
@@ -0,0 +1,111 @@
1
+ # som-multimodal-datareduction
2
+
3
+ > **Dataset & method paper - please cite:**
4
+ > C. Renteria, W. Yan, Y. L. Huang, D. D. Arola, *"Contributions to enamel durability
5
+ > with aging: An application of data science tools,"* **Journal of the Mechanical
6
+ > Behavior of Biomedical Materials** 129, 105147 (2022).
7
+ > doi:[10.1016/j.jmbbm.2022.105147](https://doi.org/10.1016/j.jmbbm.2022.105147)
8
+
9
+ A reproducible, command-line pipeline that applies **Self-Organizing Maps (SOMs)** plus
10
+ **k-means** to *multimodal* materials data - reducing high-dimensional, mixed-source
11
+ measurements to interpretable maps. It is the de-widgetized, packaged version of the
12
+ analysis behind the paper above, in which nanomechanical, Raman, and fracture
13
+ measurements of tooth enamel are fused to map structure-property relationships with
14
+ aging across species.
15
+
16
+ The shipped dataset (`data/general_main.csv`, 138 measurements) carries eight features -
17
+ modulus, hardness, carbonate, crystallinity, fluorescence, depth, fracture toughness
18
+ (`kc`), and a crack-resistance parameter (`b`) - plus tooth/mammal/position metadata.
19
+
20
+ ## What it produces
21
+
22
+ | Figure | Description |
23
+ |--------|-------------|
24
+ | `component_planes.png` | One heat map per feature over the trained SOM grid, k-means cluster borders overlaid - shows how each property varies and which co-vary. |
25
+ | `cluster_map_by_<label>.png` | SOM nodes colored by k-means cluster, data points colored by a metadata column (e.g. `mammal`) - shows how groups distribute across the map. |
26
+ | `umatrix.png` | Unified distance matrix (inter-node distances) with projected samples - reveals cluster boundaries. |
27
+ | `cluster_diagnostics.png` | Elbow + silhouette vs. *k* to choose the cluster count. |
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ git clone https://github.com/crentb/som-multimodal-datareduction.git
33
+ cd som-multimodal-datareduction
34
+ pip install -e ".[dev]" # core + test/lint tools; or drop [dev] for runtime only
35
+ ```
36
+
37
+ No GPU or deep-learning stack is required - only the standard scientific-Python
38
+ libraries. The SOM core (SOMPY) is **vendored**, so nothing extra is fetched at install.
39
+
40
+ ## Quickstart
41
+
42
+ End-to-end (train -> figures) on the bundled data:
43
+
44
+ ```bash
45
+ som-pipeline --data-csv data/general_main.csv --n-clusters 6 --output-dir outputs
46
+ ```
47
+
48
+ Or step by step:
49
+
50
+ ```bash
51
+ som-train --data-csv data/general_main.csv --mapsize 25 25 --output-dir outputs
52
+ som-analysis --output-dir outputs --k-min 2 --k-max 12 # pick k (elbow/silhouette)
53
+ som-visualize --output-dir outputs --n-clusters 6 --label-column mammal
54
+ ```
55
+
56
+ Every entry point shares the same flags (`--features`, `--mapsize`, `--normalization`,
57
+ `--n-clusters`, `--label-column`, ...); run any with `-h` for the full list. Use
58
+ `--features` to point the same pipeline at a different column set or dataset.
59
+
60
+ ## How it works
61
+
62
+ ```
63
+ CSV --> train --> som_codebook.h5 --> visualize --> PNG figures
64
+ (SOMPY build+train, (rebuild SOM, k-means
65
+ topographic/quantization over codebook, render)
66
+ error, save codebook)
67
+ ```
68
+
69
+ - **`config.RunConfig`** - one dataclass holding every parameter; shared by all CLIs.
70
+ - **`train.py`** - builds a SOMPY map (`var` normalization, PCA init), trains it,
71
+ reports topographic + quantization error, and writes the codebook + data to HDF5.
72
+ - **`io.py`** - the HDF5 schema (codebook / data / mapsize / feature names / specimen
73
+ ids), interchangeable with the original notebooks.
74
+ - **`visualize.py`** - reloads the codebook, clusters it with k-means, and renders the
75
+ figures via the engine.
76
+ - **`analysis.py`** - elbow + silhouette diagnostics for choosing *k*.
77
+
78
+ ## Repository layout
79
+
80
+ ```
81
+ som_multimodal/
82
+ config.py train.py visualize.py analysis.py pipeline.py io.py
83
+ engine/ MODIFIED tfprop_sompy visualization layer (credited)
84
+ _vendor/sompy/ vendored SOMPY core (Apache-2.0, verbatim)
85
+ data/ general_main.csv + data dictionary
86
+ tests/ fast, synthetic, CPU tests
87
+ ```
88
+
89
+ ## Attribution
90
+
91
+ This project **builds on, and contains modified copies of, prior open-source work**;
92
+ only the overall pipeline, the HDF5 schema, the CLI, the enamel feature set, and the
93
+ dataset are original here.
94
+
95
+ - **SOMPY** - Vahid Moosavi (@sevamoo) et al., Apache-2.0 - the SOM core, vendored.
96
+ - **tfprop_sompy** - Gota Kikugawa & Yuta Nishimura (Tohoku University) - the
97
+ visualization layer, used here in **modified** form.
98
+ - Notebook/template lineage: Tim Letz (UW SOM lab) and the Huang group (UW) MSESOM.
99
+
100
+ Full details and per-file modification notes: [`NOTICE`](NOTICE) and
101
+ [`som_multimodal/engine/ACKNOWLEDGMENTS.md`](som_multimodal/engine/ACKNOWLEDGMENTS.md).
102
+
103
+ ## Citing
104
+
105
+ Please cite the **JMBBM 2022 paper** above (the dataset and method) and, optionally, this
106
+ software via [`CITATION.cff`](CITATION.cff).
107
+
108
+ ## License
109
+
110
+ [Apache-2.0](LICENSE). Vendored/modified upstream code is redistributed under its
111
+ original Apache-2.0 terms with attribution preserved.
@@ -0,0 +1,112 @@
1
+ # Packaging + tooling for som-multimodal-datareduction (PEP 621).
2
+ # Editable-installable ("pip install -e .[dev]"); deps, lint/format/type config,
3
+ # and test markers all live here so one config drives local dev and CI.
4
+ #
5
+ # The vendored SOM core (som_multimodal/_vendor) and the modified visualization
6
+ # engine (som_multimodal/engine) are EXCLUDED from ruff/black/mypy: they are
7
+ # upstream / upstream-derived code carried for fidelity, not held to this
8
+ # project's style. The original-authored pipeline + tests ARE gated.
9
+ [build-system]
10
+ requires = ["setuptools>=68", "wheel"]
11
+ build-backend = "setuptools.build_meta"
12
+
13
+ [project]
14
+ name = "som-multimodal-datareduction"
15
+ version = "0.2.0"
16
+ description = "Self-Organizing-Map data reduction for multimodal materials data (nanomechanics + Raman + fracture), applied to tooth enamel."
17
+ readme = "README.md"
18
+ requires-python = ">=3.10"
19
+ license = { text = "Apache-2.0" }
20
+ authors = [{ name = "Cameron B. Renteria", email = "crentb@uw.edu" }]
21
+ keywords = [
22
+ "self-organizing map", "SOM", "unsupervised learning", "multimodal",
23
+ "data reduction", "clustering", "materials science", "tooth enamel",
24
+ "Raman", "nanoindentation",
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 3 - Alpha",
28
+ "Intended Audience :: Science/Research",
29
+ "License :: OSI Approved :: Apache Software License",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Topic :: Scientific/Engineering :: Visualization",
36
+ ]
37
+
38
+ # Core runtime deps. No GPU / deep-learning stack: SOMPY needs only the standard
39
+ # scientific Python libraries; `tables` (PyTables) backs the HDF5 codebook I/O.
40
+ dependencies = [
41
+ "numpy>=1.24",
42
+ "scipy>=1.10",
43
+ "scikit-learn>=1.3",
44
+ "scikit-image>=0.20", # vendored SOMPY's umatrix view uses skimage.feature.blob_log
45
+ "joblib>=1.2", # vendored SOMPY imports joblib directly (also a sklearn dep)
46
+ "pandas>=1.5",
47
+ "matplotlib>=3.7",
48
+ "tables>=3.8",
49
+ ]
50
+
51
+ [project.optional-dependencies]
52
+ dev = ["pytest>=8.0", "pytest-cov>=4.1", "ruff==0.14.10", "black==26.3.1", "mypy==1.17.1", "pre-commit>=3.7"]
53
+
54
+ [project.scripts]
55
+ som-train = "som_multimodal.train:main"
56
+ som-visualize = "som_multimodal.visualize:main"
57
+ som-analysis = "som_multimodal.analysis:main"
58
+ som-pipeline = "som_multimodal.pipeline:main"
59
+
60
+ [project.urls]
61
+ Homepage = "https://github.com/crentb/som-multimodal-datareduction"
62
+ Issues = "https://github.com/crentb/som-multimodal-datareduction/issues"
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["."]
66
+ include = ["som_multimodal*"]
67
+
68
+ [tool.setuptools.package-data]
69
+ # Ship the vendored SOMPY license alongside the vendored code.
70
+ "som_multimodal._vendor.sompy" = ["LICENSE"]
71
+
72
+ [tool.pytest.ini_options]
73
+ testpaths = ["tests"]
74
+ markers = [
75
+ "slow: full-size SOM training on the real dataset; skipped in default CI",
76
+ ]
77
+
78
+ [tool.ruff]
79
+ line-length = 100
80
+ target-version = "py310"
81
+ # Vendored SOMPY + modified engine are not held to this project's lint rules.
82
+ extend-exclude = ["som_multimodal/_vendor", "som_multimodal/engine"]
83
+
84
+ [tool.ruff.lint]
85
+ select = ["E", "F", "I"] # pycodestyle errors, pyflakes, isort
86
+ ignore = ["E501", "E402", "F841"] # long lines (black), import-after-stmt (CLIs), unused locals
87
+
88
+ [tool.black]
89
+ line-length = 100
90
+ target-version = ["py310", "py311", "py312"]
91
+ extend-exclude = '''
92
+ /(
93
+ som_multimodal/_vendor
94
+ | som_multimodal/engine
95
+ )/
96
+ '''
97
+
98
+ [tool.mypy]
99
+ python_version = "3.10"
100
+ ignore_missing_imports = true # third-party libs (sompy, tables, ...) ship no stubs
101
+ exclude = ['som_multimodal/_vendor/', 'som_multimodal/engine/']
102
+
103
+ # Treat the vendored SOMPY + modified engine as opaque: don't type-check them even
104
+ # when the original-authored code imports them (they are upstream-derived).
105
+ [[tool.mypy.overrides]]
106
+ module = ["som_multimodal._vendor.*", "som_multimodal.engine.*"]
107
+ follow_imports = "skip"
108
+ ignore_errors = true
109
+
110
+ [tool.coverage.run]
111
+ source = ["som_multimodal"]
112
+ omit = ["som_multimodal/_vendor/*", "som_multimodal/engine/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,30 @@
1
+ """
2
+ som-multimodal-datareduction
3
+ ============================
4
+
5
+ A reproducible, command-line pipeline that applies Self-Organizing Maps (SOMs)
6
+ plus k-means to *multimodal* materials data -- reducing high-dimensional,
7
+ mixed-source measurements (here: nanomechanics + Raman + fracture metrics on tooth
8
+ enamel) to interpretable cluster maps and component planes.
9
+
10
+ The SOM core (SOMPY) and its visualization layer (tfprop_sompy) are vendored and
11
+ *modified* from prior open-source work; see ``som_multimodal/engine/ACKNOWLEDGMENTS.md``
12
+ and ``NOTICE``. The pipeline, HDF5 schema, feature set, and dataset are original to
13
+ this project.
14
+
15
+ Public API:
16
+ RunConfig -- one config object for the whole pipeline
17
+ DEFAULT_FEATURES -- the eight enamel feature columns
18
+
19
+ Command-line entry points:
20
+ python -m som_multimodal.train (or: som-train)
21
+ python -m som_multimodal.visualize (or: som-visualize)
22
+ python -m som_multimodal.analysis (or: som-analysis)
23
+ python -m som_multimodal.pipeline (or: som-pipeline)
24
+ """
25
+
26
+ from som_multimodal.config import DEFAULT_FEATURES, RunConfig
27
+
28
+ __version__ = "0.1.0"
29
+
30
+ __all__ = ["RunConfig", "DEFAULT_FEATURES", "__version__"]