nygctech / hudson

Pyseq 4i spatial pipeline
GNU General Public License v3.0
2 stars 2 forks source link

stats on cell segmentation ie total number of cells, avg/std of size #32

Closed krpandit closed 12 hours ago

SRodwin commented 12 hours ago

Added to segmentation.py diam = cellpose.utils.diameters(masks) std_diam = np.std(diam[1]) mean_diam = np.mean(diam[1])

smk_logger.info('Writing metrics to Summary') with open(snakemake.input[1], 'r') as file: data = yaml.safe_load(file)

data['segmentation'] = {} data['segmentation']['number_of_cells'] = int(diam[1].shape[0]) data['segmentation']['avergae_cell_size'] = round(float(mean_diam), 4) data['segmentation']['cell_size_standard_deviation'] = round(float(std_diam), 4)

with open(snakemake.input[1], 'w') as file: yaml.dump(data, file)