def test_dce_path_data_constructor(): """ Test if the dce function is working when passing the path data to the constructor. """ # Load the data with only a single serie currdir = os.path.dirname(os.path.abspath(__file__)) path_data = os.path.join(currdir, 'data', 'dce') # Create an object to handle the data dce_mod = DCEModality(path_data) # Check that the data have not been read assert_true(not dce_mod.is_read()) dce_mod.read_data_from_path() # Check that the data have been read assert_true(dce_mod.is_read()) # Check the type of the data assert_equal(dce_mod.data_.dtype, np.float64) # Check that the dimension are the one that we expect assert_equal(dce_mod.data_.shape, (2, 368, 448, 5)) # We need to check that the minimum and maximum were proprely computed assert_equal(dce_mod.min_series_, 0.) assert_equal(dce_mod.max_series_, 616.) # Check that the data are identical data = np.load(os.path.join(currdir, 'data', 'data_dce_data.npy')) assert_array_equal(dce_mod.data_, data) # Check that bin is what we expect data = np.load(os.path.join(currdir, 'data', 'bin_dce_data.npy')) # Check that each array are the same for exp, gt in zip(dce_mod.bin_series_, data): assert_array_equal(exp, gt) # Check that pdf is what we expect data = np.load(os.path.join(currdir, 'data', 'pdf_dce_data.npy')) # Check that each array are the same for exp, gt in zip(dce_mod.pdf_series_, data): assert_array_equal(exp, gt)
def test_read_dce_data(): """ Test if we can read 2 dce series. """ # Load the data with only a single serie currdir = os.path.dirname(os.path.abspath(__file__)) path_data = os.path.join(currdir, 'data', 'dce') # Create an object to handle the data dce_mod = DCEModality() # Check that the data have not been read assert_true(not dce_mod.is_read()) dce_mod.read_data_from_path(path_data) # Check that the data have been read assert_true(dce_mod.is_read()) # Check the type of the data assert_equal(dce_mod.data_.dtype, np.float64) # Check that the dimension are the one that we expect assert_equal(dce_mod.data_.shape, (2, 368, 448, 5)) # Check that the data are identical data = np.load(os.path.join(currdir, 'data', 'data_dce_data.npy')) assert_array_equal(dce_mod.data_, data) # We need to check that the minimum and maximum were proprely computed assert_equal(dce_mod.min_series_, 0.) assert_equal(dce_mod.max_series_, 616.) # Check that bin is what we expect data = np.load(os.path.join(currdir, 'data', 'bin_dce_data.npy')) # Check that each array are the same for exp, gt in zip(dce_mod.bin_series_, data): assert_array_equal(exp, gt) # Check that pdf is what we expect data = np.load(os.path.join(currdir, 'data', 'pdf_dce_data.npy')) # Check that each array are the same for exp, gt in zip(dce_mod.pdf_series_, data): assert_array_equal(exp, gt) # Check the value present in the dictionary assert_equal(dce_mod.metadata_['size'], (448, 368, 5)) assert_equal(dce_mod.metadata_['origin'], (-139.197998046875, -125.99199676513672, -6.814799785614014)) assert_equal(dce_mod.metadata_['direction'], (0.9999267096574318, -1.3680395668288353e-08, -0.012106829215863141, 0.0016226550415489812, 0.9909776862500729, 0.13401713452043554, 0.011997595770753412, -0.1340269575662008, 0.9909050571781686)) assert_equal(dce_mod.metadata_['spacing'], (0.67633926868439, 0.67633926868439, 1.249927043914795)) assert_equal(dce_mod.metadata_['TR'], 2350.0) assert_equal(dce_mod.metadata_['TE'], 101.0) assert_equal(dce_mod.metadata_['flip-angle'], 140.0) assert_array_equal(dce_mod.time_info_, np.array([0., 0.]))