Skip to content

Drift corr reference working#9

Open
EmanPaoli wants to merge 4 commits intomasterfrom
drift_corr_reference_working
Open

Drift corr reference working#9
EmanPaoli wants to merge 4 commits intomasterfrom
drift_corr_reference_working

Conversation

@EmanPaoli
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@vilim vilim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I would suggest one simplification though: removing the reference_params_queue and reference_event, and always having only save_paramters with an additional boolean flag is_reference. This removes a lot of code duplication (e.g. you don't need ReferenceParamters, just keep ReferenceSettings and change the convert_save_params function)

Comment thread twop/state.py
dz = st.dz
z_th = st.z_th
n_frames_exp = st.n_frames_exp
rp = ReferenceParameters(n_frames_ref=n_frames_ref,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since everything is the same, you can use the st.params.values (this gives you a dictionary), so
so the function becomes a one-liner

rp = ReferenceParamters(**st.params.values)

Comment thread twop/streaming_save.py
Path(self.save_parameters.output_dir) / "original" / "stack_metadata.json"
).is_file():
shutil.rmtree(Path(self.save_parameters.output_dir) / "original")
if not self.ref_event.is_set():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a simpler if, the only thing that changes is original vs anatomy in the folder name.

Comment thread twop/streaming_save.py
try:
self.update_n_t(self.n_frames_queue.get(timeout=0.001))
n_total = self.save_parameters.n_t * self.save_parameters.n_z
print(n_total)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the prints

Comment thread twop/streaming_save.py
else:
fl.save(
Path(self.save_parameters.output_dir)
/ "anatomy/{:04d}.h5".format(self.i_block),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, a simpler if which just changes the folder name will do

Comment thread twop/state.py

def advance_plane(self):
self.motors["z"].move_rel(self.experiment_settings.dz / 1000)
print("plane advanced by by", self.experiment_settings.dz)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra print

Comment thread twop/state.py
self.experiment_settings.n_planes - 1) * self.experiment_settings.dz
print("moving stage up by", mic_to_move)
self.motors["z"].move_rel(mic_to_move / 1000)
sleep(0.2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this time should be set as a constant, possibly parameterized later with a config file, like lightsheet. Also, the moving time might be longer than 0.2s if you are returning to the first plane from the end of the reference stack

Comment thread twop/state.py
self.n_frames_ref = Param(10, (1, 500))
self.extra_planes = Param(1, (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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants