Closed faberno closed 2 months ago
Nice find :+1: I could reproduce the bug and see the mismatching orientation when looking at the .mat
file.
I assume we haven't found this bug yet because we always placed the probe centrally so that it works symmetrically. But maybe this caused some off-by-one errors.
In addition to using transpose
instead of rot90
we would also have to remove this line in order to obtain a correctly flipped time series data, because now the sensor elements are correctly ordered
# reverse the order of detector elements from matlab to python order
raw_time_series_data = raw_time_series_data[::-1, :]
Describe the bug The kwave adapter uses rot90 to orient the images/volumes for the kwave axis convention. But rot90 does not preserve the original positions in the image. This is because np.arrays origin is the top-left corner and rot90 maps this corner to top-right, instead preserving it at the top left.
Here an example based optical_and_acoustic_simulation.py, where the sensor position and vessel position are set to VOLUME_TRANSDUCER_DIM_IN_MM/3 (not in the middle as before): In the original slice the vessel sits at index 125. After rot90 it sits at index 250. Intead transpose would be the correct behaviour.
By looking the p0 map and the sensor in kwave we can see that this unaligns sensor and the properties:
Specify a priority (low, medium, high) high
To Reproduce
-> optical_and_acoustic_simulation.py
tissue_dict["vessel_1"] = sp.define_circular_tubular_structure_settings( tube_start_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/3, 0, 5], tube_end_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/3, VOLUME_PLANAR_DIM_IN_MM, 5], molecular_composition=sp.TISSUE_LIBRARY.blood(), radius_mm=2, priority=3, consider_partial_volume=True, adhere_to_deformation=False )
delete vessel_2
device = sp.PhotoacousticDevice(device_position_mm=np.array([VOLUME_TRANSDUCER_DIM_IN_MM/3, VOLUME_PLANAR_DIM_IN_MM/2, 0]), field_of_view_extent_mm=np.asarray([-15, 15, 0, 0, 0, 20]))
Additional context Solution: -> acoustic_forward_module_k_wave_adapter.py
data_dict[Tags.DATA_FIELD_SPEED_OF_SOUND] = data_dict[Tags.DATA_FIELD_SPEED_OF_SOUND][image_slice].T data_dict[Tags.DATA_FIELD_DENSITY] = data_dict[Tags.DATA_FIELD_DENSITY][image_slice].T data_dict[Tags.DATA_FIELD_ALPHA_COEFF] = data_dict[Tags.DATA_FIELD_ALPHA_COEFF][image_slice].T data_dict[Tags.DATA_FIELD_INITIAL_PRESSURE] = data_dict[Tags.DATA_FIELD_INITIAL_PRESSURE][image_slice].T