OpenwaterHealth / OpenLIFU-python

focused ultrasound toolbox
GNU Affero General Public License v3.0
12 stars 2 forks source link

Port over solution creation and scaling code #126

Closed ebrahimebrahim closed 3 weeks ago

ebrahimebrahim commented 1 month ago

In #104 the focus was on porting over the solution analysis function.

In this issue we are indicating that we also need

Depends on #104 Would be nice to have #125 done before starting on this

ebrahimebrahim commented 1 month ago

When we port over calc_solution we will want to stack simulation outputs over foci.

In the initial attempt in SlicerOpenLIFU (linked above) you can see that it was done by List[PlanFocus] where a PlanFocus contained a simulation output xarray. We will get away from this, because of the fix introduced in #127 .

After the fix in #127 here is a way to stack multiple simulation outputs into the correct sort of xarray dataset.

combined_dataset = xarray.concat(
    [
        sim.assign_coords(focal_point_index=i)
        for i,sim in enumerate(sims)
    ],
    dim='focal_point_index',
)

assuming sims is a list of individual xarray datasets (one for each focal point and ordered in the same order as the list of focal points) that are output of openlifu.sim.run_similation.