Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix silent calibration failures #214

Merged
merged 26 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
256ff44
plot the calibrated LC states in a pop-up window
ziw-liu Sep 28, 2022
4f1e760
fix attribute name
ziw-liu Sep 28, 2022
83636d3
fix typo
ziw-liu Sep 28, 2022
6399766
fix aspect ratio
ziw-liu Sep 28, 2022
608f8b9
fix dict key
ziw-liu Sep 28, 2022
8da9796
fix string formatting
ziw-liu Sep 28, 2022
1d0fd89
fix marker color
ziw-liu Sep 28, 2022
8053a3c
fix marker size/color confusion
ziw-liu Sep 28, 2022
98d4a5d
fix typo
ziw-liu Sep 28, 2022
b430f9a
fix annotation position
ziw-liu Sep 28, 2022
f9b8082
fix typo
ziw-liu Sep 28, 2022
9a709bc
move plotting to main thread
ziw-liu Sep 28, 2022
2c75a9c
fix slot type
ziw-liu Sep 28, 2022
ebb2086
fix event loop context
ziw-liu Sep 28, 2022
a1741ee
Plot circle
talonchandler Sep 29, 2022
3597319
Annotation offset in better coordinates
talonchandler Sep 29, 2022
80ab4a4
Close open plots before starting
talonchandler Sep 29, 2022
c1170cc
First draft constrained calibration
talonchandler Sep 30, 2022
c152536
Merge branch 'plot-calibration-states' into small-swing-fix
talonchandler Sep 30, 2022
2d899b0
Create calibration script
talonchandler Sep 30, 2022
cdd067e
Second draft calibration
talonchandler Sep 30, 2022
378b3d6
Calibrate script v3 w/ Ziwen
talonchandler Sep 30, 2022
e493ad1
Specify 4/5 state in script
talonchandler Sep 30, 2022
8ee03b4
Merge branch 'main' into small-swing-fix
talonchandler Sep 30, 2022
4f14502
Clean up calibration script
talonchandler Oct 2, 2022
467c5f3
`calibrate.py` -> `repeat_calibration.py`
talonchandler Oct 3, 2022
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
14 changes: 9 additions & 5 deletions recOrder/plugin/workers/calibration_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def _calibrate_4state(self):
Run through the 4-state calibration algorithm
"""

search_radius = np.min((self.calib.swing/self.calib.ratio, 0.05))

self.calib.calib_scheme = '4-State'

self._check_abort()
Expand All @@ -240,19 +242,21 @@ def _calibrate_4state(self):
self._check_abort()

# Optimize 60 deg state
self.calib.opt_I60(0.05, 0.05)
self.calib.opt_I60(search_radius, search_radius)
self.progress_update.emit((75, 'Calibrating State 3...'))

self._check_abort()

# Optimize 120 deg state
self.calib.opt_I120(0.05, 0.05)
self.calib.opt_I120(search_radius, search_radius)
self.progress_update.emit((85, 'Writing Metadata...'))

self._check_abort()

def _calibrate_5state(self):

search_radius = np.min((self.calib.swing, 0.05))

self.calib.calib_scheme = '5-State'

# Optimize Extinction State
Expand All @@ -268,19 +272,19 @@ def _calibrate_5state(self):
self._check_abort()

# Optimize 45 deg state
self.calib.opt_I45(0.05, 0.05)
self.calib.opt_I45(search_radius, search_radius)
self.progress_update.emit((65, 'Calibrating State 3...'))

self._check_abort()

# Optimize 90 deg state
self.calib.opt_I90(0.05, 0.05)
self.calib.opt_I90(search_radius, search_radius)
self.progress_update.emit((75, 'Calibrating State 4...'))

self._check_abort()

# Optimize 135 deg state
self.calib.opt_I135(0.05, 0.05)
self.calib.opt_I135(search_radius, search_radius)
self.progress_update.emit((85, 'Writing Metadata...'))

self._check_abort()
Expand Down
28 changes: 28 additions & 0 deletions recOrder/scripts/repeat_calibration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This script can be modified to debug and test calibrations

import napari
import time
import matplotlib.pyplot as plt
from recOrder.plugin.widget.main_widget import MainWidget

save_dir = "./"
swings = [0.1, 0.03, 0.01, 0.005]
repeats = 5

def main():
viewer = napari.Viewer()
recorder = MainWidget(viewer)
viewer.window.add_dock_widget(recorder)
recorder.ui.qbutton_gui_mode.click()
recorder.calib_scheme = '5-State'

for repeat in range(repeats):
for swing in swings:
print("Calibrating with swing = " + str(swing))
recorder.swing = swing
recorder.directory = save_dir
recorder.run_calibration()
time.sleep(100)

if __name__ == "__main__":
main()