def test_inf_prediction():
    '''Test for function which classifies images as with and
       without inflection'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    data_encoding.noise_image(temp, plate_temp, 'musicalrobot/data/')
    file_path = 'musicalrobot/data/noise_images/'
    result_df, nonoise_index = data_encoding.noise_prediction(file_path)
    data_encoding.inf_images(temp, plate_temp, 2, nonoise_index,
                             'musicalrobot/data/')
    file_path = 'musicalrobot/data/inf_images/'
    inf_pred, inf_index = data_encoding.inf_prediction(file_path)
    assert isinstance(inf_pred, dict), 'Output is not a dictionary'
    assert isinstance(inf_index, list), 'Output is not a list'
    return
Exemplo n.º 2
0
def test_pixel_intensity():
    '''Test for function which determines sample temperature and plate temperature'''
    pixel_frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/CHCl_CA_DES_5_31_19.tiff')
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames, pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    n_columns = 12
    n_rows = 8
    sample_location = pixel_analysis.peak_values(column_sum, row_sum,
                                                 n_columns, n_rows, img_eq)
    x_name = 'Row'
    y_name = 'Column'
    plate_name = 'plate_location'
    pixel_sample, pixel_plate = pixel_analysis.pixel_intensity(
        sample_location, pixel_frames, x_name, y_name, plate_name)
    assert isinstance(pixel_sample, list), 'Output is not a list'
    assert isinstance(pixel_plate, list), 'Output is not a list'
    assert len(
        pixel_sample
    ) == n_columns * n_rows, 'Temperature obtained for wrong number of samples'
    assert len(
        pixel_plate
    ) == n_columns * n_rows, 'Temperature obtained for wrong number of plate locations'
    return
Exemplo n.º 3
0
def test_inflection_temp():
    '''Test for wrapping function'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    path = 'musicalrobot/data/'
    sorted_regprops, s_temp, p_temp, s_infl, result_df = edge_detection.inflection_temp(
        crop_frame, n_rows, n_columns, path)
    assert isinstance(crop_frame, list), 'Output is not a list'
    assert isinstance(s_infl, list), 'Output is not a list'
    assert len(s_infl) == n_samples, 'Wrong number of samples detected'
    for i in range(len(crop_frame)):
        assert len(sorted_regprops[i]
                   ) == n_samples, 'Wrong number of samples detected'
    assert isinstance(s_temp, list), 'Sample temperature output is not a list'
    assert isinstance(p_temp, list), 'Plate temperature output is not a list'
    assert len(
        s_temp
    ) == n_samples, 'Temperature obtained for wrong number of samples'
    assert len(
        p_temp
    ) == n_samples, 'Temperature obtained for wrong number of plate locations'
    assert isinstance(result_df, pd.DataFrame), 'Output is not a dataframe'
    assert len(
        result_df
    ) == n_samples, 'Inflection temperatures obtained for wrong number of samples'
    return
Exemplo n.º 4
0
def test_input_file():
    '''Test for function which loads the input file'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    assert isinstance(frames, np.ndarray), 'Output is not an array'
    return
Exemplo n.º 5
0
def test_sample_temp():
    '''Test for function which obtaines temperature of samples and plate temperature'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    # flip_frames = edge_detection.flip_frame(crop_frame)
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    assert isinstance(temp, list), 'Sample temperature output is not a list'
    assert isinstance(plate_temp,
                      list), 'Plate temperature output is not a list'
    assert len(
        temp) == n_samples, 'Temperature obtained for wrong number of samples'
    assert len(
        plate_temp
    ) == n_samples, 'Temperature obtained for wrong number of plate locations'
    return
