diff --git a/PyNutil/coordinate_extraction.py b/PyNutil/coordinate_extraction.py index 5df3143f50ea3c8bf9a377e265fe9820b8879ba6..b6740dd44f562c9a81945a0017b752424c8a52ae 100644 --- a/PyNutil/coordinate_extraction.py +++ b/PyNutil/coordinate_extraction.py @@ -93,7 +93,7 @@ def folder_to_atlas_space( object_cutoff=0, ): """Apply Segmentation to atlas space to all segmentations in a folder.""" - + """Return pixel_points, centroids, points_len, centroids_len, segmentation_filenames, """ # This should be loaded above and passed as an argument slices = load_visualign_json(quint_alignment) diff --git a/PyNutil/counting_and_load.py b/PyNutil/counting_and_load.py index 7f620120f3008a402a40d9fff337e32d96e48b7c..b5faacade63770b7f818d6c181d1ef03cf1bffbc 100644 --- a/PyNutil/counting_and_load.py +++ b/PyNutil/counting_and_load.py @@ -117,7 +117,7 @@ def pixel_count_per_region( """Read flat file and write into an np array""" """Read flat file, write into an np array, assign label file values, return array""" -def flat_to_array(flat_file, labelfile): +def flat_to_dataframe(flat_file, labelfile): with open(flat_file, "rb") as f: # I don't know what b is, w and h are the width and height that we get from the # flat file header @@ -145,9 +145,9 @@ def flat_to_array(flat_file, labelfile): values = image_arr[coordsx, coordsy] # assign x,y coords from image_array into values lbidx = labelfile["idx"].values allen_id_image = lbidx[values.astype(int)] - return allen_id_image + #return allen_id_image -#def count_per_uniqueidx() + #def count_per_uniqueidx() """count pixels for unique idx""" unique_ids, counts = np.unique(allen_id_image, return_counts=True) diff --git a/PyNutil/load_workflow.py b/PyNutil/load_workflow.py index ca271c976ae2ae5d0bf5a29ba0b7bb9fe589e994..c99fd13a3be3e58d6f4356a072d55191400d4e1d 100644 --- a/PyNutil/load_workflow.py +++ b/PyNutil/load_workflow.py @@ -6,27 +6,27 @@ import pandas as pd import numpy as np #from read_and_write import flat_to_array, label_to_array -from counting_and_load import flat_to_array +from counting_and_load import flat_to_dataframe 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 = flat_to_array(base, label) -plt.imshow(flat_to_array(base, label)) +#plt.imshow(flat_to_array(base, label)) +df_area_per_label = flat_to_dataframe(base, label) """count pixels in np array for unique idx, return pd df""" -unique_ids, counts = np.unique(allen_id_image, return_counts=True) +#unique_ids, counts = np.unique(allen_id_image, return_counts=True) -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 -df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "area_count"]) +#df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "area_count"]) # create a pandas df with regions and pixel counts - """add region name and colours corresponding to each idx into dataframe. This could be a separate function"""