Skip to content

Create new task schema for iteratively sampling orientations from ODF in MTEX #567

Open

Description

@gcapes

Sam Engel already uses this method, but not as a Matflow task.

Activity

  1. self-assigned this
    on Sep 1, 2026
  2. dkfellows commented on Sep 1, 2026

    @dkfellows
    Collaborator

    NB: Reported that this method converges rapidly on the origin model despite being more computationally heavy than simple random sampling, so is of a lot of interest.

  3. gcapes commented on Sep 1, 2026

    @gcapes
    CollaboratorAuthor

    Guy has a notebook which compares the two methods.

  4. gcapes commented on Sep 7, 2026

    @gcapes
    CollaboratorAuthor

    @Gbowker would you be able to send me something to get me started with this? Thanks

  5. Gbowker commented on Sep 7, 2026

    @Gbowker
    Collaborator

    Hi Gerard, Here is the script and input files I have which does this in MTEX:

    texture sampling.zip

    We just need to write the task_schema and workflow to accompany it:
    Inputs:

    • .crc filepaths
    • corrections (one set of three angles for each .crc file)
      Outputs:
    • combined_texture.png pole figures
    • sampled_texture.txt
    • sampled_texture.png pole figures

    The script uses an older version of MTEX (5.3) but should work for a later version with small tweaks.
    I needed to use MTEX 5.3 due to the requirements of the industrial partners.
    Let me know if this is enough to get you started!

  6. gcapes commented on Sep 8, 2026

    @gcapes
    CollaboratorAuthor

    Thanks Guy. I've tried to run the script with MTEX 5.3 and MATLAB R2024b, but get an error:

    47D.crc
        89    88   135
    
    Error using loadEBSD_crc (line 30)
    EBSD format 'CRC' does not match the data
     file: '47D.crc'
    
    Error in EBSD.load (line 86)
      ebsd{k} = feval(['loadEBSD_',char(interface)],...
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error in EBSD2model_varargs>loadmap_correct (line 129)
        ebsdmap = EBSD.load(filepath,CS,'interface','crc','convertSpatial2EulerReferenceFrame', 'Bunge');
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error in EBSD2model_varargs (line 27)
        corrected_maps{m} = loadmap_correct(maps(m), CS, corrections(m,:));
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    

    Would you mind checking the files in the zip archive? Thanks

  7. Gbowker commented on Sep 8, 2026

    @Gbowker
    Collaborator

    Hi Gerard, Matlab just needs absolute paths rather than relative ones. So you need to include your pwd in the path for each .crc file.

  8. gcapes commented on Sep 8, 2026

    @gcapes
    CollaboratorAuthor

    Thanks Guy. I've tried that but I get the same error, only this time will the full rather than absolute path. It's complaining that the EBSD format doesn't match the data, rather than not being able to find the file.

  9. gcapes commented on Sep 15, 2026

    @gcapes
    CollaboratorAuthor

    I met with Guy and now have some new files which ran successfully.

    Notes from our chat:

    • Don't want ebsd_maps.txt as input for the matflow task. Want list of (any number of) file paths, and corrections for each path (list of three correction values). Also need euler_degrees: true/false as input. mtex expects degrees.
    • Keep two versions of mtex in the matflow task: 5.3 and latest.
    • New files contain three datasets. Test all three run with MATLAB before moving on.
    • Get code working with both MTEX 5.3 and MTEX 6.0.0
  10. gcapes commented on Sep 17, 2026

    @gcapes
    CollaboratorAuthor

    For the MatFlow tasks, I think the existing MATLAB script does a few things which should be separated into distinct tasks:

    • Save ebsd orientations from combined maps
    • Plot pole figures for the ODF (task already exists in MatFlow)
    • Create ODF from orientations, then save texture sampled using MCMC
    • Plot pole figures for sampled texture (task already exists in MatFlow)

    The implications for the above are that

    • the orientations needs to be saved after the first task as an HDF file as the required input format for the plot_pole_figures task
    • the ODF should be generated from orientations for the MCMC sampling
  11. gcapes commented on Sep 23, 2026

    @gcapes
    CollaboratorAuthor

    Implementing the first task in MatFlow has revealed #576.
    I've been looking to reuse existing code (get_EBSD_orientations_from_CRC_file) to load the CRC files, but I'm unclear whether this will work for the purposes required here as we need to do three rotations. When I try I get this error about types:

    34      corrected_maps{m} = get_EBSD_orientations_from_CRC_file(ebsd_map_path, ...
    Error using MException
    MESSAGE input must be a character vector or string scalar.
    
    Error in interfaceError (line 28)
    e = MException('mtex:wrongInterface',...
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error in loadEBSD_crc (line 32)
      interfaceError(fname);
      ^^^^^^^^^^^^^^^^^^^^^
    Error in Novelis_EBSD2model_varargs>get_EBSD_orientations_from_CRC_file (line 311)
        ebsd = loadEBSD_crc(CRCFilePath, referenceFrameTransformation{:});
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error in Novelis_EBSD2model_varargs (line 34)
        corrected_maps{m} = get_EBSD_orientations_from_CRC_file(ebsd_map_path, ...
    
  12. gcapes commented on Sep 24, 2026

    @gcapes
    CollaboratorAuthor

    I'd confused some of the required input formats around cells, but the final problem is that the MTEX rotation function looks only to be able to do one rotation at a time, so we cannot pass in a vector of 3 euler angles and use the MatFlow function.
    So use Guy's code instead, and Adam is looking into #576.

  13. gcapes commented on Sep 24, 2026

    @gcapes
    CollaboratorAuthor

    #576 has now been fixed.

  14. Gbowker commented on Sep 24, 2026

    @Gbowker
    Collaborator

    Great, thankyou - how close are you to getting the MCMC task finished now?

  15. gcapes commented on Sep 24, 2026

    @gcapes
    CollaboratorAuthor

    Making steady progress. I could do with another chat next week if you're around on Monday?
    It wasn't EBSD.orientations that we needed to export to HDF, rather orientations sampled from the ODF. So I think I've done that, but can't get the pole figure quite right.
    Other tasks do that, but we need to save the actual orienations rather than a sample from an ODF.

  16. gcapes commented on Sep 28, 2026

    @gcapes
    CollaboratorAuthor

    I'm not sure whether I've captured all that is needed for the pole figures plot. Your script contains

    CS = crystalSymmetry('m-3m', [4.04 4.04 4.04], 'mineral', 'Aluminum', 'color', [0 0.8 1]);
    

    and I'm not sure whether the matflow input parameter crystal_symmetry: cubic is enough? The help/notation isn't super clear, but cubic looks to equate to the first term m-3m.

  17. gcapes commented on Oct 1, 2026

    @gcapes
    CollaboratorAuthor

    Hi @Gbowker ,
    I think this is ready for you to test now. If you pull this branch, there's one thing you'd need to change in the demo workflow, which is the path to the CRC files under

    tasks:
    - schema: combine_orientations_from_EBSD_maps
      inputs:
        CRC_file_paths:
    

    I'll add some demo workflow files once you're happy with the workflow.

  18. Gbowker commented on Oct 1, 2026

    @Gbowker
    Collaborator

    Fantastic Gerard will give that a go later today! :)
    Thanks!

  19. gcapes commented on Oct 1, 2026

    @gcapes
    CollaboratorAuthor

    Great! I'm still looking at getting the pole figure plots the same as you made with MATLAB so watch this space 🤞

  20. gcapes commented on Oct 1, 2026

    @gcapes
    CollaboratorAuthor

    Debugging info for me for later:
    The same MTEXprefs value is set in MATLAB and via MatFlow for pfAnnotations.
    In MATLAB, this draws the XYZ labels, but in MatFlow it doesn't. Why?
    In MATLAB, adding manual annotations draws on top the existing XYZ ones, which is messy.
    In MatFlow, there are no existing annotations so it works out ok.

  21. gcapes commented on Oct 8, 2026

    @gcapes
    CollaboratorAuthor

    Maybe look at startup_mtex script and compare with Matflow matlab_env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions