V2 refactor#478
Open
peterhollender wants to merge 22 commits into
Open
Conversation
- Trims unnecessary parts of the project, including - legacy scripts - the io module (now covered in `openlifu-sdk`) - unused parts of Database (gridweights) - Reorganizes `virtual_fit` module into `seg` - Eliminates "eager" imports in `openlifu.__init__`, to prevent the many-seconds-long importing when accessing any submodule. - Moves importing of heavier-weight packages (which are being made optional by this branch) into the methods that call them, so that the objects can be partially-used without having those dependencies imported. Code that touches `openlifu.virtual_fit` needs to be refactored to use `openlifu.seg.virtualfit`, and code that used things like `openlifu.Transducer` will need to be changed to use `openlifu.xdc.Transducer` reorganize virtual fit and geo remove gridweights Unused enhancement Update transducer.py remove legacy scripts,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary —
v2_refactorintomain21 commits, 34 files, +2748/−244. Fixes/relates to issues #8, #467, #468.
High-level themes
Sessiontransducer-tracking + photoscan data into a first-classPhotoscanRegistrationtype.SolutionAnalysispersistence.OpenLIFUFieldDatagains units/precision/display fields;__repr__/_repr_html_/get_summary()added across the model.Breaking / semantic changes to call out for reviewers
openlifu.db.sessionPhotoscanRegistration:photoscan_id,transform,approval,id.TransducerTrackingResult:photoscan_to_volume_transform,transducer_to_volume_tracking_approved,photoscan_to_volume_tracking_approved.photoscan_registration_id,approval(replacestransducer_to_volume_tracking_approved),id,target_id.Sessionadds:solution_id(auto-cleared whenarray_transformchanges), explicitphotoscans/photocollectionslists, andphotoscan_registrations.Session.from_dictsynthesizesPhotoscanRegistrationobjects with id{photoscan_id}__pr__{n:02d}from old embedded PV transforms so existing sessions load.openlifu.db.databasewrite_solution_analysis,load_solution_analysis,get_solution_analysis_filepath→{solution_dir}/{solution_id}_analysis.json.load_sessionnow auto-populates missingphotoscans/photocollectionsfrom index files and drops orphaned TT results whosephotoscan_registration_idis missing (logs a warning).openlifu.plan.solution/solution_analysisSolutiongainsget_mask(...),get_mainlobe_mask,get_sidelobe_mask.Solution.analyze()computes mainlobe centroid from intensity (ipa_mainlobe, cutoffipk * 10^(−3/20)) instead of pressure. Focal-point metrics will shift slightly vsmain.SolutionAnalysisOptionsdefault changes (numeric → auto-derived):mainlobe_aspect_ratio:(1, 1, 5)→(1, 1, 7)mainlobe_radius:2.5e-3→None(derived from beamwidth)beamwidth_radius:5e-3→None(derived from2.0 * fnum * wavelength)sidelobe_radius:3e-3→None(beamwidth × 1.5)sidelobe_zmin:1e-3→None(falls back to 10 mm scaled todistance_units,DEFAULT_SIDELOBE_ZMIN_MM = 10.0)distance_unitsrestricted to("mm", "cm", "m")estimated_tx_temperature_rise_Clabel renamed: "Estimated TX Temperature Rise" → "Est. Transmitter Heating".model_tx_temperature_risebounds-check messages downgraded fromWARNING→DEBUG(they were noisy). Corresponding pytest cases removed.openlifu.cloudCloud.__init__(environment: str = ENV_PROD);Api.__init__(api_url);Websocket.__init__(api_url, update_callback).openlifu.cloud.const.API_URLremoved; replaced byAPI_URL_PRODandAPI_URL_DEV.Cloud._componentsno longer registersSystems(matches sample-DB layout).openlifu.xdc.transducerarrayTransducerArraygains device-connection & config-validation surface:TransducerArray.get_connected(...),TransducerArray.from_module_user_configs(...),TransducerArray.to_device_config(), plus a full repr suite (__repr__,__str__,_repr_pretty_,_repr_html_).openlifu.xdc:DeviceConfigMismatchError,arrays_structurally_equal._validate_device_config_against_connected,_build_meshless_default_template,_canonicalize_array_for_compare,get_gap_from_angle.openlifu.util.annotationsOpenLIFUFieldDataNamedTuple → frozen dataclass with 5 new optional fields (units,display_units,unit_options,precision,units_field). Backwards-compatible: 2-arg positional construction still works, attribute access unchanged.util/field_display.pyfor reading annotation metadata off dataclass fields.Additive-only changes (no reviewer concern)
bf/apod_methods/*,bf/delay_methods/direct.py,bf/focal_patterns/*,bf/pulse.py,bf/sequence.py,sim/sim_setup.py,seg/virtual_fit.py,seg/seg_method.py,xdc/element.py: all addget_summary(), richer repr, and expandedOpenLIFUFieldDatametadata; no signature changes on existing methods.util/units.rescale_coords: parameter now acceptsDataset | DataArray.param_constraint.py: symbol swap inPARAM_STATUS_SYMBOLS(❗ → ⚠️,❌ → ⛔).Tests
tests/test_transducer.py(+400) andtests/test_transducer_array_device_config.py(+233) — cover the newTransducerArraytype, device-config match/mismatch, and repr paths.tests/test_database.py(+55) exercisesload_solution_analysis/write_solution_analysisand the photoscan-registration index behavior.test_solution_analysiscases whose warnings were downgraded to debug.test_package::test_versionfailure (stale editable install in local venv; not caused by this branch).Bug caught during review
Original diff added
"run_virtual_fit"toopenlifu.plan.__init__'s__all__without an import, which would have causedAttributeErroronopenlifu.plan.run_virtual_fit. Fixed in185beee—run_virtual_fitremains accessible viaopenlifu.seg.Downstream compatibility
SlicerOpenLIFU has been co-developed against this branch and already calls the new APIs (
TransducerArray.get_connected,Database.load_solution_analysis/write_solution_analysis,PhotoscanRegistration,Cloud(env), newOpenLIFUFieldDatafields). No SlicerOpenLIFU references to any removed symbol remain. This branch is a required bump for the in-flight SlicerOpenLIFU work.