Mercurial > repos > imgteam > 2d_filter_segmentation_by_features
comparison 2d_filter_segmentation_by_features.py @ 1:6ad1d3cfdea1 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_filter_segmentation_by_features/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:10:21 +0000 |
parents | e576b73a2e2f |
children | 9d47aabda459 |
comparison
equal
deleted
inserted
replaced
0:e576b73a2e2f | 1:6ad1d3cfdea1 |
---|---|
1 import argparse | 1 import argparse |
2 import sys | 2 import sys |
3 import skimage.io | 3 |
4 import pandas as pd | |
5 import skimage.io | |
4 import skimage.util | 6 import skimage.util |
5 import pandas as pd | 7 |
6 | 8 |
7 if __name__ == "__main__": | 9 if __name__ == "__main__": |
8 parser = argparse.ArgumentParser(description='Filter segmentation by features') | 10 parser = argparse.ArgumentParser(description='Filter segmentation by features') |
9 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') | 11 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') |
10 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') | 12 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') |
13 args = parser.parse_args() | 15 args = parser.parse_args() |
14 | 16 |
15 img_in = skimage.io.imread(args.input_file.name) | 17 img_in = skimage.io.imread(args.input_file.name) |
16 features = pd.read_csv(args.feature_file, delimiter="\t") | 18 features = pd.read_csv(args.feature_file, delimiter="\t") |
17 rules = pd.read_csv(args.rule_file, delimiter="\t") | 19 rules = pd.read_csv(args.rule_file, delimiter="\t") |
18 | 20 |
19 cols = [a for a in rules.columns if not 'Unnamed' in a] | 21 cols = [a for a in rules.columns if 'Unnamed' not in a] |
20 for a_c in cols: | 22 for a_c in cols: |
21 a_min = rules[rules.ix[:, 0] == 'min'][a_c] | 23 a_min = rules[rules.ix[:, 0] == 'min'][a_c] |
22 a_max = rules[rules.ix[:, 0] == 'max'][a_c] | 24 a_max = rules[rules.ix[:, 0] == 'max'][a_c] |
23 for a_l in features.label: | 25 for a_l in features.label: |
24 a_val = float(features[features['label'] == a_l][a_c]) | 26 a_val = float(features[features['label'] == a_l][a_c]) |