cdi-stools 0.3.1__tar.gz → 0.3.3__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.3.3/CHANGELOG.md +260 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/PKG-INFO +48 -58
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/README.md +47 -57
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/pyproject.toml +1 -1
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/__init__.py +1 -1
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/bcdi_core.py +24 -18
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/bcdi_gui.py +335 -9
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_gui_tabs.py +169 -46
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/viz3d.py +1 -1
- cdi_stools-0.3.1/CHANGELOG.md +0 -91
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/LICENSE +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/CDI_ST_logo.png +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/__main__.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/facets.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_autophase_infer.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_autophase_model.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_autophase_train.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_data_generator.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_dataset.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_demo.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_experimental_loader.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_phase_model.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_phase_retrieval.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_train.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/nn_visualize.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/ortho.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/recon.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/requirements.txt +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.3}/src/cdi_st/trainlog.py +0 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.3.3] - 2026-11-17
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Some missing reflections for hexagonal and rhombohedral materials.**
|
|
8
|
+
|
|
9
|
+
- A reflection typed as any member of its family is now found. Previously only
|
|
10
|
+
the stored representative and its Friedel mate matched, so `(0 -1 10)` in
|
|
11
|
+
corundum reported "not found" even though the peak was in the table under
|
|
12
|
+
another label.
|
|
13
|
+
- Window no longer open larger than the screen.
|
|
14
|
+
- The Beam tab's control column scrolls instead of being squeezed
|
|
15
|
+
- `BCDISimulator.simulate()` returned `None` when called without a progress
|
|
16
|
+
callback: `if progress_cb: progress_cb(100);return ...etc` put the `return` inside
|
|
17
|
+
the `if`. Present since 0.2.2 and invisible from the GUI, which always passes a
|
|
18
|
+
callback, but it made the simulator unusable from a script.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **Reconstruction without a neural network.** A `HIO/RAAR/ER only` mode runs the
|
|
23
|
+
standard iterative algorithms from a random start with no checkpoint file, and
|
|
24
|
+
without importing PyTorch at all, so it works on a machine that cannot run a
|
|
25
|
+
network.
|
|
26
|
+
- **Render quality control in the 3D viewer**, chosen before rendering: Draft
|
|
27
|
+
(15,000 points), Standard (60,000, the default), High (200,000) and Maximum
|
|
28
|
+
(1,000,000). Higher settings also smooth the isosurface less, so density and
|
|
29
|
+
strain stay distinguishable. Measured on a 128^3 reconstruction with 268,000
|
|
30
|
+
support voxels: 0.4 s, 0.5 s, 1.4 s and 1.4 s respectively. The old viewer was
|
|
31
|
+
fixed at 15,000 points and 4,000 interior points, with no way to change them.
|
|
32
|
+
- **Auto-update view** toggle. With it on, changing any viewer setting re-renders
|
|
33
|
+
without pressing "Update view". Changes are coalesced for 450 ms so dragging a
|
|
34
|
+
slider does not start a render on every step.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Turbo is the default colormap in the 3D viewer; magma and cividis added.
|
|
39
|
+
- Reconstruction modes are named in plain language and name the networks:
|
|
40
|
+
"AutoPhaseNet -> HIO/RAAR/ER refinement", "AutoPhaseNet alone (fast, rough)",
|
|
41
|
+
"HIO/RAAR/ER only - no neural network", "Both networks averaged
|
|
42
|
+
(AutoPhaseNet + PhaseUNet3D)". `nn_only` and `ensemble` are no longer shown to
|
|
43
|
+
the user; the internal keys are unchanged so saved settings keep working.
|
|
44
|
+
- The checkpoint field is disabled when a mode needs no network.
|
|
45
|
+
- Simulation tabs are named "Material", "Beam", "Results" without numbering.
|
|
46
|
+
|
|
47
|
+
## [0.3.2] - 2026-11-08
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- The launcher window was missing: `main()` opened the simulation window
|
|
52
|
+
directly, so the data-analysis tabs were unreachable from the installed
|
|
53
|
+
package. The v0.3.0 rewrite of `bcdi_gui.py` had dropped `Launcher`,
|
|
54
|
+
`CDIStSplash`, `MW_Analysis` and `ReportsDialog`. All four are restored, and
|
|
55
|
+
`MW_Sim` keeps its Reports & Suggestions button.
|
|
56
|
+
|
|
57
|
+
## [0.3.1] - 2026-11-08
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- `ModuleNotFoundError: No module named 'bcdi_core'` on launch. The modules
|
|
62
|
+
imported each other as top-level names, which works when the files sit
|
|
63
|
+
together in one folder but not from inside the `cdi_st` package. Imports are
|
|
64
|
+
now package-relative, with a fallback so the files still run directly from a
|
|
65
|
+
plain folder.
|
|
66
|
+
|
|
67
|
+
## [0.3.0] - 2026-11-08
|
|
68
|
+
|
|
69
|
+
Faceted particles, photon-budget noise, detector/sample space, standalone phase
|
|
70
|
+
retrieval and training diagnostics.
|
|
71
|
+
|
|
72
|
+
With thanks to **Dr. Gerards Hinsley**, whose review of v0.2.2 prompted most of
|
|
73
|
+
the changes in this release: the facet options, the photon-count control, the
|
|
74
|
+
detector-space toggle, the standalone reconstruction path, the training log, and
|
|
75
|
+
the corrections to the noise model and colour-scale controls.
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
**Simulation**
|
|
80
|
+
- Crystallographic facet shapes built from a Wulff half-space construction
|
|
81
|
+
(`facets.py`): octahedron, cuboctahedron, truncated octahedron, truncated cube,
|
|
82
|
+
rhombic dodecahedron, tunable Wulff, and hexagonal prism / bipyramid /
|
|
83
|
+
truncated bipyramid. Facet normals come from the reciprocal lattice, so the
|
|
84
|
+
construction is correct for every crystal system.
|
|
85
|
+
- Facet multiplicities control: a ratio of facet distances, off by default,
|
|
86
|
+
enabled by a tick box, with a plain-language tooltip giving the shape each
|
|
87
|
+
value produces.
|
|
88
|
+
- Particle size entered directly in nm; supercell multiples follow from the
|
|
89
|
+
lattice vectors. Cell limit raised from 2500 to 100000 per axis, with a size
|
|
90
|
+
notice above 2M atoms and a confirmation above 10M.
|
|
91
|
+
- Photon number: the pattern is scaled to a chosen number of photons before
|
|
92
|
+
Poisson sampling, so the counting statistics mean something. The field accepts
|
|
93
|
+
scientific notation (1e9, 2.5e12).
|
|
94
|
+
- Detector / sample space toggle. `ortho.det_matrix` builds the real
|
|
95
|
+
(dq/dpx, dq/dpy, dq/drocking) transform; the Results tab switches between the
|
|
96
|
+
orthogonal lab q grid and the raw skewed detector grid and reports the skew.
|
|
97
|
+
- Custom 2theta with a live readout: the offset from the nearest reflection, the
|
|
98
|
+
resulting dq, and the peak shift in both simulation voxels and real detector
|
|
99
|
+
pixels, with a warning when the peak leaves the frame.
|
|
100
|
+
- Prismatic dislocation loop alongside the existing line dislocations.
|
|
101
|
+
- Separate simulation grid control, independent of the detector panel size.
|
|
102
|
+
- Visualization controls (bonds, strain, dislocation) grouped together.
|
|
103
|
+
|
|
104
|
+
**Data processing**
|
|
105
|
+
- read reconstructions from `.npz`, `.npy`, `.h5`, `.cxi`,
|
|
106
|
+
`.nxs` and `.mat`, including PyNX `/entry_1/image_1/data` and amplitude/phase
|
|
107
|
+
pairs, so work reconstructed outside CDI-St can be loaded.
|
|
108
|
+
- per-step training log (`.log` + `.jsonl`) that flags NaN/Inf
|
|
109
|
+
losses, non-finite gradients and weights, and loss spikes, then dumps input
|
|
110
|
+
statistics and the likely cause. `scan_dataset()` pre-flights a training set.
|
|
111
|
+
|
|
112
|
+
### Changed
|
|
113
|
+
|
|
114
|
+
- Read noise is applied only to integrating detectors. Hybrid photon-counting
|
|
115
|
+
detectors (EIGER, PILATUS, MAXIPIX, MERLIN, TIMEPIX) have Poisson statistics
|
|
116
|
+
only, and the Readout option disables itself when one is selected.
|
|
117
|
+
- Noise controls are named per effect (Poisson / Readout / Air / Dead px /
|
|
118
|
+
Hot px) instead of a single "Add noise", and all are off by default, so the
|
|
119
|
+
ideal pattern is what you see until you ask for noise.
|
|
120
|
+
- Default simulation grid raised from 128 to 192, giving 2.25x the pixels in the
|
|
121
|
+
2D slices for about 2 s per simulation.
|
|
122
|
+
- The simulation panel is resizable; the fixed 520 px left column is a splitter.
|
|
123
|
+
- Frame transform uses cubic interpolation (0.7% round-trip error, against 3.6%
|
|
124
|
+
for linear).
|
|
125
|
+
|
|
126
|
+
### Fixed
|
|
127
|
+
|
|
128
|
+
- Poisson noise was on by default and applied the photon budget unconditionally,
|
|
129
|
+
which quantised 83% of the volume to zero counts and erased the weak fringes
|
|
130
|
+
in the 3D peak and the 2D slices. Noise is now opt-in.
|
|
131
|
+
- The simulation grid was capped by the detector panel size, so a 128 x 128
|
|
132
|
+
panel forced 128^3 slices regardless of the grid setting. Panel geometry
|
|
133
|
+
(exported as metadata) and simulation grid are now independent.
|
|
134
|
+
- Reflections are labelled by their canonical Friedel mate, so selecting (1 1 1)
|
|
135
|
+
no longer displays (-1 -1 -1). Both label the same physical peak; the hkl
|
|
136
|
+
search simply reached the negative representative first. The raw index is kept
|
|
137
|
+
as `hkl_raw`.
|
|
138
|
+
- `select_reflection` returns full-precision d, 2theta, q, |F|^2 and LP. It
|
|
139
|
+
previously used the four-decimal values rounded for the table.
|
|
140
|
+
- Half-voxel registration error in the detector/lab transform. An orthogonal
|
|
141
|
+
transform is now an exact no-op for any q-grid convention.
|
|
142
|
+
- Shrinkwrap could inflate the support until the algorithm fit the noise (89% of
|
|
143
|
+
the array at 1e5 counts). An absolute cap keeps reconstructions stable from
|
|
144
|
+
1e3 to 1e8 photons.
|
|
145
|
+
- Selecting a large detector preset set the transform size to the full panel:
|
|
146
|
+
Eiger2 4M attempted a 2068^3 complex FFT, about 140 GB.
|
|
147
|
+
- The facet ratio control was not read when building, and the large-supercell
|
|
148
|
+
notice was missing.
|
|
149
|
+
|
|
150
|
+
## [0.2.2] — 2026-06-18
|
|
151
|
+
|
|
152
|
+
### Fixed
|
|
153
|
+
- **ID01 SPEC+EDF conversion now tolerates missing edge frames.**
|
|
154
|
+
Acquisitions are sometimes started a frame late or stopped a frame
|
|
155
|
+
early, so a SPEC scan can list frames 262–662 (401 points) while the
|
|
156
|
+
EDF directory only has 263–661 (399 files). The converter now probes
|
|
157
|
+
the disk first, loads only the EDF files that actually exist, and
|
|
158
|
+
trims the per-frame motor arrays (`eta`, `phi`, `nu`, `delta`,
|
|
159
|
+
`mpx4inr`) to stay in lock-step with the loaded data. A clear note
|
|
160
|
+
identifies which leading / trailing / interior frames were skipped.
|
|
161
|
+
New helper `_filter_existing_edf_frames()` exposes this filtering for
|
|
162
|
+
programmatic use.
|
|
163
|
+
|
|
164
|
+
## [0.2.1] — 2026-06-15
|
|
165
|
+
|
|
166
|
+
### Added
|
|
167
|
+
- **PETRA III P10 / DESY Eiger compressed-data support.** Auto-imports
|
|
168
|
+
`hdf5plugin` at module load so bitshuffle + LZ4 compressed datasets
|
|
169
|
+
(the Eiger default at DESY P10 and many other beamlines) read
|
|
170
|
+
transparently. `hdf5plugin>=4.0` is now a runtime dependency.
|
|
171
|
+
- **HDF5 external-link resolution.** The P10 loader now enumerates and
|
|
172
|
+
resolves external links in master files instead of relying on h5py's
|
|
173
|
+
default link-following, which was unreliable on Windows. Each chunk is
|
|
174
|
+
opened directly to bypass any path-mangling. Master files with hundreds
|
|
175
|
+
of external links to chunk files (the standard Eiger layout) work out
|
|
176
|
+
of the box.
|
|
177
|
+
- **Scan range selection for P10** (new in the P10 converter dialog)
|
|
178
|
+
similar to the ID01 SPEC+EDF scan browser. Avoids loading 49 GB of
|
|
179
|
+
detector frames into RAM when you only need the rocking-curve maximum:
|
|
180
|
+
- **Probe scan** button reads chunk metadata only (no decompression),
|
|
181
|
+
instantly reporting total frame count, detector shape, and estimated
|
|
182
|
+
full-load memory footprint.
|
|
183
|
+
- **Frame range** (`from`, `to`) reads only the requested global frame
|
|
184
|
+
range across all chunks. Loaded chunk-by-chunk so memory scales with
|
|
185
|
+
the chosen range, not the total dataset size.
|
|
186
|
+
- **Detector ROI** reads a centered square ROI from each frame instead
|
|
187
|
+
of the full detector. For BCDI you typically only need ~256×256
|
|
188
|
+
around the Bragg peak — cuts memory by `(2167*2070)/(roi²)` for
|
|
189
|
+
Eiger 4M data.
|
|
190
|
+
- **Memory budget** (default 8 GB) the loader refuses reads that
|
|
191
|
+
would exceed this and tells you which `frame_range` would fit,
|
|
192
|
+
instead of crashing the Python process with an OOM error.
|
|
193
|
+
- **Programmatic API additions** to `nn_experimental_loader`:
|
|
194
|
+
`p10_scan_info()` for cheap metadata previews, plus new
|
|
195
|
+
`frame_range`, `detector_roi`, `memory_budget_gb` parameters on
|
|
196
|
+
`load_p10_from_external_links()` and `p10_h5_to_npz()`.
|
|
197
|
+
|
|
198
|
+
### Fixed
|
|
199
|
+
- Cryptic "Can't synchronously read data (can't open directory)" error
|
|
200
|
+
on P10 / Eiger files. The message was HDF5 looking for the compression
|
|
201
|
+
plugin DLL in a non-existent directory — now caught and converted to
|
|
202
|
+
a clear "install hdf5plugin" instruction.
|
|
203
|
+
- AutoPhase_NN tab missing `_on_epoch` slot (introduced in 0.2.0 during
|
|
204
|
+
the live-curve refactor; AutoPhase_NN's `epoch_done` signal had no
|
|
205
|
+
receiver and emitted unhandled errors). Restored.
|
|
206
|
+
- CDI_NN `KeyError: 'phase_true'` — `BCDIDataset.__getitem__` now exposes
|
|
207
|
+
the GUI's expected keys (`phase_true`, `amplitude`) alongside the legacy
|
|
208
|
+
ones (`target_phase`, `input`).
|
|
209
|
+
- `BCDIPhaseLoss` accepts both the GUI's descriptive kwargs (`alpha_amp`,
|
|
210
|
+
`beta_phase`, `gamma_diff`, `diff_amp`) and the original short ones
|
|
211
|
+
(`alpha`, `beta`, `gamma`, `amplitude`). Either spelling now works.
|
|
212
|
+
- Training Stop button no longer crashes the program. `QThread.terminate()`
|
|
213
|
+
was killing PyTorch mid-`backward()` and corrupting CUDA / autograd
|
|
214
|
+
state — replaced with a cooperative `request_stop()` flag that the
|
|
215
|
+
training loop checks at batch / epoch boundaries, then exits cleanly
|
|
216
|
+
with a saved checkpoint.
|
|
217
|
+
|
|
218
|
+
### Changed
|
|
219
|
+
- Live training curve in AutoPhase_NN and CDI_NN the dashed "running"
|
|
220
|
+
line updates every ~2 s during training so users can see progress
|
|
221
|
+
immediately on slow CPU runs (rather than staring at a blank plot
|
|
222
|
+
for an entire epoch).
|
|
223
|
+
- `inspect_h5()` now properly shows external links with their target
|
|
224
|
+
files and `[OK]` / `[MISSING]` markers. The empty-looking `/entry/data/`
|
|
225
|
+
group on Eiger masters is no longer misleading.
|
|
226
|
+
|
|
227
|
+
## [0.1.0] — Alpha — 2026-05-08
|
|
228
|
+
|
|
229
|
+
### Added
|
|
230
|
+
- **Initial public release** of CDI-ST as a packaged Python application.
|
|
231
|
+
- BCDI Simulation module (Material → Beam → Results)
|
|
232
|
+
- Material presets: Si, Ge, Pt, Au, SiC, GaAs, and more
|
|
233
|
+
- CIF import for arbitrary crystals
|
|
234
|
+
- Particle shapes: cube, sphere, cylinder, hexagonal prism, octahedron, dodecahedron
|
|
235
|
+
- Strain fields: radial gradient, edge dislocation, random
|
|
236
|
+
- Configurable line dislocations: edge / screw / mixed with arbitrary Burgers vector
|
|
237
|
+
- 3D atomic lattice viewer (Plotly)
|
|
238
|
+
- Detector presets: Maxipix 2×2, Eiger 2M, custom rectangular
|
|
239
|
+
- Analytical and FFT simulation paths
|
|
240
|
+
- BCDI Data Analysis module (Generate Data → AutoPhase_NN → CDI_NN → Reconstruction → 3D Viewer)
|
|
241
|
+
- Training-data generator with random material/shape/size/strain/dislocation
|
|
242
|
+
- Toggles for randomized strain and dislocations
|
|
243
|
+
- AutoPhaseNet3D (unsupervised, dual-decoder, physics-driven loss)
|
|
244
|
+
- PhaseUNet3D (supervised, BCDI loss with α/β/γ weights)
|
|
245
|
+
- Inference: NN-only, refined (HIO+RAAR+ER), ensemble, compare
|
|
246
|
+
- Iterative phase retrieval: HIO (β=0.9), RAAR (β=0.9), ER, with shrink-wrap
|
|
247
|
+
- Experimental data loader: HDF5, ID01 SPEC+EDF, q-space orthogonalization
|
|
248
|
+
- Detector chip-gap masking, hot pixel removal, beamstop streak removal
|
|
249
|
+
- 3D viewer with point cloud / isosurface / surface-only modes
|
|
250
|
+
- Per-voxel opacity weighted by intensity
|
|
251
|
+
- VTI export for ParaView
|
|
252
|
+
- Splash screen and theme-matched launcher
|
|
253
|
+
- In-app Reports & Suggestions feature
|
|
254
|
+
- Cross-platform support (Linux, macOS, Windows) via PyQt6
|
|
255
|
+
- MIT license, full source on GitHub
|
|
256
|
+
|
|
257
|
+
### Known limitations (alpha)
|
|
258
|
+
- Q-space orthogonalization is ID01-specific (can be extended)
|
|
259
|
+
- Some checkpoints from earlier prototypes lack `grid_size` metadata
|
|
260
|
+
- Mask-aware modulus constraint not yet implemented (gaps are filled instead)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cdi-stools
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Coherent Diffraction Imaging Simulation Tools — BCDI simulation and NN-based phase retrieval
|
|
5
5
|
Project-URL: Homepage, https://github.com/SAIDIsoufiane/CDI-St
|
|
6
6
|
Project-URL: Documentation, https://github.com/SAIDIsoufiane/CDI-St#readme
|
|
@@ -55,7 +55,7 @@ Description-Content-Type: text/markdown
|
|
|
55
55
|
|
|
56
56
|
# CDI-ST
|
|
57
57
|
|
|
58
|
-
**Coherent Diffraction Imaging
|
|
58
|
+
**Coherent Diffraction Imaging - Simulation Tools**
|
|
59
59
|
|
|
60
60
|
An end-to-end Bragg Coherent Diffraction Imaging (BCDI) Python application using low computational resources with an easy to learn GUI:
|
|
61
61
|
crystal lattice construction, X-ray scattering simulation, neural-network phase retrieval,
|
|
@@ -78,8 +78,8 @@ and 3D visualization, in a single GUI.
|
|
|
78
78
|
</tr>
|
|
79
79
|
<tr>
|
|
80
80
|
<td align="center"><sub>Launcher</sub></td>
|
|
81
|
-
<td align="center"><sub>Material
|
|
82
|
-
<td align="center"><sub>Results
|
|
81
|
+
<td align="center"><sub>Material - crystal builder</sub></td>
|
|
82
|
+
<td align="center"><sub>Results - simulated Bragg peak</sub></td>
|
|
83
83
|
</tr>
|
|
84
84
|
<tr>
|
|
85
85
|
<td><img src="docs/screenshots/3d_viewer.png" width="280"/></td>
|
|
@@ -87,9 +87,9 @@ and 3D visualization, in a single GUI.
|
|
|
87
87
|
<td><img src="docs/screenshots/reconstruction.png" width="280"/></td>
|
|
88
88
|
</tr>
|
|
89
89
|
<tr>
|
|
90
|
-
<td align="center"><sub>3D Viewer
|
|
90
|
+
<td align="center"><sub>3D Viewer - diffraction simulation</sub></td>
|
|
91
91
|
<td align="center"><sub>2D reconstruction</sub></td>
|
|
92
|
-
<td align="center"><sub>3D Viewer
|
|
92
|
+
<td align="center"><sub>3D Viewer - reconstruction</sub></td>
|
|
93
93
|
</tr>
|
|
94
94
|
</table>
|
|
95
95
|
|
|
@@ -134,18 +134,18 @@ more recently by neural networks.
|
|
|
134
134
|
| 3. Simulate diffraction | Compute the 3D Bragg peak | **BCDI Simulation → Results** |
|
|
135
135
|
| 4. Generate training data | Build a labeled dataset of (object, diffraction) pairs | **BCDI Data Analysis → Generate Data** |
|
|
136
136
|
| 5. Train an unsupervised NN | AutoPhase_NN: physics-driven, no ground truth | **BCDI Data Analysis → AutoPhase_NN** |
|
|
137
|
-
| 6. Train a supervised NN | CDI_NN:
|
|
138
|
-
| 7. Reconstruct |
|
|
137
|
+
| 6. Train a supervised NN | CDI_NN: learning the phase mapping | **BCDI Data Analysis → CDI_NN** |
|
|
138
|
+
| 7. Reconstruct | HIO/RAAR/ER on their own, or a network seed refined by them | **BCDI Data Analysis → Reconstruction** |
|
|
139
139
|
| 8. Visualize and export | Interactive 3D viewer, ParaView VTI export | **BCDI Data Analysis → 3D Viewer** |
|
|
140
140
|
|
|
141
141
|
---
|
|
142
142
|
|
|
143
143
|
## The simulation pipeline
|
|
144
144
|
|
|
145
|
-
### 1. Material
|
|
145
|
+
### 1. Material : build the crystal
|
|
146
146
|
|
|
147
|
-
Choose from preset materials (
|
|
148
|
-
CIF file. The crystal is built atom-by-atom from the unit cell, replicated to the
|
|
147
|
+
Choose from the preset materials (Al, Cu, Au, Pt, W, Fe, Si, Ge, SiC (3C and 4H),
|
|
148
|
+
ZnO, GaN, Te, Fe3GeTe2, Fe5GeTe2) or import any CIF file. The crystal is built atom-by-atom from the unit cell, replicated to the
|
|
149
149
|
requested supercell size.
|
|
150
150
|
|
|
151
151
|
You can:
|
|
@@ -158,9 +158,13 @@ You can:
|
|
|
158
158
|
|
|
159
159
|
The 3D lattice view (powered by Plotly) shows every atom in the supercell.
|
|
160
160
|
|
|
161
|
-
### 2. Beam
|
|
161
|
+
### 2. Beam : define the X-ray geometry
|
|
162
162
|
|
|
163
|
-
Select a reflection (h k l) from the auto-computed list of allowed peaks.
|
|
163
|
+
Select a reflection (h k l) from the auto-computed list of allowed peaks. The
|
|
164
|
+
search bounds each index separately from the geometry, so materials with a long
|
|
165
|
+
c axis keep their high-l reflections — `(0 0 6)` for Fe3GeTe2, `(0 0 8)` for
|
|
166
|
+
4H-SiC, `(0 0 6)` and `(0 -1 10)` for corundum. Typing any member of a family
|
|
167
|
+
finds that family, whichever member the table happens to list.
|
|
164
168
|
The Beam tab also lets you set:
|
|
165
169
|
- **Beam energy** (and the resulting wavelength)
|
|
166
170
|
- **Detector geometry**: pixel pitch, sample-to-detector distance, detector size
|
|
@@ -169,7 +173,7 @@ The Beam tab also lets you set:
|
|
|
169
173
|
|
|
170
174
|
Detector preset auto-fills the geometry parameters.
|
|
171
175
|
|
|
172
|
-
### 3. Results
|
|
176
|
+
### 3. Results : run the simulation
|
|
173
177
|
|
|
174
178
|
CDI-ST computes the diffraction in **two paths**:
|
|
175
179
|
|
|
@@ -186,7 +190,7 @@ or for use as ground truth when training NNs.
|
|
|
186
190
|
|
|
187
191
|
## The data-analysis pipeline
|
|
188
192
|
|
|
189
|
-
### 4. Generate Data
|
|
193
|
+
### 4. Generate Data : create training samples
|
|
190
194
|
|
|
191
195
|
Generates a dataset of synthetic BCDI samples for NN training. Each sample
|
|
192
196
|
contains the ground-truth phase, support, and the simulated diffraction
|
|
@@ -202,7 +206,7 @@ intensity. You control:
|
|
|
202
206
|
Samples save as `sample_XXXXX.npz` and a `manifest.json`. Generation is
|
|
203
207
|
parallelizable and resumable.
|
|
204
208
|
|
|
205
|
-
### 5. AutoPhase_NN
|
|
209
|
+
### 5. AutoPhase_NN : unsupervised physics-driven NN
|
|
206
210
|
|
|
207
211
|
AutoPhase_NN is a 3D dual-decoder convolutional network that learns to invert the
|
|
208
212
|
Fourier modulus constraint **without ground truth**. It predicts the object's
|
|
@@ -214,7 +218,7 @@ et al. npj Computational Materials 8.1 (2022) ) reimplemented for this codebase.
|
|
|
214
218
|
Training is GPU-accelerated (CUDA preferred) and converges in a few dozen
|
|
215
219
|
epochs on 2,000+ samples. The best checkpoint is saved automatically.
|
|
216
220
|
|
|
217
|
-
### 6. CDI_NN
|
|
221
|
+
### 6. CDI_NN : supervised PhaseUNet3D
|
|
218
222
|
|
|
219
223
|
A 3D U-Net that predicts the phase field from the diffraction magnitude, trained
|
|
220
224
|
against the ground-truth phase from the data generator.
|
|
@@ -223,15 +227,24 @@ Use AutoPhase_NN when you don't trust your simulator's ground truth (or have
|
|
|
223
227
|
none). Use CDI_NN when you have a high-fidelity simulator and want a direct
|
|
224
228
|
mapping. Use both via the **ensemble** mode in the Reconstruction tab.
|
|
225
229
|
|
|
226
|
-
### 7. Reconstruction
|
|
230
|
+
### 7. Reconstruction : invert experimental or simulated data
|
|
227
231
|
|
|
228
232
|
Load any `.npz` (simulated) or `.h5` (experimental) BCDI file, or convert a
|
|
229
233
|
SPEC + EDF scan from ID01 directly via the dialog. Choose:
|
|
230
234
|
|
|
231
|
-
- **
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
- **HIO/RAAR/ER only — no neural network**: the standard iterative algorithms
|
|
236
|
+
from a random start. No checkpoint, no PyTorch, nothing trained - this is the
|
|
237
|
+
option to use if you cannot run a network, and it is what most published BCDI
|
|
238
|
+
work uses.
|
|
239
|
+
- **AutoPhaseNet alone**: one forward pass (~100 ms), with twin-image
|
|
240
|
+
suppression and COM centering. A quick look.
|
|
241
|
+
- **AutoPhaseNet → HIO/RAAR/ER refinement**: network seed, then the classical
|
|
242
|
+
algorithms polish it. The usual choice.
|
|
243
|
+
- **Both networks averaged (AutoPhaseNet + PhaseUNet3D)**, optionally refined:
|
|
244
|
+
averaging two independent guesses cancels some of the error each makes alone.
|
|
245
|
+
Needs the second checkpoint.
|
|
246
|
+
|
|
247
|
+
If refinement comes out worse than the network alone, the network output is kept.
|
|
235
248
|
|
|
236
249
|
The output is a complex object (amplitude + phase), a binary support, the
|
|
237
250
|
R-factor convergence curve, and 2D slices at the COM of the reconstruction.
|
|
@@ -243,7 +256,7 @@ For experimental data, the loader handles:
|
|
|
243
256
|
- Bragg-peak-centered cropping
|
|
244
257
|
- Optional q-space orthogonalization via xrayutilities (with `[id01]` extra)
|
|
245
258
|
|
|
246
|
-
### 8. 3D Viewer
|
|
259
|
+
### 8. 3D Viewer : interactive visualization
|
|
247
260
|
|
|
248
261
|
The viewer renders the reconstruction in three modes:
|
|
249
262
|
|
|
@@ -252,47 +265,24 @@ The viewer renders the reconstruction in three modes:
|
|
|
252
265
|
- **Isosurface**: smoothed iso-shell with internal data points showing through
|
|
253
266
|
- **Surface only**: bare iso-mesh with edges visible
|
|
254
267
|
|
|
268
|
+
**Render quality** is chosen before rendering - Draft (15,000 points), Standard
|
|
269
|
+
(60,000, the default), High (200,000) or Maximum (1,000,000). Higher settings also
|
|
270
|
+
smooth the isosurface less, so density and strain stay distinguishable. On a 128³
|
|
271
|
+
reconstruction with 268,000 support voxels these take roughly 0.4 s, 0.5 s, 1.4 s
|
|
272
|
+
and 1.4 s.
|
|
273
|
+
|
|
255
274
|
Controls:
|
|
256
|
-
- Threshold (% of peak amplitude), voxel size, opacity, colormap
|
|
275
|
+
- Threshold (% of peak amplitude), voxel size, opacity, colormap (Turbo by default)
|
|
257
276
|
- Color scale auto / manual (`vmin` / `vmax`)
|
|
258
277
|
- Clip plane on any axis
|
|
278
|
+
- **Auto-update view**: re-renders as soon as a setting changes, instead of
|
|
279
|
+
pressing "Update view". Changes are coalesced briefly so dragging a slider does
|
|
280
|
+
not start a render on every step.
|
|
259
281
|
- Mouse: left-drag rotate, right-drag pan, wheel zoom, double-click reset
|
|
260
282
|
- Export PNG snapshot or VTI (ParaView)
|
|
261
283
|
|
|
262
284
|
---
|
|
263
285
|
|
|
264
|
-
## Project structure
|
|
265
|
-
|
|
266
|
-
```
|
|
267
|
-
cdi-st/
|
|
268
|
-
├── src/cdi_st/
|
|
269
|
-
│ ├── __init__.py
|
|
270
|
-
│ ├── __main__.py # python -m cdi_st
|
|
271
|
-
│ ├── bcdi_gui.py # main entry point + launcher + splash
|
|
272
|
-
│ ├── bcdi_core.py # crystal builder, simulator, reflection calculator
|
|
273
|
-
│ ├── nn_gui_tabs.py # all NN-related GUI tabs
|
|
274
|
-
│ ├── nn_data_generator.py # training-data generator
|
|
275
|
-
│ ├── nn_dataset.py # PyTorch Dataset wrapper
|
|
276
|
-
│ ├── nn_phase_model.py # PhaseUNet3D (supervised)
|
|
277
|
-
│ ├── nn_autophase_model.py # AutoPhaseNet3D (unsupervised)
|
|
278
|
-
│ ├── nn_train.py # supervised training CLI
|
|
279
|
-
│ ├── nn_autophase_train.py # unsupervised training CLI
|
|
280
|
-
│ ├── nn_phase_retrieval.py # HIO / RAAR / ER iterative algorithms
|
|
281
|
-
│ ├── nn_autophase_infer.py # inference: nn_only / refined / ensemble
|
|
282
|
-
│ ├── nn_experimental_loader.py # h5/spec/edf loading + preprocessing
|
|
283
|
-
│ ├── nn_demo.py
|
|
284
|
-
│ ├── nn_visualize.py
|
|
285
|
-
│ └── CDI_ST_logo.png
|
|
286
|
-
├── tests/
|
|
287
|
-
├── docs/
|
|
288
|
-
├── pyproject.toml
|
|
289
|
-
├── README.md
|
|
290
|
-
├── LICENSE
|
|
291
|
-
└── CHANGELOG.md
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
286
|
## Citing
|
|
297
287
|
|
|
298
288
|
If you use CDI-ST in published research, please cite:
|
|
@@ -315,7 +305,7 @@ MIT — see [LICENSE](LICENSE).
|
|
|
315
305
|
|
|
316
306
|
## Author
|
|
317
307
|
|
|
318
|
-
**Soufiane SAIDI**
|
|
308
|
+
**Soufiane SAIDI** - saidisoufiane@hotmail.com
|
|
319
309
|
|
|
320
310
|
We heavily encourage you to use the in-app **Reports & Suggestions** button to send any type of feedback.
|
|
321
311
|
|
|
@@ -327,4 +317,4 @@ Built on the shoulders of the BCDI and python community:
|
|
|
327
317
|
[PyNX](https://pynx.esrf.fr/), [BCDI-Utilities](https://github.com/carnisj/bcdi),
|
|
328
318
|
[cdiutils](https://github.com/clatlan/cdiutils), [Atomsk](https://atomsk.univ-lille.fr/) , [xrayutilities](https://xrayutilities.sourceforge.io/),
|
|
329
319
|
[scikit-image](https://scikit-image.org/), [PyQt6](https://www.riverbankcomputing.com/software/pyqt/),
|
|
330
|
-
and the AutoPhaseNN paper by Yao et al.
|
|
320
|
+
and the AutoPhaseNN paper by Yao et al.(2022) (https://doi.org/10.1038/s41524-022-00803-w).
|