Skip to content

Legacy_tutorials

Fabian Brinkmann edited this page Jul 27, 2022 · 5 revisions

Install Mesh2HRTF

Follow the steps described here

Scattering from a rigid sphere by a point source

Pre-processing

  • Open Blender
  • Delete any objects, to have an empty space
  • Add an ico-sphere mesh (3D View: Add -> Mesh -> Ico Sphere)
  • Adjust the mesh settings
    • Subdivisions: 6
    • Size: 100
    • Location: 0, 0, 0
    • Rotation: 0, 0, 0
  • Rename the ico-sphere object to "Reference" Tutorial_1c

  • Export files for the numerical calculation (Info: File -> Export -> NumCalc (.inp)) If you cannot find the export option, go to the 'Mesh2Input' Section and just follow the 'Installation' section Tutorial_1d

  • Choose or create an export folder, e.g., /Users/JDoe/Simulations/RigidSpherePointSource

CAUTION: Before you click on 'Export Mesh2HRTF' you have to adjust the following settings accordingly!

  • Adjust the export settings
    • Title: Scattering from a rigid sphere by a point source
    • Ear: none
    • Pictures: False
    • Point Source: 0 0.2 0
    • Reciprocity: False
    • c: 343.18
    • rho: 1.1839
    • Unit: mm
    • Ev.Grid1: HPlane
    • Ev.Grid2: none
    • Ev.Grid3: none
    • Ev.Grid4: none
    • Ev.Grid5: none
    • NF-Calc.: False
    • Freq step: 1000
    • Freq max: 16000
    • Freq.-dep.: False
    • Method: ML-FMM BEM
    • CPU (first): depends on your setup
    • CPU (last): depends on your setup
    • Num. of used cores: depends on your setup Tutorial_1e

Numerical Calculation

Using the scripts at ARI

  • Start the numerical calculation by using the startNumCalc script, e.g., by entering startNumCalc /Users/JDoe/Simulations/RigidSpherePointSource into the terminal on Mac OS X

Using the scripts elsewhere (you personal computer)

  • Copy the contents of the NumCalc source-folder (Makefile, NC_Main,...) into each CPU_Core folder (NumCalc\CPU_1_Core_1,...)
  • Execute the Makefile and run the NumCalc script in each subdirectory

Post-processing

  • When all calculation processes are done, run Output2HRTF in Matlab If the script can't be executed or errors occur, check if you have done the Installation of the 'Output2HRTF' section correctly

  • Create VTK-files for visualization in Paraview by executing the following Matlab script: Make sure that you added the directory EvalTools\Source in the source files to your Matlab path. Otherwise there might be an error!

      :::matlab
      if ~exist('Visualization','dir')
          mkdir('Visualization');
      end
      if exist('ObjectMesh.mat','file')
          load('ObjectMesh.mat')
          if ~exist(['Visualization' filesep 'ObjectMesh'],'dir')
              mkdir(['Visualization' filesep 'ObjectMesh'])
          end
          EvalTools_export2VTK(['Visualization' filesep 'ObjectMesh' filesep],nodes{1}(:,2:end),elements{1}(:,2:end),20*log10(abs(element_data{1})/0.00002),'amp')
      end
    
  • Start Paraview

  • Load the VTK-files They are located in Visualization\ObjectMesh within your project folder

When you click on 'Apply' the visualization should look like this:

Radiation from an active vibrating element in a rigid sphere

Pre-processing

  • Open Blender

  • Delete any objects, to have an empty space

  • Add an ico-sphere mesh (3D View: Add -> Mesh -> Ico Sphere) Tutorial_1a

  • Adjust the mesh settings

    • Subdivisions: 6
    • Size: 100
    • Location: 0, 0, 0
    • Rotation: 0, 0, 0 Tutorial_1b
  • Rename the ico-sphere object to "Reference" Tutorial_1c

  • Go to the materials panel

  • Add three materials (Skin,Left ear,Right ear) Tutorial_2a

  • Switch to edit-mode (3D View: Object Mode -> Edit mode) Tutorial_2b

  • Select all elements (press 'A')

  • Assign the material Skin to all Tutorial_2c

  • Select a single element

  • Assign the material Left ear to this element Tutorial_2d

  • Export files for the numerical calculation (Info: File -> Export -> NumCalc (.inp)) If you cannot find the export option, go to the 'Mesh2Input' Section and just follow the 'Installation' section

  • Choose or create an export folder, e.g., /Users/JDoe/Simulations/RigidSphereVibratingElement

    CAUTION: Before you click on 'Export Mesh2HRTF' you have to adjust the following settings accordingly!

  • Adjust the export settings

    • Title: Radiation from a active vibrating element in a sphere
    • Ear: left
    • Pictures: False
    • Point Source: 0 101 0
    • Reciprocity: True
    • c: 343.18
    • rho: 1.1839
    • Unit: mm
    • Ev.Grid1: ARI
    • Ev.Grid2: none
    • Ev.Grid3: none
    • Ev.Grid4: none
    • Ev.Grid5: none
    • NF-Calc.: False
    • Freq step: 1000
    • Freq max: 16000
    • Freq.-dep.: False
    • Method: ML-FMM BEM
    • CPU (first): depends on your setup
    • CPU (last): depends on your setup
    • Num. of used cores: depends on your setup Tutorial_2e

