def setUp(self): self.pwd = get_installdir() self.deid = os.path.abspath("%s/../examples/deid/deid.dicom" % self.pwd) self.dataset = get_dataset("dicom-cookies") self.tmpdir = tempfile.mkdtemp() print("\n######################START######################")
def setUp(self): self.pwd = get_installdir() self.deid = os.path.abspath("%s/../examples/deid/deid.dicom" % self.pwd) self.dataset = get_dataset("animals") # includes private tags self.tmpdir = tempfile.mkdtemp() print("\n######################START######################")
def test_get_installdir(self): '''get install directory should return the base of where singularity is installed ''' print("Testing finding the installation directory.") from deid.utils import get_installdir whereami = get_installdir() self.assertTrue(whereami.endswith('deid'))
def get_dataset(dataset=None): '''get_dataset will return some data provided by the application, based on a user-provided label. In the future, we can add https endpoints to retrieve online datasets. ''' data_base = get_installdir() valid_datasets = {'dicom-cookies': '%s/data/dicom-cookies' % data_base} if dataset is not None: # In case the user gave an extension dataset = os.path.splitext(dataset)[0].lower() if dataset in valid_datasets: return valid_datasets[dataset] bot.info("Valid datasets include: %s" % (','.join(list(valid_datasets.keys()))))
def get_dataset(dataset=None): """get_dataset will return some data provided by the application, based on a user-provided label. In the future, we can add https endpoints to retrieve online datasets. """ data_base = get_installdir() valid_datasets = { "dicom-cookies": os.path.join(data_base, "data", "dicom-cookies"), "animals": os.path.join(data_base, "data", "animals"), "humans": os.path.join(data_base, "data", "humans"), } if dataset is not None: # In case the user gave an extension dataset = os.path.splitext(dataset)[0].lower() if dataset in valid_datasets: return valid_datasets[dataset] bot.info("Valid datasets include: %s" % (",".join(list(valid_datasets.keys()))))
def find_deid(path=None): """find_deid is a helper function to load_deid to find a deid file in a folder, or return the path provided if it is the file. Parameters ========== path: a path on the filesystem. If not provided, will assume PWD. """ # A default deid will be loaded if all else fails default_deid = os.path.join(get_installdir(), "data", "deid.dicom") if path is None: path = os.getcwd() # The user has provided a directory if os.path.isdir(path): contenders = [ "%s/%s" % (path, x) for x in os.listdir(path) if x.startswith("deid") ] if len(contenders) == 0: bot.warning( "No deid settings files found in %s, will use default dicom.deid." % path) contenders.append(default_deid) elif len(contenders) > 1: bot.warning("Multiple deid files found in %s, will use first." % (path)) path = contenders[0] # We have a file path at this point if not os.path.exists(path): bot.exit("Cannot find deid file %s, exiting." % (path)) return path
# Create a DeidRecipe from deid.config import DeidRecipe recipe = DeidRecipe() # Since we didn't load a custom deid recipe text file, we get a default # WARNING No specification, loading default base deid.dicom # You can add custom deid files with .load(). # We can look at the criteria loaded: recipe.deid # You can also provide your own deid recipe file, and in doing so, you # won't load a default path = os.path.abspath("%s/../examples/deid/" % get_installdir()) recipe = DeidRecipe(deid=path) # You can also choose to load the default base with your own recipe recipe = DeidRecipe(deid=path, base=True) # Or specify a different base entirely. The base is the deid.<tag> in the # deid.data folder. So for example, under deid/data/deid.dicom.chest.xray we would # do: recipe = DeidRecipe(deid=path, base=True, default_base='dicom.xray.chest') # We can also specify one of the deid recipes provided by the library as our # only to use. recipe = DeidRecipe(deid='dicom.xray.chest') # This is to encourage sharing! If you have a general recipe that others might
def setUp(self): self.pwd = get_installdir() self.tmpdir = tempfile.mkdtemp() print("\n######################START######################")
def setUp(self): self.pwd = get_installdir() self.deidpath = os.path.abspath("%s/tests/resources/" % self.pwd) self.dataset = get_dataset("animals") self.tmpdir = tempfile.mkdtemp() print("\n######################START######################")