diff --git a/PyNutil/coordinate_extraction.py b/PyNutil/coordinate_extraction.py index f218125eb2490c8902cea25d7a2dca0b47b9f7c9..5a7b98978f8c23787d004445e5ecdfc9de59c3d7 100644 --- a/PyNutil/coordinate_extraction.py +++ b/PyNutil/coordinate_extraction.py @@ -2,8 +2,8 @@ import numpy as np import pandas as pd from DeepSlice.coord_post_processing.spacing_and_indexing import number_sections import json -from .read_and_write import loadVisuAlignJson -from .counting_and_load import labelPoints +from .read_and_write import load_visualign_json +from .counting_and_load import label_points from .visualign_deformations import triangulate, transform_vec from glob import glob from tqdm import tqdm @@ -13,181 +13,187 @@ import threading # related to coordinate_extraction -def getCentroidsAndArea(Segmentation, pixelCutOff=0): - """this function returns the center coordinate of each object in the segmentation. - You can set a pixelCutOff to remove objects that are smaller than that number of pixels +def get_centroids_and_area(segmentation, pixel_cut_off=0): + """This function returns the center coordinate of each object in the segmentation. + You can set a pixel_cut_off to remove objects that are smaller than that number of pixels. """ - # SegmentationBinary = ~np.all(Segmentation == 255, axis=2) - labels = measure.label(Segmentation) - # this finds all the objects in the image - labelsInfo = measure.regionprops(labels) - # remove objects that are less than pixelCutOff - labelsInfo = [label for label in labelsInfo if label.area > pixelCutOff] - # get the centre points of the objects - centroids = np.array([label.centroid for label in labelsInfo]) - # get the area of the objects - area = np.array([label.area for label in labelsInfo]) - # get the coordinates for all the pixels in each object - coords = np.array([label.coords for label in labelsInfo], dtype=object) + labels = measure.label(segmentation) + # This finds all the objects in the image + labels_info = measure.regionprops(labels) + # Remove objects that are less than pixel_cut_off + labels_info = [label for label in labels_info if label.area > pixel_cut_off] + # Get the centre points of the objects + centroids = np.array([label.centroid for label in labels_info]) + # Get the area of the objects + area = np.array([label.area for label in labels_info]) + # Get the coordinates for all the pixels in each object + coords = np.array([label.coords for label in labels_info], dtype=object) return centroids, area, coords # related to coordinate extraction -def transformToRegistration(SegHeight, SegWidth, RegHeight, RegWidth): - """this function returns the scaling factors to transform the segmentation to the registration space""" - Yscale = RegHeight / SegHeight - Xscale = RegWidth / SegWidth - return Yscale, Xscale +def transform_to_registration(seg_height, seg_width, reg_height, reg_width): + """This function returns the scaling factors to transform the segmentation to the registration space.""" + y_scale = reg_height / seg_height + x_scale = reg_width / seg_width + return y_scale, x_scale # related to coordinate extraction -def findMatchingPixels(Segmentation, id): - """this function returns the Y and X coordinates of all the pixels in the segmentation that match the id provided""" - mask = Segmentation == id +def find_matching_pixels(segmentation, id): + """This function returns the Y and X coordinates of all the pixels in the segmentation that match the id provided.""" + mask = segmentation == id mask = np.all(mask, axis=2) id_positions = np.where(mask) - idY, idX = id_positions[0], id_positions[1] - return idY, idX + id_y, id_x = id_positions[0], id_positions[1] + return id_y, id_x # related to coordinate extraction -def scalePositions(idY, idX, Yscale, Xscale): - """this function scales the Y and X coordinates to the registration space. - (the Yscale and Xscale are the output of transformToRegistration)""" - idY = idY * Yscale - idX = idX * Xscale - return idY, idX +def scale_positions(id_y, id_x, y_scale, x_scale): + """This function scales the Y and X coordinates to the registration space. + (The y_scale and x_scale are the output of transform_to_registration.) + """ + id_y = id_y * y_scale + id_x = id_x * x_scale + return id_y, id_x # related to coordinate extraction -def transformToAtlasSpace(anchoring, Y, X, RegHeight, RegWidth): - """transform to atlas space using the QuickNII anchoring vector""" - O = anchoring[0:3] - U = anchoring[3:6] - # swap order of U - U = np.array([U[0], U[1], U[2]]) - V = anchoring[6:9] - # swap order of V - V = np.array([V[0], V[1], V[2]]) - # scale X and Y to between 0 and 1 using the registration width and height - Yscale = Y / RegHeight - Xscale = X / RegWidth - # print("width: ", RegWidth, " height: ", RegHeight, " Xmax: ", np.max(X), " Ymax: ", np.max(Y), " Xscale: ", np.max(Xscale), " Yscale: ", np.max(Yscale)) - XYZV = np.array([Yscale * V[0], Yscale * V[1], Yscale * V[2]]) - XYZU = np.array([Xscale * U[0], Xscale * U[1], Xscale * U[2]]) - O = np.reshape(O, (3, 1)) - return (O + XYZU + XYZV).T +def transform_to_atlas_space(anchoring, y, x, reg_height, reg_width): + """Transform to atlas space using the QuickNII anchoring vector.""" + o = anchoring[0:3] + u = anchoring[3:6] + # Swap order of U + u = np.array([u[0], u[1], u[2]]) + v = anchoring[6:9] + # Swap order of V + v = np.array([v[0], v[1], v[2]]) + # Scale X and Y to between 0 and 1 using the registration width and height + y_scale = y / reg_height + x_scale = x / reg_width + # print("width: ", reg_width, " height: ", reg_height, " Xmax: ", np.max(x), " Ymax: ", np.max(y), " Xscale: ", np.max(x_scale), " Yscale: ", np.max(y_scale)) + xyz_v = np.array([y_scale * v[0], y_scale * v[1], y_scale * v[2]]) + xyz_u = np.array([x_scale * u[0], x_scale * u[1], x_scale * u[2]]) + o = np.reshape(o, (3, 1)) + return (o + xyz_u + xyz_v).T # points.append would make list of lists, keeping sections separate. # related to coordinate extraction -# this function returns an array of points -def FolderToAtlasSpace( - folder, QUINT_alignment, pixelID=[0, 0, 0], nonLinear=True, method="all" +# This function returns an array of points +def folder_to_atlas_space( + folder, quint_alignment, pixel_id=[0, 0, 0], non_linear=True, method="all" ): - "apply Segmentation to atlas space to all segmentations in a folder" + """Apply Segmentation to atlas space to all segmentations in a folder.""" - # this should be loaded above and passed as an argument - slices = loadVisuAlignJson(QUINT_alignment) + # This should be loaded above and passed as an argument + slices = load_visualign_json(quint_alignment) - segmentationFileTypes = [".png", ".tif", ".tiff", ".jpg", ".jpeg"] - Segmentations = [ + segmentation_file_types = [".png", ".tif", ".tiff", ".jpg", ".jpeg"] + segmentations = [ file for file in glob(folder + "/*") - if any([file.endswith(type) for type in segmentationFileTypes]) + if any([file.endswith(type) for type in segmentation_file_types]) ] - # order segmentations and sectionNumbers - # Segmentations = [x for _,x in sorted(zip(SectionNumbers,Segmentations))] - # SectionNumbers.sort() - pointsList = [None] * len(Segmentations) + # Order segmentations and section_numbers + # segmentations = [x for _,x in sorted(zip(section_numbers,segmentations))] + # section_numbers.sort() + points_list = [None] * len(segmentations) threads = [] - for SegmentationPath, index in zip(Segmentations, range(len(Segmentations))): - seg_nr = int(number_sections([SegmentationPath])[0]) + for segmentation_path, index in zip(segmentations, range(len(segmentations))): + seg_nr = int(number_sections([segmentation_path])[0]) current_slice_index = np.where([s["nr"] == seg_nr for s in slices]) current_slice = slices[current_slice_index[0][0]] x = threading.Thread( - target=SegmentationToAtlasSpace, + target=segmentation_to_atlas_space, args=( current_slice, - SegmentationPath, - pixelID, - nonLinear, - pointsList, + segmentation_path, + pixel_id, + non_linear, + points_list, index, method, ), ) threads.append(x) - ##this converts the segmentation to a point cloud - # start threads + ## This converts the segmentation to a point cloud + # Start threads [t.start() for t in threads] - # wait for threads to finish + # Wait for threads to finish [t.join() for t in threads] - # flatten pointsList - points = [item for sublist in pointsList for item in sublist] + # Flatten points_list + points = [item for sublist in points_list for item in sublist] return np.array(points) # related to coordinate extraction -# this function returns an array of points -def SegmentationToAtlasSpace( +# This function returns an array of points +def segmentation_to_atlas_space( slice, - SegmentationPath, - pixelID="auto", - nonLinear=True, - pointsList=None, + segmentation_path, + pixel_id="auto", + non_linear=True, + points_list=None, index=None, method="per_pixel", ): - """combines many functions to convert a segmentation to atlas space. It takes care - of deformations""" - Segmentation = cv2.imread(SegmentationPath) - if pixelID == "auto": - # remove the background from the segmentation - SegmentationNoBackGround = Segmentation[~np.all(Segmentation == 255, axis=2)] - pixelID = np.vstack( - {tuple(r) for r in SegmentationNoBackGround.reshape(-1, 3)} - ) # remove background - # currently only works for a single label - pixelID = pixelID[0] - - # transform pixels to registration space (the registered image and segmentation have different dimensions) - SegHeight = Segmentation.shape[0] - SegWidth = Segmentation.shape[1] - RegHeight = slice["height"] - RegWidth = slice["width"] - # this calculates reg/seg - Yscale, Xscale = transformToRegistration(SegHeight, SegWidth, RegHeight, RegWidth) + """Combines many functions to convert a segmentation to atlas space. It takes care + of deformations.""" + segmentation = cv2.imread(segmentation_path) + if pixel_id == "auto": + # Remove the background from the segmentation + segmentation_no_background = segmentation[~np.all(segmentation == 255, axis=2)] + pixel_id = np.vstack( + {tuple(r) for r in segmentation_no_background.reshape(-1, 3)} + ) # Remove background + # Currently only works for a single label + pixel_id = pixel_id[0] + + # Transform pixels to registration space (the registered image and segmentation have different dimensions) + seg_height = segmentation.shape[0] + seg_width = segmentation.shape[1] + reg_height = slice["height"] + reg_width = slice["width"] + # This calculates reg/seg + y_scale, x_scale = transform_to_registration( + seg_height, seg_width, reg_height, reg_width + ) if method in ["per_object", "all"]: - # this function returns the centroids, area and coordinates of all the objects in the segmentation - # right now we only use centroids - binary_seg = Segmentation == pixelID + # This function returns the centroids, area and coordinates of all the objects in the segmentation + # Right now we only use centroids + binary_seg = segmentation == pixel_id binary_seg = np.all(binary_seg, axis=2) - centroids, area, coords = getCentroidsAndArea(binary_seg, pixelCutOff=0) - print("number of objects: ", len(centroids)) + centroids, area, coords = get_centroids_and_area(binary_seg, pixel_cut_off=0) + print("Number of objects: ", len(centroids)) # print(centroids) if method in ["per_pixel", "all"]: - ID_pixels = findMatchingPixels(Segmentation, pixelID) - # scale the seg coordinates to reg/seg - scaledY, scaledX = scalePositions(ID_pixels[0], ID_pixels[1], Yscale, Xscale) + id_pixels = find_matching_pixels(segmentation, pixel_id) + # Scale the seg coordinates to reg/seg + scaled_y, scaled_x = scale_positions( + id_pixels[0], id_pixels[1], y_scale, x_scale + ) - if nonLinear: + if non_linear: if "markers" in slice: - # this creates a triangulation using the reg width - triangulation = triangulate(RegWidth, RegHeight, slice["markers"]) - newX, newY = transform_vec(triangulation, scaledX, scaledY) + # This creates a triangulation using the reg width + triangulation = triangulate(reg_width, reg_height, slice["markers"]) + new_x, new_y = transform_vec(triangulation, scaled_x, scaled_y) else: print( - f"no markers found for {slice['filename']}, result for section will be linear" + f"No markers found for {slice['filename']}, result for section will be linear." ) - newX, newY = scaledX, scaledY + new_x, new_y = scaled_x, scaled_y else: - newX, newY = scaledX, scaledY - # scale U by Uxyz/RegWidth and V by Vxyz/RegHeight - points = transformToAtlasSpace(slice["anchoring"], newY, newX, RegHeight, RegWidth) + new_x, new_y = scaled_x, scaled_y + # Scale U by Uxyz/RegWidth and V by Vxyz/RegHeight + points = transform_to_atlas_space( + slice["anchoring"], new_y, new_x, reg_height, reg_width + ) # points = points.reshape(-1) - pointsList[index] = np.array(points) + points_list[index] = np.array(points) diff --git a/PyNutil/counting_and_load.py b/PyNutil/counting_and_load.py index d33bc04a599a4645210018a6f1f7bd5220d6bbcb..b31daa8795c342b68c60c062e453204de747451c 100644 --- a/PyNutil/counting_and_load.py +++ b/PyNutil/counting_and_load.py @@ -4,40 +4,40 @@ import struct # related to counting and load -def labelPoints(points, label_volume, scale_factor=1): - """this function takes a list of points and assigns them to a region based on the regionVolume. - These regions will just be the values in the regionVolume at the points. - it returns a dictionary with the region as the key and the points as the value""" - # first convert the points to 3 columns +def label_points(points, label_volume, scale_factor=1): + """This function takes a list of points and assigns them to a region based on the region_volume. + These regions will just be the values in the region_volume at the points. + It returns a dictionary with the region as the key and the points as the value.""" + # First convert the points to 3 columns points = np.reshape(points, (-1, 3)) - # scale the points + # Scale the points points = points * scale_factor - # round the points to the nearest whole number + # Round the points to the nearest whole number points = np.round(points).astype(int) x = points[:, 0] y = points[:, 1] z = points[:, 2] - # get the label value for each point + # Get the label value for each point labels = label_volume[x, y, z] return labels # related to counting_and_load -def PixelCountPerRegion(labelsDict, df_label_colours): +def pixel_count_per_region(labels_dict, df_label_colours): """Function for counting no. of pixels per region and writing to CSV based on - a dictionary with the region as the key and the points as the value,""" - counted_labels, label_counts = np.unique(labelsDict, return_counts=True) - # which regions have pixels, and how many pixels are there per region + a dictionary with the region as the key and the points as the value.""" + counted_labels, label_counts = np.unique(labels_dict, return_counts=True) + # Which regions have pixels, and how many pixels are there per region counts_per_label = list(zip(counted_labels, label_counts)) - # create a list of unique regions and pixel counts per region + # Create a list of unique regions and pixel counts per region df_counts_per_label = pd.DataFrame(counts_per_label, columns=["idx", "pixel_count"]) - # create a pandas df with regions and pixel counts + # Create a pandas df with regions and pixel counts # df_label_colours = pd.read_csv(label_colours, sep=",") - # find colours corresponding to each region ID and add to the pandas dataframe + # 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_counts_per_label based on "idx" + # Look up name, r, g, b in df_allen_colours in df_counts_per_label based on "idx" new_rows = [] for index, row in df_counts_per_label.iterrows(): mask = df_label_colours["idx"] == row["idx"] @@ -58,32 +58,32 @@ def PixelCountPerRegion(labelsDict, df_label_colours): return df_counts_per_label_name -"""read flat file and write into an np array""" +"""Read flat file and write into an np array""" -def flat_to_array(flatfile): - with open(flatfile, "rb") as f: - # i dont know what b is, w and h are the width and height that we get from the +def flat_to_array(flat_file): + 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 b, w, h = struct.unpack(">BII", f.read(9)) - # data is a one dimensional list of values - # it has the shape width times height + # Data is a one dimensional list of values + # It has the shape width times height data = struct.unpack(">" + ("xBH"[b] * (w * h)), f.read(b * w * h)) - # convert flat file data into an array, previously data was a tuple - imagedata = np.array(data) + # Convert flat file data into an array, previously data was a tuple + image_data = np.array(data) - # create an empty image array in the right shape, write imagedata into image_array + # Create an empty image array in the right shape, write image_data into image_array image = np.zeros((h, w)) for x in range(w): for y in range(h): - image[y, x] = imagedata[x + y * w] + image[y, x] = image_data[x + y * w] image_arr = np.array(image) return image_arr -# import flat files, count pixels per label, np.unique... etc. nitrc.org/plugins/mwiki/index.php?title=visualign:Deformation +# Import flat files, count pixels per label, np.unique... etc. nitrc.org/plugins/mwiki/index.php?title=visualign:Deformation """ base=slice["filename"][:-4] @@ -92,4 +92,4 @@ def flat_to_array(flatfile): with open(base+".flat","rb") as f: b,w,h=struct.unpack(">BII",f.read(9)) data=struct.unpack(">"+("xBH"[b]*(w*h)),f.read(b*w*h)) -""" +""" \ No newline at end of file diff --git a/PyNutil/main.py b/PyNutil/main.py index 02568fa56f73a8e9dc9464114f16e8c00829c6e5..b5a8a82039d1ccb95ce0b03891e6f1c90b3e8460 100644 --- a/PyNutil/main.py +++ b/PyNutil/main.py @@ -1,11 +1,12 @@ from .metadata import metadata_loader -from .read_and_write import readAtlasVolume, WritePointsToMeshview -from .coordinate_extraction import FolderToAtlasSpace -from .counting_and_load import labelPoints, PixelCountPerRegion +from .read_and_write import read_atlas_volume, write_points_to_meshview +from .coordinate_extraction import folder_to_atlas_space +from .counting_and_load import label_points, pixel_count_per_region import json import pandas as pd from datetime import datetime + class PyNutil: def __init__( self, @@ -50,9 +51,9 @@ class PyNutil: atlas_root_path = self.config["annotation_volume_directory"] current_atlas_path = self.config["annotation_volumes"][self.atlas]["volume"] print("loading atlas volume") - startTime = datetime.now() - atlas_volume = readAtlasVolume(atlas_root_path + current_atlas_path) - time_taken = datetime.now() - startTime + start_time = datetime.now() + atlas_volume = read_atlas_volume(atlas_root_path + current_atlas_path) + time_taken = datetime.now() - start_time print(f"atlas volume loaded in: {time_taken} ✅") atlas_label_path = self.config["annotation_volumes"][self.atlas]["labels"] print("loading atlas labels") @@ -60,7 +61,7 @@ class PyNutil: print("atlas labels loaded ✅") return atlas_volume, atlas_labels - def get_coordinates(self, nonLinear=True, method="all"): + def get_coordinates(self, non_linear=True, method="all"): if not hasattr(self, "atlas_volume"): raise ValueError( "Please run build_quantifier before running get_coordinates" @@ -70,15 +71,15 @@ class PyNutil: f"method {method} not recognised, valid methods are: per_pixel, per_object, or all" ) print("extracting coordinates") - pixel_points = self.extract_coordinates(nonLinear, method) + pixel_points = self.extract_coordinates(non_linear, method) self.pixel_points = pixel_points - def extract_coordinates(self, nonLinear, method): - return FolderToAtlasSpace( + def extract_coordinates(self, non_linear, method): + return folder_to_atlas_space( self.segmentation_folder, self.alignment_json, - pixelID=self.colour, - nonLinear=nonLinear, + pixel_id=self.colour, + non_linear=non_linear, method=method, ) @@ -95,10 +96,10 @@ class PyNutil: print("quantification complete ✅") def label_points(self): - return labelPoints(self.pixel_points, self.atlas_volume, scale_factor=2.5) + return label_points(self.pixel_points, self.atlas_volume, scale_factor=1) def count_pixels_per_region(self, labeled_points): - return PixelCountPerRegion(labeled_points, self.atlas_labels) + return pixel_count_per_region(labeled_points, self.atlas_labels) def save_analysis(self, output_folder): if not hasattr(self, "pixel_points"): @@ -119,9 +120,9 @@ class PyNutil: print("analysis saved ✅") def write_points_to_meshview(self, output_folder): - WritePointsToMeshview( + write_points_to_meshview( self.pixel_points, self.labeled_points, output_folder + "/pixels_meshview.json", self.atlas_labels, - ) + ) \ No newline at end of file diff --git a/PyNutil/oop_example.py b/PyNutil/oop_example.py index 4bdc2eeeb6103dda97c86eea54283522dd6b13ea..80e6b963b259cb120ad7e7a0862062fc61362374 100644 --- a/PyNutil/oop_example.py +++ b/PyNutil/oop_example.py @@ -1,14 +1,7 @@ class Demo: - def __init__(self, test): - self.test = test - - def print_test(self): - print(self.test) - self.output = 'success' - - - - - - - \ No newline at end of file + def __init__(self, test): + self.test = test + + def print_test(self): + print(self.test) + self.output = "success" diff --git a/PyNutil/read_and_write.py b/PyNutil/read_and_write.py index 9e1849061cf376fdc8130c6547acef6a0812ffb7..8de8ce0899ff9f5ded2030804bd378c22870d432 100644 --- a/PyNutil/read_and_write.py +++ b/PyNutil/read_and_write.py @@ -9,58 +9,58 @@ import nrrd # related to read and write # this function reads a VisuAlign JSON and returns the slices -def loadVisuAlignJson(filename): +def load_visualign_json(filename): with open(filename) as f: vafile = json.load(f) slices = vafile["slices"] return slices -# related to read_and_write, used in WritePointsToMeshview +# related to read_and_write, used in write_points_to_meshview # this function returns a dictionary of region names -def createRegionDict(points, regions): +def create_region_dict(points, regions): """points is a list of points and regions is an id for each point""" - regionDict = { + region_dict = { region: points[regions == region].flatten().tolist() for region in np.unique(regions) } - return regionDict + return region_dict -# related to read and write: WritePoints +# related to read and write: write_points # this function writes the region dictionary to a meshview json -def WritePoints(pointsDict, filename, infoFile): +def write_points(points_dict, filename, info_file): meshview = [ { "idx": idx, - "count": len(pointsDict[name]) // 3, - "name": str(infoFile["name"].values[infoFile["idx"] == name][0]), - "triplets": pointsDict[name], - "r": str(infoFile["r"].values[infoFile["idx"] == name][0]), - "g": str(infoFile["g"].values[infoFile["idx"] == name][0]), - "b": str(infoFile["b"].values[infoFile["idx"] == name][0]), + "count": len(points_dict[name]) // 3, + "name": str(info_file["name"].values[info_file["idx"] == name][0]), + "triplets": points_dict[name], + "r": str(info_file["r"].values[info_file["idx"] == name][0]), + "g": str(info_file["g"].values[info_file["idx"] == name][0]), + "b": str(info_file["b"].values[info_file["idx"] == name][0]), } - for name, idx in zip(pointsDict.keys(), range(len(pointsDict.keys()))) + for name, idx in zip(points_dict.keys(), range(len(points_dict.keys()))) ] # write meshview json with open(filename, "w") as f: json.dump(meshview, f) -# related to read and write: WritePointsToMeshview -# this function combines createRegionDict and WritePoints functions -def WritePointsToMeshview(points, pointNames, filename, infoFile): - regionDict = createRegionDict(points, pointNames) - WritePoints(regionDict, filename, infoFile) +# related to read and write: write_points_to_meshview +# this function combines create_region_dict and write_points functions +def write_points_to_meshview(points, point_names, filename, info_file): + region_dict = create_region_dict(points, point_names) + write_points(region_dict, filename, info_file) # I think this might not need to be its own function :) -def SaveDataframeasCSV(df_to_save, output_csv): +def save_dataframe_as_csv(df_to_save, output_csv): """Function for saving a df as a CSV file""" df_to_save.to_csv(output_csv, sep=";", na_rep="", index=False) -def FlattoArray(flatfile): +def flat_to_array(flatfile): """Read flat file and write into an np array, return array""" with open(flatfile, "rb") as f: # i dont know what b is, w and h are the width and height that we get from the @@ -83,7 +83,7 @@ def FlattoArray(flatfile): return image_arr -def LabeltoArray(label_path, image_array): +def label_to_array(label_path, image_array): """assign label file values into image array, return array""" labelfile = pd.read_csv(label_path) allen_id_image = np.zeros((h, w)) # create an empty image array @@ -96,7 +96,7 @@ def LabeltoArray(label_path, image_array): return allen_id_image -def FilesinDirectory(directory): +def files_in_directory(directory): """return list of flat file names in a directory""" list_of_files = [] for file in os.scandir(directory): @@ -110,6 +110,6 @@ def FilesinDirectory(directory): return list_of_files -def readAtlasVolume(atlas_volume_path): +def read_atlas_volume(atlas_volume_path): data, header = nrrd.read(atlas_volume_path) - return data + return data \ No newline at end of file diff --git a/PyNutil/testing_openflatfile.py b/PyNutil/testing_openflatfile.py index e6e630ef96dd4081959f006f620c895d71bde5ed..cad94888fa88e025bc7c7ed192e1ed1d0f6c0493 100644 --- a/PyNutil/testing_openflatfile.py +++ b/PyNutil/testing_openflatfile.py @@ -29,10 +29,10 @@ with open(base, "rb") as f: image_arr = np.array(image) print(image_arr.shape) - image_arr = cv2.resize(image_arr,(9848,12784),interpolation=cv2.INTER_NEAREST) + image_arr = cv2.resize(image_arr, (9848, 12784), interpolation=cv2.INTER_NEAREST) print(image_arr.shape) - val,count = np.unique(image_arr, return_counts=True) - print(list(zip(val,count))) + val, count = np.unique(image_arr, return_counts=True) + print(list(zip(val, count))) # show image with plt.imshow(image_arr) diff --git a/testOOP.py b/testOOP.py index 235481d020f2140b797aae05b52dac15ecbc0e10..617dcf7c6cc809fc4beab7192dce593735a9604f 100644 --- a/testOOP.py +++ b/testOOP.py @@ -1,10 +1,10 @@ from PyNutil import PyNutil -pnt = PyNutil(settings_file=r"test/test5_NOP_s037.json") +pnt = PyNutil(settings_file=r"test/test4_2017.json") # pnt.build_quantifier() pnt.get_coordinates() pnt.quantify_coordinates() -pnt.save_analysis("outputs/test5_NOP_25") +pnt.save_analysis("outputs/test4_2017")