Numerical Calculation

Using the scripts at ARI

  • Start the numerical calculation by using the startNumCalc script, e.g., by entering startNumCalc /Users/JDoe/Simulations/RigidSpherePointSource into the terminal on Mac OS X

Using the scripts elsewhere (you personal computer)

  • Copy the contents of the NumCalc source-folder (Makefile, NC_Main,...) into each CPU_Core folder (NumCalc\CPU_1_Core_1,...)
  • Execute the Makefile and run the NumCalc script in each subdirectory

Post-processing

  • When all calculation processes are done, run Output2HRTF in Matlab

If the script can't be executed or errors occur, check if you have done the Installation of the 'Output2HRTF' section correctly

  • Create VTK-files for visualization in Paraview by executing the following Matlab script: Make sure that you added the directory EvalTools\Source in the source files to your Matlab path. Otherwise there might be an error!

      :::matlab
      if ~exist('Visualization','dir')
          mkdir('Visualization');
      end
      if exist('ObjectMesh.mat','file')
          load('ObjectMesh.mat')
          if ~exist(['Visualization' filesep 'ObjectMesh'],'dir')
              mkdir(['Visualization' filesep 'ObjectMesh'])
          end
          EvalTools_export2VTK(['Visualization' filesep 'ObjectMesh' filesep],nodes{1}(:,2:end),elements{1}(:,2:end),20*log10(abs(element_data{1})/0.00002),'amp')
      end
    
  • Start Paraview

  • Load the VTK-files They are located in Visualization\ObjectMesh within your project folder

When you click on 'Apply' the visualization should look like this:

HRTF Calculations

Uniform Calculation (all elements have the same size):

  • Open Blender

  • Either open the .blend file or import the .stl, .obj, oder .ply files (File -> Open or File -> Import -> ply) For the tutorial we use this .blend file mesh from Ziegelwanger et al (2015). Cite this paper when using this mesh.

  • Check if Rotation, Location and Scale are all set to 0

  • Check wether the ear canal is placed on the y-axis (or Frankfurt Plane)

  • Rename the object to "Reference"

  • Go to the materials panel

  • Add three materials (Skin,Left ear,Right ear)

  • Switch to edit-mode (3D View: Object Mode -> Edit mode)

  • Select all elements (press 'A')

  • Assign the material Skin to all

  • Assign the material Left ear and Right ear to elements within the ear canal. These will represent the microphones

  • Export files for the numerical calculation (Info: File -> Export -> NumCalc (.inp)) If you cannot find the export option, go to the 'Mesh2Input' Section and just follow the 'Installation' section

  • Choose or create an export folder, e.g., /Users/JDoe/Simulations/UniformHRTFCalculation

    CAUTION: Before you click on 'Export Mesh2HRTF' you have to adjust the following settings accordingly!

  • Adjust the export settings

    • Title: Uniform HRTF Calculation
    • Ear: both
    • Pictures: False
    • Point Source: 0 101 0
    • Reciprocity: True
    • c: 343.18
    • rho: 1.1839
    • Unit: mm
    • Ev.Grid1: ARI
    • Ev.Grid2: none
    • Ev.Grid3: none
    • Ev.Grid4: none
    • Ev.Grid5: none
    • NF-Calc.: False
    • Freq step: 100
    • Freq max: 16000
    • Freq.-dep.: False
    • Method: ML-FMM BEM
    • CPU (first): depends on your setup
    • CPU (last): depends on your setup
    • Num. of used cores: depends on your setup

Numerical Calculation

Using the scripts at ARI

  • Start the numerical calculation by using the startNumCalc script, e.g., by entering startNumCalc /Users/JDoe/Simulations/UniformHRTFCalculation into the terminal on Mac OS X

Using the scripts elsewhere (you personal computer)

  • Copy the contents of the NumCalc source-folder (Makefile, NC_Main,...) into each CPU_Core folder (NumCalc\CPU_1_Core_1,...)
  • Execute the Makefile and run the NumCalc script in each subdirectory

