-
Notifications
You must be signed in to change notification settings - Fork 11
/
single_file_histogram.py
executable file
·34 lines (28 loc) · 1.43 KB
/
single_file_histogram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env python
"""Generate an area weighted histogram of a single feature from a single mesh from a single segmentation
Useful to get a sense of how your configuration for meshing and quantification looks. Also nice for responding to reviewer requests!
Usage: python single_file_histogram.py input_csv.csv -n featurename
"""
__author__ = "Benjamin Barad"
__email__ = "[email protected]"
__license__ = "GPLv3"
import os
import click
import pandas as pd
from morphometrics_stats import histogram, weighted_median
@click.command()
@click.argument('input', type=str)
@click.option('-n', '--featurename', type=str, required=True, default='curvedness_VV', help="Name of feature to extract")
def main(input, featurename):
"""Generate an area weighted histogram of a single feature from a single mesh from a single segmentation
Useful to get a sense of how your configuration for meshing and quantification looks. Also nice for responding to reviewer requests!
"""
df = pd.read_csv(input)
data = df[featurename].values
areas = df['area'].values
output_name = input[:-4] + '_' + featurename + '.svg'
print('Generating histogram for feature {}'.format(featurename))
print('Area Weighted Median: {}'.format(weighted_median(data, areas)))
histogram([data], [areas], [os.path.basename(input)[:-4]], os.path.basename(input)+ " "+ featurename, featurename, filename=output_name)
if __name__ == '__main__':
main()