Skip to content

Commit

Permalink
Merge pull request #283 from jadball/master
Browse files Browse the repository at this point in the history
Add Astra support
  • Loading branch information
jonwright authored May 21, 2024
2 parents dd2c425 + 07a0f01 commit 8e87e16
Show file tree
Hide file tree
Showing 7 changed files with 2,192 additions and 21 deletions.
35 changes: 29 additions & 6 deletions ImageD11/nbGui/3DXRD/1_3DXRD_refine_parameters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"import ImageD11.columnfile\n",
"from ImageD11.sinograms import properties, dataset\n",
"\n",
"from ImageD11.blobcorrector import eiger_spatial"
"from ImageD11.blobcorrector import eiger_spatial\n",
"from ImageD11.peakselect import select_ring_peaks_by_intensity"
]
},
{
Expand Down Expand Up @@ -198,7 +199,7 @@
"# this indicates the fractional intensity cutoff we will select\n",
"# if the blue line does not look elbow-shaped in the logscale plot, try changing the \"doplot\" parameter (the y scale of the logscale plot) until it does\n",
"\n",
"cf_strong = utils.selectpeaks(cf_3d, frac=0.985, dsmax=1.04, doplot=0.8, dstol=0.01)\n",
"cf_strong = select_ring_peaks_by_intensity(cf_3d, frac=0.985, dsmax=1.04, doplot=0.8, dstol=0.01)\n",
"print(f\"Got {cf_strong.nrows} strong peaks for indexing\")\n",
"cf_strong.writefile(f'{sample}_{dataset}_3d_peaks_strong.flt')"
]
Expand All @@ -214,7 +215,7 @@
"# we will also export some additional strong peaks across all rings\n",
"# this will be useful for grain refinement later (using makemap)\n",
"\n",
"cf_strong_allrings = utils.selectpeaks(cf_3d, frac=0.95, dsmax=cf_3d.ds.max(), doplot=0.05, dstol=0.01)\n",
"cf_strong_allrings = select_ring_peaks_by_intensity(cf_3d, frac=0.95, dsmax=cf_3d.ds.max(), doplot=0.05, dstol=0.01)\n",
"print(f\"Got {cf_strong_allrings.nrows} strong peaks for makemap\")\n",
"cf_strong_allrings_path = f'{sample}_{dataset}_3d_peaks_strong_all_rings.flt'\n",
"cf_strong_allrings.writefile(cf_strong_allrings_path)"
Expand Down Expand Up @@ -307,6 +308,25 @@
"ImageD11.indexing.loglevel = 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# let's plot the assigned peaks\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"# indexer.ra is the ring assignments\n",
"\n",
"ax.scatter(cf_strong.ds, cf_strong.eta, c=indexer.ra, cmap='tab20', s=1)\n",
"ax.set_xlabel(\"d-star\")\n",
"ax.set_ylabel(\"eta\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -396,7 +416,8 @@
"outputs": [],
"source": [
"omegas_sorted = np.sort(ds.omega)[0]\n",
"omega_slop = np.round(np.diff(omegas_sorted).mean(), 3)\n",
"omega_step = np.round(np.diff(omegas_sorted).mean(), 3)\n",
"omega_slop = omega_step/2\n",
"\n",
"makemap_hkl_tol_seq = [0.05, 0.025, 0.01]"
]
Expand All @@ -409,12 +430,14 @@
},
"outputs": [],
"source": [
"symmetry = \"cubic\"\n",
"\n",
"for inc, makemap_tol in enumerate(makemap_hkl_tol_seq):\n",
" print(f\"Running makemap {inc+1}/{len(makemap_hkl_tol_seq)}\")\n",
" if inc == 0: # ubi into map\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_ubi_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s cubic -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_ubi_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s {symmetry} -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort\n",
" else: # map into map\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_map_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s cubic -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort"
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_map_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s {symmetry} -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort"
]
},
{
Expand Down
28 changes: 25 additions & 3 deletions ImageD11/nbGui/3DXRD/2_3DXRD_index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,25 @@
"ImageD11.indexing.loglevel = 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# let's plot the assigned peaks\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"# indexer.ra is the ring assignments\n",
"\n",
"ax.scatter(cf_strong.ds, cf_strong.eta, c=indexer.ra, cmap='tab20', s=1)\n",
"ax.set_xlabel(\"d-star\")\n",
"ax.set_ylabel(\"eta\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -424,7 +443,8 @@
"outputs": [],
"source": [
"omegas_sorted = np.sort(ds.omega)[0]\n",
"omega_slop = np.round(np.diff(omegas_sorted).mean(), 3)\n",
"omega_step = np.round(np.diff(omegas_sorted).mean(), 3)\n",
"omega_slop = omega_step/2\n",
"\n",
"makemap_hkl_tol_seq = [0.05, 0.025, 0.01]"
]
Expand All @@ -437,12 +457,14 @@
},
"outputs": [],
"source": [
"symmetry = \"cubic\"\n",
"\n",
"for inc, makemap_tol in enumerate(makemap_hkl_tol_seq):\n",
" print(f\"Running makemap {inc+1}/{len(makemap_hkl_tol_seq)}\")\n",
" if inc == 0: # ubi into map\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_ubi_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s cubic -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_ubi_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s {symmetry} -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort\n",
" else: # map into map\n",
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_map_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s cubic -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort"
" makemap_output = !makemap.py -p {ds.parfile} -u {tmp_map_path} -U {tmp_map_path} -f {cf_strong_allrings_path} -F {unindexed_flt_path} -s {symmetry} -t {makemap_hkl_tol_seq[inc]} --omega_slop={omega_slop} --no_sort"
]
},
{
Expand Down
7 changes: 5 additions & 2 deletions ImageD11/nbGui/S3DXRD/2_S3DXRD_sinograms_map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@
"outputs": [],
"source": [
"fig, a = plt.subplots(1,2,figsize=(10,5))\n",
"rec = a[0].imshow(grainsinos[8].recons[\"iradon\"], vmin=0, origin=\"lower\")\n",
"sin = a[1].imshow(grainsinos[8].ssino, aspect='auto')\n",
"rec = a[0].imshow(grainsinos[0].recons[\"iradon\"], vmin=0, origin=\"lower\")\n",
"sin = a[1].imshow(grainsinos[0].ssino, aspect='auto')\n",
"\n",
"# Function to update the displayed image based on the selected frame\n",
"def update_frame(i):\n",
Expand Down Expand Up @@ -1044,6 +1044,9 @@
" print(\"Whole sample mask recon\")\n",
" whole_sample_sino, xedges, yedges = np.histogram2d(cf_4d.dty, cf_4d.omega, bins=[ds.ybinedges, ds.obinedges])\n",
" whole_sample_recon = run_iradon(whole_sample_sino, ds.obincens, pad, shift, workers=nthreads, apply_halfmask=is_half_scan, mask_central_zingers=is_half_scan)\n",
" \n",
" recon_man_mask = apply_manual_mask(whole_sample_recon)\n",
" \n",
" if manual_threshold is None:\n",
" thresh = threshold_otsu(recon_man_mask)\n",
" else:\n",
Expand Down
Loading

0 comments on commit 8e87e16

Please sign in to comment.