agencyenterprise/neurotechdevkit

Slice `SteadyStateResult3D` to `SteadyStateResult2D`

Closed this issue · 0 comments

Background

The benchmark paper (Aubry et al., 2022) simulates scenarios with 3-D physics but only compares results in 2-D. This seems to be a common use-case, because it is easier and faster to visualize 2-D results.

Describe the new feature or enhancement

Please provide a clear and concise description of what you want to add or change.
I would like to be able to convert the SteadyStateResult3D output of a 3-D simulation to a SteadyStateResult2D that just encapsulates the slice of interest.

Please describe how you would use this new feature.
To validate NDK's 3-D simulations against the publicly available Stride simulation output for the same scenarios.

Relevant issues: #88 and #89

Describe your proposed implementation

_Describe how you think the feature or improvement should be implemented (e.g., as a new method on an existing class? as new capability added to an existing method?)
As a method in SteadyStateResult3D essentially replicating the slicing done by render_steady_state_amplitudes:

field = self.get_steady_state()
slice_axis = self.scenario.slice_axis
slice_position = self.scenario.slice_position
field = slice_field(field, self.scenario, slice_axis, slice_position)
extent = drop_element(self.scenario.extent, slice_axis)
origin = drop_element(np.array(self.scenario.origin, dtype=float), slice_axis)

(but to construct a SteadyStateResult2D)

Describe possible alternatives

If you've suggested an implementation above, list here any alternative implementations you can think of, and brief comments explaining why the chosen implementation is better.

Possible alternative: Slice result.wavefield directly.

Cons: SteadyStateResult associates with the underlying wavefield data. many helper functions/methods, such as .steady_state and _metrics.py

def calculate_all_metrics(
result: results.SteadyStateResult,
) -> dict[str, dict[str, float | str]]:
"""Calculate all metrics for the steady-state result and return as a dictionary.

take a SteadyStateResult as an input, making it difficult to pass in a numpy array directly.