Skip to content

Commit f5fc04f

Browse files
authored
Merge pull request #4 from tinabe/nanoseg-demo
Update with edge peaks filtering.
2 parents 7072c93 + 410ed84 commit f5fc04f

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

06 Nanocrystal segmentation in SPED data - Demonstration on partly overlapping MgO cubes.ipynb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"metadata": {},
8484
"outputs": [],
8585
"source": [
86-
"dp = pxm.load_hspy('SPED_data_of_MgO_nanoparticles_bin2,2,1,1.hdf5',\n",
86+
"dp = pxm.load_hspy('SPED_MgO.hdf5',\n",
8787
" lazy=False,\n",
8888
" assign_to='electron_diffraction2d')"
8989
]
@@ -96,10 +96,8 @@
9696
]
9797
},
9898
{
99-
"cell_type": "code",
100-
"execution_count": null,
99+
"cell_type": "markdown",
101100
"metadata": {},
102-
"outputs": [],
103101
"source": [
104102
"dp.plot(cmap='magma_r')"
105103
]
@@ -138,7 +136,7 @@
138136
"cell_type": "markdown",
139137
"metadata": {},
140138
"source": [
141-
"Find the position of the direct beam in background subtracted data."
139+
"Find the position of the direct beam in the background subtracted data."
142140
]
143141
},
144142
{
@@ -192,6 +190,15 @@
192190
"dp_rb.set_scan_calibration(scale_real)"
193191
]
194192
},
193+
{
194+
"cell_type": "code",
195+
"execution_count": null,
196+
"metadata": {},
197+
"outputs": [],
198+
"source": [
199+
"dp_rb.save('dp_rb_final.hdf5')"
200+
]
201+
},
195202
{
196203
"cell_type": "markdown",
197204
"metadata": {},
@@ -260,35 +267,32 @@
260267
]
261268
},
262269
{
263-
"cell_type": "code",
264-
"execution_count": null,
270+
"cell_type": "markdown",
265271
"metadata": {},
266-
"outputs": [],
267272
"source": [
268-
"dp_padded = np.zeros((dp.data.shape[0],dp.data.shape[1],\n",
269-
" dp.data.shape[2]+12,dp.data.shape[2]+12))\n",
270-
"dp_padded[:,:,6:dp.data.shape[2]+6,6:dp.data.shape[2]+6] = dp_rb.data\n",
271-
"dp_padded = pxm.ElectronDiffraction2D(dp_padded)\n",
272-
"dp_padded.set_diffraction_calibration(scale)\n",
273-
"dp_padded.set_scan_calibration(scale_real)"
273+
"Filter away the peaks at the edges of the patterns, since it is not possible to get a correct sub-pixel refinement of these peaks. "
274274
]
275275
},
276276
{
277-
"cell_type": "markdown",
278-
"metadata": {},
277+
"cell_type": "code",
278+
"execution_count": null,
279+
"metadata": {
280+
"scrolled": false
281+
},
282+
"outputs": [],
279283
"source": [
280-
"Padding is used so that peaks at the edges of the diffraction patterns are treated correctly."
284+
"peaks_filtered = peaks.filter_vectors_detector_edge(exclude_width=74)"
281285
]
282286
},
283287
{
284288
"cell_type": "code",
285289
"execution_count": null,
286290
"metadata": {
287-
"scrolled": false
291+
"scrolled": true
288292
},
289293
"outputs": [],
290294
"source": [
291-
"refine_gen = SubpixelrefinementGenerator(dp_padded, peaks)\n",
295+
"refine_gen = SubpixelrefinementGenerator(dp_rb, peaks_filtered)\n",
292296
"peaks_refined = DiffractionVectors(\n",
293297
" refine_gen.center_of_mass_method(square_size=4))\n",
294298
"peaks_refined.axes_manager.set_signal_dimension(0)"
@@ -392,7 +396,7 @@
392396
"metadata": {},
393397
"outputs": [],
394398
"source": [
395-
"Gs = unique_peaks.filter_vector_magnitudes(\n",
399+
"Gs = unique_peaks.filter_vectors_magnitudes(\n",
396400
" min_magnitude=10*scale, max_magnitude=np.inf)\n",
397401
"print(np.shape(Gs)[0], ' unique vectors.')"
398402
]
@@ -527,7 +531,7 @@
527531
"metadata": {},
528532
"outputs": [],
529533
"source": [
530-
"i = 26\n",
534+
"i = 25\n",
531535
"sep_i = separate_watershed(\n",
532536
" VDFs.inav[i].data, min_distance=min_distance, min_size=min_size,\n",
533537
" max_size=max_size, max_number_of_grains=max_number_of_grains,\n",

0 commit comments

Comments
 (0)