Browse Source

Code clean, fixed black images with preheat

master
Carlos Reding 1 year ago
parent
commit
fa211c6efc
1 changed files with 8 additions and 11 deletions
  1. 8
    11
      puppeteer/_core.py

+ 8
- 11
puppeteer/_core.py View File

@@ -34,7 +34,7 @@ if os.path.exists(Path + hw_fName):
__FILTER_PWM__ = hwSettings["filterSet"] # Filter locations
# Default camera settings
__SHUTTER_SPEED__ = hwSettings["SHUTTER_SPEED"] # Shutter speed time in SECONDS. Defaults to 0.25s
__SHUTTER_SPEED__ = hwSettings["SHUTTER_SPEED"] # Shutter speed time in SECONDS.
DEFAULT_ISO = hwSettings["DEFAULT_ISO"]
ISO_F1 = hwSettings["ISO_F1"]
ISO_F2 = hwSettings["ISO_F2"]
@@ -64,7 +64,7 @@ else:
__FILTER_PWM__["No_Filter"] = 1460 # No filter (RGB image).
# Default camera settings
__SHUTTER_SPEED__ = 0.1 # Shutter speed time in SECONDS. Defaults to 0.1s
__SHUTTER_SPEED__ = 0.1 # Shutter speed time in SECONDS.
DEFAULT_ISO = 10
ISO_F1 = 100
ISO_F2 = 100
@@ -121,7 +121,7 @@ def _img_settings(Camera, Filter=None):
if Filter == "Filter_1":
Camera.iso = ISO_F1
elif Filter == "Filter_2":
# SHUTTER_SPEED = 5 # Uncomment after Rob/Kai tests
# SHUTTER_SPEED = 5 # Uncomment after Rob/Kai tests
Camera.iso = ISO_F2
elif Filter == "Filter_3":
Camera.iso = ISO_F3
@@ -133,7 +133,7 @@ def _img_settings(Camera, Filter=None):
# Camera.resolution = (int(max_res[0]), int(max_res[1]))
Camera.resolution = (1640, 1232) # Smallest resolution with full FoV (partial FoV results in plate not fully captured).
# imdev v2 has issues with 'exposure_mode = off' causing black img.
t.sleep(0.25) # Solves those issues (WTF?) as long as it's _BEFORE_ exposure_mode.
t.sleep(0.125) # Solves those issues (WTF?) as long as it's _BEFORE_ exposure_mode.
Camera.exposure_mode = 'off' # Lock Settings.
return Camera

@@ -242,8 +242,6 @@ def img_acquisition_routine_replicates(self, light_intensity, wavelength,
yield photo_path + file_name + str(r) + self._pic_ext
if light_intensity == 255 or flag is True:
yield photo_path + "findWells" + self._pic_ext
# When finished, switch OFF
self._device._modulate_LED_intensity(0, channel=wavelength)

def _average_image(self, photo_path, replicate_name, replicates=__REPLICATES__):
"""
@@ -964,8 +962,7 @@ class SetProtocol:
info.insert(0, current_time)
fOut.writelines(','.join(str(entry) for entry in info) + "\n")

def _preheat_channel(self, PREHEAT_TIME=None,
wavelength=None):
def _preheat_channel(self, wavelength=None):
"""
Private method. Turn lights on for a pre-defined amount of time
to heat up the LEDs. This step is called before data acquisition,
@@ -976,9 +973,9 @@ class SetProtocol:
them up right before a read, we seek to harmonise the
working conditions of all LEDs.
"""
if wavelength is not None and PREHEAT_TIME is not None:
if wavelength is not None:
self._device._modulate_LED_intensity(255, channel=wavelength)
t.sleep(PREHEAT_TIME)
t.sleep(self.__PREHEAT_TIME__)

def Run(self, assay_length="00:00:00", read_every="00:00:00",
temperature=None, light_range=(0, 255), recalculate_wells=False,
@@ -1119,10 +1116,10 @@ class SetProtocol:
# Set camera on-the-fly to adapt to different wavelenghts.
# Because this step happens with any filter, it does not require
# a post-read reset.
self._preheat_channel(wavelength) # Preheat LEDs. **DO NOT** move from here.
self._device._camera = _img_settings(self._device._camera,
Filter=flt)
servo_state = self._device.set_filter(flt, current_pwm=servo_state)
self._preheat_channel(self.__PREHEAT_TIME__, wavelength) # Preheat LEDs.
self._data_acquisition(light_range, current_time, flt,
wavelength, referenceRead)
# Turn LED off

Loading…
Cancel
Save