Mercurial > repos > imgteam > 2d_feature_extraction
annotate 2d_feature_extraction.py @ 5:2436a8807ad1 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
author | imgteam |
---|---|
date | Thu, 04 Apr 2024 15:23:23 +0000 |
parents | 0a53256b48c6 |
children | 5bc8cdc17fd0 |
rev | line source |
---|---|
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
1 import argparse |
4
0a53256b48c6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit 6b687746bdb3d5d1fb11ecffd6dd1bf42dc2c38d
imgteam
parents:
3
diff
changeset
|
2 |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
3 import numpy as np |
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
4 import pandas as pd |
4
0a53256b48c6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit 6b687746bdb3d5d1fb11ecffd6dd1bf42dc2c38d
imgteam
parents:
3
diff
changeset
|
5 import skimage.feature |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
6 import skimage.io |
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
7 import skimage.measure |
4
0a53256b48c6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit 6b687746bdb3d5d1fb11ecffd6dd1bf42dc2c38d
imgteam
parents:
3
diff
changeset
|
8 import skimage.morphology |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
9 import skimage.segmentation |
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
10 |
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
11 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
12 if __name__ == '__main__': |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
13 |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
14 parser = argparse.ArgumentParser(description='Extract image features') |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
15 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
16 # TODO create factory for boilerplate code |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
17 features = parser.add_argument_group('compute features') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
18 features.add_argument('--all', dest='all_features', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
19 features.add_argument('--label', dest='add_label', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
20 features.add_argument('--patches', dest='add_roi_patches', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
21 features.add_argument('--max_intensity', dest='max_intensity', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
22 features.add_argument('--mean_intensity', dest='mean_intensity', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
23 features.add_argument('--min_intensity', dest='min_intensity', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
24 features.add_argument('--moments_hu', dest='moments_hu', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
25 features.add_argument('--centroid', dest='centroid', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
26 features.add_argument('--bbox', dest='bbox', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
27 features.add_argument('--area', dest='area', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
28 features.add_argument('--filled_area', dest='filled_area', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
29 features.add_argument('--convex_area', dest='convex_area', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
30 features.add_argument('--perimeter', dest='perimeter', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
31 features.add_argument('--extent', dest='extent', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
32 features.add_argument('--eccentricity', dest='eccentricity', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
33 features.add_argument('--equivalent_diameter', dest='equivalent_diameter', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
34 features.add_argument('--euler_number', dest='euler_number', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
35 features.add_argument('--inertia_tensor_eigvals', dest='inertia_tensor_eigvals', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
36 features.add_argument('--major_axis_length', dest='major_axis_length', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
37 features.add_argument('--minor_axis_length', dest='minor_axis_length', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
38 features.add_argument('--orientation', dest='orientation', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
39 features.add_argument('--solidity', dest='solidity', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
40 features.add_argument('--moments', dest='moments', action='store_true') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
41 features.add_argument('--convexity', dest='convexity', action='store_true') |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
42 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
43 parser.add_argument('--label_file_binary', dest='label_file_binary', action='store_true') |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
44 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
45 parser.add_argument('--raw', dest='raw_file', type=argparse.FileType('r'), |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
46 help='Original input file', required=False) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
47 parser.add_argument('label_file', type=argparse.FileType('r'), |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
48 help='Label input file') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
49 parser.add_argument('output_file', type=argparse.FileType('w'), |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
50 help='Tabular output file') |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
51 args = parser.parse_args() |
4
0a53256b48c6
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit 6b687746bdb3d5d1fb11ecffd6dd1bf42dc2c38d
imgteam
parents:
3
diff
changeset
|
52 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
53 label_file_binary = args.label_file_binary |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
54 label_file = args.label_file.name |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
55 out_file = args.output_file.name |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
56 add_patch = args.add_roi_patches |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
57 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
58 raw_image = None |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
59 if args.raw_file is not None: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
60 raw_image = skimage.io.imread(args.raw_file.name) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
61 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
62 raw_label_image = skimage.io.imread(label_file) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
63 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
64 df = pd.DataFrame() |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
65 if label_file_binary: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
66 raw_label_image = skimage.measure.label(raw_label_image) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
67 regions = skimage.measure.regionprops(raw_label_image, intensity_image=raw_image) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
68 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
69 df['it'] = np.arange(len(regions)) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
70 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
71 if add_patch: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
72 df['image'] = df['it'].map(lambda ait: regions[ait].image.astype(np.float).tolist()) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
73 df['intensity_image'] = df['it'].map(lambda ait: regions[ait].intensity_image.astype(np.float).tolist()) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
74 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
75 # TODO no matrix features, but split in own rows? |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
76 if args.add_label or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
77 df['label'] = df['it'].map(lambda ait: regions[ait].label) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
78 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
79 if raw_image is not None: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
80 if args.max_intensity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
81 df['max_intensity'] = df['it'].map(lambda ait: regions[ait].max_intensity) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
82 if args.mean_intensity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
83 df['mean_intensity'] = df['it'].map(lambda ait: regions[ait].mean_intensity) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
84 if args.min_intensity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
85 df['min_intensity'] = df['it'].map(lambda ait: regions[ait].min_intensity) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
86 if args.moments_hu or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
87 df['moments_hu'] = df['it'].map(lambda ait: regions[ait].moments_hu) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
88 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
89 if args.centroid or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
90 df['centroid'] = df['it'].map(lambda ait: regions[ait].centroid) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
91 if args.bbox or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
92 df['bbox'] = df['it'].map(lambda ait: regions[ait].bbox) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
93 if args.area or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
94 df['area'] = df['it'].map(lambda ait: regions[ait].area) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
95 if args.filled_area or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
96 df['filled_area'] = df['it'].map(lambda ait: regions[ait].filled_area) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
97 if args.convex_area or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
98 df['convex_area'] = df['it'].map(lambda ait: regions[ait].convex_area) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
99 if args.perimeter or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
100 df['perimeter'] = df['it'].map(lambda ait: regions[ait].perimeter) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
101 if args.extent or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
102 df['extent'] = df['it'].map(lambda ait: regions[ait].extent) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
103 if args.eccentricity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
104 df['eccentricity'] = df['it'].map(lambda ait: regions[ait].eccentricity) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
105 if args.equivalent_diameter or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
106 df['equivalent_diameter'] = df['it'].map(lambda ait: regions[ait].equivalent_diameter) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
107 if args.euler_number or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
108 df['euler_number'] = df['it'].map(lambda ait: regions[ait].euler_number) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
109 if args.inertia_tensor_eigvals or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
110 df['inertia_tensor_eigvals'] = df['it'].map(lambda ait: regions[ait].inertia_tensor_eigvals) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
111 if args.major_axis_length or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
112 df['major_axis_length'] = df['it'].map(lambda ait: regions[ait].major_axis_length) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
113 if args.minor_axis_length or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
114 df['minor_axis_length'] = df['it'].map(lambda ait: regions[ait].minor_axis_length) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
115 if args.orientation or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
116 df['orientation'] = df['it'].map(lambda ait: regions[ait].orientation) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
117 if args.solidity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
118 df['solidity'] = df['it'].map(lambda ait: regions[ait].solidity) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
119 if args.moments or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
120 df['moments'] = df['it'].map(lambda ait: regions[ait].moments) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
121 if args.convexity or args.all_features: |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
122 perimeter = df['it'].map(lambda ait: regions[ait].perimeter) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
123 area = df['it'].map(lambda ait: regions[ait].area) |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
124 df['convexity'] = area / (perimeter * perimeter) |
0
96909b9d1df1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_feature_extraction/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
imgteam
parents:
diff
changeset
|
125 |
5
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
126 del df['it'] |
2436a8807ad1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
imgteam
parents:
4
diff
changeset
|
127 df.to_csv(out_file, sep='\t', line_terminator='\n', index=False) |