def test_inflection_point(): '''Test for function which obtains the melting point of all 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 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') p_peaks, p_infl = edge_detection.peak_detection(temp, plate_temp, 'Plate') inf_temp = edge_detection.inflection_point(temp, plate_temp, s_peaks, p_peaks) assert isinstance(inf_temp, list), 'Output is not a list' assert len( inf_temp) == n_samples, 'Wrong number of melting points determined' return
def pixel_temp(frames, n_frames, n_columns, n_rows): ''' Function to determine the temperature of the samples and plate locations by analysing pixel values and finding peaks. Parameters ----------- frames: Array The frames of a video to be analysed. n_frames: Int Number of frames in the video n_columns: Int Number of columns of samples in the image n_rows: Int Number of rows of samples in the image. Returns -------- m_df : Dataframe A dataframe containing row and column coordinates of each sample and its respective inflection point obtained. ''' # flip_frames = edge_detection.flip_frame(frames) #Function to obtained an equalized image using all the frames #in the video. img_eq = image_eq(n_frames, frames) #Funtion to determine sum of pixels over all the rows and columns #to obtain plots with peaks at the sample position in the array. column_sum, row_sum = pixel_sum(img_eq) # Function to find peaks from the column_sum and row_sum arrays r_peaks, c_peaks = peak_values(column_sum, row_sum, n_columns, n_rows, img_eq) # Function to return a dataframe with sample locations and respective plate locations. sample_location = locations(r_peaks, c_peaks, img_eq) # Function to find pixel intensity at all sample locations # and plate locations in each frame. temp, plate_temp = pixel_intensity(sample_location, frames, x_name='Row', y_name='Column', plate_name='plate_location') #Function to obtain the peaks in sample temperature profile s_peaks, s_infl = edge_detection.peak_detection(temp, plate_temp, 'Sample') # Function to obtain the peaks in plate location temperature profile p_peaks, p_infl = edge_detection.peak_detection(temp, plate_temp, 'Plate') # Function to obtain the inflection point(melting point) from the temperature profile. inf_temp = inflection_point(temp, plate_temp, s_peaks, p_peaks) # Dataframe with sample location (row and column coordinates) and respective inflection point. m_df = pd.DataFrame({ 'Row': sample_location.Row, 'Column': sample_location.Column, 'Melting point': inf_temp }) return m_df
def final_result(temp, plate_temp, path): ''' Funtion to classify temperature profiles as noisy or noiseless Parameters ----------- temp : List Temperature of all the samples in every frame of the video. plate_temp : List Temperature profiles of all the plate locations path : String Path to the location to temporarily store neural network input images. Returns -------- result_df : Dataframe Dataframe containing well number, predictions of noise net anf inflection net and melting point. ''' # Generating noise images noise_image(temp, plate_temp, path) # Making predictions using noise net file_path = path + 'noise_images/' result_df, nonoise_index = noise_prediction(file_path) # Generating inflection images inf_images(temp, plate_temp, 2, nonoise_index, path) # Making prediction using inflection net file_path = path + 'inf_images/' inf_pred, inf_index = inf_prediction(file_path) # Extracting melting point s_peaks, s_infl = ed.peak_detection(temp, plate_temp, 'Sample') melting_point = np.asarray(s_infl)[:, 0] # Adding inflection and melting point data to the dataframe result_df['Inf net'] = '-' result_df['Melting point'] = '-' for i in nonoise_index: result_df['Inf net'].loc[i] = inf_pred[i] for i in inf_index: result_df['Melting point'].loc[i] = melting_point[i] result_df['Inf net'].replace(0, 'Inflection', inplace=True) result_df['Inf net'].replace(1, 'No Inflection', inplace=True) result_df['Noise net'].replace(0, 'Noiseless', inplace=True) result_df['Noise net'].replace(1, 'Noisy', inplace=True) return result_df