copick-utils 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- copick_utils/io/readers.py +132 -0
- {copick_utils-0.5.0.dist-info → copick_utils-0.6.0.dist-info}/METADATA +1 -2
- {copick_utils-0.5.0.dist-info → copick_utils-0.6.0.dist-info}/RECORD +6 -6
- copick_utils/writers/__init__.py +0 -0
- /copick_utils/{writers/write.py → io/writers.py} +0 -0
- {copick_utils-0.5.0.dist-info → copick_utils-0.6.0.dist-info}/LICENSE.txt +0 -0
- {copick_utils-0.5.0.dist-info → copick_utils-0.6.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
def tomogram(run,
|
|
4
|
+
voxel_size: float = 10,
|
|
5
|
+
algorithm: str = 'wbp',
|
|
6
|
+
raise_error: bool = False):
|
|
7
|
+
|
|
8
|
+
voxel_spacing_obj = run.get_voxel_spacing(voxel_size)
|
|
9
|
+
|
|
10
|
+
if voxel_spacing_obj is None:
|
|
11
|
+
# Query Avaiable Voxel Spacings
|
|
12
|
+
availableVoxelSpacings = [tomo.voxel_size for tomo in run.voxel_spacings]
|
|
13
|
+
|
|
14
|
+
# Report to the user which voxel spacings they can use
|
|
15
|
+
message = (f"[Warning] No tomogram found for {run.name} with voxel size {voxel_size} and tomogram type {algorithm}"
|
|
16
|
+
f"Available spacings are: {', '.join(map(str, availableVoxelSpacings))}" )
|
|
17
|
+
if raise_error:
|
|
18
|
+
raise ValueError(message)
|
|
19
|
+
else:
|
|
20
|
+
print(message)
|
|
21
|
+
return None
|
|
22
|
+
|
|
23
|
+
tomogram = voxel_spacing_obj.get_tomogram(algorithm)
|
|
24
|
+
if tomogram is None:
|
|
25
|
+
# Get available algorithms
|
|
26
|
+
availableAlgorithms = [tomo.tomo_type for tomo in run.get_voxel_spacing(voxel_size).tomograms]
|
|
27
|
+
|
|
28
|
+
# Report to the user which algorithms are available
|
|
29
|
+
message = (f"[Warning] No tomogram found for {run.name} with voxel size {voxel_size} and tomogram type {algorithm}"
|
|
30
|
+
f"Available algorithms are: {', '.join(availableAlgorithms)}")
|
|
31
|
+
if raise_error:
|
|
32
|
+
raise ValueError(message)
|
|
33
|
+
else:
|
|
34
|
+
print(message)
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
return tomogram.numpy()
|
|
38
|
+
|
|
39
|
+
def segmentation(run,
|
|
40
|
+
voxel_spacing: float,
|
|
41
|
+
segmentation_name: str,
|
|
42
|
+
session_id=None,
|
|
43
|
+
user_id=None,
|
|
44
|
+
raise_error = False):
|
|
45
|
+
|
|
46
|
+
seg = run.get_segmentations(name=segmentation_name,
|
|
47
|
+
session_id = session_id,
|
|
48
|
+
user_id = user_id,
|
|
49
|
+
voxel_size = voxel_spacing)
|
|
50
|
+
|
|
51
|
+
# No Segmentations Are Available, Result in Error
|
|
52
|
+
if len(seg) == 0:
|
|
53
|
+
# Get all available segmentations with their metadata
|
|
54
|
+
available_segs = run.get_segmentations(voxel_size=voxel_spacing)
|
|
55
|
+
seg_info = [(s.name, s.user_id, s.session_id) for s in available_segs]
|
|
56
|
+
|
|
57
|
+
# Format the information for display
|
|
58
|
+
seg_details = [f"(name: {name}, user_id: {uid}, session_id: {sid})"
|
|
59
|
+
for name, uid, sid in seg_info]
|
|
60
|
+
|
|
61
|
+
message = ( f'\nNo segmentation found matching:\n'
|
|
62
|
+
f' name: {segmentation_name}, user_id: {user_id}, session_id: {session_id}\n'
|
|
63
|
+
f'Available segmentations in {run.name} are:\n ' +
|
|
64
|
+
'\n '.join(seg_details) )
|
|
65
|
+
if raise_error:
|
|
66
|
+
raise ValueError(message)
|
|
67
|
+
else:
|
|
68
|
+
print(message)
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
# No Segmentations Are Available, Result in Error
|
|
72
|
+
if len(seg) > 1:
|
|
73
|
+
print(f'[Warning] More Than 1 Segmentation is Available for the Query Information. '
|
|
74
|
+
f'Available Segmentations are: {seg} '
|
|
75
|
+
f'Defaulting to Loading: {seg[0]}\n')
|
|
76
|
+
seg = seg[0]
|
|
77
|
+
|
|
78
|
+
return seg.numpy()
|
|
79
|
+
|
|
80
|
+
def coordinates(run, # CoPick run object containing the segmentation data
|
|
81
|
+
name: str, # Name of the object or protein for which coordinates are being extracted
|
|
82
|
+
user_id: str, # Identifier of the user that generated the picks
|
|
83
|
+
session_id: str = None, # Identifier of the session that generated the picks
|
|
84
|
+
voxel_size: float = 10, # Voxel size of the tomogram, used for scaling the coordinates
|
|
85
|
+
raise_error: bool = False):
|
|
86
|
+
|
|
87
|
+
# Retrieve the pick points associated with the specified object and user ID
|
|
88
|
+
picks = run.get_picks(object_name=name, user_id=user_id, session_id=session_id)
|
|
89
|
+
|
|
90
|
+
if len(picks) == 0:
|
|
91
|
+
# Get all available segmentations with their metadata
|
|
92
|
+
|
|
93
|
+
available_picks = run.get_picks()
|
|
94
|
+
picks_info = [(s.pickable_object_name, s.user_id, s.session_id) for s in available_picks]
|
|
95
|
+
|
|
96
|
+
# Format the information for display
|
|
97
|
+
picks_details = [f"(name: {name}, user_id: {uid}, session_id: {sid})"
|
|
98
|
+
for name, uid, sid in picks_info]
|
|
99
|
+
|
|
100
|
+
message = ( f'\nNo picks found matching:\n'
|
|
101
|
+
f' name: {name}, user_id: {user_id}, session_id: {session_id}\n'
|
|
102
|
+
f'Available picks are:\n '
|
|
103
|
+
+ '\n '.join(picks_details) )
|
|
104
|
+
if raise_error:
|
|
105
|
+
raise ValueError(message)
|
|
106
|
+
else:
|
|
107
|
+
print(message)
|
|
108
|
+
return None
|
|
109
|
+
elif len(picks) > 1:
|
|
110
|
+
# Format pick information for display
|
|
111
|
+
picks_info = [(p.pickable_object_name, p.user_id, p.session_id) for p in picks]
|
|
112
|
+
picks_details = [f"(name: {name}, user_id: {uid}, session_id: {sid})"
|
|
113
|
+
for name, uid, sid in picks_info]
|
|
114
|
+
|
|
115
|
+
print(f'[Warning] More than 1 pick is available for the query information.'
|
|
116
|
+
f'\nAvailable picks are:\n ' +
|
|
117
|
+
'\n '.join(picks_details) +
|
|
118
|
+
f'\nDefaulting to loading:\n {picks[0]}\n')
|
|
119
|
+
points = picks[0].points
|
|
120
|
+
|
|
121
|
+
# Initialize an array to store the coordinates
|
|
122
|
+
nPoints = len(picks[0].points) # Number of points retrieved
|
|
123
|
+
coordinates = np.zeros([len(picks[0].points), 3]) # Create an empty array to hold the (z, y, x) coordinates
|
|
124
|
+
|
|
125
|
+
# Iterate over all points and convert their locations to coordinates in voxel space
|
|
126
|
+
for ii in range(nPoints):
|
|
127
|
+
coordinates[ii,] = [points[ii].location.z / voxel_size, # Scale z-coordinate by voxel size
|
|
128
|
+
points[ii].location.y / voxel_size, # Scale y-coordinate by voxel size
|
|
129
|
+
points[ii].location.x / voxel_size] # Scale x-coordinate by voxel size
|
|
130
|
+
|
|
131
|
+
# Return the array of coordinates
|
|
132
|
+
return coordinates
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: copick-utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Utilities for copick
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Kyle Harrington
|
|
@@ -15,7 +15,6 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
18
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
19
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
21
20
|
Requires-Dist: copick (>=0.8.0)
|
|
@@ -2,14 +2,14 @@ copick_utils/__about__.py,sha256=7D13PJEcpdhEa6RrlKLt7IEkoVVVGuzqHJb5MQxgLiI,135
|
|
|
2
2
|
copick_utils/__init__.py,sha256=v-RIkEuGuAXivakLMrneraDQd7cWN7zsdGLmjwLtDDw,113
|
|
3
3
|
copick_utils/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
copick_utils/features/skimage.py,sha256=t38jpu-ntC7Zw--1qSxWhGIg9e02RLhVBZEySIa5dQs,4036
|
|
5
|
+
copick_utils/io/readers.py,sha256=ajqe64e5tp67iZoqSV6AsjpGX25Rdz_q0tX8qXVVp7g,5902
|
|
6
|
+
copick_utils/io/writers.py,sha256=KhdZUUZrZR02bzS5SWM9q-u4y2s1qxcySwN3MN5j5YA,3055
|
|
5
7
|
copick_utils/pickers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
8
|
copick_utils/pickers/grid_picker.py,sha256=NhFbWxMQREb0fLKTho4602yzH7zE6DCkJY94dgJ-gIQ,2353
|
|
7
9
|
copick_utils/segmentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
10
|
copick_utils/segmentation/picks_from_segmentation.py,sha256=Ne_RYfnEFaV_qwNw4uOwPfLLgGxHMEQ2uecp9X2_EVc,2951
|
|
9
11
|
copick_utils/segmentation/segmentation_from_picks.py,sha256=3oIlFWRAR904j5IpC5Fo8Y4gP9iL6qUiwybRgJvhzmc,6820
|
|
10
|
-
copick_utils/
|
|
11
|
-
copick_utils/
|
|
12
|
-
copick_utils-0.
|
|
13
|
-
copick_utils-0.
|
|
14
|
-
copick_utils-0.5.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
15
|
-
copick_utils-0.5.0.dist-info/RECORD,,
|
|
12
|
+
copick_utils-0.6.0.dist-info/LICENSE.txt,sha256=3UHKsYd99Gh_qf1a9s8G5sdKqafgbGs5WIMoeX0OcdY,1105
|
|
13
|
+
copick_utils-0.6.0.dist-info/METADATA,sha256=TwbWK0CmHk8pB7tI401f3khfIG8mMEtTENOg2b1brOY,2742
|
|
14
|
+
copick_utils-0.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
15
|
+
copick_utils-0.6.0.dist-info/RECORD,,
|
copick_utils/writers/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|