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

Add region name and colours to area reports

parent 5fd21f1f
No related branches found
No related tags found
No related merge requests found
Showing
with 45 additions and 13 deletions
......@@ -10,7 +10,7 @@ import json
from datetime import datetime
#import json, use to define input parameters
with open('../test/test1.json', 'r') as f:
with open('../test/test5_NOP_s037.json', 'r') as f:
input = json.load(f)
#print(input)
......
......@@ -7,7 +7,7 @@ import numpy as np
from read_and_write import FlattoArray, LabeltoArray
base= r"../test_data/ttA_2877_NOP_atlasmaps/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat"
base= r"../test_data/tTA_2877_NOP_s037_atlasmap/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat"
label = r"../annotation_volumes\allen2017_colours.csv"
image_arr = FlattoArray(base)
......@@ -33,18 +33,40 @@ area_per_label = list(zip(unique_ids,counts))
df_area_per_label = pd.DataFrame(area_per_label, columns=["idx","area_count"])
# create a pandas df with regions and pixel counts
print(df_area_per_label)
df_area_per_label.to_csv("../outputs/s037_area_per_idx.csv", sep=";", na_rep='', index= False)
"""add region name and colours corresponding to each idx into dataframe.
This could be a separate function"""
df_label_colours =pd.read_csv(label, sep=",")
# find colours corresponding to each region ID and add to the pandas dataframe
#look up name, r, g, b in df_allen_colours in df_area_per_label based on "idx"
new_rows = []
for index, row in df_area_per_label.iterrows():
mask = df_label_colours["idx"] == row["idx"]
current_region_row = df_label_colours[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
# Count area per unique label
# Scale up to size of corresponding segmentation
# calculate segmentation value per slice
# divide segmentation value per idx per slice by area per idx per slice
# output reports
# also do for whole brain
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)
#Also to do:
# fix position of clear label in label files
df_area_per_label_name = pd.DataFrame(new_rows)
print(df_area_per_label_name)
df_area_per_label_name.to_csv("../outputs/test5_s037_area_per_idx.csv", sep=";", na_rep='', index= False)
# Count area per unique label in one flat file - done.
# Scale up to size of corresponding segmentation/ or size of reference atlas if points are already scaled?
# divide "segmentation value per idx per slice" by "area per idx per slice"
# also do for whole brain - need to loop through and match up section with corresponding atlasmap
# output reports per brain and per slice
{ "volume_path": "../annotation_volumes/annotation_10_reoriented_2017.nrrd",
"label_path": "../annotation_volumes/allen2017_colours.csv",
"segmentation_folder": "../test_data/ttA_2877_NOP",
"segmentation_folder": "../test_data/ttA_2877_NOP_segmentations",
"alignment_json": "../test_data/ttA_2877_NOP_horizontal_final_2017.json",
"nonlinear": true,
"colour": [0, 0, 255],
......
{ "volume_path": "../annotation_volumes/annotation_10_reoriented_2017.nrrd",
"label_path": "../annotation_volumes/allen2017_colours.csv",
"segmentation_folder": "../test_data/ttA_2877_NOP_s037_seg",
"alignment_json": "../test_data/ttA_2877_NOP_horizontal_final_2017.json",
"nonlinear": true,
"colour": [0, 0, 255],
"points_json_path": "../outputs/test5_points.json",
"counts_per_label_name": "../outputs/test5_counts_per_allenID_2017.csv"
}
File added
test_data/tTA_2877_NOP_s037_seg/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png

273 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s001.png

311 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s004.png

285 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s007.png

305 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s013.png

268 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s016.png

325 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s019.png

254 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s022.png

291 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s025.png

232 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s028.png

303 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s031.png

299 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s034.png

298 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png

273 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s040.png

249 KiB

test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s043.png

252 KiB

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