Skip to content
Snippets Groups Projects
Commit a4f77df0 authored by Sharon Yates's avatar Sharon Yates
Browse files

Added area_fraction, cleaned up slice_report

There is an error in the combined_report (it sums the area_fraction).
parent 8ce710ca
No related branches found
No related tags found
No related merge requests found
...@@ -236,9 +236,28 @@ class PyNutil: ...@@ -236,9 +236,28 @@ class PyNutil:
current_df_new = current_df.merge(self.atlas_labels, on= 'idx', how='left') current_df_new = current_df.merge(self.atlas_labels, on= 'idx', how='left')
""" """
all_region_df = self.atlas_labels.merge(ra, on = 'idx', how='left') all_region_df = self.atlas_labels.merge(ra, on = 'idx', how='left')
current_df_new = all_region_df.merge(current_df, on= 'idx', how= 'left') current_df_new = all_region_df.merge(current_df, on= 'idx', how= 'left', suffixes= (None,"_y")).drop(columns=["a","VIS", "MSH", "name_y","r_y","g_y","b_y"])
current_df_new["area_fraction"] = current_df_new["pixel_count"] / current_df_new["region_area"]
"""
new_rows = []
for index, row in all_region_df.iterrows():
mask = current_df["idx"] == row ["idx"]
current_region_row = current_df[mask]
region_area = current_region_row["pixel_count"].values
object_count = current_region_row["object_count"].values
row["pixel_count"] = region_area[0]
row["object_count"] = object_count[0]
new_rows.append[row]
current_df_new = pd.DataFrame(new_rows)
"""
""" """
new_rows = [] new_rows = []
for index, row in current_df.iterrows(): for index, row in current_df.iterrows():
...@@ -258,13 +277,17 @@ class PyNutil: ...@@ -258,13 +277,17 @@ class PyNutil:
current_df_new = pd.DataFrame(new_rows)""" current_df_new = pd.DataFrame(new_rows)"""
#per_section_df.append(current_df_new)
per_section_df.append(current_df_new) per_section_df.append(current_df_new)
prev_pl += pl prev_pl += pl
prev_cl += cl prev_cl += cl
##Sharon. and then here you should group on r,g,b,idx, and name since you dont want any of these summed ##Sharon. and then here you should group on r,g,b,idx, and name since you dont want any of these summed
self.label_df = pd.concat(per_section_df).groupby(['idx']).sum().reset_index() #Currently, it takes sum of area_fraction. This is incorrect.
self.label_df = pd.concat(per_section_df).groupby(['idx','name','r','g','b']).sum().reset_index()
#self.label_df = pd.concat(per_section_df).groupby(['idx','name','r','g','b']).sum().reset_index()
self.labeled_points = labeled_points self.labeled_points = labeled_points
self.labeled_points_centroids = labeled_points_centroids self.labeled_points_centroids = labeled_points_centroids
self.per_section_df = per_section_df self.per_section_df = per_section_df
......
...@@ -9,3 +9,6 @@ pnt.get_coordinates(object_cutoff=0) ...@@ -9,3 +9,6 @@ pnt.get_coordinates(object_cutoff=0)
pnt.quantify_coordinates() pnt.quantify_coordinates()
pnt.save_analysis("outputs/test8_PyNutil") pnt.save_analysis("outputs/test8_PyNutil")
# remove name, r, g, b, from pixel_
# add to region_areas df
\ No newline at end of file
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