def test_plot_to_array():
    '''Test for function which generates a gray images
       of the temperature profile'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    for i in range(len(temp)):
        x = plate_temp[i]
        y = temp[i]
        length = 2
        gray_image = data_encoding.plot_to_array(x, y, length)
        assert isinstance(gray_image, np.ndarray), 'Output is not an array'
        assert len(gray_image) == 200, 'Incorrectly sized output array'
    return
Exemplo n.º 7
0
def test_pixel_intensity():
    '''Test for function which determines sample temperature and plate temperature'''
    frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    img_eq = pixel_analysis.image_eq(pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    n_columns = 3
    n_rows = 3
    r_peaks, c_peaks = pixel_analysis.peak_values(column_sum,
                                                  row_sum,
                                                  n_columns,
                                                  n_rows,
                                                  freeze_heat=False)
    sample_location = pixel_analysis.locations(r_peaks, c_peaks, img_eq)
    x_name = 'Row'
    y_name = 'Column'
    plate_name = 'plate_location'
    pixel_sample, pixel_plate = pixel_analysis.pixel_intensity(
        sample_location, pixel_frames, x_name, y_name, plate_name)
    assert isinstance(pixel_sample, list), 'Output is not a list'
    assert isinstance(pixel_plate, list), 'Output is not a list'
    assert len(
        pixel_sample
    ) == n_columns * n_rows, 'Temperature obtained for wrong number of samples'
    assert len(
        pixel_plate
    ) == n_columns * n_rows, 'Temperature obtained for wrong number of plate locations'
    return
Exemplo n.º 8
0
def test_locations():
    '''Test for functin which returns a dataframe containing row and column
    locations of samples and their respective plate location at which temperature
    profiles are monitored'''
    frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    img_eq = pixel_analysis.image_eq(pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    n_columns = 3
    n_rows = 3
    r_peaks, c_peaks = pixel_analysis.peak_values(column_sum,
                                                  row_sum,
                                                  n_columns,
                                                  n_rows,
                                                  freeze_heat=False)
    sample_location = pixel_analysis.locations(r_peaks, c_peaks, img_eq)
    assert isinstance(sample_location,
                      pd.DataFrame), 'Output is not a dataframe'
    assert len(
        sample_location
    ) == n_columns * n_rows, 'Wrong number of sample locations are present'
    return
Exemplo n.º 9
0
def test_choose_crop():
    """
    Will ask user to choose if the image will be cropped or not. Will skip the
        specific image

    Allowed inputs are y or n. Any other inputs will result in a re-request

    Parameters:
    -----------
    tocrop : array
        The raw tiff file that is stored in a dictionary and pulled from each
        key using a wrapper. Acts as the base image for the auto_crop

    plotname : string
        Name pulled from the orginal file name - is the chart title

    Returns:
    --------
    crop: array
        The array of the tiff file with the requested columns/rows removed. Needs
        to be returned twice to save to the dictionary and then be able to be
        out of the function for use in next functions.

    """
    #Inputs
    tocrop = ed.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    plotname = 'DA_ST_Mid_50_1'

    #running
    #crop, crop = bk.choose_crop(tocrop, plotname)

    #asserts

    return
Exemplo n.º 10
0
def test_plot_image():
    """
    Test: Plots the given cropped image - used as an internal function

    Parameters:
    -----------
    crop: array
        The array of the tiff file with the requested columns/rows removed

    plotname : string
        Name pulled from the orginal file name - is the chart title

    Returns:
    --------
    No returns : will print the plot

    """
    tocrop = ed.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    left = 3
    right = 5
    top = 3
    bottom = 10
    plotname = 'DA_ST_Mid_50_1'

    crop = bk.image_crop(tocrop, left, right, top, bottom)
    bk.plot_image(crop, plotname)

    return
Exemplo n.º 11
0
def test_auto_crop():
    """
    Will request an imput from the user to determine how much of the image to
        crop off the sides, top, and bottom. Will produce a cropped image

    Inputs MUST be numerical. the program will fail if not numerical

    Parameters:
    -----------
    tocrop : array
        The raw tiff file that is stored in a dictionary and pulled from each
        key using a wrapper. Acts as the base image for the auto_crop

    plotname : string
        Name pulled from the orginal file name - is the chart title

    Returns:
    --------
    crop: array
        The array of the tiff file with the requested columns/rows removed
    """
    #inputs
    tocrop = ed.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    plotname = 'DA_ST_Mid_50_1'

    #Running
    #crop = bk.auto_crop(tocrop, plotname)

    #asserts

    return
Exemplo n.º 12
0
def test_sample_peaks():
    ''' Test for function which obtains the peaks in the sample temperature profile'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    # flip_frames = edge_detection.flip_frame(crop_frame)
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    s_peaks, s_infl = edge_detection.peak_detection(temp, plate_temp, 'Sample')
    assert isinstance(s_peaks, list), 'Output is not a list'
    assert isinstance(s_infl, list), 'Output is not a list'
    assert len(s_peaks) == n_samples, 'Wrong number of peaks detected'
    assert len(
        s_infl
    ) == n_samples, 'Wrong number of inflection temperatures detected'
    return
Exemplo n.º 13
0
def test_image_eq():
    ''' Test for fucntion which equalizes a low contrast image'''
    pixel_frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/CHCl_CA_DES_5_31_19.tiff')
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames, pixel_frames)
    assert isinstance(img_eq, np.ndarray), 'Output is not an array'
    assert pixel_frames[
        0].shape == img_eq.shape, 'Output array shape is not same as the input array shape.'
    return