Post-processing

  • When all calculation processes are done, run Output2HRTF in Matlab

If the script can't be executed or errors occur, check if you have done the Installation of the 'Output2HRTF' section correctly

  • Now you can use the SOFA Matlab API toolbox ( 'Output2HRTF') to plot your HRTF using these instructions: a) your_variable = SOFAload('EvaluationGrid.sofa'); b) SOFAplotHRTF(your_variable, 'mode'); you can choose from the following modes to display the HRTF:

          - 'EtcHorizontal'  energy-time curve in the horizontal plane (+/- 5 deg)
          - 'EtcMedian'      energy-time curve in the median plane (+/- 2 deg)
          - 'MagHorizontal'  magnitude spectra in the horizontal plane (+/- 5 deg)
          - 'MagMedian'      magnitude spectra in the median plane (+/- 2 deg)
          - 'magspectrum'    single magnitude spectrum for direction DIR in COLOR
    

The following image shows the energy time curve in the horzontal pane (mode = EtcHorizontal):

Non-Uniform Calculation:

  • Open Blender

  • Either open the .blend file or import the .stl, .obj, oder .ply files (File -> Open or File -> Import -> ply) For the tutorial we use this .blend file mesh from Ziegelwanger et al (2015). Cite this paper when using this mesh.

  • Check if Rotation, Location and Scale are all set to 0

  • Check wether the ear canal is placed on the y-axis (or Frankfurt Plane)

  • Rename the object either to "L20000" or "R20000"

  • Go to the materials panel

  • Add three materials (Skin,Left ear,Right ear)

  • Switch to edit-mode (3D View: Object Mode -> Edit mode)

  • Select all elements (press 'A')

  • Assign the material Skin to all

  • Assign the material Left ear orRight ear (depending which mesh you have) to elements within the ear canal. These will represent the microphones

  • Export files for the numerical calculation (Info: File -> Export -> NumCalc (.inp)) If you cannot find the export option, go to the 'Mesh2Input' Section and just follow the 'Installation' section

  • Choose or create an export folder, e.g., /Users/JDoe/Simulations/NonUniformHRTFCalculation

    CAUTION: Before you click on 'Export Mesh2HRTF' you have to adjust the following settings accordingly!

  • Adjust the export settings

    • Title: Nonuniform HRTF Calculation
    • Ear: both
    • Pictures: False
    • Point Source: 0 101 0
    • Reciprocity: True
    • c: 343.18
    • rho: 1.1839
    • Unit: mm
    • Ev.Grid1: ARI
    • Ev.Grid2: none
    • Ev.Grid3: none
    • Ev.Grid4: none
    • Ev.Grid5: none
    • NF-Calc.: False
    • Freq step: 100
    • Freq max: 16000
    • Freq.-dep.: True
    • Method: ML-FMM BEM
    • CPU (first): depends on your setup
    • CPU (last): depends on your setup
    • Num. of used cores: depends on your setup

Numerical Calculation

Using the scripts at ARI

  • Start the numerical calculation by using the startNumCalc script, e.g., by entering startNumCalc /Users/JDoe/Simulations/NonUniformHRTFCalculation into the terminal on Mac OS X

Using the scripts elsewhere (you personal computer)

  • Copy the contents of the NumCalc source-folder (Makefile, NC_Main,...) into each CPU_Core folder (NumCalc\CPU_1_Core_1,...)
  • Execute the Makefile and run the NumCalc script in each subdirectory

Post-processing

  • When all calculation processes are done, run Output2HRTF in Matlab

If the script can't be executed or errors occur, check if you have done the Installation of the 'Output2HRTF' section correctly

  • Now you can use the SOFA Matlab API toolbox ( 'Output2HRTF') to plot your HRTF using these instructions: a) your_variable = SOFAload('EvaluationGrid.sofa'); b) SOFAplotHRTF(your_variable, 'mode'); you can choose from the following modes to display the HRTF:

          - 'EtcHorizontal'  energy-time curve in the horizontal plane (+/- 5 deg)
          - 'EtcMedian'      energy-time curve in the median plane (+/- 2 deg)
          - 'MagHorizontal'  magnitude spectra in the horizontal plane (+/- 5 deg)
          - 'MagMedian'      magnitude spectra in the median plane (+/- 2 deg)
          - 'magspectrum'    single magnitude spectrum for direction DIR in COLOR
    

The following image shows the energy time curve in the horzontal pane for the right ear (mode = EtcHorizontal):

References

Ziegelwanger, H., Majdak, P., Kreuzer, W. (2015): Numerical calculation of listener-specific head-related transfer functions and sound localization: Microphone model and mesh discretization, in: The Journal of the Acoustical Society of America

Clone this wiki locally