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

added emoji

parent 1e51888c
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,8 @@ def getCentroidsAndArea(Segmentation, pixelCutOff=0):
"""this function returns the center coordinate of each object in the segmentation.
You can set a pixelCutOff to remove objects that are smaller than that number of pixels
"""
SegmentationBinary = ~np.all(Segmentation == 255, axis=2)
labels = measure.label(SegmentationBinary)
# SegmentationBinary = ~np.all(Segmentation == 255, axis=2)
labels = measure.label(Segmentation)
# this finds all the objects in the image
labelsInfo = measure.regionprops(labels)
# remove objects that are less than pixelCutOff
......@@ -144,11 +144,6 @@ def SegmentationToAtlasSpace(
"""combines many functions to convert a segmentation to atlas space. It takes care
of deformations"""
Segmentation = cv2.imread(SegmentationPath)
if method in ["per_object", "all"]:
# this function returns the centroids, area and coordinates of all the objects in the segmentation
# right now we only use centroids
centroids, area, coords = getCentroidsAndArea(Segmentation, pixelCutOff=0)
print("number of objects: ", len(centroids))
if pixelID == "auto":
# remove the background from the segmentation
SegmentationNoBackGround = Segmentation[~np.all(Segmentation == 255, axis=2)]
......@@ -157,7 +152,7 @@ def SegmentationToAtlasSpace(
) # remove background
# currently only works for a single label
pixelID = pixelID[0]
ID_pixels = findMatchingPixels(Segmentation, pixelID)
# transform pixels to registration space (the registered image and segmentation have different dimensions)
SegHeight = Segmentation.shape[0]
SegWidth = Segmentation.shape[1]
......@@ -166,8 +161,20 @@ def SegmentationToAtlasSpace(
# this calculates reg/seg
Yscale, Xscale = transformToRegistration(SegHeight, SegWidth, RegHeight, RegWidth)
# scale the seg coordinates to reg/seg
scaledY, scaledX = scalePositions(ID_pixels[0], ID_pixels[1], Yscale, Xscale)
if method in ["per_object", "all"]:
# this function returns the centroids, area and coordinates of all the objects in the segmentation
# right now we only use centroids
binary_seg = Segmentation == pixelID
binary_seg = np.all(binary_seg, axis=2)
centroids, area, coords = getCentroidsAndArea(binary_seg, pixelCutOff=0)
print("number of objects: ", len(centroids))
# print(centroids)
if method in ["per_pixel", "all"]:
ID_pixels = findMatchingPixels(Segmentation, pixelID)
# scale the seg coordinates to reg/seg
scaledY, scaledX = scalePositions(ID_pixels[0], ID_pixels[1], Yscale, Xscale)
if nonLinear:
if "markers" in slice:
# this creates a triangulation using the reg width
......
......@@ -53,11 +53,11 @@ class PyNutil:
startTime = datetime.now()
self.atlas_volume = readAtlasVolume(atlas_root_path + current_atlas_path)
time_taken = datetime.now() - startTime
print(f"atlas volume loaded in: {time_taken}")
print(f"atlas volume loaded in: {time_taken}")
atlas_label_path = self.config["annotation_volumes"][self.atlas]["labels"]
print("loading atlas labels")
self.atlas_labels = pd.read_csv(atlas_root_path + atlas_label_path)
print("atlas labels loaded")
print("atlas labels loaded")
def get_coordinates(self, nonLinear=True, method="all"):
if not hasattr(self, "atlas_volume"):
......@@ -90,7 +90,7 @@ class PyNutil:
self.label_df = PixelCountPerRegion(labeled_points, self.atlas_labels)
self.labeled_points = labeled_points
print("quantification complete")
print("quantification complete")
def save_analysis(self, output_folder):
if not hasattr(self, "pixel_points"):
......@@ -113,4 +113,4 @@ class PyNutil:
output_folder + "/pixels_meshview.json",
self.atlas_labels,
)
print("analysis saved")
print("analysis saved")
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