def test_dce_get_pdf_roi(): """Test the function to get a pdf from ROI.""" # Load the data with only a single serie currdir = os.path.dirname(os.path.abspath(__file__)) path_data = os.path.join(currdir, 'data', 'dce_folders') # Create the list of path path_data_list = [os.path.join(path_data, 's_2'), os.path.join(path_data, 's_1')] # Create an object to handle the data dce_mod = DCEModality() dce_mod.read_data_from_path(path_data_list) # Create ground truth array pos = np.ones((368, 448), dtype=bool) neg = np.zeros((368, 448), dtype=bool) gt_index = np.rollaxis(np.array([neg, pos, pos, pos, neg]), 0, 3) # Compute the histgram for the required data pdf, bins = dce_mod.get_pdf_list(roi_data=(gt_index)) pdf_roi = np.load(os.path.join(currdir, 'data', 'pdf_roi.npy')) bins_roi = np.load(os.path.join(currdir, 'data', 'bins_roi.npy')) for pdf_s, bins_s, pdf_gt, bins_gt in zip(pdf, bins, pdf_roi, bins_roi): assert_array_equal(pdf_s, pdf_gt) assert_array_equal(bins_s, bins_gt)
def test_dce_get_pdf_wt_roi(): """Test the function to get a pdf wihtout ROI.""" # Load the data with only a single serie currdir = os.path.dirname(os.path.abspath(__file__)) path_data = os.path.join(currdir, 'data', 'dce_folders') # Create the list of path path_data_list = [os.path.join(path_data, 's_2'), os.path.join(path_data, 's_1')] # Create an object to handle the data dce_mod = DCEModality() dce_mod.read_data_from_path(path_data_list) # Compute the histgram for the required data pdf, bins = dce_mod.get_pdf_list() for pdf_s, bins_s, pdf_gt, bins_gt in zip(pdf, bins, dce_mod.pdf_series_, dce_mod.bin_series_): assert_array_equal(pdf_s, pdf_gt) assert_array_equal(bins_s, bins_gt)