Skip to content
Snippets Groups Projects
Commit c63310dc authored by Harry Carey's avatar Harry Carey
Browse files

added testOOP as a temporary file while building the PyNutil class

parent 922d1c08
No related branches found
No related tags found
No related merge requests found
......@@ -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()
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")
......@@ -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
......@@ -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
......
from PyNutil import PyNutil
pnt = PyNutil(
'test',
'test',
[0,0,0],
"allen2017")
pnt.build_quantifier()
pnt.get_coordinates()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment