Conversation
…d in the main, master motor class, enum for movement type
…ian blurring of the reference decided by the user (depending on exp type) now in pixel but in microns as soon as I have the calibrations
# Conflicts: # twop/scanning.py # twop/state.py # twop/streaming_save.py
| self.extra_planes = Param(11, (1, 500)) | ||
| self.dz = Param(1.0, (0.1, 20.0), unit="um") | ||
| self.xy_th = Param(5.0, (0.1, 20.0), unit="um") | ||
| self.z_th = Param(self.dz, (self.dz, self.dz * 4), unit="um") |
There was a problem hiding this comment.
you might have problems with parameters that depend on other parameters (I think here the values will just be copied)
| self.n_frames_ref = Param(10, (1, 500)) | ||
| self.extra_planes = Param(11, (1, 500)) | ||
| self.dz = Param(1.0, (0.1, 20.0), unit="um") | ||
| self.xy_th = Param(5.0, (0.1, 20.0), unit="um") |
There was a problem hiding this comment.
the _th are thresholds? please use longer names
| n_frames_exp = st.n_frames_exp | ||
| sigma_k = st.sigma_k | ||
| size_k = st.size_k | ||
| rp = ReferenceParameters(n_frames_ref=n_frames_ref, |
There was a problem hiding this comment.
if all the names are same, you can covert settings to a dictionary (provided by lighparam). Also we should add a possibility to make a dataclass out of a Parameterized
| errors = [] | ||
| planes = np.size(self.reference, 0) | ||
| for i in range(planes): | ||
| ref_im = np.squeeze(self.reference[i, :, :]) |
| planes = np.size(self.reference, 0) | ||
| for i in range(planes): | ||
| ref_im = np.squeeze(self.reference[i, :, :]) | ||
| output = register_translation(ref_im, test_image) |
There was a problem hiding this comment.
once you upgrade scikit-image to 0.17 the function has been moved
| z_disp = ind - ((self.reference_params.n_planes - 1) / 2) | ||
| vector = vectors[ind] | ||
| np.append(vector, z_disp) | ||
| vector = self.real_units(vector) |
There was a problem hiding this comment.
a more concise way of doing thse would be self.to_real_units(np.r_[vector, z_disp]) without the np.append np.r_ is a shortcut to concatenate
| while not self.stop_event.is_set(): | ||
| number_of_frames = 0 | ||
| frame_container = [] | ||
| while number_of_frames == self.reference_params.n_frames_exp: |
There was a problem hiding this comment.
this is a bit strange condition? I aussume it will never be fullfilled unless self.reference_params.n_frames_exp is 0, because the loop does not update the self.reference_params
| self.encoding = encoding | ||
| self.port = port | ||
| self.device = device | ||
| rm = pyvisa.ResourceManager() |
There was a problem hiding this comment.
I guess you will have to put this back. For testing I suggest a FakeLaserPowerController class
| w_fov = conv_fact * self.scanning_parameters.voltage_x | ||
| return (self.scanning_parameters.n_x / w_fov) / 1000 | ||
|
|
||
| def save_reference(self, raw_reference): |
There was a problem hiding this comment.
I don't think this class should be managing the saving of the reference. Try to constrain it just to do drift correction and nothing else.
| self.input_commands_queues["y"].put((vector[0], self.mov_type)) | ||
| self.input_commands_queues["z"].put((vector[2], self.mov_type)) | ||
|
|
||
| def reference_processing(self, input_ref): |
There was a problem hiding this comment.
A tip for speed: once you received the reference, you can immediately fourier transform it and low-pass filter it in fourier space. That way the register_translation will be much faster (see the space argument here https://scikit-image.org/docs/stable/api/skimage.registration.html?highlight=phase_cross_correlation#phase-cross-correlation and the source code of the function)
| self.name = "reference" | ||
| self.n_frames_ref = Param(10, (1, 500)) | ||
| self.extra_planes = Param(11, (1, 500)) | ||
| self.dz = Param(1.0, (0.1, 20.0), unit="um") |
There was a problem hiding this comment.
Isn't there already a parameter like this in status? Don't duplicate parameters, move them through queues
| z_th: float = 1 | ||
| n_frames_exp: int = 5 | ||
| size_k: int = 0 | ||
| sigma_k: int = 5 |
| self.calibration_vector = None | ||
|
|
||
| def run(self): | ||
| while True: |
There was a problem hiding this comment.
this should be while not stop_event.is_set() otherwise this process won't close properly. Also make sure it is .join() in the experiment termination function
| self.calibration_vector = [pix_millimeter, pix_millimeter, self.reference_params.dz] # x,y,z cal vect | ||
| while not self.stop_event.is_set(): | ||
| number_of_frames = 0 | ||
| frame_container = [] |
There was a problem hiding this comment.
Do you know the size of the frame container? If so better use a preallocated numpy then index it
| frame_container = [] | ||
| while number_of_frames == self.reference_params.n_frames_exp: | ||
| try: | ||
| frame = self.data_queue.get(timeout=0.001) |
There was a problem hiding this comment.
If you get from data_queue does the Saver still get the same data? You have to have into account that the get() method in a multiprocessing.queue not only obtains an element of the queue but also deletes it from the queue.
| out = queue.get(timeout=0.001) | ||
| except Empty: | ||
| pass | ||
| return out |
There was a problem hiding this comment.
This while will freeze the process here if nothing is received for whatever reason
| def calculate_fov(self): | ||
| # calculate pix per millimeters | ||
| # formula: width FOV (microns) = 167.789 * Voltage | ||
| conv_fact = 167.789 |
There was a problem hiding this comment.
conv_fact should not be declared here. Add it to a ParametrizedQt class here or in the state and set the attribute gui=False
| ) | ||
|
|
||
| def toggle_start(self): | ||
| if self.chk_drift_corr.isChecked() is True: |
There was a problem hiding this comment.
is True is redundant as the if statement is already evaluating isChecked() which returns only True or False
| self.duration_queue = duration_queue | ||
| self.n_frames_queue = Queue() | ||
| self.correction_event = correction | ||
| self.correction_status = False |
There was a problem hiding this comment.
why having a boolean and an event when you can just have the event?
| self.setup_tasks(read_task, write_task, shutter_task) | ||
| if self.scanning_parameters.reset_shutter or toggle_shutter: | ||
| self.toggle_shutter(shutter_task) | ||
| pass |
No description provided.