Mercurial > repos > imgteam > points_association_nn
annotate points_association_nn.py @ 4:f3fad67af22c draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:11:50 +0000 |
parents | b30aa285ac0a |
children |
rev | line source |
---|---|
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
1 """ |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
2 Copyright 2021 Biomedical Computer Vision Group, Heidelberg University. |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
3 Author: Qi Gao (qi.gao@bioquant.uni-heidelberg.de) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
4 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
5 Distributed under the MIT license. |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
6 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
7 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
8 """ |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
9 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
10 import argparse |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
11 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
12 import numpy as np |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
13 import pandas as pd |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
14 import skimage.util |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
15 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
16 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
17 def disk_mask(imsz, ir, ic, nbpx): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
18 ys, xs = np.ogrid[-nbpx:nbpx + 1, -nbpx:nbpx + 1] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
19 se = xs ** 2 + ys ** 2 <= nbpx ** 2 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
20 mask = np.zeros(imsz, dtype=int) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
21 if ir - nbpx < 0 or ic - nbpx < 0 or ir + nbpx + 1 > imsz[0] or ic + nbpx + 1 > imsz[1]: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
22 mask = skimage.util.pad(mask, nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
23 mask[ir:ir + 2 * nbpx + 1, ic:ic + 2 * nbpx + 1] = se |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
24 mask = skimage.util.crop(mask, nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
25 else: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
26 mask[ir - nbpx:ir + nbpx + 1, ic - nbpx:ic + nbpx + 1] = se |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
27 return mask |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
28 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
29 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
30 def find_nn(cim, icy, icx, nim, nbpx): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
31 mask = disk_mask(cim.shape, icy, icx, nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
32 iys_nim, ixs_nim = np.where(nim * mask) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
33 if iys_nim.size == 0: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
34 return np.NaN, np.NaN |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
35 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
36 d2 = (icy - iys_nim) ** 2 + (icx - ixs_nim) ** 2 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
37 I1 = np.argsort(d2) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
38 iy_nim = iys_nim[I1[0]] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
39 ix_nim = ixs_nim[I1[0]] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
40 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
41 mask = disk_mask(cim.shape, iy_nim, ix_nim, nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
42 iys_cim, ixs_cim = np.where(cim * mask) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
43 d2 = (iy_nim - iys_cim) ** 2 + (ix_nim - ixs_cim) ** 2 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
44 I2 = np.argsort(d2) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
45 if not iys_cim[I2[0]] == icy or not ixs_cim[I2[0]] == icx: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
46 return np.NaN, np.NaN |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
47 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
48 return iy_nim, ix_nim |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
49 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
50 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
51 def points_linking(fn_in, fn_out, nbpx=6, th=25, minlen=50): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
52 data = pd.read_csv(fn_in, delimiter="\t") |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
53 all_data = np.array(data) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
54 assert all_data.shape[1] in [3, 4], 'unknow collum(s) in input data!' |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
55 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
56 coords = all_data[:, :3].astype('int64') |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
57 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
58 frame_1st = np.min(coords[:, 0]) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
59 frame_end = np.max(coords[:, 0]) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
60 assert set([i for i in range(frame_1st, frame_end + 1)]).issubset(set(coords[:, 0].tolist())), "spots missing at some time point!" |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
61 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
62 nSlices = frame_end |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
63 stack_h = np.max(coords[:, 2]) + nbpx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
64 stack_w = np.max(coords[:, 1]) + nbpx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
65 stack = np.zeros((stack_h, stack_w, nSlices), dtype='int8') |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
66 stack_r = np.zeros((stack_h, stack_w, nSlices), dtype='float64') |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
67 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
68 for i in range(all_data.shape[0]): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
69 iyxz = tuple(coords[i, ::-1] - 1) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
70 stack[iyxz] = 1 |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
71 if all_data.shape[1] == 4: |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
72 stack_r[iyxz] = all_data[i, -1] |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
73 else: |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
74 stack_r[iyxz] = 1 |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
75 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
76 tracks_all = np.array([], dtype=float).reshape(0, nSlices, 4) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
77 maxv = np.max(stack_r) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
78 br_max = maxv |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
79 idx_max = np.argmax(stack_r) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
80 while 1: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
81 iyxz = np.unravel_index(idx_max, stack.shape) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
82 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
83 spot_br = np.empty((nSlices, 1)) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
84 track = np.empty((nSlices, 3)) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
85 for i in range(nSlices): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
86 spot_br[i] = np.NaN |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
87 track[i, :] = np.array((np.NaN, np.NaN, np.NaN)) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
88 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
89 spot_br[iyxz[2]] = maxv |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
90 track[iyxz[2], :] = np.array(iyxz[::-1]) + 1 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
91 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
92 # forward |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
93 icy = iyxz[0] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
94 icx = iyxz[1] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
95 for inz in range(iyxz[2] + 1, nSlices): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
96 iny, inx = find_nn(stack[:, :, inz - 1], icy, icx, stack[:, :, inz], nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
97 if np.isnan(iny) and not inz == nSlices - 1: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
98 iny, inx = find_nn(stack[:, :, inz - 1], icy, icx, stack[:, :, inz + 1], nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
99 if np.isnan(iny): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
100 break |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
101 else: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
102 iny = icy |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
103 inx = icx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
104 stack[iny, inx, inz] = 1 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
105 stack_r[iny, inx, inz] = stack_r[iny, inx, inz - 1] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
106 elif np.isnan(iny) and inz == nSlices - 1: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
107 break |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
108 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
109 track[inz, :] = np.array((inz, inx, iny)) + 1 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
110 spot_br[inz] = stack_r[iny, inx, inz] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
111 icy = iny |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
112 icx = inx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
113 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
114 # backward |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
115 icy = iyxz[0] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
116 icx = iyxz[1] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
117 for inz in range(iyxz[2] - 1, -1, -1): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
118 iny, inx = find_nn(stack[:, :, inz + 1], icy, icx, stack[:, :, inz], nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
119 if np.isnan(iny) and not inz == 0: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
120 iny, inx = find_nn(stack[:, :, inz + 1], icy, icx, stack[:, :, inz - 1], nbpx) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
121 if np.isnan(iny): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
122 break |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
123 else: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
124 iny = icy |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
125 inx = icx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
126 stack[iny, inx, inz] = 1 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
127 stack_r[iny, inx, inz] = stack_r[iny, inx, inz + 1] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
128 elif np.isnan(iny) and inz == 0: |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
129 break |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
130 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
131 track[inz, :] = np.array((inz, inx, iny)) + 1 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
132 spot_br[inz] = stack_r[iny, inx, inz] |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
133 icy = iny |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
134 icx = inx |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
135 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
136 for iz in range(nSlices): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
137 if not np.isnan(track[iz, 0]): |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
138 stack[track[iz, 2].astype(int) - 1, track[iz, 1].astype(int) - 1, iz] = 0 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
139 stack_r[track[iz, 2].astype(int) - 1, track[iz, 1].astype(int) - 1, iz] = 0 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
140 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
141 # discard short trajectories |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
142 if np.count_nonzero(~np.isnan(spot_br)) > np.max((1, minlen * (frame_end - frame_1st) / 100)): |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
143 tmp = np.concatenate((track, spot_br), axis=1) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
144 tracks_all = np.concatenate((tracks_all, tmp.reshape(1, -1, 4)), axis=0) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
145 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
146 maxv = np.max(stack_r) |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
147 idx_max = np.argmax(stack_r) |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
148 if maxv < th * br_max / 100 or maxv == 0: |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
149 break |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
150 |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
151 with pd.ExcelWriter(fn_out) as writer: |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
152 if tracks_all.shape[0] == 0: |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
153 df = pd.DataFrame() |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
154 df['No tracks found'] = np.NaN |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
155 df.to_excel(writer, index=False, float_format='%.2f') |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
156 else: |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
157 for i in range(tracks_all.shape[0]): |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
158 df = pd.DataFrame() |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
159 df['FRAME'] = tracks_all[i, :, 0] |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
160 df['POS_X'] = tracks_all[i, :, 1] |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
161 df['POS_Y'] = tracks_all[i, :, 2] |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
162 if all_data.shape[1] == 4: |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
163 df['INTENSITY'] = tracks_all[i, :, 3] |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
164 df.to_excel(writer, sheet_name='spot%s' % (i + 1), index=False, float_format='%.2f') |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
165 writer.save() |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
166 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
167 |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
168 if __name__ == "__main__": |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
169 parser = argparse.ArgumentParser(description="Association of points in consecutive frames using the nearest neighbor algorithm") |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
170 parser.add_argument("fn_in", help="Coordinates (and intensities) of input points (tsv tabular)") |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
171 parser.add_argument("fn_out", help="Name of output file (xlsx)") |
2
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
172 parser.add_argument("nbpx", type=int, help="Neighborhood size (in pixel) for associating points") |
b30aa285ac0a
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit bf6e2870c94ed4ceb8bce4003813fe11724f5ca2"
imgteam
parents:
0
diff
changeset
|
173 parser.add_argument("thres", type=float, help="Tracks with all intensities lower than certain percentage (%) of the global maximal intensity will be discarded") |
0
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
174 parser.add_argument("minlen", type=float, help="Minimum length of tracks (percentage of senquence length)") |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
175 args = parser.parse_args() |
04e692ee53a8
"planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points_association_nn/ commit db4c2a87a21f32e5d12d11e68f32773bfc06fcfd"
imgteam
parents:
diff
changeset
|
176 points_linking(args.fn_in, args.fn_out, args.nbpx, args.thres, args.minlen) |