Skip to content

Commit

Permalink
Merge pull request #77 from AdvancedPhotonSource/limit-position-updates
Browse files Browse the repository at this point in the history
NEW: Add update magnitude limit parameter to Position Options
  • Loading branch information
carterbox authored Mar 8, 2024
2 parents cc49202 + 6eb7b1d commit 391abdf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ptychodus/controller/tike/positionCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def createInstance(cls, presenter: TikePositionCorrectionPresenter,

view.positionRegularizationCheckBox.toggled.connect(
presenter.setPositionRegularizationEnabled)
view.updateMagnitudeLimitLineEdit.valueChanged.connect(presenter.setUpdateMagnitudeLimit)

controller._syncModelToView()

Expand All @@ -37,6 +38,7 @@ def _syncModelToView(self) -> None:

self._view.positionRegularizationCheckBox.setChecked(
self._presenter.isPositionRegularizationEnabled())
self._view.updateMagnitudeLimitLineEdit.setValue(self._presenter.getUpdateMagnitudeLimit())

def update(self, observable: Observable) -> None:
if observable is self._presenter:
Expand Down
8 changes: 8 additions & 0 deletions ptychodus/model/tike/positionCorrection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
from decimal import Decimal

from ...api.settings import SettingsGroup, SettingsRegistry
from .adaptiveMoment import TikeAdaptiveMomentPresenter, TikeAdaptiveMomentSettings
Expand All @@ -12,6 +13,7 @@ def __init__(self, settingsGroup: SettingsGroup) -> None:
'UsePositionCorrection', False)
self.usePositionRegularization = settingsGroup.createBooleanEntry(
'UsePositionRegularization', False)
self.updateMagnitudeLimit = settingsGroup.createRealEntry('Update Magnitude Limit', '0.0')
# TODO transform: Global transform of positions.
# TODO origin: The rotation center of the transformation.

Expand Down Expand Up @@ -42,3 +44,9 @@ def isPositionRegularizationEnabled(self) -> bool:

def setPositionRegularizationEnabled(self, enabled: bool) -> None:
self._settings.usePositionRegularization.value = enabled

def getUpdateMagnitudeLimit(self) -> Decimal:
return self._settings.updateMagnitudeLimit.value

def setUpdateMagnitudeLimit(self, value: Decimal) -> None:
self._settings.updateMagnitudeLimit.value = value
1 change: 1 addition & 0 deletions ptychodus/model/tike/reconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def getPositionOptions(self,
vdecay=float(settings.vdecay.value),
mdecay=float(settings.mdecay.value),
use_position_regularization=settings.usePositionRegularization.value,
update_magnitude_limit=float(settings.updateMagnitudeLimit.value),
)

return options
Expand Down
5 changes: 5 additions & 0 deletions ptychodus/view/tike.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,22 @@ def __init__(self, parent: Optional[QWidget]) -> None:
super().__init__('Position Correction', parent)
self.positionRegularizationCheckBox = QCheckBox('Use Regularization')
self.adaptiveMomentView = TikeAdaptiveMomentView.createInstance()
self.updateMagnitudeLimitLineEdit = DecimalLineEdit.createInstance()

@classmethod
def createInstance(cls, parent: Optional[QWidget] = None) -> TikePositionCorrectionView:
view = cls(parent)

view.positionRegularizationCheckBox.setToolTip(
'Whether the positions are constrained to fit a random error plus affine error model.')
view.updateMagnitudeLimitLineEdit.setToolTip(
'When set to a positive number, x and y update magnitudes are clipped (limited) '
'to this value.')

layout = QFormLayout()
layout.addRow(view.positionRegularizationCheckBox)
layout.addRow(view.adaptiveMomentView)
layout.addRow('Update Magnitude Limit:', view.updateMagnitudeLimitLineEdit)
view.setLayout(layout)

return view
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ install_requires =

[options.extras_require]
ptychonn = ptychonn ==0.2.*
tike = tike ==0.25.*
tike = tike ==0.25.*,>=0.25.3
gui = pyqt5 ==5.*
globus =
gladier >=0.9
Expand Down

0 comments on commit 391abdf

Please sign in to comment.