|
83 | 83 | "metadata": {},
|
84 | 84 | "outputs": [],
|
85 | 85 | "source": [
|
86 |
| - "dp = pxm.load_hspy('MgO2_16_TX5_c_bin2,2.hdf5',\n", |
| 86 | + "dp = pxm.load_hspy('SPED_data_of_MgO_nanoparticles_bin2,2,1,1.hdf5',\n", |
87 | 87 | " lazy=False,\n",
|
88 | 88 | " assign_to='electron_diffraction2d')"
|
89 | 89 | ]
|
|
167 | 167 | "metadata": {},
|
168 | 168 | "outputs": [],
|
169 | 169 | "source": [
|
170 |
| - "dp.align2D(shifts=shifts, crop=False, fill_value=0)" |
| 170 | + "dp.align2D(shifts=shifts, crop=True)" |
171 | 171 | ]
|
172 | 172 | },
|
173 | 173 | {
|
|
183 | 183 | "metadata": {},
|
184 | 184 | "outputs": [],
|
185 | 185 | "source": [
|
186 |
| - "scale = 0.03246\n", |
187 |
| - "scale_real = 2.56\n", |
| 186 | + "scale = 0.03246 \n", |
| 187 | + "scale_real = 3.03\n", |
188 | 188 | "dp.set_diffraction_calibration(scale)\n",
|
189 | 189 | "dp.set_scan_calibration(scale_real)\n",
|
190 | 190 | "\n",
|
|
284 | 284 | "cell_type": "code",
|
285 | 285 | "execution_count": null,
|
286 | 286 | "metadata": {
|
287 |
| - "scrolled": true |
| 287 | + "scrolled": false |
288 | 288 | },
|
289 | 289 | "outputs": [],
|
290 | 290 | "source": [
|
|
392 | 392 | "metadata": {},
|
393 | 393 | "outputs": [],
|
394 | 394 | "source": [
|
395 |
| - "gmags = unique_peaks.get_magnitudes()\n", |
396 |
| - "gmags.data[gmags.data<10*scale] = 0\n", |
397 |
| - "Gs = unique_peaks.data[np.where(gmags)]\n", |
398 |
| - "Gs = pxm.DiffractionVectors(Gs)\n", |
399 |
| - "print(np.shape(Gs)[0], ' unique vectors.')\n", |
400 |
| - "Gs.axes_manager.set_signal_dimension(0)" |
| 395 | + "Gs = unique_peaks.filter_vector_magnitudes(\n", |
| 396 | + " min_magnitude=10*scale, max_magnitude=np.inf)\n", |
| 397 | + "print(np.shape(Gs)[0], ' unique vectors.')" |
401 | 398 | ]
|
402 | 399 | },
|
403 | 400 | {
|
|
427 | 424 | "cell_type": "markdown",
|
428 | 425 | "metadata": {},
|
429 | 426 | "source": [
|
430 |
| - "Optionally save and load the unique peaks\n", |
431 |
| - "\n", |
432 |
| - "`np.save('peaks.npy', Gs.data)\n", |
433 |
| - "Gs = np.load('peaks.npy', allow_pickle=True)\n", |
434 |
| - "Gs = pxm.DiffractionVectors(Gs)\n", |
435 |
| - "Gs.axes_manager.set_signal_dimension(0)`" |
| 427 | + "Optionally save and load the unique peaks" |
436 | 428 | ]
|
437 | 429 | },
|
438 | 430 | {
|
|
523 | 515 | "source": [
|
524 | 516 | "min_distance = 5.5\n",
|
525 | 517 | "min_size = 10\n",
|
526 |
| - "max_size = None\n", |
| 518 | + "max_size = np.inf\n", |
527 | 519 | "max_number_of_grains = np.inf\n",
|
528 | 520 | "marker_radius = 2\n",
|
529 | 521 | "exclude_border = 2"
|
|
535 | 527 | "metadata": {},
|
536 | 528 | "outputs": [],
|
537 | 529 | "source": [
|
538 |
| - "i = 27\n", |
| 530 | + "i = 26\n", |
539 | 531 | "sep_i = separate_watershed(\n",
|
540 | 532 | " VDFs.inav[i].data, min_distance=min_distance, min_size=min_size,\n",
|
541 | 533 | " max_size=max_size, max_number_of_grains=max_number_of_grains,\n",
|
|
653 | 645 | {
|
654 | 646 | "cell_type": "code",
|
655 | 647 | "execution_count": null,
|
656 |
| - "metadata": {}, |
| 648 | + "metadata": { |
| 649 | + "scrolled": true |
| 650 | + }, |
657 | 651 | "outputs": [],
|
658 | 652 | "source": [
|
659 | 653 | "hs.plot.plot_images(corrsegs.segments, cmap='magma_r', axes_decor='off',\n",
|
|
688 | 682 | "cell_type": "markdown",
|
689 | 683 | "metadata": {},
|
690 | 684 | "source": [
|
691 |
| - "#### Create a signal mask for the direct beam\n", |
692 | 685 | "Create a signal mask so that the region in the centre of each PED pattern, including the direct beam, can be excluded in the machine learning. "
|
693 | 686 | ]
|
694 | 687 | },
|
|
707 | 700 | "cell_type": "markdown",
|
708 | 701 | "metadata": {},
|
709 | 702 | "source": [
|
710 |
| - "#### Perform single value decomposition (SVD)" |
| 703 | + "Perform single value decomposition (SVD)" |
711 | 704 | ]
|
712 | 705 | },
|
713 | 706 | {
|
|
736 | 729 | "cell_type": "markdown",
|
737 | 730 | "metadata": {},
|
738 | 731 | "source": [
|
739 |
| - "#### Investigate the scree plot and use it as a guide to determine the number of components" |
| 732 | + "Investigate the scree plot and use it as a guide to determine the number of components" |
740 | 733 | ]
|
741 | 734 | },
|
742 | 735 | {
|
|
757 | 750 | "cell_type": "markdown",
|
758 | 751 | "metadata": {},
|
759 | 752 | "source": [
|
760 |
| - "### NMF" |
| 753 | + "NMF" |
761 | 754 | ]
|
762 | 755 | },
|
763 | 756 | {
|
|
870 | 863 | "cell_type": "markdown",
|
871 | 864 | "metadata": {},
|
872 | 865 | "source": [
|
873 |
| - "#### Investigate the normalised cross-correlations\n", |
874 | 866 | "Calculate the matrix of normalised cross-correlation for both the loadings and patterns first, to find suitable correlation threshold values. "
|
875 | 867 | ]
|
876 | 868 | },
|
|
890 | 882 | "metadata": {},
|
891 | 883 | "outputs": [],
|
892 | 884 | "source": [
|
893 |
| - "ncc_nmf = learn.get_ncc_matrix()\n", |
| 885 | + "ncc_nmf = learn.get_ncc_matrix()" |
| 886 | + ] |
| 887 | + }, |
| 888 | + { |
| 889 | + "cell_type": "code", |
| 890 | + "execution_count": null, |
| 891 | + "metadata": {}, |
| 892 | + "outputs": [], |
| 893 | + "source": [ |
894 | 894 | "ncc_nmf.plot(scalebar=False, cmap='RdBu')"
|
895 | 895 | ]
|
896 | 896 | },
|
|
0 commit comments