def run_all_embryos(): for embryo in TRAIN_EMBRYOS.keys(): tiff = fm.get_tiff_file(embryo) rf = extract_region_with_cells(tiff) features = rf.extract_features() try: mc = Multiclusterer(features) labels_count = mc.count_labels() fm.save_results( labels_count, file_name="Labels_counts_multiclustering_emb{}".format(embryo), timestamped=True) mc.plot_results() except: try: features = features.drop('centroid_3D', axis=1) mc = Multiclusterer(features) labels_count = mc.count_labels() fm.save_results( labels_count, file_name="Labels_counts_multiclustering_emb{}".format( embryo), timestamped=True) except Exception as e: print(repr(e)) plt.show()
print("Data processing is now finished") print("I am ready to save the results.") file_name = input( '''Which file name do you want to use (press enter to use "classification_results") ?''' ) return file_name if __name__ == '__main__': logging.basicConfig(level=logging.INFO) print("Hello my friend,") # get a file from its embryo code #tiff = fm.get_tiff_file(EMBRYO) #get a file from path path = get_path_input() tiff = fm.get_tiff_file(path) # Extract a RegionFrame including all the regions 3D of the image rf = extract_region_with_cells(tiff, filter=100) # Extract features from the regions features = rf.extract_features() # Classify features using tail filtering, PCA and MeanShift f_label = classify(features) file_name = get_res_file_name() if file_name == "": file_name = "classification_results" save_results_classif(features, f_label, file_name=file_name) #Plot results viewer = MultiLayerViewer(tiff) viewer.plot_imgs(features=f_label) viewer.show()
"Embryo {} : {} points (final)".format( emb, len(f_data))) sns.distplot(mean_int, ax=ax[i][3]) # plot the threshold with a red cross if thresh is not None: ax[i][1].plot(thresh, 0, marker="x", color='r') ax[i][3].plot(thresh, 0, marker="x", color='r') i += 1 plt.tight_layout() plt.show() if __name__ == '__main__': dir = "features" files = fm.get_files(dir=dir) dataset = {} for file in files: emb = int(file.split('emb')[1].split('.')[0]) print(file) dataset[emb] = fm.get_data_from_file(file) break tiff = fm.get_tiff_file(emb) for ds in dataset.values(): f_label = classify(ds) viewer = MultiLayerViewer(tiff) viewer.plot_imgs(features=f_label) plt.show()
else: ax.imshow(image, cmap=cmap) if __name__ == '__main__': """FILE_NAME = "C10DsRedlessxYw_emb11_Center_Out.tif" PATH_TO_CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) PATH_TO_ROOT_DIR = os.path.normpath(os.path.join(PATH_TO_CURRENT_DIR, '..')) sys.path.append(PATH_TO_ROOT_DIR) DATA_PATH = os.path.join(PATH_TO_ROOT_DIR, 'data') EMB_PATH = os.path.join(DATA_PATH, 'embryos') file_path = os.path.join(EMB_PATH, FILE_NAME)""" emb = fm.get_tiff_file(8) ch1 = emb[:, :, :, 0] lbl_img = label_filter(ch1[0])[0] props = [ region_properties(label_image=label_filter(img, filter=100)[0], image=img, properties=[ 'extent', 'max_intensity', 'area', "mean_intensity", "bbox" ]) for img in ch1 ] viewer = MultiLayerViewer(emb, channel=0) viewer.plot_imgs(properties=props) plt.show() # display_file(file_path) """