Repository navigation
Expand file tree
/
Copy pathvisualizer.py
More file actions
96 lines (71 loc) · 2.2 KB
/
Copy pathvisualizer.py
File metadata and controls
96 lines (71 loc) · 2.2 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import napari
import numpy as np
from pathlib import Path
import argparse
def parse_args():
parser = argparse.ArgumentParser(
description="Visualizer",
formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument(
'--path',
type=str,
required=True,
help='Path to the folder with the .npy files.'
)
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
full_path = Path(args.path)
file_id = full_path.name
base_path = full_path
sv_file = base_path / f'{file_id}_sv_normal.npy'
nv_file = base_path / f'{file_id}_nv_normal.npy'
svt_file = base_path / f'{file_id}_sv_tang.npy'
nvt_file = base_path / f'{file_id}_nv_tang.npy'
viewer = napari.Viewer()
try:
sv_norm_data = np.load(sv_file)
viewer.add_vectors(
sv_norm_data,
name=f'{file_id}_sv_norm',
length=5,
edge_width=0.5,
edge_color='lime'
)
except FileNotFoundError:
print(f"Error: File not found {sv_file}")
try:
nv_norm_data = np.load(nv_file)
viewer.add_vectors(
nv_norm_data,
name=f'{file_id}_nv_norm',
length=5,
edge_width=0.5,
edge_color='#ff557fff'
)
except FileNotFoundError:
print(f"Error: File not found {nv_file}")
try:
svt_norm_data = np.load(svt_file)
viewer.add_vectors(
svt_norm_data,
name=f'{file_id}_sv_tan',
length=5,
edge_width=0.5,
edge_color='yellow'
)
except FileNotFoundError:
print(f"Error: File not found {svt_file}")
try:
nvt_norm_data = np.load(nvt_file)
viewer.add_vectors(
nvt_norm_data,
name=f'{file_id}_nv_tan',
length=5,
edge_width=0.5,
edge_color='#aa00ffff'
)
except FileNotFoundError:
print(f"Error: File not found {nvt_file}")
napari.run()