def test_array_filtering(): a = read_RF('rfdat.bin', 1556, 256) b = RF_bars(a, 256) c = b[0:2] data_filtered = array_filtering(c) assert len(signal.find_peaks_cwt(data_filtered[:, 0], np.arange( 1, 500))) < len(signal.find_peaks_cwt(c[0], np.arange(1, 500))) assert len(signal.find_peaks_cwt(data_filtered[:, 1], np.arange( 1, 500))) < len(signal.find_peaks_cwt(c[1], np.arange(1, 500)))
def test_read_RFdata(): bin_data = read_RF('test.bin', 1, 1) assert bin_data == np.array([770])
def test_read_RF_data_wrong_data_type(): with pytest.raises(NotBinaryFileError): read_RF('bmode.json', 1556, 256)
def test_read_RF_data_missing_data(): with pytest.raises(MissingDataError): read_RF('test.bin', 10, 10)
def test_read_RF_data_missing_file(): with pytest.raises(FileNotFoundError): read_RF('apple.dat', 10, 10)
from read_RFdata import read_RF, RF_bars from B_mode_image_creation import array_filtering,\ logarithmic_compression, equalization from B_mode_outputs import image_save, image_plot from argparse_input import main_args import logging if __name__ == "__main__": JSON_filename, RF_data_filename, image_filename, display, save =\ main_args() logging.basicConfig(filename='Logging_file.log', filemode='w', level=logging.DEBUG, format='%(asctime)s %(message)s') c, fs, axial_samples, beam_spacing, num_beams = \ read_JSON_data(JSON_filename) rf_data = read_RF(RF_data_filename, axial_samples, num_beams) rf_data_bars = RF_bars(rf_data, num_beams) rf_array_filtered = array_filtering(rf_data_bars) log_rf_array_filtered = logarithmic_compression(rf_array_filtered) RFarray_equalized = equalization(log_rf_array_filtered) if save: image_save(image_filename, RFarray_equalized, beam_spacing, axial_samples, num_beams, fs, c) if display: image_plot(RFarray_equalized, beam_spacing, axial_samples, num_beams, fs, c)