def testCorrectTwoShellOk(self): dann = Dry() model2s = dann.train_model(bval2s) dann.fwe(dwis2s, model2s, bval2s, testingdir) self.assertTrue(os.path.isfile(os.path.join(testingdir, "merged1/tissue_volume_fraction.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "merged1/fwe_dwi.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "merged2/tissue_volume_fraction.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "merged2/fwe_dwi.nii.gz")))
def testCorrectOneShellOk(self): dann = Dry() model1s = dann.train_model(bval1s) dann.fwe(dwis1s, model1s, bval1s, testingdir) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test1/tissue_volume_fraction.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test1/fwe_dwi.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test2/tissue_volume_fraction.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test2/fwe_dwi.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test3/tissue_volume_fraction.nii.gz"))) self.assertTrue(os.path.isfile(os.path.join(testingdir, "test3/fwe_dwi.nii.gz")))
def testCorrectEmptyOutputFolder(self): dann = Dry() model = dann.train_model(bval1s) dann.fwe(dwis1s, model, bval1s) self.assertTrue(os.path.isfile("test1/tissue_volume_fraction.nii.gz")) self.assertTrue(os.path.isfile("test1/fwe_dwi.nii.gz")) self.assertTrue(os.path.isfile("test2/tissue_volume_fraction.nii.gz")) self.assertTrue(os.path.isfile("test2/fwe_dwi.nii.gz")) self.assertTrue(os.path.isfile("test3/tissue_volume_fraction.nii.gz")) self.assertTrue(os.path.isfile("test3/fwe_dwi.nii.gz"))
from dry.dry import Dry if __name__ == "__main__": bfile = 'dry/data/one-shell/test_ok.bvals' dwi = ['dry/data/one-shell/test1.nii.gz', 'dry/data/one-shell/test2.nii.gz', 'dry/data/one-shell/test3.nii.gz'] dann = Dry() model1s = dann.train_model(bfile) dann.correct_fwe(dwi, model1s, bfile, output_folder='dry/data') # bfile = 'dry/data/two-shell/merged.bval' # dwi = ['dry/data/two-shell/merged1.nii.gz', # 'dry/data/two-shell/merged2.nii.gz'] # dann = Dry() # model2s = dann.train_model(bfile) # dann.correct_fwe(dwi, model2s, bfile, output_folder='dry/data')
def testCorrectDifferentBval(self): dann = Dry() model = dann.train_model(bval1s) with self.assertRaises(ValueError): dann.fwe(dwis1s, model, bval2s, testingdir)
def testCorrectEmptyBval(self): dann = Dry() model = dann.train_model(bval1s) with self.assertRaises(ValueError): dann.fwe(dwis1s, model, None, testingdir)
def testCorrectEmtpyDwi(self): dann = Dry() model = dann.train_model(bval1s) with self.assertRaises(ValueError): dann.fwe(None, model, bval1s, testingdir)
def testLoadModelOK(self): dann = Dry() model = dann.train_model(bval1s) dann.save_model(model, os.path.join(testingdir, "testmodel")) model2 = dann.load_model(os.path.join(testingdir, "testmodel")) self.assertIsInstance(model2, Sequential)
def testSaveModelOK(self): dann = Dry() model = dann.train_model(bval1s) dann.save_model(model, os.path.join(testingdir, "testmodel")) self.assertTrue(os.path.isfile(os.path.join(testingdir, "testmodel")))
def testTrainModelOk(self): dann = Dry() model = dann.train_model(bval1s) self.assertIsInstance(model, Sequential)
def testTrainModelEmptyBval(self): dann = Dry() with self.assertRaises(FileNotFoundError): dann.train_model("")