Skip to content

Commit 7f32872

Browse files
Typo & Naming
The laser ni class had a typo from the recent import. Also found that the photometrics class was riddled with things that don't adhere to our naming styles. Updated and will test. Also added another note to the documentation about the most recent version of the PVCAM library.
1 parent 71a10fa commit 7f32872

File tree

3 files changed

+59
-43
lines changed

3 files changed

+59
-43
lines changed

docs/source/user_guide/hardware/pvcam.rst

+8
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ Photometrics Drivers
1919
in in srcs/model/devices/APIs/photo_metrics/PyVCAM-master. To install this API, go to this
2020
folder in the command line and from within your **navigate** environment, run
2121
``python setup.py install``.
22+
23+
.. Note::
24+
25+
The most up-to-date version of PVCAM can be found on `GitHub <https://github.com/Photometrics/PyVCAM>`_.
26+
27+
28+
29+

src/navigate/model/devices/camera/photometrics.py

+47-40
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151

5252
def build_photometrics_connection(camera_connection):
53-
"""Build Sutter Stage Serial Port connection
53+
"""Build Photometrics connection
5454
5555
Import Photometrics API and Initialize Camera Controller.
5656
@@ -66,7 +66,6 @@ def build_photometrics_connection(camera_connection):
6666
"""
6767
try:
6868
pvc.init_pvcam()
69-
# camera_names = Camera.get_available_camera_names()
7069
camera_to_open = Camera.select_camera(camera_connection)
7170
camera_to_open.open()
7271
return camera_to_open
@@ -97,8 +96,8 @@ def __init__(
9796
microscope_name: str,
9897
device_connection: Any,
9998
configuration: Dict[str, Any],
100-
*args: Optional[Any],
101-
**args: Optional[Any],
99+
*_: Optional[Any],
100+
**__: Optional[Any],
102101
) -> None:
103102
"""Initialize the Photometrics class.
104103
@@ -113,6 +112,15 @@ def __init__(
113112
"""
114113
super().__init__(microscope_name, device_connection, configuration)
115114

115+
#: int: Binning in x direction
116+
self.x_binning = None
117+
118+
#: int: Binning in y direction
119+
self.y_binning = None
120+
121+
#: obj: Data Buffer
122+
self._data_buffer = None
123+
116124
self.camera_parameters["supported_readout_directions"] = [
117125
"Top-to-Bottom",
118126
"Bottom-to-Top",
@@ -128,19 +136,19 @@ def __init__(
128136
self.configuration = configuration
129137

130138
#: int: Exposure Time in milliseconds
131-
self._exposuretime = 20
139+
self._exposure_time = 20
132140

133141
#: int: Scan Mode (0 = Normal, 1 = ASLM)
134-
self._scanmode = 0
142+
self._scan_mode = 0
135143

136144
#: int: Scan Delay
137-
self._scandelay = 1
145+
self._scan_delay = 1
138146

139147
#: int: Number of frames
140-
self._numberofframes = 100
148+
self._number_of_frames = 100
141149

142150
#: obj: Data Buffer
143-
self._databuffer = None
151+
self._data_buffer = None
144152

145153
#: int: Number of frames received
146154
self._frames_received = 0
@@ -182,7 +190,7 @@ def __del__(self):
182190

183191
@classmethod
184192
def connect(cls, camera_connection):
185-
"""Build Sutter Stage Serial Port connection
193+
"""Build Photometrics Stage Serial Port connection
186194
187195
Import Photometrics API and Initialize Camera Controller.
188196
@@ -232,7 +240,7 @@ def report_settings(self):
232240
print("internal_line_interval")
233241
print("sensor size" + str(self.camera_controller.sensor_size))
234242
print("image_height and width" + str(self.x_pixels) + ", " + str(self.y_pixels))
235-
print("exposure_time" + str(self._exposuretime))
243+
print("exposure_time" + str(self._exposure_time))
236244

237245
def close_camera(self):
238246
"""Close Photometrics Camera"""
@@ -251,7 +259,7 @@ def set_sensor_mode(self, mode):
251259
modes_dict = {"Normal": 0, "Light-Sheet": 1}
252260
if mode in modes_dict:
253261
self.camera_controller.prog_scan_mode = modes_dict[mode]
254-
self._scanmode = modes_dict[mode]
262+
self._scan_mode = modes_dict[mode]
255263
else:
256264
print("Camera mode not supported" + str(modes_dict[mode]))
257265
logger.debug("Camera mode not supported" + str(modes_dict[mode]))
@@ -278,7 +286,7 @@ def set_readout_direction(self, mode):
278286
logger.debug("Camera readout direction not supported")
279287

280288
def calculate_readout_time(self):
281-
"""Calculate duration of time needed to readout an image.
289+
"""Calculate duration of time needed to read out an image.
282290
283291
Calculates the readout time and maximum frame rate according to the camera
284292
configuration settings.
@@ -290,7 +298,7 @@ def calculate_readout_time(self):
290298
Returns
291299
-------
292300
readout_time : float
293-
Duration of time needed to readout an image in seconds.
301+
Duration of time needed to read out an image in seconds.
294302
"""
295303

296304
# get the readout time from the Photometrics camera in us
@@ -313,9 +321,9 @@ def set_exposure_time(self, exposure_time):
313321
exposure_time : float
314322
Exposure time in milliseconds.
315323
"""
316-
self._exposuretime = int(exposure_time * 1000)
317-
self.camera_controller.exp_time = self._exposuretime
318-
self.camera_controller.start_live(self._exposuretime)
324+
self._exposure_time = int(exposure_time * 1000)
325+
self.camera_controller.exp_time = self._exposure_time
326+
self.camera_controller.start_live(self._exposure_time)
319327
return exposure_time
320328

321329
def set_line_interval(self, line_interval_time):
@@ -326,8 +334,8 @@ def set_line_interval(self, line_interval_time):
326334
line_interval_time : float
327335
Line interval duration.
328336
"""
329-
# todo calculate line delay from scandelay
330-
self._scandelay = line_interval_time
337+
# todo calculate line delay from scan delay
338+
self._scan_delay = line_interval_time
331339
self.camera_controller.prog_scan_line_delay = line_interval_time
332340

333341
def calculate_light_sheet_exposure_time(
@@ -354,36 +362,36 @@ def calculate_light_sheet_exposure_time(
354362
"""
355363

356364
# size of ROI
357-
nbrows = self.y_pixels
365+
number_rows = self.y_pixels
358366

359367
# transform exposure time to milliseconds for Photometrics API.
360368
full_chip_exposure_time = full_chip_exposure_time * 1000
361369

362370
# equations to calculate ASLM parameters
363-
linedelay = self.camera_parameters.get("unitforlinedelay", 1) / 1000
364-
ASLM_lineExposure = int(
365-
np.ceil(full_chip_exposure_time / (1 + (1 + nbrows) / shutter_width))
371+
line_delay = self.camera_parameters.get("unitforlinedelay", 1) / 1000
372+
aslm_line_exposure = int(
373+
np.ceil(full_chip_exposure_time / (1 + (1 + number_rows) / shutter_width))
366374
)
367-
ASLM_line_delay = (
375+
aslm_line_delay = (
368376
int(
369377
np.ceil(
370-
(full_chip_exposure_time - ASLM_lineExposure)
371-
/ ((nbrows + 1) * linedelay)
378+
(full_chip_exposure_time - aslm_line_exposure)
379+
/ ((number_rows + 1) * line_delay)
372380
)
373381
)
374382
- 1
375383
)
376384

377-
ASLM_acquisition_time = (
378-
(ASLM_line_delay + 1) * nbrows * linedelay
379-
+ ASLM_lineExposure
380-
+ (ASLM_line_delay + 1) * linedelay
385+
aslm_acquisition_time = (
386+
(aslm_line_delay + 1) * number_rows * line_delay
387+
+ aslm_line_exposure
388+
+ (aslm_line_delay + 1) * line_delay
381389
)
382390

383-
self.camera_parameters["line_interval"] = ASLM_lineExposure
384-
self._exposuretime = ASLM_lineExposure
385-
self._scandelay = ASLM_line_delay
386-
return ASLM_lineExposure / 1000, ASLM_line_delay, ASLM_acquisition_time / 1000
391+
self.camera_parameters["line_interval"] = aslm_line_exposure
392+
self._exposure_time = aslm_line_exposure
393+
self._scan_delay = aslm_line_delay
394+
return aslm_line_exposure / 1000, aslm_line_delay, aslm_acquisition_time / 1000
387395

388396
def set_binning(self, binning_string):
389397
"""Set Photometrics binning mode.
@@ -488,11 +496,11 @@ def initialize_image_series(self, data_buffer=None, number_of_frames=100):
488496
"""
489497

490498
# set camera parameters depending on acquisition mode
491-
self._scanmode = self.camera_controller.prog_scan_mode
492-
if self._scanmode == 1:
499+
self._scan_mode = self.camera_controller.prog_scan_mode
500+
if self._scan_mode == 1:
493501
# Programmable scan mode (ASLM)
494502
self.camera_controller.exp_mode = "Edge Trigger"
495-
self.camera_controller.prog_scan_line_delay = self._scandelay
503+
self.camera_controller.prog_scan_line_delay = self._scan_delay
496504
self.camera_controller.exp_out_mode = 4
497505

498506
else:
@@ -502,7 +510,7 @@ def initialize_image_series(self, data_buffer=None, number_of_frames=100):
502510

503511
# Prepare for buffered acquisition
504512
#: int: Number of frames
505-
self._numberofframes = number_of_frames
513+
self._number_of_frames = number_of_frames
506514

507515
#: obj: Data Buffer
508516
self._data_buffer = data_buffer
@@ -542,13 +550,12 @@ def _receive_images(self):
542550
frame["pixel_data"][:]
543551
)
544552
# Delete copied frame for memory management
545-
frame = None
546553
del frame
547554

548555
frame_to_return = [self._frames_received]
549556
self._frames_received += 1
550557
# check to make sure the next frame exist in buffer
551-
if self._frames_received >= self._numberofframes:
558+
if self._frames_received >= self._number_of_frames:
552559
self._frames_received = 0
553560
return frame_to_return
554561

src/navigate/model/devices/laser/ni.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ def __init__(
8686
"laser"
8787
][device_id]["onoff"]["hardware"].get("type", None)
8888

89-
9089
if analog == "NI" and digital == "NI":
9190
modulation_type = "mixed"
9291
elif analog == "NI":
93-
odulation_type = "analog"
92+
modulation_type = "analog"
9493
elif digital == "NI":
9594
modulation_type = "digital"
95+
else:
96+
raise ValueError("Laser modulation type not recognized.")
9697

9798
#: str: The modulation type of the laser - Analog, Digital, or Mixed.
9899
self.modulation_type = modulation_type
@@ -261,4 +262,4 @@ def __del__(self):
261262
try:
262263
self.laser_do_task.close()
263264
except Exception as e:
264-
logger.exception(f"Error stopping task: {traceback.format_exc()}")
265+
logger.exception(f"Error stopping task: {traceback.format_exc()}")

0 commit comments

Comments
 (0)