.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/01_modelling/plot_08_sensitivity_thresholding.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_01_modelling_plot_08_sensitivity_thresholding.py: Segmenting sensitivity distributions ==================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Imports .. GENERATED FROM PYTHON SOURCE LINES 9-13 .. code-block:: Python import numpy as np import crtomo import pylab as plt .. GENERATED FROM PYTHON SOURCE LINES 14-15 create and save a FEM-grid .. GENERATED FROM PYTHON SOURCE LINES 15-28 .. code-block:: Python grid = crtomo.crt_grid.create_surface_grid( nr_electrodes=40, spacing=0.25, depth=10, char_lengths=[0.1, 0.5, 0.5, 0.5], left=5, right=5, ) grid.plot_grid() grid.save_elem_file('elem.dat') grid.save_elec_file('elec.dat') .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_08_sensitivity_thresholding_001.png :alt: plot 08 sensitivity thresholding :srcset: /_examples/01_modelling/images/sphx_glr_plot_08_sensitivity_thresholding_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found .. GENERATED FROM PYTHON SOURCE LINES 29-30 create the measurement configuration .. GENERATED FROM PYTHON SOURCE LINES 30-35 .. code-block:: Python configs = np.array(( (1, 20, 2, 18), )) .. GENERATED FROM PYTHON SOURCE LINES 36-37 for different background, plot the sensitivities .. GENERATED FROM PYTHON SOURCE LINES 37-60 .. code-block:: Python bg = 100 td = crtomo.tdMan(grid=grid) td.configs.add_to_configs(configs) td.add_homogeneous_model(bg, 0) td.model(sensitivities=True) fig, ax = plt.subplots(1, 1) s_abs = np.abs(td.parman.parsets[2]) threshold = np.quantile(s_abs, 0.75) s_abs[s_abs <= threshold] = 0 s_abs[s_abs > threshold] = 1 td.plot.plot_elements_to_ax( s_abs, ax=ax, plot_colorbar=True, cmap_name='binary', ) fig.tight_layout() fig.show() fig.savefig('test_sens.jpg', dpi=300) # sphinx_gallery_thumbnail_number = -1 .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_08_sensitivity_thresholding_002.png :alt: plot 08 sensitivity thresholding :srcset: /_examples/01_modelling/images/sphx_glr_plot_08_sensitivity_thresholding_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none attempting modeling b' ######### CMod ############\nLicence:\nCopyright \xc2\xa9 1990-2020 Andreas Kemna \nCopyright \xc2\xa9 2008-2020 CRTomo development team (see AUTHORS file)\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \xe2\x80\x9cSoftware\xe2\x80\x9d), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \xe2\x80\x9cAS IS\xe2\x80\x9d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n \n \n CRMod Process_ID :: 5063\n OpenMP max threads: 4\n Git-Branch master\n Commit-ID cb89ccd2c4341b9b08bbe7bb08f5aea0d60916ee\n Created Mon-Mar-25-14:34:56-2024\n Compiler \n OS GNU/Linux\n\n Reading Input-Files\n++ check 1\r++ check 2 done!\n\rGetting voltage 1 No electrode cap file\n \n Rescheduling..\n less nodes than wavenumbers\n OpenMP threads: 3( 4)\n\n\r Calculating Potentials : Wavenumber 2 \r Calculating Potentials : Wavenumber 3 \r Calculating Potentials : Wavenumber 3 \r Calculating Potentials : Wavenumber 4 \r Calculating Potentials : Wavenumber 5 \r Calculating Potentials : Wavenumber 6 \r Calculating Potentials : Wavenumber 7 \r Calculating Potentials : Wavenumber 8 \r Calculating Potentials : Wavenumber 9 \r Calculating Potentials : Wavenumber 10 \r Calculating Potentials : Wavenumber 11 done, now processing\n solution time 0d/ 0h/ 0m/ 3s/ 652ms\n\n Modelling completedSTOP 0\n' reading voltages reading sensitivities .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 10.538 seconds) .. _sphx_glr_download__examples_01_modelling_plot_08_sensitivity_thresholding.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_08_sensitivity_thresholding.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_08_sensitivity_thresholding.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_08_sensitivity_thresholding.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_