-
Notifications
You must be signed in to change notification settings - Fork 7
P/transducerdef update #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bb7c544 to
70b4c28
Compare
|
I think you forgot to |
|
There is a folder |
| if self.impulse_response.ndim != 1 or len(self.impulse_response)<2: | ||
| raise ValueError("Impulse response must be a 1-dimensional array.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is raised when using the openlifu_2x400_evt1_005.json example, because len(self.impulse_response) is 1 in that example:
{
"type": "TransducerArray",
"id": "openlifu_2x400_evt1_005",
"name": "OpenLIFU 2x 400kHz EVT1 S/N 005",
"modules": [
{
...,
"impulse_response": [
1350.0
],
...,
},
...,
]
...,
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is making it so that the transducer openlifu_2x400_evt1_005.json cannot be loaded into SlicerOpenLIFU. But I am not sure how to fix it unless I understand the intention behind enforcing len(self.impulse_response)<2.
Once way to see this error in the unit tests for quick debugging is to change impulse_response in tests/resources/example_db/transducers/example_transducer_array2/example_transducer_array2.json to a list of length 1 instead of 2 by deleting an element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh maybe the re-uploaded dvc doesn't have the correct fixes...
|
Note that there is no way to write a EDIT: Correction -- you can use Database.write_transducer on a TransducerArray, and it should use TransducerArray's to_file, but for reasons I can't remember it did not work out for me. So in any case something has to be done if we want to support writing |
Reworking Transducer Def for #380 and #381 Minor fixes for inverting TX polarity. Add module invert to logger printout New TransducerArray made TransformedTransducer subclass of Transducer Update Elements format, database loading add backwards compatibilty, database write Update db_dvc.dvc bugfix in transducer, upload test script new tests Fixes for Pytest Update test_watertank.py Update test_watertank_simulation.py Update test_watertank.py remove `module_invert` from LIFUInterface the `module_invert` attribute of LIFUInterface had no function after instantiation, as it passed it's state through to `TxDevice`. `TxDevice` also passes `module_invert` through to the `TxRegisters`, but because we call `enum_tx_7332_devices()` at various points, which re-instantiates the `TxRegisters`, the `TxDevice` needs to (for now) hold that state.
The `impulse_response` attribute was getting a little complicated whether or not it was None, a single value, or an array, so I split it into a scaling `sensitivity` attribute and a unitless `impulse_response`. This also comes with improvements to merging arrays with different sensitivities.
It was not being converted to a numpy array on read
It was wrongly being converted to list
When the impulse response is global to the transducer array, rather than per module, it is not converted to a numpy array when it should be.
"Smart transducer loading" means reading via Transducer or TransducerArray's serializer depending on the "type" field in the json file. This functionality was stuck inside of Databse, but we expose it as a general utility to support its use in SlicerOpenLIFU.
6bb29ef to
d54143d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, everything looks good now and I think it's all working in SlicerOpenLIFU branch here: OpenwaterHealth/SlicerOpenLIFU#478, with the exception that openlifu_2x400_evt1_005.json cannot be loaded in SlicerOpenLIFU as indicated in the comment. This is not part of any actual example session though, so no sessions are broken.
I think it just remains to fix the openlifu_2x400_evt1_005.json example if you want to, and if you don't then let me know and I will merge
df31968 to
ff812fd
Compare
ebrahimebrahim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the _005 definition -- it loads in SlicerOpenLIFU now!
Merging!

This makes some substantial changes to the way we store transducer definitions on disk, and carries these changes throughout the codebase. Major updates include:
TransducerArrayclass that explicitly holds multipleTransformedTransducers(also a new class - a thin wrapper for Transducers). This allows for per-module modification of module positioning and properties, with a simpleto_transducermethod that bakes array together into a single conventionalTransducer.sensitivityandimpulse_responseattributes toTransducer, which propagate down to elements. The split ofsensitivitymeans that impulse responses are no longer length-1 arrays when they mean to encode simple scaling, In both cases, these attributes also exist forElement, and are elegantly ignored when set toNone. Theto_dictandfrom_dictmethods have been updated to exclude these attributes if they areNone, since they will pick up theNoneon instantiation, and it would create confusing verbiosity in the .json files for users not actually specifying them for bothTransducerandElement. The addition toTransducerhas the benefit of making the json file shorter - if you determine that your array is less, sensitive, you don't need to change every element, just the overall sensivity.Elementattributes (x,y,zbecomesposition,length,widthbecomessize, andaz,el,rollbecome orientation.module_invertattribute has been added toTransducer, which trickles through to register computation, allowing particular modules to invert their output to compensate for flipped polarity arraysiomodule has been updated to handle themodule_invertattributeSolutionobjects now carry around theTransducerthat was used in their creation. This alleviates the need to separately carry around theTransducerfor bringing it'smodule_invertattribute intoLIFUInterface.set_solutionnotebooks