Exemplo n.º 14
0
def test_image_eq():
    ''' Test for fucntion which equalizes a low contrast image'''
    frames = edge_detection.input_file('../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85,40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames,pixel_frames)
    assert isinstance(img_eq,np.ndarray),'Output is not an array'
    assert pixel_frames[0].shape == img_eq.shape, 'Output array shape is not same as the input array shape.'
    return
Exemplo n.º 15
0
def test_flip_frame():
    '''Test for function which flips the frames horizontally
       and vertically to correct for the mirroring during recording.'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    flip_frames = edge_detection.flip_frame(crop_frame)
    assert isinstance(flip_frames, list), 'Output is not a list'
    return
Exemplo n.º 16
0
def test_pixel_temp():
    '''Test for the wrapping function'''
    pixel_frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/CHCl_CA_DES_5_31_19.tiff')
    n_frames = len(pixel_frames)
    n_columns = 12
    n_rows = 8
    m_df = pixel_analysis.pixel_temp(pixel_frames, n_frames, n_columns, n_rows)
    assert isinstance(m_df, pd.DataFrame), 'Output obtained is not a dataframe'
    assert len(
        m_df
    ) == n_columns * n_rows, 'Temperature obtained for wrong number of samples'
    return
Exemplo n.º 17
0
def test_pixel_temp():
    '''Test for the wrapping function'''
    frames = edge_detection.input_file('../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85,40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    n_frames = len(pixel_frames)
    n_columns = 3
    n_rows = 3
    m_df = pixel_analysis.pixel_temp(pixel_frames,n_frames,n_columns,n_rows)
    assert isinstance(m_df,pd.DataFrame),'Output obtained is not a dataframe'
    assert len(m_df)==n_columns*n_rows,'Temperature obtained for wrong number of samples'
    return
Exemplo n.º 18
0
def test_pixel_sum():
    '''Test for function which obtains the sum of pixels over all rows and columns'''
    pixel_frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/CHCl_CA_DES_5_31_19.tiff')
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames, pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    assert isinstance(column_sum, list), 'Column sum is not a list'
    assert isinstance(row_sum, list), 'Row sum is not a list'
    assert len(row_sum) == img_eq.shape[
        0], 'The length of row_sum is not equal to number of rows in the input image'
    assert len(column_sum) == img_eq.shape[
        1], 'The length of column_sum is not equal to number of columns in the input image'
    return
Exemplo n.º 19
0
def test_pixel_sum():
    '''Test for function which obtains the sum of pixels over all rows and columns'''
    frames = edge_detection.input_file('../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85,40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames,pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    assert isinstance(column_sum,list),'Column sum is not a list'
    assert isinstance(row_sum,list),'Row sum is not a list'
    assert len(row_sum) == img_eq.shape[0], 'The length of row_sum is not equal to number of rows in the input image'
    assert len(column_sum) == img_eq.shape[1], 'The length of column_sum is not equal to number of columns in the input image'
    return
Exemplo n.º 20
0
def test_edge_detection():
    ''' Test for function which detects edges,fills and labels the samples'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    # flip_frames = edge_detection.flip_frame(crop_frame)
    n_samples = 9
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    assert isinstance(labeled_samples, np.ndarray), 'Output is not an array'
    assert crop_frame[
        0].shape == labeled_samples.shape, 'Input and Output array shapes are different.'
    return
Exemplo n.º 21
0
def test_image_crop():
    """
    Test:
    Function is used within the auto_crop function to  crop using the inputs
    given by the user.

    Parameters:
    -----------
    tocrop : array
        The raw tiff file that is stored in a dictionary and pulled from each
        key using a wrapper. Acts as the base image for the auto_crop

    left : int
        Number of pixels taken off of the left side of the image

    right : int
        Number of pixels taken off of the right side of the image

    top : int
        Number of pixels taken off of the top side of the image

    bottom : int
        Number of pixels taken off of the bottom side of the image

    Returns
    --------
    crop : array
        The array of the tiff file with the requested columns/rows removed

    """
    #set Inputs
    tocrop = ed.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    left = 3
    right = 5
    top = 3
    bottom = 10

    #running
    #crop = bk.image_crop(tocrop, left, right, top, bottom)

    #asserts
    #assert isinstance(crop, np.ndarray), "output in not an array"

    return
Exemplo n.º 22
0
def test_peak_values():
    '''Test for function which finds peaks from the column_sum and row_sum arrays
        and return a dataframe with sample locations and plate locations.'''
    pixel_frames = edge_detection.input_file(
        '../musical-robot/musicalrobot/data/CHCl_CA_DES_5_31_19.tiff')
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames, pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    n_columns = 12
    n_rows = 8
    sample_location = pixel_analysis.peak_values(column_sum, row_sum,
                                                 n_columns, n_rows, img_eq)
    assert isinstance(sample_location,
                      pd.DataFrame), 'Output is not a dataframe'
    assert len(
        sample_location
    ) == n_columns * n_rows, 'Wrong number of sample locations are present'
    return
Exemplo n.º 23
0
def test_peak_values():
    '''Test for function which finds peaks from the column_sum and row_sum arrays
        and return a dataframe with sample locations and plate locations.'''
    frames = edge_detection.input_file('../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85,40:120])
    pixel_frames = edge_detection.flip_frame(crop_frame)
    n_frames = len(pixel_frames)
    img_eq = pixel_analysis.image_eq(n_frames,pixel_frames)
    column_sum, row_sum = pixel_analysis.pixel_sum(img_eq)
    n_columns = 3
    n_rows = 3
    r_peaks, c_peaks = pixel_analysis.peak_values(column_sum,row_sum,n_columns,n_rows,img_eq)
    assert isinstance(r_peaks, list), 'Output is not a list'
    assert isinstance(c_peaks, list), 'Output is not a list'
    assert len(r_peaks) == n_rows, 'Wrong number of sample rows detected'
    assert len(c_peaks) == n_columns, 'Wrong number of sample columns detected'
    return
Exemplo n.º 24
0
def test_derivative():
    '''Test for function which calculates the derivative
       of the temperature profile for neural network input'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    derivative_list = data_encoding.derivative(temp, plate_temp)
    assert isinstance(derivative_list, list), 'Output is not a list'
    assert len(derivative_list) == len(temp), 'Incorrect number of derivatives'
    return
Exemplo n.º 25
0
def test_final_result():
    '''Test for the wrappung function'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    path = 'musicalrobot/data/'
    result_df = data_encoding.final_result(temp, plate_temp, path)
    assert isinstance(result_df, pd.DataFrame), 'Output is not a dataframe'
    assert len(result_df) == len(temp), 'Incorrect number of samples classfied'
    return
Exemplo n.º 26
0
def test_inflection_points():
    """
    This is a rewrap of the inflection point analysis function using the additive
        rows and columns to find the centriods. All function are the same, but
        the variable names have been changed to match the rest of the bulk
        wrapping functions

    IMPORTANT: This function assumes that the sample is being run on a 96 well
        plate. If this is not correct the number of detected wells will be off

    Parameters:
    -----------
    crop: array
        The array of the tiff file with the requested columns/rows removed

    Returns:
    --------
    inf_temp : list
        the inflection points of the wells in the video

    """
    #Inputs
    tocrop = ed.input_file(
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    left = 3
    right = 5
    top = 3
    bottom = 10
    plotname = 'DA_ST_Mid_50_1'

    #crop = bk.image_crop(tocrop, left, right, top, bottom)

    #running
    #inf_temp = bk.inflection_points(crop)

    #asserts

    return
Exemplo n.º 27
0
def test_sort_regprops():
    '''Test for function which sorts the dataframes in the dictionary regprops'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    # flip_frames = edge_detection.flip_frame(crop_frame)
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    assert isinstance(sorted_regprops, dict), 'Output is not a dictionary'
    assert len(sorted_regprops) == len(
        crop_frame
    ), 'The number of dataframes in the dictionary is not equal to number of frames input.'
    for i in range(len(crop_frame)):
        assert len(sorted_regprops[i]
                   ) == n_samples, 'Wrong number of samples detected'
    return
Exemplo n.º 28
0
def test_noise_prediction():
    '''Test for function which classifies images as noisy or
       not noisy'''
    file_name = (
        '../musical-robot/musicalrobot/data/10_17_19_PPA_Shallow_plate.tiff')
    frames = edge_detection.input_file(file_name)
    crop_frame = []
    for frame in frames:
        crop_frame.append(frame[35:85, 40:120])
    n_samples = 9
    n_rows = 3
    n_columns = 3
    labeled_samples = edge_detection.edge_detection(crop_frame, n_samples)
    regprops = edge_detection.regprop(labeled_samples, crop_frame, n_rows,
                                      n_columns)
    sorted_regprops = edge_detection.sort_regprops(regprops, n_columns, n_rows)
    temp, plate_temp = edge_detection.sample_temp(sorted_regprops, crop_frame)
    data_encoding.noise_image(temp, plate_temp, 'musicalrobot/data/')
    file_path = 'musicalrobot/data/noise_images/'
    result_df, nonoise_index = data_encoding.noise_prediction(file_path)
    assert isinstance(result_df, pd.DataFrame), 'Output is not a dataframe'
    assert len(result_df) == len(
        temp), 'Incorrect number of samples in the dataframe'
    assert isinstance(nonoise_index, list), 'Output is not a list'