Skip to content

Conversation

@ltetrel
Copy link
Contributor

@ltetrel ltetrel commented Oct 16, 2024

This adds minimal solution analysis code so it outputs at least the mainlobe_pnp_MPa attribute. The rest has been commented out for future work, additionnal modules/functions are also added to prepare future work.

Please check the #TODO comments in the code for technical discussions.

This adds minimal solution analysis code so it outputs at least the `mainlobe_pnp_MPa` attribute. The rest has been commented out for future work, additionnal modules/functions are also added to prepare future work.
@ebrahimebrahim
Copy link
Collaborator

@ltetrel To help with linting issues I recommend installing the pre-commit hooks.

pip install pre-commit # in your python env
pre-commit install # while inside the repo directory

Then commits will automatically have some formatting fixes, which deals with most issues

you can also run it directly: pre-commit run -a

@ebrahimebrahim ebrahimebrahim linked an issue Oct 16, 2024 that may be closed by this pull request
@ltetrel
Copy link
Contributor Author

ltetrel commented Oct 16, 2024

@ebrahimebrahim thanks, was just about to do it,

Copy link
Collaborator

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

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

Exciting to see this coming together!

I focused on the parts that are involved in getting mainlobe_pnp_MPa and left some broad comments for now

After another round of changes and after we discuss in our meeting soon you can request review again and I will dive into more detail. Perhaps we'll want to merge #127 first as well, as I mention below.

assert dataclasses_are_equal(Solution.from_files(json_filepath, nc_filepath), example_solution)


def test_solution_analysis(example_solution: Solution, example_transducer: Transducer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good to test that we can run the function without error with default options.
Besides this we should also unit-test individual things eventually.

In this PR we should unit-test the functionality that is needed for getting the mainlobe_pnp_MPa:

  • calc_dist_from_focus
  • offset_grid
  • mask_focus
  • rescale_coords
  • get_ndgrid_from_arr

Having these unit tests will be more important than moving on to #105 to get the rest of the solution analysis code. Because these are components that will directly be involved in determining how to scale the pulse to be requested from the hardware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep makes sense, do we want to have tests against a reference data, or only the run (like for analyze)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think not necessarily reference data but just tests on small toy examples to verify that the individual functions do what they are intended to do.

foc,
options.mainlobe_radius,
mask_op=MaskOp.LESS_EQUAL,
units="m",
Copy link
Collaborator

Choose a reason for hiding this comment

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

These units "m" are the units of the options.mainlobe_radius, right? If so I think that the units really should be specified in that options object, or at least there should be a docstring under the mainlobe_radius attribute of the SolutionOptions class indicating that it must be specified in meters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, aspect_ratio does not have units, it is just a scalar to scale and take into account voxel anisotropy. the units here are used to defined to what units all the spatial dimension should be rescaled to.

@peterhollender you coonfirm ?

@ltetrel
Copy link
Contributor Author

ltetrel commented Oct 18, 2024

@ebrahimebrahim as suggested, there may be some regression in the solution analysis mainlobe_pnp_MPa that can be resolved later in another issue.

When you agree with the current status, I will squash everything so we have only one commit.

@ebrahimebrahim
Copy link
Collaborator

Sounds good and thank you for all this work -- will review soon (later today or early Mon) and let you know

Copy link
Collaborator

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

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

I tried it out, everything looks good as far as I can tell. Thank you for all the work on this and the unit tests. As we discussed you can go ahead and open an issue to track the fact that we do not yet know for sure that analyze is producing the correct output. I think the same of get_beamwidth, right? It is not unit tested and we don't know that it is working for sure, so you can mention that in the issue as well.

@ebrahimebrahim ebrahimebrahim merged commit 17b3f32 into main Oct 22, 2024
9 checks passed
@ebrahimebrahim
Copy link
Collaborator

ebrahimebrahim commented Oct 22, 2024

OOPS.
I merged before checking that your commits follow the required style.
Sorry this is my fault, I think you said you would squash everything later, but I forgot about this.
I am going to undo this by ripping the commits out of the main branch ( 🤫 ),
then can you please re-make this PR and just squash the commits? TY and sorry about that

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.

Port over minimal solution analysis code from matlab

3 participants