Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4cce5ae
Merge pull request #477 from ptycho/hotfixes
daurer Feb 10, 2023
6949de8
initial implementation of multislice ePIE
daurer Aug 23, 2023
97a51e4
code runs but probably still bug for slices > 1
daurer Aug 23, 2023
b35c3de
save slices infomation and fix the update loop
yiranlus Oct 24, 2023
67eb25a
object as product of all slices at each iteration
yiranlus Oct 26, 2023
6a7e8f9
iterating over pods to allow for modes
kahntm Oct 31, 2023
8da41aa
swapped loops
kahntm Nov 1, 2023
c9e71b1
added the 3PIE article to the engine
kahntm Nov 1, 2023
d4b178b
renamed the engine to match the algorithm name in the literature
kahntm Nov 1, 2023
aa97276
renamed the file to match the engine and algorithm name
kahntm Nov 1, 2023
a4b83ec
python convention for class names
kahntm Nov 2, 2023
55a7b26
file name as class name
kahntm Nov 2, 2023
7a65a77
added semi-functioning switching on of slices at arbitrary iterations
kahntm Nov 5, 2023
90058d1
allow non equal slice spacing
yiranlus Nov 6, 2023
391cc4f
add object regularisation
yiranlus Jan 26, 2024
e412764
Merge pull request #473 from ptycho/dev
bjoernenders Feb 5, 2024
381065c
Merge branch 'multi-slice-epie' of https://github.com/ptycho/ptypy in…
kahntm Mar 11, 2024
c601059
Merge pull request #542 from ptycho/dev
daurer Mar 11, 2024
36b9370
Wrap nccl.get_unique_id in try/except (#549)
daurer Mar 21, 2024
e76ea2d
Merge pull request #561 from ptycho/dev
daurer Aug 29, 2024
4dea7a9
Merge pull request #576 from ptycho/dev
daurer Sep 5, 2024
1681bec
Merge pull request #610 from ptycho/dev
daurer May 9, 2025
cdf33cc
Add option to provide defocus for nearfield data (#620)
daurer Jul 18, 2025
f3e160a
Merge remote-tracking branch 'origin/master' into multi-slice-epie
ltang320 Sep 10, 2025
a1180a1
add GPU version 3pie file
ltang320 Sep 15, 2025
e22d520
add threepin gpu version test
ltang320 Sep 15, 2025
5550e01
Remove test three_pie_cupy and start a new branch
ltang320 Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion ptypy/custom/threepie.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class ThreePIE(stochastic.EPIE):
help = File path for the slice data
doc =

[object_regularization_rate]
default = 0.0
type = float
help = regularization rate for object slices
doc =

"""
def __init__(self, ptycho_parent, pars=None):
super(ThreePIE, self).__init__(ptycho_parent, pars)
Expand Down Expand Up @@ -227,4 +233,30 @@ def multislice_update(self, view):
for i in range(1, self.p.number_of_slices):
self.ob *= self._object[i]

return error
if self.p.object_regularization_rate > 0:
self.apply_object_regularization()
Comment on lines +236 to +237

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably make sense to move this a bit higher up to make sure that self.ob is calculated for plotting after the regulariser has been applied...


return error

def apply_object_regularization(self):
# single mode implementation
# only valide for slices with identical thickness
assert(self.p.number_of_slices > 1)
assert(isinstance(self.p.slice_thickness, float))

shape = self._object[0].S["Sscan_00G00"].data.shape[1:]
psize = self._object[0].S["Sscan_00G00"].psize[0]
kz = np.fft.fftfreq(self.p.number_of_slices, self.p.slice_thickness)[..., np.newaxis, np.newaxis]
ky = np.fft.fftfreq(shape[0], psize)[..., np.newaxis]
kx = np.fft.fftfreq(shape[1], psize)

# calculate the weight array
w = 1 - 2*np.arctan2(self.p.object_regularization_rate**2 * kz**2, kx**2+ky**2+np.spacing(1))/np.pi
Comment on lines +247 to +254

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is basically just calculating some weights w and does not depend on any current update so can be moved into a separate function, e.g. initialize_regularizer and called once in the constructor. In this current implementation the weights are re-calculated for every iteration which seems unnecessary.


current_object = np.fft.ifftn(np.fft.fftn([self._object[i].S["Sscan_00G00"].data[0,...] for i in range(len(self._object))]) * w)

print("object shape", self._object[0].S["Sscan_00G00"].data.shape)
print("w shape", w.shape)
print("current shape", current_object.shape)
for i in range(len(self._object)):
self._object[i].S["Sscan_00G00"].data[0, ...] = current_object[i, ...]