Skip to content

Commit ecaeeea

Browse files
author
Joel Vincent Bernier
committed
added blob finding to fiber generation
1 parent f5388e9 commit ecaeeea

File tree

2 files changed

+50
-20
lines changed

2 files changed

+50
-20
lines changed

conda.recipe/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ requirements:
2929
- matplotlib
3030
- numba
3131
- numpy
32-
- progressbar >=2.3
32+
- progressbar
3333
- python
3434
- python.app # [osx]
3535
- pyyaml
3636
- scikit-image
3737
- scikit-learn
3838
- scipy
39-
- wxpython ==3
39+
- wxpython
4040

4141
test:
4242
imports:

hexrd/findorientations.py

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
from hexrd.fitgrains import get_instrument_parameters
2828

29-
logger = logging.getLogger(__name__)
30-
31-
save_as_ascii = False # FIX LATER...
29+
from skimage.feature import blob_dog, blob_log
3230

3331
# just require scikit-learn?
3432
have_sklearn = False
@@ -43,9 +41,20 @@
4341
pass
4442

4543

44+
method = "blob_dog" # !!! have to get this from the config
45+
save_as_ascii = False # FIX LATER...
46+
47+
logger = logging.getLogger(__name__)
48+
49+
50+
# =============================================================================
51+
# FUNCTIONS
52+
# =============================================================================
53+
54+
4655
def generate_orientation_fibers(
4756
eta_ome, chi, threshold, seed_hkl_ids, fiber_ndiv,
48-
filt_stdev=0.8, ncpus=1):
57+
method='blob_dog', filt_stdev=0.8, ncpus=1):
4958
"""
5059
From ome-eta maps and hklid spec, generate list of
5160
quaternions from fibers
@@ -82,21 +91,42 @@ def generate_orientation_fibers(
8291
numSpots = []
8392
coms = []
8493
for i in seed_hkl_ids:
85-
# First apply filter
86-
this_map_f = -ndimage.filters.gaussian_laplace(
87-
eta_ome.dataStore[i], filt_stdev)
88-
89-
labels_t, numSpots_t = ndimage.label(
90-
this_map_f > threshold,
91-
structureNDI_label
92-
)
93-
coms_t = np.atleast_2d(
94-
ndimage.center_of_mass(
95-
this_map_f,
96-
labels=labels_t,
97-
index=np.arange(1, np.amax(labels_t)+1)
94+
if method == 'label':
95+
# First apply filter
96+
this_map_f = -ndimage.filters.gaussian_laplace(
97+
eta_ome.dataStore[i], filt_stdev)
98+
99+
labels_t, numSpots_t = ndimage.label(
100+
this_map_f > threshold,
101+
structureNDI_label
98102
)
99-
)
103+
coms_t = np.atleast_2d(
104+
ndimage.center_of_mass(
105+
this_map_f,
106+
labels=labels_t,
107+
index=np.arange(1, np.amax(labels_t) + 1)
108+
)
109+
)
110+
elif method in ['blob_log', 'blob_dog']:
111+
# must scale map
112+
this_map = eta_ome.dataStore[i]
113+
this_map[np.isnan(this_map)] = 0.
114+
this_map -= np.min(this_map)
115+
scl_map = 2*this_map/np.max(this_map) - 1.
116+
117+
# FIXME: need to expose the parameters to config options.
118+
if method == 'blob_log':
119+
blobs = np.atleast_2d(
120+
blob_log(scl_map, min_sigma=0.5, max_sigma=5,
121+
num_sigma=10, threshold=0.01, overlap=0.1)
122+
)
123+
else:
124+
blobs = np.atleast_2d(
125+
blob_dog(scl_map, min_sigma=0.5, max_sigma=5,
126+
sigma_ratio=1.6, threshold=0.01, overlap=0.1)
127+
)
128+
numSpots_t = len(blobs)
129+
coms_t = blobs[:, :2]
100130
numSpots.append(numSpots_t)
101131
coms.append(coms_t)
102132
pass

0 commit comments

Comments
 (0)