diff --git a/PyNutil/folder_of_segmentations_to_meshview_multithreaded.py b/PyNutil/folder_of_segmentations_to_meshview_multithreaded.py index 9e5625dc19693537afdd6d5ce5f1062c0e35939f..f84c282ff8c22a4f954eb75c20cf76bf49eb5478 100644 --- a/PyNutil/folder_of_segmentations_to_meshview_multithreaded.py +++ b/PyNutil/folder_of_segmentations_to_meshview_multithreaded.py @@ -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) diff --git a/PyNutil/load_workflow.py b/PyNutil/load_workflow.py index 7b3b845eb3cfb3aa7b3624aa7270a160d1ba6c4f..140221a60febad3f149e33338bbe9829d28c97d0 100644 --- a/PyNutil/load_workflow.py +++ b/PyNutil/load_workflow.py @@ -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 diff --git a/test/test1.json b/test/test1.json index 59285f9a39419c1e183fc8f37a530153e7155d32..c8f58ec3c54cc8e5649e636deb7c52b2ae2cbd58 100644 --- a/test/test1.json +++ b/test/test1.json @@ -1,6 +1,6 @@ { "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], diff --git a/test/test5_NOP_s037.json b/test/test5_NOP_s037.json new file mode 100644 index 0000000000000000000000000000000000000000..76b2b27790a0c70c3c776bda8036fdbba014022b --- /dev/null +++ b/test/test5_NOP_s037.json @@ -0,0 +1,10 @@ +{ "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" +} + diff --git a/test_data/tTA_2877_NOP_s037_atlasmap/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat b/test_data/tTA_2877_NOP_s037_atlasmap/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat new file mode 100644 index 0000000000000000000000000000000000000000..032447fb2ee643e352a567b0a2d4ccd96a25da57 Binary files /dev/null and b/test_data/tTA_2877_NOP_s037_atlasmap/2877_NOP_tTA_lacZ_Xgal_s037_nl.flat differ diff --git a/test_data/tTA_2877_NOP_s037_seg/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png b/test_data/tTA_2877_NOP_s037_seg/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png new file mode 100644 index 0000000000000000000000000000000000000000..21492482967429d42e4bb5b941ba271020f0f179 Binary files /dev/null and b/test_data/tTA_2877_NOP_s037_seg/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s001.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s001.png new file mode 100644 index 0000000000000000000000000000000000000000..69ed078de15e071b1d3117b04db7bfe998174246 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s001.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s004.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s004.png new file mode 100644 index 0000000000000000000000000000000000000000..faf463c509484d2489432d4e7cb604630ce36583 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s004.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s007.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s007.png new file mode 100644 index 0000000000000000000000000000000000000000..a7a7adf076204f930a975134896617967e84d53b Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s007.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s013.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s013.png new file mode 100644 index 0000000000000000000000000000000000000000..72bf5e465c9ed3b688de3711460149bc7401b90f Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s013.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s016.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s016.png new file mode 100644 index 0000000000000000000000000000000000000000..eab2ab5ec00188cebf5acf4473535e93e893c387 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s016.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s019.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s019.png new file mode 100644 index 0000000000000000000000000000000000000000..03604cd642edf89eb433fe2e417024239fe897aa Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s019.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s022.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s022.png new file mode 100644 index 0000000000000000000000000000000000000000..665812f037474fef5de09e35bde3a09125566506 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s022.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s025.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s025.png new file mode 100644 index 0000000000000000000000000000000000000000..5b20b10412fa87e6c6c11a0106c544e79b2d3cf1 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s025.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s028.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s028.png new file mode 100644 index 0000000000000000000000000000000000000000..a472c108a47c3fb4b2634618d51607deae5eafdd Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s028.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s031.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s031.png new file mode 100644 index 0000000000000000000000000000000000000000..6b01dbb18b22eee7ec557b5ee3e7698c37c07816 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s031.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s034.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s034.png new file mode 100644 index 0000000000000000000000000000000000000000..363624d5913e7c02edf1e67726d780e742f997b5 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s034.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png new file mode 100644 index 0000000000000000000000000000000000000000..21492482967429d42e4bb5b941ba271020f0f179 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s037.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s040.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s040.png new file mode 100644 index 0000000000000000000000000000000000000000..d5a809dbb229e94aa1a09fef49375ad66993a822 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s040.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s043.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s043.png new file mode 100644 index 0000000000000000000000000000000000000000..36a377760f02343c1bfbed3c5523a83cfc8e05db Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s043.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s046.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s046.png new file mode 100644 index 0000000000000000000000000000000000000000..707101b7fc960a71811a81aaa0fb78b91b4a9052 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s046.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s049.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s049.png new file mode 100644 index 0000000000000000000000000000000000000000..e498d5dff523e11ef98ebaf449808228a2682c18 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s049.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s052.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s052.png new file mode 100644 index 0000000000000000000000000000000000000000..7b2ef43dae862c791b993a96a4eda84359b9e2c3 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s052.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s055.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s055.png new file mode 100644 index 0000000000000000000000000000000000000000..d99e13ce0489b9bb81b32563674893febc9b531e Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s055.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s058.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s058.png new file mode 100644 index 0000000000000000000000000000000000000000..62772416be1a227dd778b23ca12ce65edb2428ca Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s058.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s062.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s062.png new file mode 100644 index 0000000000000000000000000000000000000000..359522ca645982506dcfb2978b3ce7b7b921834b Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s062.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s065.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s065.png new file mode 100644 index 0000000000000000000000000000000000000000..c8613609781e517a915a11bbf09f46caaaaba31e Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s065.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s068.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s068.png new file mode 100644 index 0000000000000000000000000000000000000000..a92c30426c859d632afbe08be5cadba19d2d4182 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s068.png differ diff --git a/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s071.png b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s071.png new file mode 100644 index 0000000000000000000000000000000000000000..b14c0bd89ff09abc34eba596e320ee7c899fcc81 Binary files /dev/null and b/test_data/tTA_2877_NOP_segmentations/2877_NOP_tTA_lacZ_Xgal_resize_Simple_Seg_s071.png differ