Skip to content

Commit

Permalink
GUI: Remove deleted reconstruction algorithms from GUI (#64)
Browse files Browse the repository at this point in the history
* API: Remove deleted reconstruction algorithms from GUI

Tike has removed conjugate gradient and adam from
its reconstruction options in v0.25.

* BUG: Remove adaptive moment and adam classses
  • Loading branch information
carterbox authored Dec 6, 2023
1 parent fa07fee commit 25704fd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 65 deletions.
8 changes: 0 additions & 8 deletions ptychodus/controller/tike/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ def createViewController(self, reconstructorName: str) -> QWidget:
view = TikeParametersView.createInstance(showCgIter=False,
showAlpha=True,
showStepLength=False)
elif reconstructorName == 'adam_grad':
view = TikeParametersView.createInstance(showCgIter=False,
showAlpha=True,
showStepLength=True)
elif reconstructorName == 'cgrad':
view = TikeParametersView.createInstance(showCgIter=True,
showAlpha=False,
showStepLength=True)
elif reconstructorName == 'lstsq_grad':
view = TikeParametersView.createInstance(showCgIter=False,
showAlpha=False,
Expand Down
7 changes: 0 additions & 7 deletions ptychodus/model/tike/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def createInstance(cls, settingsRegistry: SettingsRegistry,
core = cls(settingsRegistry)

try:
from .reconstructor import AdaptiveMomentGradientDescentReconstructor
from .reconstructor import ConjugateGradientReconstructor
from .reconstructor import DifferenceMapReconstructor
from .reconstructor import IterativeLeastSquaresReconstructor
from .reconstructor import RegularizedPIEReconstructor
Expand All @@ -183,8 +181,6 @@ def createInstance(cls, settingsRegistry: SettingsRegistry,

if isDeveloperModeEnabled:
core.reconstructorList.append(NullReconstructor('rpie'))
core.reconstructorList.append(NullReconstructor('adam_grad'))
core.reconstructorList.append(NullReconstructor('cgrad'))
core.reconstructorList.append(NullReconstructor('lstsq_grad'))
core.reconstructorList.append(NullReconstructor('dm'))
else:
Expand All @@ -193,9 +189,6 @@ def createInstance(cls, settingsRegistry: SettingsRegistry,
core._probeCorrectionSettings,
core._objectCorrectionSettings)
core.reconstructorList.append(RegularizedPIEReconstructor(tikeReconstructor))
core.reconstructorList.append(
AdaptiveMomentGradientDescentReconstructor(tikeReconstructor))
core.reconstructorList.append(ConjugateGradientReconstructor(tikeReconstructor))
core.reconstructorList.append(IterativeLeastSquaresReconstructor(tikeReconstructor))
core.reconstructorList.append(DifferenceMapReconstructor(tikeReconstructor))

Expand Down
50 changes: 0 additions & 50 deletions ptychodus/model/tike/reconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,56 +252,6 @@ def reconstruct(self, parameters: ReconstructInput) -> ReconstructOutput:
return self._tikeReconstructor(parameters, self._algorithmOptions)


class AdaptiveMomentGradientDescentReconstructor(Reconstructor):

def __init__(self, tikeReconstructor: TikeReconstructor) -> None:
super().__init__()
self._algorithmOptions = tike.ptycho.solvers.AdamOptions()
self._tikeReconstructor = tikeReconstructor

@property
def name(self) -> str:
return self._algorithmOptions.name

@property
def _settings(self) -> TikeSettings:
return self._tikeReconstructor._settings

def reconstruct(self, parameters: ReconstructInput) -> ReconstructOutput:
self._algorithmOptions.num_batch = self._settings.numBatch.value
self._algorithmOptions.batch_method = self._settings.batchMethod.value
self._algorithmOptions.num_iter = self._settings.numIter.value
self._algorithmOptions.convergence_window = self._settings.convergenceWindow.value
self._algorithmOptions.alpha = float(self._settings.alpha.value)
self._algorithmOptions.step_length = float(self._settings.stepLength.value)
return self._tikeReconstructor(parameters, self._algorithmOptions)


class ConjugateGradientReconstructor(Reconstructor):

def __init__(self, tikeReconstructor: TikeReconstructor) -> None:
super().__init__()
self._algorithmOptions = tike.ptycho.solvers.CgradOptions()
self._tikeReconstructor = tikeReconstructor

@property
def name(self) -> str:
return self._algorithmOptions.name

@property
def _settings(self) -> TikeSettings:
return self._tikeReconstructor._settings

def reconstruct(self, parameters: ReconstructInput) -> ReconstructOutput:
self._algorithmOptions.num_batch = self._settings.numBatch.value
self._algorithmOptions.batch_method = self._settings.batchMethod.value
self._algorithmOptions.num_iter = self._settings.numIter.value
self._algorithmOptions.convergence_window = self._settings.convergenceWindow.value
self._algorithmOptions.cg_iter = self._settings.cgIter.value
self._algorithmOptions.step_length = float(self._settings.stepLength.value)
return self._tikeReconstructor(parameters, self._algorithmOptions)


class IterativeLeastSquaresReconstructor(Reconstructor):

def __init__(self, tikeReconstructor: TikeReconstructor) -> None:
Expand Down

0 comments on commit 25704fd

Please sign in to comment.