diff --git a/PyNutil/dream_workflow.py b/PyNutil/dream_workflow.py index 205896ba2029a7afde79730204dabcd495b0e9c6..eedf748c8c90f88e2f3e6d6ab19291179f3c7cc4 100644 --- a/PyNutil/dream_workflow.py +++ b/PyNutil/dream_workflow.py @@ -22,12 +22,12 @@ quantifier.load_mask(mask_path=r"blablabla/") quantifier.load_custom_regions(custom_region_json=r"blablabla/") # run coordinate extraction # ideally extract coordinates per section and whole brain -points = quantifier.get_coordinates() +quantifier.get_coordinates() quantifier.save_coordinates() -objects = quantifier.get_objects() +quantifier.get_objects() -loads = quantifier.get_loads() +quantifier.get_loads() quantifier.save_segmentation_atlas_overlays() diff --git a/PyNutil/main.py b/PyNutil/main.py index 0626eeb014bd875d30e18075059dcf933c6e6c74..71fd2b39100531cddb863663d7a294dfc50c57b1 100644 --- a/PyNutil/main.py +++ b/PyNutil/main.py @@ -1,5 +1,5 @@ from .metadata import metadata_loader -from read_and_write import readAtlasVolume +from .read_and_write import readAtlasVolume class PyNutil: @@ -13,7 +13,7 @@ class PyNutil: self.config, self.metadata_path = metadata_loader.load_config() if atlas not in self.config["annotation_volumes"]: raise ValueError( - f"Atlas {atlas} not found in config file\n valid atlases are {self.config['annotation_volumes'].keys()}" + f"Atlas {atlas} not found in config file, valid atlases are: \n{' , '.join(list(self.config['annotation_volumes'].keys()))}" ) self.segmentation_folder = segmentation_folder self.json_file = json_file @@ -23,5 +23,11 @@ class PyNutil: def build_quantifier(self): # do all the expensive computations - atlas_path = self.config["annotation_volumes"][self.atlas]["volume"] - self.atlas_volume = readAtlasVolume(self.atlas) + atlas_root_path = self.config["annotation_volume_directory"] + current_atlas_path = self.config["annotation_volumes"][self.atlas]["volume"] + print("loading atlas volume") + self.atlas_volume = readAtlasVolume(atlas_root_path + current_atlas_path) + + def get_coordinates(self): + if not hasattr(self, "atlas_volume"): + raise ValueError("Please run build_quantifier before running get_coordinates") diff --git a/PyNutil/metadata/config.json b/PyNutil/metadata/config.json index 1ec2ba3bfbe14bf1994199f79e8c2dc870f8bce7..5cab460fcd262288ee1f71d9a8de5f543fc754c6 100644 --- a/PyNutil/metadata/config.json +++ b/PyNutil/metadata/config.json @@ -22,6 +22,7 @@ "WHS_Atlas_Rat_Brain_v4":{ "labels":"WHS_v4_colours.csv", "volume":"None" - }, - "annotation_volume_directory":"annotation_volumes/" -}} \ No newline at end of file + } +}, +"annotation_volume_directory":"PyNutil/metadata/annotation_volumes/" +} \ No newline at end of file diff --git a/PyNutil/metadata/metadata_loader.py b/PyNutil/metadata/metadata_loader.py index ec273633cec9518eccb6c9cc9db11ef815da986b..ae3361f7d15394ba1799ae800dfa3b3c867d0dc9 100644 --- a/PyNutil/metadata/metadata_loader.py +++ b/PyNutil/metadata/metadata_loader.py @@ -11,7 +11,7 @@ def load_config() -> dict: :rtype: dict """ # returns a path to the config file assuming that it is in the same directory as this script - path = str(Path(__file__).parent.parent.absolute()) + "/config.json" + path = str(Path(__file__).parent.parent.absolute()) + "/metadata/config.json" # open the config file with open(path, "r") as f: # load the config file diff --git a/testOOP.py b/testOOP.py new file mode 100644 index 0000000000000000000000000000000000000000..2c6c0e3ba52a7ddcae2fbc45374bee9724d6d036 --- /dev/null +++ b/testOOP.py @@ -0,0 +1,16 @@ +from PyNutil import PyNutil + + + + + +pnt = PyNutil( + 'test', + 'test', + [0,0,0], + "allen2017") + +pnt.build_quantifier() + +pnt.get_coordinates() +