cdi-stools 0.1.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.
- cdi_stools-0.1.0/.gitignore +45 -0
- cdi_stools-0.1.0/CHANGELOG.md +45 -0
- cdi_stools-0.1.0/LICENSE +21 -0
- cdi_stools-0.1.0/PKG-INFO +337 -0
- cdi_stools-0.1.0/README.md +287 -0
- cdi_stools-0.1.0/pyproject.toml +121 -0
- cdi_stools-0.1.0/src/cdi_st/CDI_ST_logo.png +0 -0
- cdi_stools-0.1.0/src/cdi_st/__init__.py +11 -0
- cdi_stools-0.1.0/src/cdi_st/__main__.py +5 -0
- cdi_stools-0.1.0/src/cdi_st/bcdi_core.py +668 -0
- cdi_stools-0.1.0/src/cdi_st/bcdi_gui.py +768 -0
- cdi_stools-0.1.0/src/cdi_st/nn_autophase_infer.py +1008 -0
- cdi_stools-0.1.0/src/cdi_st/nn_autophase_model.py +405 -0
- cdi_stools-0.1.0/src/cdi_st/nn_autophase_train.py +409 -0
- cdi_stools-0.1.0/src/cdi_st/nn_data_generator.py +440 -0
- cdi_stools-0.1.0/src/cdi_st/nn_dataset.py +260 -0
- cdi_stools-0.1.0/src/cdi_st/nn_demo.py +334 -0
- cdi_stools-0.1.0/src/cdi_st/nn_experimental_loader.py +899 -0
- cdi_stools-0.1.0/src/cdi_st/nn_gui_tabs.py +3662 -0
- cdi_stools-0.1.0/src/cdi_st/nn_phase_model.py +346 -0
- cdi_stools-0.1.0/src/cdi_st/nn_phase_retrieval.py +720 -0
- cdi_stools-0.1.0/src/cdi_st/nn_train.py +354 -0
- cdi_stools-0.1.0/src/cdi_st/nn_visualize.py +378 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
build/
|
|
3
|
+
dist/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
.Python
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
.venv/
|
|
15
|
+
.env/
|
|
16
|
+
ENV/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Test / coverage
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
.tox/
|
|
30
|
+
.cache
|
|
31
|
+
|
|
32
|
+
# Tools
|
|
33
|
+
.mypy_cache/
|
|
34
|
+
.ruff_cache/
|
|
35
|
+
|
|
36
|
+
# Project-specific
|
|
37
|
+
training_data/
|
|
38
|
+
checkpoints_*/
|
|
39
|
+
*.pt
|
|
40
|
+
*.npz
|
|
41
|
+
*.h5
|
|
42
|
+
*.vti
|
|
43
|
+
|
|
44
|
+
# Logs
|
|
45
|
+
*.log
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to CDI-ST are documented here.
|
|
4
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
+
and the project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] — Alpha — 2026-05-08
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Initial public release** of CDI-ST as a packaged Python application.
|
|
13
|
+
- BCDI Simulation module (Material → Beam → Results)
|
|
14
|
+
- Material presets: Si, Ge, Pt, Au, SiC, GaAs, and more
|
|
15
|
+
- CIF import for arbitrary crystals
|
|
16
|
+
- Particle shapes: cube, sphere, cylinder, hexagonal prism, octahedron, dodecahedron
|
|
17
|
+
- Strain fields: radial gradient, edge dislocation, random
|
|
18
|
+
- Configurable line dislocations: edge / screw / mixed with arbitrary Burgers vector
|
|
19
|
+
- 3D atomic lattice viewer (Plotly)
|
|
20
|
+
- Detector presets: Maxipix 2×2, Eiger 2M, custom rectangular
|
|
21
|
+
- Analytical and FFT simulation paths
|
|
22
|
+
- BCDI Data Analysis module (Generate Data → AutoPhase_NN → CDI_NN → Reconstruction → 3D Viewer)
|
|
23
|
+
- Training-data generator with random material/shape/size/strain/dislocation
|
|
24
|
+
- Toggles for randomized strain and dislocations
|
|
25
|
+
- AutoPhaseNet3D (unsupervised, dual-decoder, physics-driven loss)
|
|
26
|
+
- PhaseUNet3D (supervised, BCDI loss with α/β/γ weights)
|
|
27
|
+
- Inference: NN-only, refined (HIO+RAAR+ER), ensemble, compare
|
|
28
|
+
- Iterative phase retrieval: HIO (β=0.9), RAAR (β=0.9), ER, with shrink-wrap
|
|
29
|
+
- Experimental data loader: HDF5, ID01 SPEC+EDF, q-space orthogonalization
|
|
30
|
+
- Detector chip-gap masking, hot pixel removal, beamstop streak removal
|
|
31
|
+
- 3D viewer with point cloud / isosurface / surface-only modes
|
|
32
|
+
- Per-voxel opacity weighted by intensity
|
|
33
|
+
- VTI export for ParaView
|
|
34
|
+
- Splash screen and theme-matched launcher
|
|
35
|
+
- In-app Reports & Suggestions feature
|
|
36
|
+
- Cross-platform support (Linux, macOS, Windows) via PyQt6
|
|
37
|
+
- MIT license, full source on GitHub
|
|
38
|
+
|
|
39
|
+
### Known limitations (alpha)
|
|
40
|
+
- Q-space orthogonalization is ID01-specific (can be extended)
|
|
41
|
+
- Some checkpoints from earlier prototypes lack `grid_size` metadata
|
|
42
|
+
- Mask-aware modulus constraint not yet implemented (gaps are filled instead)
|
|
43
|
+
|
|
44
|
+
[Unreleased]: https://github.com/Refze/CDI-St/compare/v0.1.0...HEAD
|
|
45
|
+
[0.1.0]: https://github.com/Refze/CDI-St/releases/tag/v0.1.0
|
cdi_stools-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Soufiane SAIDI
|
|
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.
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cdi-stools
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Coherent Diffraction Imaging Simulation Tools — BCDI simulation and NN-based phase retrieval
|
|
5
|
+
Project-URL: Homepage, https://github.com/Refze/CDI-St
|
|
6
|
+
Project-URL: Documentation, https://github.com/Refze/CDI-St#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/Refze/CDI-St
|
|
8
|
+
Project-URL: Issues, https://github.com/Refze/CDI-St/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Refze/CDI-St/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Soufiane SAIDI <saidisoufiane@hotmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: BCDI,Bragg coherent diffraction imaging,ID01,X-ray diffraction,crystallography,neural network,phase retrieval,synchrotron
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: diffpy-structure>=3.1
|
|
28
|
+
Requires-Dist: h5py>=3.7
|
|
29
|
+
Requires-Dist: matplotlib>=3.6
|
|
30
|
+
Requires-Dist: numpy>=1.22
|
|
31
|
+
Requires-Dist: pandas>=1.5
|
|
32
|
+
Requires-Dist: plotly>=5.13
|
|
33
|
+
Requires-Dist: pyqt6-webengine>=6.4
|
|
34
|
+
Requires-Dist: pyqt6>=6.4
|
|
35
|
+
Requires-Dist: scikit-image>=0.20
|
|
36
|
+
Requires-Dist: scipy>=1.10
|
|
37
|
+
Requires-Dist: torch>=2.0
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: cdi-st[id01,vtk]; extra == 'all'
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
44
|
+
Provides-Extra: id01
|
|
45
|
+
Requires-Dist: silx>=2.0; extra == 'id01'
|
|
46
|
+
Requires-Dist: xrayutilities>=1.7; extra == 'id01'
|
|
47
|
+
Provides-Extra: vtk
|
|
48
|
+
Requires-Dist: vtk>=9.2; extra == 'vtk'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
<div align="center">
|
|
52
|
+
|
|
53
|
+
<img src="docs/screenshots/CDI_ST_logo.png" alt="CDI-ST" width="600"/>
|
|
54
|
+
|
|
55
|
+
# CDI-ST
|
|
56
|
+
|
|
57
|
+
**Coherent Diffraction Imaging — Simulation Tools**
|
|
58
|
+
|
|
59
|
+
A Python application for end-to-end Bragg Coherent Diffraction Imaging (BCDI):
|
|
60
|
+
crystal lattice construction, X-ray scattering simulation, neural-network phase retrieval,
|
|
61
|
+
and 3D visualization, in a single GUI.
|
|
62
|
+
|
|
63
|
+
[](https://pypi.org/project/cdi-stools/)
|
|
64
|
+
[](https://pypi.org/project/cdi-stools/)
|
|
65
|
+
[](https://opensource.org/licenses/MIT)
|
|
66
|
+
[]()
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
## Screenshots
|
|
71
|
+
|
|
72
|
+
<table>
|
|
73
|
+
<tr>
|
|
74
|
+
<td><img src="docs/screenshots/launcher.png" width="280"/></td>
|
|
75
|
+
<td><img src="docs/screenshots/material_tab.png" width="280"/></td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td align="center"><sub>Launcher</sub></td>
|
|
79
|
+
<td align="center"><sub>Material — crystal builder</sub></td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><img src="docs/screenshots/results.png" width="280"/></td>
|
|
83
|
+
<td><img src="docs/screenshots/3d_viewer.png" width="280"/></td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td align="center"><sub>Results — simulated Bragg peak</sub></td>
|
|
87
|
+
<td align="center"><sub>3D Viewer — reconstruction</sub></td>
|
|
88
|
+
</tr>
|
|
89
|
+
</table>
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install cdi-stools
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
After installation, launch the GUI from any terminal:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cdi-st or cdi-stools
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For ID01 / synchrotron `.spec` + `.edf` data support:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install "cdi-stools[id01]"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For everything:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pip install "cdi-stools[all]"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Support for other beamlines filenames comming in future updates...
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
> **Note**: `cdi-st` ships a Qt-based GUI. On Linux, you may need system Qt
|
|
122
|
+
> dependencies (`sudo apt install libxcb-cursor0 libxkbcommon-x11-0` on Ubuntu/Debian).
|
|
123
|
+
> On Windows and macOS the wheel includes everything.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## What is BCDI?
|
|
128
|
+
|
|
129
|
+
Bragg Coherent Diffraction Imaging is a synchrotron technique that reconstructs the
|
|
130
|
+
3D shape and atomic-displacement field of nanocrystals by inverting the diffraction
|
|
131
|
+
intensity around a Bragg peak. The intensity gives only |F(q)|², so reconstruction
|
|
132
|
+
must recover the missing phase by iterative algorithms (HIO, RAAR, ER),
|
|
133
|
+
more recently by neural networks.
|
|
134
|
+
|
|
135
|
+
**CDI-ST integrates the entire workflow into one tool:**
|
|
136
|
+
|
|
137
|
+
| Step | What you do | Where in the GUI |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| 1. Build a crystal | Define material, shape, orientation, optional defects | **BCDI Simulation → Material** |
|
|
140
|
+
| 2. Set the X-ray geometry | Beam energy, detector geometry, oversampling | **BCDI Simulation → Beam** |
|
|
141
|
+
| 3. Simulate diffraction | Compute the 3D Bragg peak | **BCDI Simulation → Results** |
|
|
142
|
+
| 4. Generate training data | Build a labeled dataset of (object, diffraction) pairs | **BCDI Data Analysis → Generate Data** |
|
|
143
|
+
| 5. Train an unsupervised NN | AutoPhase_NN: physics-driven, no ground truth | **BCDI Data Analysis → AutoPhase_NN** |
|
|
144
|
+
| 6. Train a supervised NN | CDI_NN: PhaseUNet3D learning the phase mapping | **BCDI Data Analysis → CDI_NN** |
|
|
145
|
+
| 7. Reconstruct | NN → optionally refine with HIO/RAAR/ER | **BCDI Data Analysis → Reconstruction** |
|
|
146
|
+
| 8. Visualize and export | Interactive 3D viewer, ParaView VTI export | **BCDI Data Analysis → 3D Viewer** |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## The simulation pipeline
|
|
151
|
+
|
|
152
|
+
### 1. Material — build the crystal
|
|
153
|
+
|
|
154
|
+
Choose from preset materials (Si, Ge, Pt, Au, SiC, GaAs, ...) or import a custom
|
|
155
|
+
CIF file. The crystal is built atom-by-atom from the unit cell, replicated to the
|
|
156
|
+
requested supercell size.
|
|
157
|
+
|
|
158
|
+
You can:
|
|
159
|
+
- Select the **particle shape**: cube, sphere, cylinder, hexagonal prism, octahedron, dodecahedron
|
|
160
|
+
- Set the **target oversampling ratio** (controls how much of the diffraction
|
|
161
|
+
volume the object occupies)
|
|
162
|
+
- Add **strain fields**: radial gradient, edge dislocation, random
|
|
163
|
+
- Add **dislocations**: edge / screw / mixed, at a configurable position with
|
|
164
|
+
an arbitrary Burgers vector
|
|
165
|
+
|
|
166
|
+
The 3D lattice view (powered by Plotly) shows every atom in the supercell.
|
|
167
|
+
|
|
168
|
+
### 2. Beam — define the X-ray geometry
|
|
169
|
+
|
|
170
|
+
Select a reflection (h k l) from the auto-computed list of allowed peaks.
|
|
171
|
+
The Beam tab also lets you set:
|
|
172
|
+
- **Beam energy** (and the resulting wavelength)
|
|
173
|
+
- **Detector geometry**: pixel pitch, sample-to-detector distance, detector size
|
|
174
|
+
- **Beam size** in microns
|
|
175
|
+
- **Detector preset**: Maxipix (516×516), Eiger 2M, custom rectangular
|
|
176
|
+
|
|
177
|
+
Detector preset auto-fills the geometry parameters.
|
|
178
|
+
|
|
179
|
+
### 3. Results — run the simulation
|
|
180
|
+
|
|
181
|
+
CDI-ST computes the diffraction in **two paths**:
|
|
182
|
+
|
|
183
|
+
- **Analytical path** (cube/rectangular shapes, no strain): closed-form Fourier transform of the support
|
|
184
|
+
- **FFT path** (any shape, any strain field): full 3D FFT of the complex object
|
|
185
|
+
|
|
186
|
+
Output: 3D diffraction volume `|F(q)|²`, displayed as 2D slices (qx-qy, qx-qz)
|
|
187
|
+
and in an interactive 3D Plotly viewer with iso-surface controls.
|
|
188
|
+
|
|
189
|
+
You can export the simulation as a `.npz` file ready for the data-analysis side,
|
|
190
|
+
or for use as ground truth when training NNs.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## The data-analysis pipeline
|
|
195
|
+
|
|
196
|
+
### 4. Generate Data — create training samples
|
|
197
|
+
|
|
198
|
+
Generates a dataset of synthetic BCDI samples for NN training. Each sample
|
|
199
|
+
contains the ground-truth phase, support, and the simulated diffraction
|
|
200
|
+
intensity. You control:
|
|
201
|
+
|
|
202
|
+
- **Number of samples** (typically 2,000–10,000)
|
|
203
|
+
- **Grid size** (64³ recommended for training, 128³ for production inference)
|
|
204
|
+
- **Materials** (random or fixed)
|
|
205
|
+
- **Particle size variation** (random supercell multiplier)
|
|
206
|
+
- **Random dislocations** adds occasional edge/screw/mixed dislocations
|
|
207
|
+
- **Random strain** adds occasional radial/edge/random strain fields
|
|
208
|
+
|
|
209
|
+
Samples save as `sample_XXXXX.npz` and a `manifest.json`. Generation is
|
|
210
|
+
parallelizable and resumable.
|
|
211
|
+
|
|
212
|
+
### 5. AutoPhase_NN — unsupervised physics-driven NN
|
|
213
|
+
|
|
214
|
+
AutoPhase_NN is a 3D dual-decoder convolutional network that learns to invert the
|
|
215
|
+
Fourier modulus constraint **without ground truth**. It predicts the object's
|
|
216
|
+
amplitude and phase such that `|FFT(amp · exp(iφ))|` matches the measured
|
|
217
|
+
magnitude. The loss is a normalized-magnitude error plus optional regularizers
|
|
218
|
+
on phase smoothness and support compactness. This is the network from (Yao, Yudong,
|
|
219
|
+
et al. npj Computational Materials 8.1 (2022) ) reimplemented for this codebase.
|
|
220
|
+
|
|
221
|
+
Training is GPU-accelerated (CUDA preferred) and converges in a few dozen
|
|
222
|
+
epochs on 2,000+ samples. The best checkpoint is saved automatically.
|
|
223
|
+
|
|
224
|
+
### 6. CDI_NN — supervised PhaseUNet3D
|
|
225
|
+
|
|
226
|
+
A 3D U-Net that predicts the phase field from the diffraction magnitude, trained
|
|
227
|
+
against the ground-truth phase from the data generator.
|
|
228
|
+
|
|
229
|
+
Use AutoPhase_NN when you don't trust your simulator's ground truth (or have
|
|
230
|
+
none). Use CDI_NN when you have a high-fidelity simulator and want a direct
|
|
231
|
+
mapping. Use both via the **ensemble** mode in the Reconstruction tab.
|
|
232
|
+
|
|
233
|
+
### 7. Reconstruction — invert experimental or simulated data
|
|
234
|
+
|
|
235
|
+
Load any `.npz` (simulated) or `.h5` (experimental) BCDI file, or convert a
|
|
236
|
+
SPEC + EDF scan from ID01 directly via the dialog. Choose:
|
|
237
|
+
|
|
238
|
+
- **NN-only**: forward pass, twin-image suppression, COM centering
|
|
239
|
+
- **Refined**: NN seed → HIO + RAAR + ER iterative phase retrieval
|
|
240
|
+
- **Ensemble**: AutoPhase_NN + CDI_NN combined, optionally refined
|
|
241
|
+
- **Compare**: runs both modes side-by-side
|
|
242
|
+
|
|
243
|
+
The output is a complex object (amplitude + phase), a binary support, the
|
|
244
|
+
R-factor convergence curve, and 2D slices at the COM of the reconstruction.
|
|
245
|
+
|
|
246
|
+
For experimental data, the loader handles:
|
|
247
|
+
- Detector chip-gap masking (Maxipix, Eiger)
|
|
248
|
+
- Hot-pixel removal
|
|
249
|
+
- Beamstop / direct-beam streak removal
|
|
250
|
+
- Bragg-peak-centered cropping
|
|
251
|
+
- Optional q-space orthogonalization via xrayutilities (with `[id01]` extra)
|
|
252
|
+
|
|
253
|
+
### 8. 3D Viewer — interactive visualization
|
|
254
|
+
|
|
255
|
+
The viewer renders the reconstruction in three modes:
|
|
256
|
+
|
|
257
|
+
- **Point cloud**: every voxel above threshold, colored by amplitude / phase / strain,
|
|
258
|
+
with per-voxel opacity weighted by intensity
|
|
259
|
+
- **Isosurface**: smoothed iso-shell with internal data points showing through
|
|
260
|
+
- **Surface only**: bare iso-mesh with edges visible
|
|
261
|
+
|
|
262
|
+
Controls:
|
|
263
|
+
- Threshold (% of peak amplitude), voxel size, opacity, colormap
|
|
264
|
+
- Color scale auto / manual (`vmin` / `vmax`)
|
|
265
|
+
- Clip plane on any axis
|
|
266
|
+
- Mouse: left-drag rotate, right-drag pan, wheel zoom, double-click reset
|
|
267
|
+
- Export PNG snapshot or VTI (ParaView)
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Project structure
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
cdi-st/
|
|
275
|
+
├── src/cdi_st/
|
|
276
|
+
│ ├── __init__.py
|
|
277
|
+
│ ├── __main__.py # python -m cdi_st
|
|
278
|
+
│ ├── bcdi_gui.py # main entry point + launcher + splash
|
|
279
|
+
│ ├── bcdi_core.py # crystal builder, simulator, reflection calculator
|
|
280
|
+
│ ├── nn_gui_tabs.py # all NN-related GUI tabs
|
|
281
|
+
│ ├── nn_data_generator.py # training-data generator
|
|
282
|
+
│ ├── nn_dataset.py # PyTorch Dataset wrapper
|
|
283
|
+
│ ├── nn_phase_model.py # PhaseUNet3D (supervised)
|
|
284
|
+
│ ├── nn_autophase_model.py # AutoPhaseNet3D (unsupervised)
|
|
285
|
+
│ ├── nn_train.py # supervised training CLI
|
|
286
|
+
│ ├── nn_autophase_train.py # unsupervised training CLI
|
|
287
|
+
│ ├── nn_phase_retrieval.py # HIO / RAAR / ER iterative algorithms
|
|
288
|
+
│ ├── nn_autophase_infer.py # inference: nn_only / refined / ensemble
|
|
289
|
+
│ ├── nn_experimental_loader.py # h5/spec/edf loading + preprocessing
|
|
290
|
+
│ ├── nn_demo.py
|
|
291
|
+
│ ├── nn_visualize.py
|
|
292
|
+
│ └── CDI_ST_logo.png
|
|
293
|
+
├── tests/
|
|
294
|
+
├── docs/
|
|
295
|
+
├── pyproject.toml
|
|
296
|
+
├── README.md
|
|
297
|
+
├── LICENSE
|
|
298
|
+
└── CHANGELOG.md
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Citing
|
|
304
|
+
|
|
305
|
+
If you use CDI-ST in published research, please cite:
|
|
306
|
+
|
|
307
|
+
```bibtex
|
|
308
|
+
@software{saidi_cdi_st_2026,
|
|
309
|
+
author = {Saidi, Soufiane},
|
|
310
|
+
title = {CDI-ST: Coherent Diffraction Imaging — Simulation Tools},
|
|
311
|
+
year = {2026},
|
|
312
|
+
publisher = {GitHub},
|
|
313
|
+
url = {https://github.com/Refze/CDI-St}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
MIT — see [LICENSE](LICENSE).
|
|
322
|
+
|
|
323
|
+
## Author
|
|
324
|
+
|
|
325
|
+
**Soufiane SAIDI** — saidisoufiane@hotmail.com
|
|
326
|
+
|
|
327
|
+
We heavily encourage you to use the in-app **Reports & Suggestions** button to send any type of feedback.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Acknowledgments
|
|
332
|
+
|
|
333
|
+
Built on the shoulders of the BCDI and python community:
|
|
334
|
+
[PyNX](https://pynx.esrf.fr/), [BCDI-Utilities](https://github.com/carnisj/bcdi),
|
|
335
|
+
[cdiutils](https://github.com/clatlan/cdiutils), [xrayutilities](https://xrayutilities.sourceforge.io/),
|
|
336
|
+
[scikit-image](https://scikit-image.org/), [PyQt6](https://www.riverbankcomputing.com/software/pyqt/),
|
|
337
|
+
and the AutoPhaseNN paper by Yao et al. (2022).
|