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

Add region name and r, g, b to section reports

parent fb7e5679
No related branches found
No related tags found
No related merge requests found
...@@ -163,7 +163,7 @@ def flat_to_dataframe(flat_file, labelfile, rescaleXY=False): ...@@ -163,7 +163,7 @@ def flat_to_dataframe(flat_file, labelfile, rescaleXY=False):
area_per_label = list(zip(unique_ids, counts)) area_per_label = list(zip(unique_ids, counts))
# create a list of unique regions and pixel counts per region # create a list of unique regions and pixel counts per region
df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "area_count"]) df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "region_area"])
# create a pandas df with regions and pixel counts # create a pandas df with regions and pixel counts
return(df_area_per_label) return(df_area_per_label)
......
...@@ -226,12 +226,31 @@ class PyNutil: ...@@ -226,12 +226,31 @@ class PyNutil:
# create the df for section report and all report # create the df for section report and all report
# pixel_count_per_region returns a df with idx, pixel count, name and RGB. # pixel_count_per_region returns a df with idx, pixel count, name and RGB.
# ra is region area list # ra is region area list from
# merge current_df onto ra (region_areas_list) based on idx column # merge current_df onto ra (region_areas_list) based on idx column
#(left means use only keys from left frame, preserve key order) #(left means use only keys from left frame, preserve key order)
current_df = ra.merge(current_df, on='idx', how='left') current_df = ra.merge(current_df, on='idx', how='left')
new_rows = []
for index, row in current_df.iterrows():
mask = self.atlas_labels["idx"] == row["idx"]
current_region_row = self.atlas_labels[mask]
current_region_name = current_region_row["name"].values
current_region_red = current_region_row["r"].values
current_region_green = current_region_row["g"].values
current_region_blue = current_region_row["b"].values
row["name"] = current_region_name[0]
row["r"] = current_region_red[0]
row["g"] = current_region_green[0]
row["b"] = current_region_blue[0]
new_rows.append(row)
current_df_new = pd.DataFrame(new_rows)
##Sharon. I would guess you should add the rgb and name adding code here ##Sharon. I would guess you should add the rgb and name adding code here
per_section_df.append(current_df) per_section_df.append(current_df_new)
prev_pl += pl prev_pl += pl
prev_cl += cl prev_cl += cl
......
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