From f282e771fafb24913c631a42918852e2a6364f41 Mon Sep 17 00:00:00 2001 From: ajacksonbq Date: Sun, 14 Jan 2024 12:34:56 -0500 Subject: [PATCH] PY: Added Python Code for Most Example Pipelines (#800) Python code examples including pipelines, plugins and generic examples have been updated. Signed-off-by: Michael Jackson Co-authored-by: Michael Jackson Co-authored-by: Jared Duffey --- .gitignore | 1 + CMakeLists.txt | 2 +- cmake/Summary.cmake | 5 +- cmake/Utility.cmake | 4 +- conda/conda_build_config.yaml | 4 +- conda/meta.yaml | 4 +- conda/recipe.yaml | 12 +- .../OrientationAnalysis/test/CMakeLists.txt | 2 +- .../test/MergeTwinsTest.cpp | 2 +- .../test/OrientationAnalysisTestUtils.hpp | 4 +- .../pipelines/Import_ASCII.d3dpipeline | 101 ++--- .../Filters/ReadVolumeGraphicsFileFilter.cpp | 4 +- .../TestOne/test/ErrorWarningFilterTest.cpp | 2 +- wrapping/python/CMakeLists.txt | 53 +-- .../{ => CxPybind}/SimplnxPython.hpp.in | 0 wrapping/python/ReadMe.md | 106 +++-- wrapping/python/docs/ReadMe.md | 8 - .../python/docs/source/ReleaseNotes_120.rst | 36 +- .../python/examples/{ => data}/angles.csv | 0 .../examples/{ => data}/test_csv_data.csv | 0 wrapping/python/examples/file_dependency.dot | 81 ++++ .../notebooks/angle_conversion.ipynb | 14 +- .../notebooks/basic_arrays.ipynb | 22 +- .../notebooks/basic_ebsd_ipf.ipynb | 62 +-- .../notebooks/basic_numpy.ipynb | 22 +- .../notebooks/create_image_geom.ipynb | 14 +- .../{ => examples}/notebooks/import_d3d.ipynb | 10 +- .../notebooks/output_file.ipynb | 12 +- .../{ => examples}/notebooks/pipeline.ipynb | 8 +- .../02_Image_Segmentation.py | 199 +++++++++ .../03_Porosity_Mesh_Export.py | 261 +++++++++++ .../Incomplete/ImportBrukerNanoEspritData.py | 40 ++ .../pipelines/Incomplete/ImportEdaxOIMData.py | 64 +++ .../01_Small_IN100_Archive.py | 40 ++ ...01_Small_IN100_Morphological_Statistics.py | 186 ++++++++ .../01_Small_IN100_Quick_Mesh.py | 92 ++++ .../02_Small_IN100_Smooth_Mesh.py | 62 +++ .../03_Small_IN100_Mesh_Statistics.py | 120 ++++++ .../04_Small_IN100_GBCD.py | 140 ++++++ ...Small_IN100_Crystallographic_Statistics.py | 153 +++++++ .../05_Small_IN100_GBCD_Metric.py | 145 +++++++ .../08_Small_IN100_Full_Reconstruction.py | 405 ++++++++++++++++++ .../OrientationAnalysis/APTR12_Analysis.py | 388 +++++++++++++++++ .../OrientationAnalysis/AVTR12_Analysis.py | 388 +++++++++++++++++ .../AlignSectionsMutualInformation.py | 113 +++++ .../OrientationAnalysis/AvizoWriters.py | 58 +++ .../OrientationAnalysis/CI_Histogram.py | 129 ++++++ .../OrientationAnalysis/Edax_IPF_Colors.py | 111 +++++ .../OrientationAnalysis/FindBiasedFeatures.py | 129 ++++++ .../OrientationAnalysis/FindBoundaryCells.py | 58 +++ .../FindGBCD-GBPDMetricBased.py | 102 +++++ .../FindLargestCrossSections.py | 124 ++++++ .../pipelines/OrientationAnalysis/ReadAng.py | 87 ++++ .../pipelines/OrientationAnalysis/ReadCTF.py | 79 ++++ .../OrientationAnalysis/TxCopper_Exposed.py | 135 ++++++ .../OrientationAnalysis/TxCopper_Unexposed.py | 135 ++++++ .../VtkRectilinearGridWriter.py | 69 +++ .../Simplnx/AppendImageGeometryZSlice.py | 168 ++++++++ .../Simplnx/ApplyTransformation_Demo.py | 94 ++++ .../Simplnx/ApplyTransformation_Image.py | 207 +++++++++ .../Simplnx/ApplyTransformation_Node.py | 140 ++++++ .../Simplnx/ArrayCalculatorExample.py | 133 ++++++ .../pipelines/Simplnx/CombineSTLFiles.py | 43 ++ .../pipelines/Simplnx/EnsembleInfoReader.py | 123 ++++++ .../pipelines/Simplnx/Import_ASCII.py | 159 +++++++ .../pipelines/Simplnx/Import_CSV_Data.py | 98 +++++ .../pipelines/Simplnx/Import_STL_Model.py | 54 +++ .../ReplaceElementAttributesWithNeighbor.py | 161 +++++++ .../Simplnx/ResamplePorosityImage.py | 121 ++++++ .../Simplnx/ResampleRectGridToImageGeom.py | 220 ++++++++++ .../pipelines/Simplnx/SurfaceNets_Demo.py | 119 +++++ .../Simplnx/Triangle_Face_Data_Demo.py | 72 ++++ .../examples/pipelines/SourceList.cmake | 86 ++++ .../examples/scripts/Combine_STL_Files.py | 43 ++ .../examples/scripts/Import_STL_File.py | 37 ++ .../python/examples/scripts/SourceList.cmake | 25 ++ .../{ => scripts}/angle_conversion.py | 3 +- .../examples/{ => scripts}/basic_arrays.py | 13 +- .../examples/{ => scripts}/basic_ebsd_ipf.py | 1 + .../examples/{ => scripts}/basic_numpy.py | 1 + .../{ => scripts}/create_ensemble_info.py | 1 + .../{ => scripts}/generated_file_list.py | 1 + .../{ => scripts}/geometry_examples.py | 16 +- .../examples/{ => scripts}/import_d3d.py | 0 .../examples/{ => scripts}/import_hdf5.py | 1 + .../examples/{ => scripts}/output_file.py | 5 +- .../python/examples/{ => scripts}/pipeline.py | 0 .../examples/{ => scripts}/read_csv_file.py | 3 +- .../{ => scripts}/read_esprit_data.py | 1 + .../TestPlugin/CreateArray.py | 1 + .../TestPlugin/InitializeData.py | 1 + .../TestPlugin/Plugin.py | 1 + .../TestPlugin/TemplateFilter.py | 1 + .../TestPlugin/__init__.py | 1 + wrapping/python/testing/anaconda_test.bat | 15 +- .../{ => testing}/simplnx_test_dirs.in.py | 26 +- wrapping/python/{ => utils}/fix_pyi_file.py | 1 + 97 files changed, 6494 insertions(+), 309 deletions(-) rename wrapping/python/{ => CxPybind}/SimplnxPython.hpp.in (100%) delete mode 100644 wrapping/python/docs/ReadMe.md rename wrapping/python/examples/{ => data}/angles.csv (100%) rename wrapping/python/examples/{ => data}/test_csv_data.csv (100%) create mode 100644 wrapping/python/examples/file_dependency.dot rename wrapping/python/{ => examples}/notebooks/angle_conversion.ipynb (89%) rename wrapping/python/{ => examples}/notebooks/basic_arrays.ipynb (88%) rename wrapping/python/{ => examples}/notebooks/basic_ebsd_ipf.ipynb (85%) rename wrapping/python/{ => examples}/notebooks/basic_numpy.ipynb (84%) rename wrapping/python/{ => examples}/notebooks/create_image_geom.ipynb (88%) rename wrapping/python/{ => examples}/notebooks/import_d3d.ipynb (91%) rename wrapping/python/{ => examples}/notebooks/output_file.ipynb (88%) rename wrapping/python/{ => examples}/notebooks/pipeline.ipynb (83%) create mode 100644 wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py create mode 100644 wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py create mode 100644 wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py create mode 100644 wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/FindBiasedFeatures.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/FindBoundaryCells.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/FindGBCD-GBPDMetricBased.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/FindLargestCrossSections.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py create mode 100644 wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/AppendImageGeometryZSlice.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/Import_CSV_Data.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py create mode 100644 wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py create mode 100644 wrapping/python/examples/pipelines/SourceList.cmake create mode 100644 wrapping/python/examples/scripts/Combine_STL_Files.py create mode 100644 wrapping/python/examples/scripts/Import_STL_File.py create mode 100644 wrapping/python/examples/scripts/SourceList.cmake rename wrapping/python/examples/{ => scripts}/angle_conversion.py (97%) rename wrapping/python/examples/{ => scripts}/basic_arrays.py (95%) rename wrapping/python/examples/{ => scripts}/basic_ebsd_ipf.py (99%) rename wrapping/python/examples/{ => scripts}/basic_numpy.py (99%) rename wrapping/python/examples/{ => scripts}/create_ensemble_info.py (99%) rename wrapping/python/examples/{ => scripts}/generated_file_list.py (99%) rename wrapping/python/examples/{ => scripts}/geometry_examples.py (96%) rename wrapping/python/examples/{ => scripts}/import_d3d.py (100%) rename wrapping/python/examples/{ => scripts}/import_hdf5.py (99%) rename wrapping/python/examples/{ => scripts}/output_file.py (93%) rename wrapping/python/examples/{ => scripts}/pipeline.py (100%) rename wrapping/python/examples/{ => scripts}/read_csv_file.py (98%) rename wrapping/python/examples/{ => scripts}/read_esprit_data.py (99%) rename wrapping/python/{examples => plugins}/TestPlugin/CreateArray.py (99%) rename wrapping/python/{examples => plugins}/TestPlugin/InitializeData.py (99%) rename wrapping/python/{examples => plugins}/TestPlugin/Plugin.py (99%) rename wrapping/python/{examples => plugins}/TestPlugin/TemplateFilter.py (99%) rename wrapping/python/{examples => plugins}/TestPlugin/__init__.py (99%) rename wrapping/python/{ => testing}/simplnx_test_dirs.in.py (69%) rename wrapping/python/{ => utils}/fix_pyi_file.py (99%) diff --git a/.gitignore b/.gitignore index 2ed0689094..0c4a391e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ test_data/ CMakeUserPresets.json Workspace /__pycache__/ +/Data/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a616d88edb..a1968ad060 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -736,7 +736,7 @@ endforeach() set(SIMPLNX_GENERATED_PYTHON_HEADER ${SIMPLNX_GENERATED_HEADER_DIR}/SimplnxPython.hpp) set(SIMPLNX_PYTHON_MODULE "simplnx") -configure_file(${simplnx_SOURCE_DIR}/wrapping/python/SimplnxPython.hpp.in ${SIMPLNX_GENERATED_PYTHON_HEADER}) +configure_file(${simplnx_SOURCE_DIR}/wrapping/python/CxPybind/SimplnxPython.hpp.in ${SIMPLNX_GENERATED_PYTHON_HEADER}) list(APPEND SIMPLNX_GENERATED_HEADERS ${SIMPLNX_GENERATED_PYTHON_HEADER} diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index 93ec193167..fdd183bef8 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -49,8 +49,7 @@ OSInformation() message(STATUS "* -------------- Dependent Libraries -------------------------------------------") message(STATUS "* Eigen (${Eigen3_VERSION}) ${Eigen3_DIR}") message(STATUS "* HDF5 (${HDF5_VERSION}) ${HDF5_INSTALL}") -# message(STATUS "* ITK (${ITK_VERSION}) ${ITK_DIR}") -message(STATUS "* Pybind11 (${pybind11_VERSION}) ${pybind11_DIR}") +message(STATUS "* ITK (${ITK_VERSION}) ${ITK_DIR}") message(STATUS "* TBB (${TBB_VERSION}) ${TBB_DIR}") message(STATUS "* fmt (${fmt_VERSION}) ${fmt_DIR}") message(STATUS "* nlohmann_json (${nlohmann_json_VERSION}) ${nlohmann_json_DIR}") @@ -73,7 +72,9 @@ message(STATUS "* SIMPLNX_BUILD_DOCS: ${SIMPLNX_BUILD_DOCS}") message(STATUS "* DREAM3D_DATA_DIR: ${DREAM3D_DATA_DIR}") message(STATUS "* -------------- Simplnx Python Configuration Options -------------------------------------") +message(STATUS "* Pybind11 (${pybind11_VERSION}) ${pybind11_DIR}") message(STATUS "* Python3_EXECUTABLE: ${Python3_EXECUTABLE}") +message(STATUS "* PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") message(STATUS "* SIMPLNX_BUILD_PYTHON: ${SIMPLNX_BUILD_PYTHON}") message(STATUS "* SIMPLNX_BUILD_PYTHON_DOCS: ${SIMPLNX_BUILD_PYTHON_DOCS}") message(STATUS "* SIMPLNX_BUILD_PYTHON_TESTS: ${SIMPLNX_BUILD_PYTHON_TESTS}") diff --git a/cmake/Utility.cmake b/cmake/Utility.cmake index 74294d1933..9845e7b342 100644 --- a/cmake/Utility.cmake +++ b/cmake/Utility.cmake @@ -275,7 +275,7 @@ function(create_pipeline_tests) get_filename_component(test_file_name ${pipeline_file_path} NAME_WE) string(REPLACE "/" "-" test_file_name "${test_file_name}") - add_test(NAME "${ARGS_PLUGIN_NAME} ${padding}${test_index} ${test_file_name}" + add_test(NAME "PIPELINE::${ARGS_PLUGIN_NAME}::${padding}${test_index}_${test_file_name}" COMMAND "${PIPELINE_RUNNER_NAME}$<$:${PIPELINE_RUNNER_DEBUG}>" --execute ${pipeline_file_path} #CONFIGURATIONS Debug WORKING_DIRECTORY ${TEST_WORKING_DIR}) @@ -473,7 +473,7 @@ function(AddPythonTest) set(oneValueArgs NAME FILE) set(multiValueArgs PYTHONPATH) cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - message(STATUS "ARGS_FILE:${ARGS_FILE}") + # message(STATUS "ARGS_FILE:${ARGS_FILE}") if(SIMPLNX_BUILD_PYTHON) if(WIN32) add_test(NAME ${ARGS_NAME} diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml index 201d269195..493a246d22 100644 --- a/conda/conda_build_config.yaml +++ b/conda/conda_build_config.yaml @@ -2,10 +2,10 @@ cxx_compiler: - vs2019 # [win] c_compiler_version: # [unix] - - 9.3.0 # [linux] + - 10.4.0 # [linux] cxx_compiler_version: - - 9.3.0 # [linux] + - 10.4.0 # [linux] python: - 3.11 diff --git a/conda/meta.yaml b/conda/meta.yaml index df78e6db52..e56a1dec41 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,5 +1,5 @@ {% set name = "simplnx" %} -{% set version = "1.2.2" %} +{% set version = "1.2.3" %} package: name: {{ name|lower }} @@ -40,7 +40,7 @@ build: requirements: build: - {{ compiler('cxx') }} - - cmake >=3.19 + - cmake >=3.26 - ninja - git host: diff --git a/conda/recipe.yaml b/conda/recipe.yaml index 0a355947b6..8a9f12ca77 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -1,5 +1,5 @@ context: - version: "1.2.1" + version: "1.2.3" name: simplnx package: @@ -26,7 +26,10 @@ source: folder: span-lite - url: https://raw.githubusercontent.com/bluequartzsoftware/simplnx-registry/9a5db7b5fa02b2495eb51654cbaab3c63820c779/ports/nod/CMakeLists.txt folder: nod - + - git_url: https://github.com/insightsoftwareconsortium/ITK + git_rev: v5.2.1 + folder: itk + build: number: 0 script_env: @@ -38,7 +41,7 @@ build: requirements: build: - "{{ compiler('cxx') }}" - - cmake >=3.19 + - cmake >=3.26 - ninja - git host: @@ -49,8 +52,6 @@ requirements: - eigen - fmt =10 - hdf5 =1.12 - - libitk =5.2 - - libitk-devel =5.2 - nlohmann_json - pybind11 >=2.10 - reproc-cpp @@ -66,7 +67,6 @@ requirements: - numpy - fmt =10 - hdf5 =1.12 - - libitk =5.2 - reproc-cpp - tbb - zlib diff --git a/src/Plugins/OrientationAnalysis/test/CMakeLists.txt b/src/Plugins/OrientationAnalysis/test/CMakeLists.txt index 4772ff2b44..1be70b2eb4 100644 --- a/src/Plugins/OrientationAnalysis/test/CMakeLists.txt +++ b/src/Plugins/OrientationAnalysis/test/CMakeLists.txt @@ -288,7 +288,7 @@ fi "${SIMPLNX_CTEST_TEST_DRIVER}" @ONLY) string(REPLACE "/" "_" test "${test}") - add_test(NAME ${PLUGIN_NAME}_${ARGS_TEST_INDEX} COMMAND "${SIMPLNX_CTEST_TEST_DRIVER}") + add_test(NAME "PIPELINE::${PLUGIN_NAME}::${ARGS_TEST_INDEX}" COMMAND "${SIMPLNX_CTEST_TEST_DRIVER}") endfunction() # ------------------------------------------------------------------------------ diff --git a/src/Plugins/OrientationAnalysis/test/MergeTwinsTest.cpp b/src/Plugins/OrientationAnalysis/test/MergeTwinsTest.cpp index 4cb923a1bf..22ae77d521 100644 --- a/src/Plugins/OrientationAnalysis/test/MergeTwinsTest.cpp +++ b/src/Plugins/OrientationAnalysis/test/MergeTwinsTest.cpp @@ -64,7 +64,7 @@ TEST_CASE("Reconstruction::MergeTwinsFilter: Valid Execution", "[Reconstruction] { constexpr StringLiteral k_ImportFileData = "import_file_data"; - auto filter = filterList->createFilter(k_ImportDream3dFilterHandle); + auto filter = filterList->createFilter(k_ReadDREAM3DFilterHandle); REQUIRE(nullptr != filter); Dream3dImportParameter::ImportData parameter; diff --git a/src/Plugins/OrientationAnalysis/test/OrientationAnalysisTestUtils.hpp b/src/Plugins/OrientationAnalysis/test/OrientationAnalysisTestUtils.hpp index 670bcaf615..cfb4246c31 100644 --- a/src/Plugins/OrientationAnalysis/test/OrientationAnalysisTestUtils.hpp +++ b/src/Plugins/OrientationAnalysis/test/OrientationAnalysisTestUtils.hpp @@ -43,8 +43,8 @@ namespace nx::core const Uuid k_ReadTextDataArrayFilterId = *Uuid::FromString("25f7df3e-ca3e-4634-adda-732c0e56efd4"); const FilterHandle k_ReadTextDataArrayFilterHandle(k_ReadTextDataArrayFilterId, k_SimplnxCorePluginId); // Make sure we can instantiate the Read DREAM3D Data File -const Uuid k_ImportDream3dFilterId = *Uuid::FromString("0dbd31c7-19e0-4077-83ef-f4a6459a0e2d"); -const FilterHandle k_ImportDream3dFilterHandle(k_ImportDream3dFilterId, k_SimplnxCorePluginId); +const Uuid k_ReadDREAM3DFilterId = *Uuid::FromString("0dbd31c7-19e0-4077-83ef-f4a6459a0e2d"); +const FilterHandle k_ReadDREAM3DFilterHandle(k_ReadDREAM3DFilterId, k_SimplnxCorePluginId); // Make sure we can instantiate the Read RenameDataObject const Uuid k_RenameDataObjectFilterId = *Uuid::FromString("911a3aa9-d3c2-4f66-9451-8861c4b726d5"); const FilterHandle k_RenameDataObjectFilterHandle(k_RenameDataObjectFilterId, k_SimplnxCorePluginId); diff --git a/src/Plugins/SimplnxCore/pipelines/Import_ASCII.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/Import_ASCII.d3dpipeline index 847983a7e5..e617e62cdb 100644 --- a/src/Plugins/SimplnxCore/pipelines/Import_ASCII.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/Import_ASCII.d3dpipeline @@ -7,9 +7,9 @@ "args": { "cell_data_name": "CellData", "dimensions": [ - 189, - 201, - 1 + 60, + 40, + 100 ], "geometry_data_path": "[Image Geometry]", "origin": [ @@ -33,54 +33,36 @@ { "args": { "created_data_group": "", - "selected_data_group": "[Image Geometry]/CellData", - "tuple_dimensions": [ - [ - 1.0, - 201.0, - 189.0 - ] - ], - "use_existing_group": true, - "wizard_data": { - "Begin Index": 33, - "Comma As Delimiter": false, - "Consecutive Delimiters": true, - "Data Headers": [ + "read_csv_data": { + "Consecutive Delimiters": false, + "Custom Headers": [ "phi1", "Phi", - "phi2", - "x", - "y", - "Image Quality", - "Confidence Index", - "Phase", - "SEM Signal", - "Fit" + "phi2" ], "Data Types": [ 8, 8, - 8, - 8, - 8, - 8, - 8, - 4, - 8, 8 ], "Delimiters": [ - 32 + "," ], "Header Line": 1, "Header Mode": 1, - "Input File Path": "Data/Small_IN100/Slice_1.ang", - "Number of Lines": 38021, - "Semicolon As Delimiter": false, - "Space As Delimiter": true, - "Tab As Delimiter": false - } + "Input File Path": "C:/Users/alejo/Downloads/DREAM3DNX-7.0.0-RC-7-UDRI-20231027.2-windows-AMD64/DREAM3DNX-7.0.0-RC-7-UDRI-20231027.2-windows-AMD64/Data/ASCIIData/EulersRotated.csv", + "Skipped Array Mask": [ + false, + false, + false + ], + "Start Import Row": 1, + "Tuple Dimensions": [ + 480001 + ] + }, + "selected_data_group": "[Image Geometry]/CellData", + "use_existing_group": true }, "comments": "", "filter": { @@ -91,7 +73,7 @@ }, { "args": { - "move_values": false, + "move_values": true, "normalize_data": false, "selected_data_array_paths": [ "[Image Geometry]/CellData/phi1", @@ -107,21 +89,6 @@ }, "isDisabled": false }, - { - "args": { - "removed_data_path": [ - "[Image Geometry]/CellData/phi1", - "[Image Geometry]/CellData/Phi", - "[Image Geometry]/CellData/phi2" - ] - }, - "comments": "", - "filter": { - "name": "simplnx::DeleteData", - "uuid": "bf286740-e987-49fe-a7c8-6e566e3a0606" - }, - "isDisabled": false - }, { "args": { "cell_ensemble_attribute_matrix_name": "[Image Geometry]/CellEnsembleData", @@ -143,11 +110,32 @@ }, "isDisabled": false }, + { + "args": { + "advanced_options": true, + "component_count": 1, + "data_format": "", + "initialization_value": "1", + "numeric_type": 4, + "output_data_array": "[Image Geometry]/CellData/Phases", + "tuple_dimensions": [ + [ + 0.0 + ] + ] + }, + "comments": "", + "filter": { + "name": "complex::CreateDataArray", + "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" + }, + "isDisabled": false + }, { "args": { "cell_euler_angles_array_path": "[Image Geometry]/CellData/Eulers", "cell_ipf_colors_array_name": "IPFColors", - "cell_phases_array_path": "[Image Geometry]/CellData/Phase", + "cell_phases_array_path": "[Image Geometry]/CellData/Phases", "crystal_structures_array_path": "[Image Geometry]/CellEnsembleData/CrystalStructures", "mask_array_path": "", "reference_dir": [ @@ -192,5 +180,6 @@ "isDisabled": true } ], + "version": 1, "workflowParams": [] } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp index 010fc131bb..17ca7b7143 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp @@ -329,13 +329,13 @@ Result ReadHeaderMetaData(const st return {metadata}; } -struct ImportVolumeGraphicsFileFilterCache +struct ReadVolumeGraphicsFileFilterCache { fs::path VgiDataFilePath; }; std::atomic_int32_t s_InstanceId = 0; -std::map s_HeaderCache; +std::map s_HeaderCache; } // namespace diff --git a/src/Plugins/TestOne/test/ErrorWarningFilterTest.cpp b/src/Plugins/TestOne/test/ErrorWarningFilterTest.cpp index 152d685ae0..50a8c5964c 100644 --- a/src/Plugins/TestOne/test/ErrorWarningFilterTest.cpp +++ b/src/Plugins/TestOne/test/ErrorWarningFilterTest.cpp @@ -15,7 +15,7 @@ constexpr int32 k_ExecuteWarning = -666000; constexpr int32 k_ExecuteError = -666001; } // namespace -TEST_CASE("ErrorWarningFilter: Instantiate Filter", "[ErrorWarningFilter]") +TEST_CASE("ErrorWarningFilter::Instantiate Filter", "[ErrorWarningFilter]") { DataStructure dataStructure; diff --git a/wrapping/python/CMakeLists.txt b/wrapping/python/CMakeLists.txt index b0a1e511a0..b357c43536 100644 --- a/wrapping/python/CMakeLists.txt +++ b/wrapping/python/CMakeLists.txt @@ -110,7 +110,7 @@ function(simplnx_create_pyi) add_custom_target(${PYI_TARGET_NAME} ALL COMMAND "${MYPY_STUBGEN_EXE}" -m "${ARGS_PYTHON_MODULE_NAME}" -o "$" - COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/fix_pyi_file.py" --input_file "$/${ARGS_PYTHON_MODULE_NAME}.pyi" + COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/utils/fix_pyi_file.py" --input_file "$/${ARGS_PYTHON_MODULE_NAME}.pyi" COMMENT "${ARGS_PYTHON_MODULE_NAME}: Generating .pyi files" WORKING_DIRECTORY $ ) @@ -284,40 +284,27 @@ endif() #------------------------------------------------------------------------------ option(SIMPLNX_BUILD_PYTHON_TESTS "Enables python based unit tests" OFF) if(SIMPLNX_BUILD_PYTHON_TESTS) + + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + set(CX_CONFIG_DIR "$") + else() + set(CX_CONFIG_DIR ".") + endif() - file(READ ${simplnx_SOURCE_DIR}/wrapping/python/simplnx_test_dirs.in.py SIMPLNX_TEST_DIRS_FILE) - - string(REPLACE "\${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" $ SIMPLNX_TEST_DIRS_FILE ${SIMPLNX_TEST_DIRS_FILE}) - string(REPLACE "\${simplnx_BINARY_DIR}" ${simplnx_BINARY_DIR} SIMPLNX_TEST_DIRS_FILE ${SIMPLNX_TEST_DIRS_FILE}) - string(REPLACE "\${DREAM3D_DATA_DIR}" ${DREAM3D_DATA_DIR} SIMPLNX_TEST_DIRS_FILE ${SIMPLNX_TEST_DIRS_FILE}) - string(REPLACE "\${simplnx_SOURCE_DIR}" ${simplnx_SOURCE_DIR} SIMPLNX_TEST_DIRS_FILE ${SIMPLNX_TEST_DIRS_FILE}) - - file(GENERATE - OUTPUT "$/simplnx_test_dirs.py" - CONTENT ${SIMPLNX_TEST_DIRS_FILE} - ) + set(DATA_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data") + + # Create a computer specific python file that defines the locations of various directories + file(READ ${simplnx_SOURCE_DIR}/wrapping/python/testing/simplnx_test_dirs.in.py SIMPLNX_TEST_DIRS_FILE) - set(PYTHON_TEST_INPUT_DIR "${simplnx_SOURCE_DIR}/wrapping/python/examples") - - set(SIMPLNX_PYTHON_TESTS - "angle_conversion" - "basic_arrays" - "basic_ebsd_ipf" - "basic_numpy" - "create_ensemble_info" - "generated_file_list" - "geometry_examples" - "import_d3d" # Dependent on 'basic_ebsd_ipf' running first - "import_hdf5" # Dependent on 'basic_ebsd_ipf' running first - "output_file" - "pipeline" - "read_csv_file" - # "read_esprit_data" - ) + string(CONFIGURE "${SIMPLNX_TEST_DIRS_FILE}" SIMPLNX_TEST_DIRS_FILE) - CreatePythonTests(PREFIX "PY_SIMPLNX" - INPUT_DIR ${PYTHON_TEST_INPUT_DIR} - TEST_NAMES ${SIMPLNX_PYTHON_TESTS} - ) + file(GENERATE + OUTPUT "$/simplnx_test_dirs.py" + CONTENT ${SIMPLNX_TEST_DIRS_FILE} + ) + # Include CMake files that define the tests that need to be run + include(${simplnx_SOURCE_DIR}/wrapping/python/examples/scripts/SourceList.cmake) + include(${simplnx_SOURCE_DIR}/wrapping/python/examples/pipelines/SourceList.cmake) endif() diff --git a/wrapping/python/SimplnxPython.hpp.in b/wrapping/python/CxPybind/SimplnxPython.hpp.in similarity index 100% rename from wrapping/python/SimplnxPython.hpp.in rename to wrapping/python/CxPybind/SimplnxPython.hpp.in diff --git a/wrapping/python/ReadMe.md b/wrapping/python/ReadMe.md index 9b808801bf..c410210dfa 100644 --- a/wrapping/python/ReadMe.md +++ b/wrapping/python/ReadMe.md @@ -1,4 +1,28 @@ -# Simplnx Python Information +# Simplnx Python Bindings + +## Directory Layout + +This directory has several areas that might be of interest depending if you are an end user or +are developing new python bindings for `simplnx`. + +- cmake + This directory holds various files used by CMake during the configuration of the python bindings +- CxPybind + This directory holds C++ implementation details for the python bindings +- docs + This directory holds the entirety of the python binding documentation +- examples + This directory holds python files showing basic usage of the simplnx python bindings +- notebools + This directory holds jupyter notebooks that use the python bindings +- pipelines + This directory holds python versions of the example pipelines that are included in the simplnx repository +- plugins + This directry holds an example simplnx plugin written in python +- testing + This directory holds specific files used for unit testing the python codes +- utils + This directory holds various utilities that are needed during the build process ## Checklist when updating Python Bindings @@ -8,7 +32,7 @@ - If you break API (any where in simplnx), update the second number - Document **ALL** new API in the appropriate documentation file(s) -- Create a ReleaseNotes_1XX.rst file with the appropriate highlights from the release +- Create a ReleaseNotes_XXX.rst file with the appropriate highlights from the release - Create example python code for any new API - Update example python codes for any changed API - Add unit test for any NEW API @@ -17,57 +41,13 @@ ## Creating the Python Bindings -### MacOS: Use Mamba - -- install mamba-forge - -[https://mamba.readthedocs.io/en/latest/mamba-installation.html](https://mamba.readthedocs.io/en/latest/mamba-installation.html) -[https://github.com/conda-forge/miniforge#mambaforge](https://github.com/conda-forge/miniforge#mambaforge) - -You want to install the "Mambaforge-MacOSX-x86_64" or "Mambaforge-MacOSX-arm64" package. -I elected to install into `/opt/local/mambaforge` - -once you get that installed do: - -```shell - [user@host] $ /opt/local/mambaforge/bin/mamba init -``` - -which will edit your .zshrc file. - -RELAUNCH A NEW TERMINAL!!!! - -```shell - [user@host] $ mamba create -n nx-build python=3.10 - [user@host] $ mamba activate nx-build - [user@host] $ mamba install boa -``` - -Create the package from the `simplnx` sources +Create an Anaconda virtual environment with the following command: ```shell - [user@host] $ cd simplnx/conda - (nx-build) [user@host] $ conda mambabuild --python 3.8 . - (nx-build) [user@host] $ conda mambabuild --python 3.9 . - (nx-build) [user@host] $ conda mambabuild --python 3.10 . - -``` - -### Windows/Linux - -```shell - [user@host] $ conda create on nx-build python=3.10 mamba boa - [user@host] $ cd simplnx/conda - [user@host] $ conda build . -``` - -For faster environment solves mamba can also be used. - -```shell - [user@host] $ conda install boa - [user@host] $ conda mambabuild --python 3.8 . - [user@host] $ conda mambabuild --python 3.9 . - [user@host] $ conda mambabuild --python 3.10 . + (base) [user@host] $ conda create --name nx-build python=3.10 conda-build + (base) [user@host] $ conda activate nx-build + (nx-build) [user@host] $ cd simplnx/conda + (nx-build) [user@host] $ conda build . ``` ### Uploading to Anaconda.org @@ -82,11 +62,11 @@ Open a "base" anaconda prompt. ## Using the Python Bindings ```shell -conda config --add channels conda-forge -conda config --set channel_priority strict -conda create -n cxpython python=3.10 -conda activate cxpython -conda install -c bluequartzsoftware simplnx + [user@host] $ conda config --add channels conda-forge + [user@host] $ conda config --set channel_priority strict + [user@host] $ conda create -n cxpython python=3.10 + [user@host] $ conda activate cxpython + [user@host] $ conda install -c bluequartzsoftware simplnx ``` If you plan to use jupyter notebooks, then any other kernels and such will also need to be installed. VS Code does this for you. @@ -101,3 +81,17 @@ SIMPLNX_EMBED_PYTHON=OFF SIMPLNX_BUILD_PYTHON_DOCS=ON Python3_EXECUTABLE=/path/to/python ``` + +## Creating Python Documentation with Sphinx + +If you are modifying the python bindings and need to update the documentation or are updating the documentation +and want to see what the final rendered HTML site looks like you will need to ensure the following python +packages are installed into your python virtual environment. + +``` shell +conda create -n d3ddocs python=3.10 sphinx myst-parser sphinx-markdown-tables sphinx_rtd_theme +conda activate d3ddocs +cd simplnx/docs/ +make clean +make html +``` diff --git a/wrapping/python/docs/ReadMe.md b/wrapping/python/docs/ReadMe.md deleted file mode 100644 index d33df08f61..0000000000 --- a/wrapping/python/docs/ReadMe.md +++ /dev/null @@ -1,8 +0,0 @@ -# Creating Python Documentation with Sphinx - -``` shell -conda create -n d3ddocs python=3.10 sphinx myst-parser sphinx-markdown-tables sphinx_rtd_theme -conda activate d3ddocs -cd simplnx/docs/ -make html -``` \ No newline at end of file diff --git a/wrapping/python/docs/source/ReleaseNotes_120.rst b/wrapping/python/docs/source/ReleaseNotes_120.rst index afae88cf61..ae34a91cbf 100644 --- a/wrapping/python/docs/source/ReleaseNotes_120.rst +++ b/wrapping/python/docs/source/ReleaseNotes_120.rst @@ -24,29 +24,29 @@ Filter Changes 1.2.0 +----------------------------------------+---------------------------------------+-----------+ | Old File Name | New File Name | Type | +========================================+=======================================+===========+ -| AbaqusHexahedronWriterFilter | WriteAbaqusHexahedronFilter | Filter | +| WriteAbaqusHexahedronFilter | WriteAbaqusHexahedronFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| AvizoRectilinearCoordinateWriterFilter | WriteAvizoRectilinearCoordinateFilter | Filter | +| WriteAvizoRectilinearCoordinateFilter | WriteAvizoRectilinearCoordinateFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| AvizoUniformCoordinateWriterFilter | WriteAvizoUniformCoordinateFilter | Filter | +| WriteAvizoUniformCoordinateFilter | WriteAvizoUniformCoordinateFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| ExportDREAM3DFilter | WriteDREAM3DFilter | Filter | +| WriteDREAM3DFilter | WriteDREAM3DFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| FeatureDataCSVWriterFilter | WriteFeatureDataCSVFilter | Filter | +| WriteFeatureDataCSVFilter | WriteFeatureDataCSVFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| ImportDeformKeyFileV12Filter | ReadDeformKeyFileV12Filter | Filter | +| ReadDeformKeyFileV12Filter | ReadDeformKeyFileV12Filter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| ImportVolumeGraphicsFileFilter | ReadVolumeGraphicsFileFilter | Filter | +| ReadVolumeGraphicsFileFilter | ReadVolumeGraphicsFileFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| ImportBinaryCTNorthstarFilter | ReadBinaryCTNorthstarFilter | Filter | +| ReadBinaryCTNorthstarFilter | ReadBinaryCTNorthstarFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| LosAlamosFFTWriterFilter | WriteLosAlamosFFTFilter | Filter | +| WriteLosAlamosFFTFilter | WriteLosAlamosFFTFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| RawBinaryReaderFilter | ReadRawBinaryFilter | Filter | +| ReadRawBinaryFilter | ReadRawBinaryFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| StlFileReaderFilter | ReadStlFileFilter | Filter | +| ReadStlFileFilter | ReadStlFileFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ -| VtkRectilinearGridWriterFilter | WriteVtkRectilinearGridFilter | Filter | +| WriteVtkRectilinearGridFilter | WriteVtkRectilinearGridFilter | Filter | +----------------------------------------+---------------------------------------+-----------+ - OrientationAnalysis @@ -54,16 +54,16 @@ Filter Changes 1.2.0 +------------------------------+-----------------------------+-----------+ | Old File Name | New File Name | Type | +==============================+=============================+===========+ -| EnsembleInfoReaderFilter | ReadEnsembleInfoFilter | Filter | +| ReadEnsembleInfoFilter | ReadEnsembleInfoFilter | Filter | +------------------------------+-----------------------------+-----------+ -| ExportGBCDGMTFileFilter | WriteGBCDGMTFileFilter | Filter | +| WriteGBCDGMTFileFilter | WriteGBCDGMTFileFilter | Filter | +------------------------------+-----------------------------+-----------+ -| ExportGBCDTriangleDataFilter | WriteGBCDTriangleDataFilter | Filter | +| WriteGBCDTriangleDataFilter | WriteGBCDTriangleDataFilter | Filter | +------------------------------+-----------------------------+-----------+ -| ImportH5Data | ReadH5Data | Utility | +| ReadH5Data | ReadH5Data | Utility | +------------------------------+-----------------------------+-----------+ -| ImportH5OimDataFilter | ReadH5OimDataFilter | Filter | +| ReadH5OimDataFilter | ReadH5OimDataFilter | Filter | +------------------------------+-----------------------------+-----------+ -| INLWriterFilter | WriteINLFileFilter | Filter | +| WriteINLFileFilter | WriteINLFileFilter | Filter | +------------------------------+-----------------------------+-----------+ diff --git a/wrapping/python/examples/angles.csv b/wrapping/python/examples/data/angles.csv similarity index 100% rename from wrapping/python/examples/angles.csv rename to wrapping/python/examples/data/angles.csv diff --git a/wrapping/python/examples/test_csv_data.csv b/wrapping/python/examples/data/test_csv_data.csv similarity index 100% rename from wrapping/python/examples/test_csv_data.csv rename to wrapping/python/examples/data/test_csv_data.csv diff --git a/wrapping/python/examples/file_dependency.dot b/wrapping/python/examples/file_dependency.dot new file mode 100644 index 0000000000..d84ad5e599 --- /dev/null +++ b/wrapping/python/examples/file_dependency.dot @@ -0,0 +1,81 @@ +digraph G { + //rankdir=LR; + + label="Python Testing File Dependency" + labelloc="t" + fontname="Fira Mono" + fontcolor="#FFFFFA" + fontsize=20 + + + graph [splines=true + bgcolor="#242627" + ] + + node [shape=record + style="filled" + fillcolor="#1D7ECD" + fontcolor="#FFFFFA" + fontname="Fira Mono" + margin="0.61,0.1" + ] + + edge [ + // dir=back + arrowtail=default + arrowhead=normal + style="" + // headport="w" + // tailport="e" + color="#FFFFFA" + ] + + +"Small_IN100.h5ebsd" [shape=record fillcolor="#23882A"] +"SmallIN100_Final.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_Morph.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_BoundaryCells.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_AvizoRectilinear.am" [shape=record fillcolor="#23882A"] +"SmallIN100_Final.vtk" [shape=record fillcolor="#23882A"] +"SmallIN100_CrystalStats.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_Mesh.dream3d" [shape=record fillcolor="#23882A"] +"FindBiasedFeatures.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_Smoothed.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_MeshStats.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_GBCD.dream3d" [shape=record fillcolor="#23882A"] +"SmallIN100_GBCD_Metric.dream3d" [shape=record fillcolor="#23882A"] +"ResamplePorosityImage.dream3d" [shape=record fillcolor="#23882A"] +"SurfaceNets_Demo.dream3d" [shape=record fillcolor="#23882A"] +"ResampleRectGridToImageGeom.dream3d" [shape=record fillcolor="#23882A"] + + "01_Small_IN100_Archive" -> "Small_IN100.h5ebsd" + + "Small_IN100.h5ebsd" -> AlignSectionsMutualInformation + "Small_IN100.h5ebsd" -> FindLargestCrossSections + + "Small_IN100.h5ebsd" -> "08_Small_IN100_Full_Reconstruction" -> "SmallIN100_Final.dream3d" + + "SmallIN100_Final.dream3d" -> "01_Small_IN100_Morphological_Statistics" -> "SmallIN100_Morph.dream3d" + "SmallIN100_Final.dream3d" -> "FindBoundaryCells" -> "SmallIN100_BoundaryCells.dream3d" + "SmallIN100_Final.dream3d" -> "AvizoWriters" -> "SmallIN100_AvizoRectilinear.am" + "SmallIN100_Final.dream3d" -> "VtkRectilinearGridWriter" -> "SmallIN100_Final.vtk" + + "SmallIN100_Morph.dream3d" -> "05_Small_IN100_Crystallographic_Statistics" -> "SmallIN100_CrystalStats.dream3d" + + "SmallIN100_CrystalStats.dream3d"->"01_Small_IN100_Quick_Mesh"-> "SmallIN100_Mesh.dream3d" + "SmallIN100_CrystalStats.dream3d" -> "FindBiasedFeatures" -> "FindBiasedFeatures.dream3d" + + "SmallIN100_Mesh.dream3d" -> "02_Small_IN100_Smooth_Mesh" -> "SmallIN100_Smoothed.dream3d" + "SmallIN100_Smoothed.dream3d" -> "03_Small_IN100_Mesh_Statistics" -> "SmallIN100_MeshStats.dream3d" + "SmallIN100_MeshStats.dream3d" -> "04_Small_IN100_GBCD" -> "SmallIN100_GBCD.dream3d" + "SmallIN100_MeshStats.dream3d" -> "05_Small_IN100_GBCD_Metric" -> "SmallIN100_GBCD_Metric.dream3d" + + + "SmallIN100_MeshStats.dream3d" -> "FindGBCD-GBPDMetricBased" + + "ResamplePorosityImage" -> "ResamplePorosityImage.dream3d" + "SurfaceNets_Demo" -> "SurfaceNets_Demo.dream3d" + "ResampleRectGridToIamgeGeom" -> "ResampleRectGridToImageGeom.dream3d" + + +} diff --git a/wrapping/python/notebooks/angle_conversion.ipynb b/wrapping/python/examples/notebooks/angle_conversion.ipynb similarity index 89% rename from wrapping/python/notebooks/angle_conversion.ipynb rename to wrapping/python/examples/notebooks/angle_conversion.ipynb index f33baab947..a31cb894f2 100644 --- a/wrapping/python/notebooks/angle_conversion.ipynb +++ b/wrapping/python/examples/notebooks/angle_conversion.ipynb @@ -28,7 +28,7 @@ "outputs": [], "source": [ "# Create a Data Structure\n", - "data_structure = cx.DataStructure()" + "data_structure = nx.DataStructure()" ] }, { @@ -38,9 +38,9 @@ "outputs": [], "source": [ "# Create a DataArray to copy the Euler Angles into \n", - "array_path = cx.DataPath(['Euler Angles'])\n", - "result = cx.CreateDataArray.execute(data_structure,\n", - " numeric_type=cx.NumericType.float32,\n", + "array_path = nx.DataPath(['Euler Angles'])\n", + "result = nx.CreateDataArray.execute(data_structure,\n", + " numeric_type=nx.NumericType.float32,\n", " component_count=3,\n", " tuple_dimensions=[[99]],\n", " output_data_array=array_path,\n", @@ -53,7 +53,7 @@ " print('No errors running the CreateDataArray filter')\n", "\n", "# Get a numpy.view into the newly created DataArray\n", - "data_array: cx.IDataArray = data_structure[array_path]\n", + "data_array: nx.IDataArray = data_structure[array_path]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "# Get a Numpy View into the data\n", @@ -84,7 +84,7 @@ "metadata": {}, "outputs": [], "source": [ - "quat_path = cx.DataPath(['Quaternions'])\n", + "quat_path = nx.DataPath(['Quaternions'])\n", "result = cxor.ConvertOrientations.execute(data_structure=data_structure,\n", " input_orientation_array_path=array_path,\n", " input_type=0,\n", @@ -98,7 +98,7 @@ " print('No errors running the ConvertOrientations filter')\n", "\n", "# Get the Quaternions and print them out.\n", - "data_array: cx.IDataArray = data_structure[quat_path]\n", + "data_array: nx.IDataArray = data_structure[quat_path]\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview()\n", "\n", diff --git a/wrapping/python/notebooks/basic_arrays.ipynb b/wrapping/python/examples/notebooks/basic_arrays.ipynb similarity index 88% rename from wrapping/python/notebooks/basic_arrays.ipynb rename to wrapping/python/examples/notebooks/basic_arrays.ipynb index f7845f8bf8..4a0dcc62b4 100644 --- a/wrapping/python/notebooks/basic_arrays.ipynb +++ b/wrapping/python/examples/notebooks/basic_arrays.ipynb @@ -24,7 +24,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_structure = cx.DataStructure()" + "data_structure = nx.DataStructure()" ] }, { @@ -33,7 +33,7 @@ "metadata": {}, "outputs": [], "source": [ - "array_type = cx.NumericType.float32" + "array_type = nx.NumericType.float32" ] }, { @@ -50,9 +50,9 @@ "outputs": [], "source": [ "# Create the Input Parameters to the CreateDataArray filter\n", - "output_array_path = cx.DataPath(['1D Array'])\n", + "output_array_path = nx.DataPath(['1D Array'])\n", "tuple_dims = [[10]]\n", - "result = cx.CreateDataArray.execute(data_structure=data_structure,\n", + "result = nx.CreateDataArray.execute(data_structure=data_structure,\n", " component_count=1,\n", " data_format='',\n", " initialization_value='10',\n", @@ -75,7 +75,7 @@ "source": [ "# We can check the output of the filter by simply printing the array\n", "# First get the array from the DataStructure\n", - "data_array: cx.IDataArray = data_structure[output_array_path]\n", + "data_array: nx.IDataArray = data_structure[output_array_path]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "# Get the raw data as an Numpy View\n", @@ -98,9 +98,9 @@ "source": [ "# Create a 2D Array with dimensions 2, 5 where the 5 is the fastest moving dimension.\n", "# Example, and Image where 5 wide x 2 High\n", - "output_array_path = cx.DataPath(['2D Array'])\n", + "output_array_path = nx.DataPath(['2D Array'])\n", "tuple_dims = [[2, 5]]\n", - "result = cx.CreateDataArray.execute(data_structure=data_structure,\n", + "result = nx.CreateDataArray.execute(data_structure=data_structure,\n", " component_count=1,\n", " data_format='',\n", " initialization_value='10',\n", @@ -114,7 +114,7 @@ "else:\n", " print('No errors running the filter')\n", "\n", - "data_array: cx.IDataArray = data_structure[output_array_path]\n", + "data_array: nx.IDataArray = data_structure[output_array_path]\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview()\n", "print(npdata)" @@ -135,9 +135,9 @@ "source": [ "# Create a 3D Array with dimensions 3, 2, 5 where the 5 is the fastest moving dimension.\n", "# Example, and Image where 5 wide x 2 High\n", - "output_array_path = cx.DataPath(['3D Array'])\n", + "output_array_path = nx.DataPath(['3D Array'])\n", "tuple_dims = [[3, 2, 5]]\n", - "result = cx.CreateDataArray.execute(data_structure=data_structure,\n", + "result = nx.CreateDataArray.execute(data_structure=data_structure,\n", " component_count=1,\n", " data_format='',\n", " initialization_value='10',\n", @@ -151,7 +151,7 @@ "else:\n", " print('No errors running the filter')\n", "\n", - "data_array: cx.IDataArray = data_structure[output_array_path]\n", + "data_array: nx.IDataArray = data_structure[output_array_path]\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview()\n", "print(npdata)" diff --git a/wrapping/python/notebooks/basic_ebsd_ipf.ipynb b/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb similarity index 85% rename from wrapping/python/notebooks/basic_ebsd_ipf.ipynb rename to wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb index 0a6a4cc20a..422b3aec4a 100644 --- a/wrapping/python/notebooks/basic_ebsd_ipf.ipynb +++ b/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb @@ -30,7 +30,7 @@ "outputs": [], "source": [ "# Create a Data Structure\n", - "data_structure = cx.DataStructure()" + "data_structure = .nxDataStructure()" ] }, { @@ -49,7 +49,7 @@ "result = cxor.ReadAngDataFilter.execute(data_structure=data_structure,\n", " cell_attribute_matrix_name='Scan Data',\n", " cell_ensemble_attribute_matrix_name='Phase Data',\n", - " data_container_name=cx.DataPath(['Small IN100']),\n", + " data_container_name=.nxDataPath(['Small IN100']),\n", " input_file='SmallIN100/Slice_1.ang',\n", ")\n", "print(f'Warnings: {result.warnings}')\n", @@ -73,7 +73,7 @@ "outputs": [], "source": [ "result = cxor.RotateEulerRefFrameFilter.execute(data_structure=data_structure,\n", - " cell_euler_angles_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", + " cell_euler_angles_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", " rotation_axis=[0, 0, 1, 90],\n", ")\n", "print(f'Warnings: {result.warnings}')\n", @@ -96,13 +96,13 @@ "metadata": {}, "outputs": [], "source": [ - "result = cx.RotateSampleRefFrameFilter.execute(data_structure=data_structure,\n", - " # created_image_geometry=cx.DataPath(['Small IN100 Rotated']),\n", + "result = .nxRotateSampleRefFrameFilter.execute(data_structure=data_structure,\n", + " # created_image_geometry=.nxDataPath(['Small IN100 Rotated']),\n", " remove_original_geometry=True,\n", " rotate_slice_by_slice=False,\n", " rotation_axis=[0, 1, 0, 180],\n", " rotation_representation=0,\n", - " selected_image_geometry=cx.DataPath(['Small IN100']),\n", + " selected_image_geometry=.nxDataPath(['Small IN100']),\n", " # rotation_matrix=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],\n", ")\n", "print(f'Warnings: {result.warnings}')\n", @@ -127,23 +127,23 @@ "metadata": {}, "outputs": [], "source": [ - "threshold_1 = cx.ArrayThreshold()\n", - "threshold_1.array_path = cx.DataPath(['Small IN100', 'Scan Data', 'Confidence Index'])\n", - "threshold_1.comparison = cx.ArrayThreshold.ComparisonType.GreaterThan\n", + "threshold_1 = .nxArrayThreshold()\n", + "threshold_1.array_path = .nxDataPath(['Small IN100', 'Scan Data', 'Confidence Index'])\n", + "threshold_1.comparison = .nxArrayThreshold.ComparisonType.GreaterThan\n", "threshold_1.value = 0.1\n", "\n", - "threshold_2 = cx.ArrayThreshold()\n", - "threshold_2.array_path = cx.DataPath(['Small IN100', 'Scan Data', 'Image Quality'])\n", - "threshold_2.comparison = cx.ArrayThreshold.ComparisonType.GreaterThan\n", + "threshold_2 = .nxArrayThreshold()\n", + "threshold_2.array_path = .nxDataPath(['Small IN100', 'Scan Data', 'Image Quality'])\n", + "threshold_2.comparison = .nxArrayThreshold.ComparisonType.GreaterThan\n", "threshold_2.value = 120\n", "\n", - "threshold_set = cx.ArrayThresholdSet()\n", + "threshold_set = .nxArrayThresholdSet()\n", "threshold_set.thresholds = [threshold_1, threshold_2]\n", - "dt = cx.DataType.boolean\n", - "result = cx.MultiThresholdObjects.execute(data_structure=data_structure,\n", + "dt = .nxDataType.boolean\n", + "result = .nxMultiThresholdObjects.execute(data_structure=data_structure,\n", " array_thresholds=threshold_set,\n", " created_data_path='Mask',\n", - " created_mask_type=cx.DataType.boolean,\n", + " created_mask_type=.nxDataType.boolean,\n", ")\n", "print(f'Warnings: {result.warnings}')\n", "if not result:\n", @@ -166,11 +166,11 @@ "outputs": [], "source": [ "result = cxor.GenerateIPFColorsFilter.execute(data_structure=data_structure,\n", - " cell_euler_angles_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", + " cell_euler_angles_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", " cell_ipf_colors_array_name='IPFColors',\n", - " cell_phases_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'Phases']),\n", - " crystal_structures_array_path=cx.DataPath(['Small IN100', 'Phase Data', 'CrystalStructures']),\n", - " mask_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'Mask']),\n", + " cell_phases_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'Phases']),\n", + " crystal_structures_array_path=.nxDataPath(['Small IN100', 'Phase Data', 'CrystalStructures']),\n", + " mask_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'Mask']),\n", " reference_dir=[0, 0, 1],\n", " use_mask=True,\n", ")\n", @@ -195,8 +195,8 @@ "outputs": [], "source": [ "result = cxitk.ITKImageWriter.execute(data_structure=data_structure, file_name='/tmp/Small_IN100_IPF_Z.png',\n", - " image_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'IPFColors']),\n", - " image_geom_path=cx.DataPath(['Small IN100']),\n", + " image_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'IPFColors']),\n", + " image_geom_path=.nxDataPath(['Small IN100']),\n", " index_offset=0,\n", " plane=0,\n", ")\n", @@ -221,7 +221,7 @@ "outputs": [], "source": [ "# First get the array from the DataStructure\n", - "data_array: cx.IDataArray = data_structure[cx.DataPath(['Small IN100', 'Scan Data', 'IPFColors'])]\n", + "data_array: .nxIDataArray = data_structure[.nxDataPath(['Small IN100', 'Scan Data', 'IPFColors'])]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview().copy()\n", @@ -249,17 +249,17 @@ "source": [ "prefix = 'Small_IN100_'\n", "result = cxor.WritePoleFigureFilter.execute(data_structure=data_structure,\n", - " cell_euler_angles_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", - " cell_phases_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'Phases']),\n", - " crystal_structures_array_path=cx.DataPath(['Small IN100', 'Phase Data', 'CrystalStructures']),\n", + " cell_euler_angles_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", + " cell_phases_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'Phases']),\n", + " crystal_structures_array_path=.nxDataPath(['Small IN100', 'Phase Data', 'CrystalStructures']),\n", " generation_algorithm=1, # Discrete = 1\n", - " mask_array_path=cx.DataPath(['Small IN100', 'Scan Data', 'Mask']),\n", - " image_geometry_path=cx.DataPath(['Small IN100 Pole Figure']),\n", + " mask_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'Mask']),\n", + " image_geometry_path=.nxDataPath(['Small IN100 Pole Figure']),\n", " image_layout=0, # O = Horizontal Layout\n", " image_prefix=prefix,\n", " image_size=512,\n", " lambert_size=64,\n", - " material_name_array_path=cx.DataPath(['Small IN100', 'Phase Data', 'MaterialName']),\n", + " material_name_array_path=.nxDataPath(['Small IN100', 'Phase Data', 'MaterialName']),\n", " num_colors=32,\n", " output_path='/tmp/small_in100_pole_figure',\n", " save_as_image_geometry=True,\n", @@ -288,7 +288,7 @@ "outputs": [], "source": [ "output_file_path = 'basic_ebsd_example.dream3d'\n", - "result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", + "result = .nxWriteDREAM3DFilter.execute(data_structure=data_structure,\n", " export_file_path=output_file_path,\n", " write_xdmf_file=True,\n", ")\n", @@ -312,7 +312,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_array: cx.IDataArray = data_structure[cx.DataPath(['Small IN100 Pole Figure', 'CellData', prefix + 'Phase_1'])]\n", + "data_array: .nxIDataArray = data_structure[.nxDataPath(['Small IN100 Pole Figure', 'CellData', prefix + 'Phase_1'])]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview().copy()\n", diff --git a/wrapping/python/notebooks/basic_numpy.ipynb b/wrapping/python/examples/notebooks/basic_numpy.ipynb similarity index 84% rename from wrapping/python/notebooks/basic_numpy.ipynb rename to wrapping/python/examples/notebooks/basic_numpy.ipynb index 1000a0ab60..e8cbf8f46a 100644 --- a/wrapping/python/notebooks/basic_numpy.ipynb +++ b/wrapping/python/examples/notebooks/basic_numpy.ipynb @@ -1,15 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import simplnx as nx\n", - "import numpy as np" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -31,7 +21,7 @@ "outputs": [], "source": [ "# Create a Data Structure\n", - "data_structure = cx.DataStructure()" + "data_structure = nx.DataStructure()" ] }, { @@ -40,9 +30,9 @@ "metadata": {}, "outputs": [], "source": [ - "array_path = cx.DataPath(['data'])\n", - "assert cx.CreateDataArray.execute(data_structure,\n", - " numeric_type=cx.NumericType.float32,\n", + "array_path = nx.DataPath(['data'])\n", + "assert nx.CreateDataArray.execute(data_structure,\n", + " numeric_type=nx.NumericType.float32,\n", " component_count=1,\n", " tuple_dimensions=[[3, 2]],\n", " output_data_array=array_path,\n", @@ -56,7 +46,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_array: cx.IDataArray = data_structure[array_path]\n", + "data_array: nx.IDataArray = data_structure[array_path]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "# Get a Numpy View into the data\n", @@ -85,7 +75,7 @@ "outputs": [], "source": [ "# Run a D3D filter to convert back to degrees\n", - "assert cx.ChangeAngleRepresentation.execute(data_structure, conversion_type=0, angles_array_path=array_path)\n", + "assert nx.ChangeAngleRepresentation.execute(data_structure, conversion_type=0, angles_array_path=array_path)\n", "\n", "# compare the 2 arrays\n", "assert np.array_equal(npdata, radians_data)" diff --git a/wrapping/python/notebooks/create_image_geom.ipynb b/wrapping/python/examples/notebooks/create_image_geom.ipynb similarity index 88% rename from wrapping/python/notebooks/create_image_geom.ipynb rename to wrapping/python/examples/notebooks/create_image_geom.ipynb index df6ada63e2..afdde37186 100644 --- a/wrapping/python/notebooks/create_image_geom.ipynb +++ b/wrapping/python/examples/notebooks/create_image_geom.ipynb @@ -16,13 +16,13 @@ "outputs": [], "source": [ "# Create the DataStructure object and define the dimensions of the geometry\n", - "data_structure = cx.DataStructure()\n", + "data_structure = nx.DataStructure()\n", "ig_dims = [10, 20, 30] # NOTE: These are in XYZ order\n", - "result = cx.CreateGeometryFilter.execute(data_structure=data_structure,\n", + "result = nx.CreateGeometryFilter.execute(data_structure=data_structure,\n", " array_handling= 0, # This does not matter for Image Geometry\n", " cell_attribute_matrix_name='Cell Data',\n", " dimensions=ig_dims, # Note that the dimensions are list as X, Y, Z\n", - " geometry_name=cx.DataPath(['Image Geometry']),\n", + " geometry_name=nx.DataPath(['Image Geometry']),\n", " geometry_type=0, # 0 = Image Geometry\n", " origin=[0.0, 0.0, 0.0],\n", " spacing=[1.0, 1.0, 1.0],\n", @@ -44,9 +44,9 @@ "# this is data that lives at the center of each cell\n", "# NOTE: we do *not* need to set the tuple dimensions because we are adding this array to the\n", "# AttributeMatrix that we generated in the last filter.\n", - "output_array_path = cx.DataPath(['Image Geometry', 'Cell Data', 'Float Cell Data'])\n", - "array_type = cx.NumericType.float32\n", - "result = cx.CreateDataArray.execute(data_structure=data_structure,\n", + "output_array_path = nx.DataPath(['Image Geometry', 'Cell Data', 'Float Cell Data'])\n", + "array_type = nx.NumericType.float32\n", + "result = nx.CreateDataArray.execute(data_structure=data_structure,\n", " component_count=1,\n", " data_format='',\n", " initialization_value='10',\n", @@ -67,7 +67,7 @@ "outputs": [], "source": [ "output_file_path = 'image_geom.dream3d'\n", - "result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", + "result = nx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", " export_file_path=output_file_path,\n", " write_xdmf_file=True,\n", ")\n", diff --git a/wrapping/python/notebooks/import_d3d.ipynb b/wrapping/python/examples/notebooks/import_d3d.ipynb similarity index 91% rename from wrapping/python/notebooks/import_d3d.ipynb rename to wrapping/python/examples/notebooks/import_d3d.ipynb index 6a1c5df8d3..f43b204316 100644 --- a/wrapping/python/notebooks/import_d3d.ipynb +++ b/wrapping/python/examples/notebooks/import_d3d.ipynb @@ -24,7 +24,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_structure = cx.DataStructure()" + "data_structure = nx.DataStructure()" ] }, { @@ -33,11 +33,11 @@ "metadata": {}, "outputs": [], "source": [ - "import_data = cx.Dream3dImportParameter.ImportData()\n", + "import_data = nx.Dream3dImportParameter.ImportData()\n", "import_data.file_path = '/private/tmp/basic_ebsd.dream3d'\n", "import_data.data_paths = None\n", "\n", - "result = cx.ReadDREAM3DFilter.execute(data_structure=data_structure,\n", + "result = nx.ReadDREAM3DFilter.execute(data_structure=data_structure,\n", " import_file_data=import_data,\n", ")\n", "print(f'Warnings: {result.warnings}')\n", @@ -60,7 +60,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_array: cx.IDataArray = data_structure[cx.DataPath(['Small IN100', 'Scan Data', 'Image Quality'])]\n", + "data_array: nx.IDataArray = data_structure[nx.DataPath(['Small IN100', 'Scan Data', 'Image Quality'])]\n", "# Get the underlying DataStore object\n", "data_store = data_array.store\n", "\n", @@ -84,7 +84,7 @@ "outputs": [], "source": [ "output_file_path = '/tmp/import_data.dream3d'\n", - "result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", + "result = nx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", " export_file_path=output_file_path,\n", " write_xdmf_file=True,\n", ")\n", diff --git a/wrapping/python/notebooks/output_file.ipynb b/wrapping/python/examples/notebooks/output_file.ipynb similarity index 88% rename from wrapping/python/notebooks/output_file.ipynb rename to wrapping/python/examples/notebooks/output_file.ipynb index c2e002bbed..5b61b0e586 100644 --- a/wrapping/python/notebooks/output_file.ipynb +++ b/wrapping/python/examples/notebooks/output_file.ipynb @@ -18,7 +18,7 @@ "outputs": [], "source": [ "# Create a Data Structure\n", - "data_structure = cx.DataStructure()" + "data_structure = nx.DataStructure()" ] }, { @@ -35,10 +35,10 @@ "outputs": [], "source": [ "# Example, and Image where 5 wide x 2 High\n", - "output_array_path = cx.DataPath(['3D Array'])\n", - "array_type = cx.NumericType.float32\n", + "output_array_path = nx.DataPath(['3D Array'])\n", + "array_type = nx.NumericType.float32\n", "tuple_dims = [[3, 2, 5]]\n", - "result = cx.CreateDataArray.execute(data_structure=data_structure,\n", + "result = nx.CreateDataArray.execute(data_structure=data_structure,\n", " component_count=1,\n", " data_format='',\n", " initialization_value='10',\n", @@ -59,7 +59,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_array: cx.IDataArray = data_structure[output_array_path]\n", + "data_array: nx.IDataArray = data_structure[output_array_path]\n", "data_store = data_array.store\n", "npdata: np.ndarray = data_store.npview()\n", "print(npdata)" @@ -72,7 +72,7 @@ "outputs": [], "source": [ "output_file_path = 'output_file_example.dream3d'\n", - "result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", + "result = nx.WriteDREAM3DFilter.execute(data_structure=data_structure,\n", " export_file_path=output_file_path,\n", " write_xdmf_file=True,\n", ")\n", diff --git a/wrapping/python/notebooks/pipeline.ipynb b/wrapping/python/examples/notebooks/pipeline.ipynb similarity index 83% rename from wrapping/python/notebooks/pipeline.ipynb rename to wrapping/python/examples/notebooks/pipeline.ipynb index eaab0002cd..d04d62d2d9 100644 --- a/wrapping/python/notebooks/pipeline.ipynb +++ b/wrapping/python/examples/notebooks/pipeline.ipynb @@ -16,11 +16,11 @@ "metadata": {}, "outputs": [], "source": [ - "data_structure = cx.DataStructure()\n", + "data_structure = nx.DataStructure()\n", "\n", - "pipeline = cx.Pipeline()\n", - "pipeline.append(cx.CreateDataArray(), {'numeric_type': cx.NumericType.int32})\n", - "pipeline[0].set_args({'numeric_type': cx.NumericType.int32})\n", + "pipeline = nx.Pipeline()\n", + "pipeline.append(nx.CreateDataArray(), {'numeric_type': nx.NumericType.int32})\n", + "pipeline[0].set_args({'numeric_type': nx.NumericType.int32})\n", "\n", "result = pipeline.execute(data_structure)\n", "\n", diff --git a/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py b/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py new file mode 100644 index 0000000000..5580c5bcab --- /dev/null +++ b/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py @@ -0,0 +1,199 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 + +generated_file_list_value = nx.GeneratedFileListParameter.ValueType() +generated_file_list_value.input_path = nxtest.GetDataDirectory() + "/Porosity_Image/" +generated_file_list_value.ordering = nx.GeneratedFileListParameter.Ordering.LowToHigh + +generated_file_list_value.file_prefix = "slice_" +generated_file_list_value.file_suffix = "" +generated_file_list_value.file_extension = ".tif" +generated_file_list_value.start_index = 11 +generated_file_list_value.end_index = 174 +generated_file_list_value.increment_index = 1 +generated_file_list_value.padding_digits = 2 + +# Instantiate Filter +nx_filter = cxitk.ITKImportImageStack() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Cell Data", + image_data_array_path="ImageData", + image_geometry_path=nx.DataPath("ImageDataContainer"), + image_transform_choice=0, + input_file_list_info=generated_file_list_value, + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("ImageDataContainer/Cell Data/ImageData") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +dt = nx.DataType.boolean # This line specifies the DataType for the threshold + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=dt, # Use the DataType variable here + use_custom_false_value=False, + use_custom_true_value=False + # custom_false_value: float = ..., # Not currently part of the code + # custom_true_value: float = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ScalarSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_path="Active", + cell_feature_group_path="CellFeatureData", + feature_ids_path="FeatureIds", + grid_geometry_path=nx.DataPath("ImageDataContainer"), + input_array_path=nx.DataPath("ImageDataContainer/Cell Data/ImageData"), + mask_path=nx.DataPath("ImageDataContainer/Cell Data/Mask"), + randomize_features=True, + scalar_tolerance=0, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.CalculateFeatureSizesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + equivalent_diameters_path="EquivalentDiameters", + feature_attribute_matrix=nx.DataPath("ImageDataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("ImageDataContainer/Cell Data/FeatureIds"), + geometry_path=nx.DataPath("ImageDataContainer"), + num_elements_path="NumElements", + save_element_sizes=False, + volumes_path="Volumes" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.CopyFeatureArrayToElementArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_array_suffix="Created Array Suffix", + feature_ids_path=nx.DataPath("ImageDataContainer/Cell Data/FeatureIds"), + selected_feature_array_path=[nx.DataPath("ImageDataContainer/CellFeatureData/EquivalentDiameters")] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + component_count=1, + data_format="", + initialization_value="1", + numeric_type=nx.NumericType.int32, + output_data_array=nx.DataPath("ImageDataContainer/Cell Data/Phases") + # tuple_dimensions: List[List[float]] = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.ConditionalSetValue() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + conditional_array_path=nx.DataPath("ImageDataContainer/Cell Data/Mask"), + invert_mask=False, + replace_value="2", + selected_array_path=nx.DataPath("ImageDataContainer/Cell Data/Phases"), + use_conditional=True + # remove_value: str = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.FindFeaturePhasesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_features_attribute_matrix_path=nx.DataPath("ImageDataContainer/CellFeatureData"), + cell_phases_array_path=nx.DataPath("ImageDataContainer/Cell Data/Phases"), + feature_ids_path=nx.DataPath("ImageDataContainer/Cell Data/FeatureIds"), + feature_phases_array_name="Phases" +) +nxtest.check_filter_result(nx_filter, result) +# Filter 9 + +# Instantiate Filter +nx_filter = nx.FindFeatureCentroidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path="Centroids", + feature_attribute_matrix=nx.DataPath("ImageDataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("ImageDataContainer/Cell Data/FeatureIds"), + selected_image_geometry=nx.DataPath("ImageDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 10 +# Instantiate Filter +nx_filter = nx.CreateAttributeMatrixFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + data_object_path=nx.DataPath("Ensemble AttributeMatrix"), + tuple_dimensions=[[3.0]] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +output_file_path = nxtest.GetDataDirectory() + "/Output/ImagesStack/Images.dream3d" +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") + diff --git a/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py b/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py new file mode 100644 index 0000000000..8740d5c417 --- /dev/null +++ b/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py @@ -0,0 +1,261 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxitk.ITKImportImageStack() + +generated_file_list_value = nx.GeneratedFileListParameter.ValueType() +generated_file_list_value.input_path = nxtest.GetDataDirectory() + "/Porosity_Image/" +generated_file_list_value.ordering = nx.GeneratedFileListParameter.Ordering.LowToHigh + +generated_file_list_value.file_prefix = "slice_" +generated_file_list_value.file_suffix = "" +generated_file_list_value.file_extension = ".tif" +generated_file_list_value.start_index = 11 +generated_file_list_value.end_index = 174 +generated_file_list_value.increment_index = 1 +generated_file_list_value.padding_digits = 2 + + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Cell Data", + image_data_array_path="ImageData", + image_geometry_path=nx.DataPath("ImageDataContainer"), + image_transform_choice=0, + input_file_list_info=generated_file_list_value, + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("ImageDataContainer/Cell Data/ImageData") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +dt = nx.DataType.boolean + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=dt, + use_custom_false_value=False, + use_custom_true_value=False + # custom_false_value: float = ..., # Not currently part of the code + # custom_true_value: float = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ScalarSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_path="Active", + cell_feature_group_path="CellFeatureData", + feature_ids_path="FeatureIds", + grid_geometry_path=nx.DataPath("ImageDataContainer"), + input_array_path=nx.DataPath("ImageDataContainer/Cell Data/ImageData"), + mask_path=nx.DataPath("ImageDataContainer/Cell Data/Mask"), + randomize_features=True, + scalar_tolerance=0, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.QuickSurfaceMeshFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_data_group_name="Face Data", + face_feature_attribute_matrix_name="Face Feature Data", + face_labels_array_name="FaceLabels", + feature_ids_path=nx.DataPath("ImageDataContainer/Cell Data/FeatureIds"), + fix_problem_voxels=True, + generate_triple_lines=False, + grid_geometry_data_path=nx.DataPath("ImageDataContainer"), + node_types_array_name="NodeTypes", + selected_data_array_paths=[], + triangle_geometry_name=nx.DataPath("TriangleDataContainer"), + vertex_data_group_name="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Instantiate Filter +nx_filter = nx.LaplacianSmoothingFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + iteration_steps=15, + lambda_value=0.2, + mu_factor=0.2, + quad_point_lambda=0.1, + surface_mesh_node_type_array_path=nx.DataPath("TriangleDataContainer/Vertex Data/NodeTypes"), + surface_point_lambda=0.0, + surface_quad_point_lambda=0.0, + surface_triple_line_lambda=0.0, + triangle_geometry_data_path=nx.DataPath("TriangleDataContainer"), + triple_line_lambda=0.1, + use_taubin_smoothing=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.SplitAttributeArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + delete_original_array=True, + multicomponent_array=nx.DataPath("TriangleDataContainer/Face Data/FaceLabels"), + postfix="-", + select_components_to_extract=False + # components_to_extract: List[List[float]] = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 7 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-0") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +dt = nx.DataType.boolean # This line specifies the DataType for the threshold + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="FaceLabels-0 Mask", + created_mask_type=dt, # Use the DataType variable here + use_custom_false_value=False, + use_custom_true_value=False + # custom_false_value: float = ..., # Not currently part of the code + # custom_true_value: float = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 8 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-1") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +dt = nx.DataType.boolean # This line specifies the DataType for the threshold + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="FaceLabels-1 Mask", + created_mask_type=dt, # Use the DataType variable here + use_custom_false_value=False, + use_custom_true_value=False + # custom_false_value: float = ..., # Not currently part of the code + # custom_true_value: float = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = nx.ConditionalSetValue() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + conditional_array_path=nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-0 Mask"), + invert_mask=False, + replace_value="1", + selected_array_path=nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-0"), + use_conditional=True + # remove_value: str = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 10 +# Instantiate Filter +nx_filter = nx.ConditionalSetValue() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + conditional_array_path=nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-1 Mask"), + invert_mask=False, + replace_value="1", + selected_array_path=nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-1"), + use_conditional=True + # remove_value: str = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = nx.CombineAttributeArraysFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + move_values=True, + normalize_data=False, + stacked_data_array_name="Face Labels", + selected_data_array_paths=[ + nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-0"), + nx.DataPath("TriangleDataContainer/Face Data/FaceLabels-1") + ] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 12 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +output_file_path = nxtest.GetDataDirectory() + "/Output/Porosity_Analysis.dream3d" +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py b/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py new file mode 100644 index 0000000000..3e0c606010 --- /dev/null +++ b/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py @@ -0,0 +1,40 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = cx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadH5OimDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("Cell Ensemble Data"), + image_geometry_name=cx.DataPath("ImageGeom"), + origin=[0.0, 0.0, 0.0], + read_pattern_data=False, + #selected_scan_names: ValueType = ..., + z_spacing=1.0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Define output file path +output_file_path = nxtest.GetDataDirectory() + "/Output/H5EspritData/H5EspritData.dream3d" +# Instantiate Filter +nx_filter = cx.WriteDREAM3DFilter() +# Execute WriteDREAM3DFilter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py b/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py new file mode 100644 index 0000000000..e3c53186e9 --- /dev/null +++ b/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py @@ -0,0 +1,64 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = cx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadH5OimDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("Cell Ensemble Data"), + image_geometry_name=cx.DataPath("ImageGeom"), + origin=[0.0, 0.0, 0.0], + read_pattern_data=False, + z_spacing=1.0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.RotateEulerRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + euler_angles_array_path=cx.DataPath("ImageGeom/Cell Data/EulerAngles"), + rotation_axis=[0.0, 0.0, 1.0, 90.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + remove_original_geometry=True, + rotate_slice_by_slice=True, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + rotation_representation=("Axis Angle"), + selected_image_geometry=cx.DataPath("ImageGeom") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Define output file path +output_file_path = nxtest.GetDataDirectory() + "/Output/EdaxOIMData/EdaxOIMData.dream3d" +# Instantiate Filter +nx_filter = cx.WriteDREAM3DFilter() +# Execute WriteDREAM3DFilter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py new file mode 100644 index 0000000000..149f3e8753 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py @@ -0,0 +1,40 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter + +generated_file_list_value = nx.GeneratedFileListParameter.ValueType() +generated_file_list_value.input_path = nxtest.GetDataDirectory() + "/Small_IN100" +generated_file_list_value.ordering = nx.GeneratedFileListParameter.Ordering.HighToLow + +generated_file_list_value.file_prefix = "Slice_" +generated_file_list_value.file_suffix = "" +generated_file_list_value.file_extension = ".ang" +generated_file_list_value.start_index = 1 +generated_file_list_value.end_index = 117 +generated_file_list_value.increment_index = 1 +generated_file_list_value.padding_digits = 0 + +nx_filter = cxor.EbsdToH5EbsdFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_file_list_info=generated_file_list_value, + output_file_path=nxtest.GetDataDirectory() + "/Output/Reconstruction/Small_IN100.h5ebsd", + reference_frame=0, + stacking_order=1, + z_spacing=0.25 +) + +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py new file mode 100644 index 0000000000..d87503c77a --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py @@ -0,0 +1,186 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Reconstruction/SmallIN100_Final.dream3d" +import_data.data_paths = None + +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.DeleteData() +# Execute Filter With Parameters +result = nx_filter.execute( + data_structure=data_structure, + removed_data_path=[nx.DataPath("DataContainer/CellFeatureData/EquivalentDiameters"), + nx.DataPath("DataContainer/CellFeatureData/NumElements"), + nx.DataPath("DataContainer/CellFeatureData/NumNeighbors"), + nx.DataPath("DataContainer/CellFeatureData/NumNeighbors2")] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.FindFeatureCentroidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path=("Centroids"), + feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.CalculateFeatureSizesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + equivalent_diameters_path=("EquivalentDiameters"), + feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + geometry_path=nx.DataPath("DataContainer"), + num_elements_path=("NumElements"), + save_element_sizes=False, + volumes_path=("Size Volumes") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.FindShapesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + aspect_ratios_array_name=("AspectRatios"), + axis_euler_angles_array_name=("AxisEulerAngles"), + axis_lengths_array_name=("AxisLengths"), + centroids_array_path=nx.DataPath("DataContainer/CellFeatureData/Centroids"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + omega3s_array_name=("Omega3s"), + selected_image_geometry=nx.DataPath("DataContainer"), + volumes_array_name=("Shape Volumes") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 6 +# Instantiate Filter +nx_filter = nx.FindNeighbors() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + # Boundary cells parameter is not currently part of the code + # boundary_cells: str = ..., + cell_feature_arrays=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geometry=nx.DataPath("DataContainer"), + neighbor_list=("NeighborList"), + number_of_neighbors=("NumNeighbors"), + shared_surface_area_list=("SharedSurfaceAreaList"), + store_boundary_cells=False, + # Surface features parameter is not currently part of the code + # surface_features: str = ..., + store_surface_features=False +) +nxtest.check_filter_result(nx_filter, result) + + + +# Filter 7 +# Instantiate Filter +nx_filter = nx.FindNeighborhoodsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path=nx.DataPath("DataContainer/CellFeatureData/Centroids"), + equivalent_diameters_array_path=nx.DataPath("DataContainer/CellFeatureData/EquivalentDiameters"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + multiples_of_average=1.0, + neighborhood_list_array_name=("NeighborhoodList"), + neighborhoods_array_name=("Neighborhoods"), + selected_image_geometry_path=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 8 +# Instantiate Filter +nx_filter = nx.FindEuclideanDistMapFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calc_manhattan_dist=True, + do_boundaries=True, + do_quad_points=True, + do_triple_lines=True, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + g_bdistances_array_name=("GBManhattanDistances"), + # Nearest neighbors array name is not currently part of the code + # nearest_neighbors_array_name: str = ..., + q_pdistances_array_name=("QPManhattanDistances"), + save_nearest_neighbors=False, + selected_image_geometry=nx.DataPath("DataContainer"), + t_jdistances_array_name=("TJManhattanDistances") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 9 +# Instantiate Filter +nx_filter = nx.FindSurfaceAreaToVolumeFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calculate_sphericity=True, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + num_cells_array_path=nx.DataPath("DataContainer/CellFeatureData/NumElements"), + selected_image_geometry=nx.DataPath("DataContainer"), + sphericity_array_name=("Sphericity"), + surface_area_volume_ratio_array_name=("SurfaceAreaVolumeRatio") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 10 +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/Statistics/SmallIN100_Morph.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py new file mode 100644 index 0000000000..e6dd9782ba --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py @@ -0,0 +1,92 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Statistics/SmallIN100_CrystalStats.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data) + +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + max_voxel=[140, 140, 99], + min_voxel=[41, 41, 0], + remove_original_geometry=True, + renumber_features=True, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +#nx_filter = nx.MoveData() +# Execute Filter with Parameters +#result = nx_filter.execute( +# data_structure=data_structure, +# data=[nx.DataPath("DataContainer/CellEnsembleData")], +# new_parent=nx.DataPath("DataContainer") +# ) +# nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.QuickSurfaceMeshFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_data_group_name=("FaceData"), + face_feature_attribute_matrix_name=("Face Feature Data"), + face_labels_array_name=("FaceLabels"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + fix_problem_voxels=False, + generate_triple_lines=False, + grid_geometry_data_path=nx.DataPath("DataContainer"), + node_types_array_name=("NodeType"), + triangle_geometry_name=nx.DataPath("TriangleDataContainer"), + vertex_data_group_name=("VertexData") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_Mesh.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py b/wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py new file mode 100644 index 0000000000..a71a8ec1be --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py @@ -0,0 +1,62 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_Mesh.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.LaplacianSmoothingFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + iteration_steps=100, + lambda_value=0.25, + mu_factor=0.2, + quad_point_lambda=0.15000001, + surface_mesh_node_type_array_path=nx.DataPath("TriangleDataContainer/VertexData/NodeType"), + surface_point_lambda=0.0, + surface_quad_point_lambda=0.0, + surface_triple_line_lambda=0.0, + triangle_geometry_data_path=nx.DataPath("TriangleDataContainer"), + triple_line_lambda=0.2, + use_taubin_smoothing=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_Smoothed.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +# ***************************************************************************** + + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py b/wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py new file mode 100644 index 0000000000..45271ef0f5 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py @@ -0,0 +1,120 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_Smoothed.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CalculateTriangleAreasFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + triangle_areas_array_path="FaceAreas", + triangle_geometry_data_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.TriangleNormalFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + surface_mesh_triangle_normals_array_path="FaceNormals", + tri_geometry_data_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.TriangleDihedralAngleFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + surface_mesh_triangle_dihedral_angles_array_name="FaceDihedralAngles", + tri_geometry_data_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateFaceIPFColoringFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + surface_mesh_face_ipf_colors_array_name="FaceIPFColors", + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.GenerateFaceMisorientationColoringFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_misorientation_colors_array_name="FaceMisorientationColors" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.SharedFeatureFaceFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + feature_face_ids_array_name="SharedFeatureFaceId", + feature_face_labels_array_name="FaceLabels", + feature_num_triangles_array_name="NumTriangles", + grain_boundary_attribute_matrix_name="SharedFeatureFace", + randomize_features=False, + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_MeshStats.dream3d" +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +# Check result for errors or warnings +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py b/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py new file mode 100644 index 0000000000..d44d5cdfe8 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py @@ -0,0 +1,140 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_MeshStats.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.FindGBCDFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + face_ensemble_attribute_matrix_name="FaceEnsembleData", + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + gbcd_array_name="GBCD", + gbcd_resolution=9.0, + surface_mesh_face_areas_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals"), + triangle_geometry=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.GenerateGBCDPoleFigureFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_intensity_array_name="MRD", + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + gbcd_array_path=nx.DataPath("TriangleDataContainer/FaceEnsembleData/GBCD"), + image_geometry_name=nx.DataPath("GBCD Pole Figure [Sigma 3]"), + misorientation_rotation=[60.0, 1.0, 1.0, 1.0], + output_image_dimension=100, + phase_of_interest=1 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.GenerateGBCDPoleFigureFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_intensity_array_name="MRD", + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + gbcd_array_path=nx.DataPath("TriangleDataContainer/FaceEnsembleData/GBCD"), + image_geometry_name=nx.DataPath("GBCD Pole Figure [Sigma 9]"), + misorientation_rotation=[39.0, 1.0, 1.0, 1.0], + output_image_dimension=100, + phase_of_interest=1 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateGBCDPoleFigureFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_intensity_array_name="MRD", + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + gbcd_array_path=nx.DataPath("TriangleDataContainer/FaceEnsembleData/GBCD"), + image_geometry_name=nx.DataPath("GBCD Pole Figure [Sigma 11]"), + misorientation_rotation=[50.5, 1.0, 1.0, 1.0], + output_image_dimension=100, + phase_of_interest=1 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.WriteGBCDGMTFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + gbcd_array_path=nx.DataPath("TriangleDataContainer/FaceEnsembleData/GBCD"), + misorientation_rotation=[60.0, 1.0, 1.0, 1.0], + output_file="Data/Output/SmallIN100GBCD/SmallIn100GMT_1.dat", + phase_of_interest=1 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.WriteGBCDTriangleDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles"), + output_file="Data/Output/SmallIN100GBCD/SmallIn100Triangles.ph", + surface_mesh_face_areas_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_GBCD.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py new file mode 100644 index 0000000000..27fdf3c976 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py @@ -0,0 +1,153 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Statistics/SmallIN100_Morph.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.DeleteData() +# Execute Filter With Parameters +result = nx_filter.execute( + data_structure=data_structure, + removed_data_path=[nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles")] + +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate and Execute Filter +# Note: This filter might need additional parameters depending on the intended data removal. +nx_filter = nx.DeleteData() +result = nx_filter.execute( + data_structure=data_structure + # removed_data_path: List[DataPath] = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.FindAvgOrientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_euler_angles_array_path="AvgEulerAngles", + avg_quats_array_path="AvgQuats", + cell_feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + cell_feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + cell_quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.FindMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + find_avg_misors=False, + misorientation_list_array_name="MisorientationList", + neighbor_list_array_path=nx.DataPath("DataContainer/CellFeatureData/NeighborhoodList") + # avg_misorientations_array_name: str = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.FindSchmidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + loading_direction=[1.0, 1.0, 1.0], + override_system=False, + poles_array_name="Poles", + schmids_array_name="Schmids", + slip_systems_array_name="SlipSystems", + store_angle_components=False + # lambdas_array_name: str = ..., # Not currently part of the code + # phis_array_name: str = ..., # Not currently part of the code + # slip_direction: List[float] = ..., # Not currently part of the code + # slip_plane: List[float] = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.FindFeatureReferenceMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_avg_misorientations_array_name="FeatureAvgMisorientations", + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + feature_reference_misorientations_array_name="FeatureReferenceMisorientations", + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + reference_orientation=0 + # cell_feature_attribute_matrix_path=nx.DataPath("DataContainer/"), # Not currently part of the code + # g_beuclidean_distances_array_path=nx.DataPath("DataContainer/"), # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = cxor.FindKernelAvgMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + kernel_average_misorientations_array_name="KernelAverageMisorientations", + kernel_size=[1, 1, 1], + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + selected_image_geometry_path=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/Statistics/SmallIN100_CrystalStats.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py new file mode 100644 index 0000000000..34d119b972 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py @@ -0,0 +1,145 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data Parameter +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_MeshStats.dream3d" +import_data.data_paths =[ + nx.DataPath("DataContainer"), + nx.DataPath("DataContainer/CellData"), + nx.DataPath("DataContainer/CellData/Image Quality"), + nx.DataPath("DataContainer/CellData/Confidence Index"), + nx.DataPath("DataContainer/CellData/SEM Signal"), + nx.DataPath("DataContainer/CellData/Fit"), + nx.DataPath("DataContainer/CellData/EulerAngles"), + nx.DataPath("DataContainer/CellData/Phases"), + nx.DataPath("DataContainer/CellData/Mask"), + nx.DataPath("DataContainer/CellData/Quats"), + nx.DataPath("DataContainer/CellData/FeatureIds"), + nx.DataPath("DataContainer/CellData/ParentIds"), + nx.DataPath("DataContainer/CellData/IPFColors"), + nx.DataPath("DataContainer/CellData/GBManhattanDistances"), + nx.DataPath("DataContainer/CellData/TJManhattanDistances"), + nx.DataPath("DataContainer/CellData/QPManhattanDistances"), + nx.DataPath("DataContainer/CellData/FeatureReferenceMisorientations"), + nx.DataPath("DataContainer/CellData/KernelAverageMisorientations"), + nx.DataPath("DataContainer/CellFeatureData"), + nx.DataPath("DataContainer/CellEnsembleData"), + nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + nx.DataPath("DataContainer/CellEnsembleData/LatticeConstants"), + nx.DataPath("DataContainer/NewGrain Data"), + nx.DataPath("DataContainer/NewGrain Data/Active"), + nx.DataPath("DataContainer/CellFeatureData/Active"), + nx.DataPath("DataContainer/CellFeatureData/AspectRatios"), + nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles"), + nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + nx.DataPath("DataContainer/CellFeatureData/AxisEulerAngles"), + nx.DataPath("DataContainer/CellFeatureData/AxisLengths"), + nx.DataPath("DataContainer/CellFeatureData/Centroids"), + nx.DataPath("DataContainer/CellFeatureData/EquivalentDiameters"), + nx.DataPath("DataContainer/CellFeatureData/FeatureAvgMisorientations"), + nx.DataPath("DataContainer/CellFeatureData/Neighborhoods"), + nx.DataPath("DataContainer/CellFeatureData/NumElements"), + nx.DataPath("DataContainer/CellFeatureData/NumNeighbors"), + #nx.DataPath("DataContainer/CellFeatureData/NumNeighbors2"), + nx.DataPath("DataContainer/CellFeatureData/Omega3s"), + nx.DataPath("DataContainer/CellFeatureData/ParentIds"), + nx.DataPath("DataContainer/CellFeatureData/Phases"), + nx.DataPath("DataContainer/CellFeatureData/Poles"), + nx.DataPath("DataContainer/CellFeatureData/Schmids"), + nx.DataPath("DataContainer/CellFeatureData/Shape Volumes"), + nx.DataPath("DataContainer/CellFeatureData/SlipSystems"), + nx.DataPath("DataContainer/CellFeatureData/SurfaceAreaVolumeRatio"), + nx.DataPath("TriangleDataContainer"), + nx.DataPath("TriangleDataContainer/SharedTriList"), + nx.DataPath("TriangleDataContainer/SharedVertexList"), + nx.DataPath("TriangleDataContainer/FaceData"), + nx.DataPath("TriangleDataContainer/VertexData"), + nx.DataPath("TriangleDataContainer/VertexData/NodeType"), + nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + nx.DataPath("TriangleDataContainer/Edge List"), + nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + nx.DataPath("TriangleDataContainer/FaceData/FaceNormals"), + nx.DataPath("TriangleDataContainer/FaceData/FaceDihedralAngles") + ] + +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data) + +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.SharedFeatureFaceFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + feature_face_ids_array_name="SharedFeatureFaceId", + feature_face_labels_array_name="FaceLabels", + feature_num_triangles_array_name="NumTriangles", + grain_boundary_attribute_matrix_name="SharedFeatureFace", + randomize_features=False, + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.FindGBCDMetricBasedFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + chosen_limit_dists=0, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + dist_output_file="Data/Output/SurfaceMesh/7_0_small_in100_distribution_1.dat", + err_output_file="Data/Output/SurfaceMesh/7_0_small_in100_distribution_errors_1.dat", + exclude_triple_lines=False, + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + misorientation_rotation=[1.0, 1.0, 1.0, 60.0], + node_types_array_path=nx.DataPath("TriangleDataContainer/VertexData/NodeType"), + num_sampl_pts=3000, + phase_of_interest=1, + save_relative_err=False, + surface_mesh_face_areas_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals"), + surface_mesh_feature_face_labels_array_path=nx.DataPath("TriangleDataContainer/SharedFeatureFace/FaceLabels"), + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_GBCD_Metric.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(import_data.file_path) +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py b/wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py new file mode 100644 index 0000000000..c9709fba7c --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py @@ -0,0 +1,405 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter + +filter_parameter = cxor.ReadH5EbsdFileParameter.ValueType() +filter_parameter.euler_representation=0 +filter_parameter.end_slice=117 +filter_parameter.selected_array_names=["Confidence Index", "EulerAngles", "Fit", "Image Quality", "Phases", "SEM Signal", "X Position", "Y Position"] +filter_parameter.input_file_path=nxtest.GetDataDirectory() + "/Output/Reconstruction/Small_IN100.h5ebsd" +filter_parameter.start_slice=6 +filter_parameter.use_recommended_transform=True + +nx_filter = cxor.ReadH5EbsdFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="CellData", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("DataContainer"), + read_h5_ebsd_parameter=filter_parameter +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/CellData/Image Quality") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 120 + +threshold_2 = nx.ArrayThreshold() +threshold_2.array_path = nx.DataPath("DataContainer/CellData/Confidence Index") +threshold_2.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_2.value = 0.1 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1, threshold_2] +dt = nx.DataType.boolean + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("DataContainer/CellData/EulerAngles"), + input_type=0, + output_orientation_array_name="Quats", + output_type=2 + +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.AlignSectionsMisorientationFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + selected_image_geometry_path=nx.DataPath("DataContainer"), + use_mask=True, + write_alignment_shifts=False + # alignment_shift_file_name: PathLike = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.IdentifySample() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + fill_holes=False, + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.AlignSectionsFeatureCentroidFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + reference_slice=0, + selected_cell_data_path=nx.DataPath("DataContainer/CellData"), + selected_image_geometry_path=nx.DataPath("DataContainer"), + use_reference_slice=True, + write_alignment_shifts=False + # alignment_shift_file_name: PathLike = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.BadDataNeighborOrientationCheckFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + image_geometry_path=nx.DataPath("DataContainer"), + misorientation_tolerance=5.0, + number_of_neighbors=4, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = cxor.NeighborOrientationCorrelationFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + correlation_array_path=nx.DataPath("DataContainer/CellData/Confidence Index"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + image_geometry_path=nx.DataPath("DataContainer"), + level=2, + min_confidence=0.2, + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats") + # ignored_data_array_paths: List[DataPath] = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = cxor.EBSDSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_name="Active", + cell_feature_attribute_matrix_name="CellFeatureData", + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_ids_array_name="FeatureIds", + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + grid_geometry_path=nx.DataPath("DataContainer"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + randomize_features=True, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 10 +# Instantiate Filter +nx_filter = nx.FindFeaturePhasesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_features_attribute_matrix_path=nx.DataPath("DataContainer/CellFeatureData"), + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + feature_phases_array_name="Phases" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = cxor.FindAvgOrientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_euler_angles_array_path="AvgEulerAngles", + avg_quats_array_path="AvgQuats", + cell_feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + cell_feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + cell_quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 12 +# Instantiate Filter +nx_filter = nx.FindNeighbors() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_arrays=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geometry=nx.DataPath("DataContainer"), + neighbor_list="NeighborList2", + number_of_neighbors="NumNeighbors2", + shared_surface_area_list="SharedSurfaceAreaList2", + store_boundary_cells=False, + store_surface_features=False + # boundary_cells: str = ..., # Not currently part of the code + # surface_features: str = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 13 +# Instantiate Filter +nx_filter = cxor.MergeTwinsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_name="Active", + angle_tolerance=2.0, + avg_quats_array_path=nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + axis_tolerance=3.0, + cell_parent_ids_array_name="ParentIds", + contiguous_neighbor_list_array_path=nx.DataPath("DataContainer/CellFeatureData/NeighborList2"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + feature_parent_ids_array_name="ParentIds", + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + new_cell_feature_attribute_matrix_name="NewGrain Data", + use_non_contiguous_neighbors=False + # non_contiguous_neighbor_list_array_path: DataPath = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 14 +# Instantiate Filter +nx_filter = nx.CalculateFeatureSizesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + equivalent_diameters_path="EquivalentDiameters", + feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + geometry_path=nx.DataPath("DataContainer"), + num_elements_path="NumElements", + save_element_sizes=False, + volumes_path="Volumes" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 15 +# Instantiate Filter +nx_filter = nx.RemoveMinimumSizeFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + apply_single_phase=False, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geom_path=nx.DataPath("DataContainer"), + min_allowed_features_size=16, + num_cells_path=nx.DataPath("DataContainer/CellFeatureData/NumElements") + # feature_phases_path: DataPath = ..., # Not currently part of the code + # phase_number: int = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 16 +# Instantiate Filter +nx_filter = nx.FindNeighbors() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_arrays=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geometry=nx.DataPath("DataContainer"), + neighbor_list="NeighborList", + number_of_neighbors="NumNeighbors", + shared_surface_area_list="SharedSurfaceAreaList", + store_boundary_cells=False, + store_surface_features=False + # boundary_cells: str = ..., # Not currently part of the code + # surface_features: str = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 17 +# Instantiate Filter +nx_filter = nx.MinNeighbors() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + apply_to_single_phase=False, + cell_attribute_matrix=nx.DataPath("DataContainer/CellData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geom=nx.DataPath("DataContainer"), + min_num_neighbors=2, + num_neighbors=nx.DataPath("DataContainer/CellFeatureData/NumNeighbors"), + phase_number=0 + # feature_phases: DataPath = ..., # Not currently part of the code + # ignored_voxel_arrays: List[DataPath] = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 18 +# Instantiate Filter +nx_filter = nx.FillBadDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + min_allowed_defect_size=1000, + selected_image_geometry=nx.DataPath("DataContainer"), + store_as_new_phase=False + # cell_phases_array_path: DataPath = ..., # Not currently part of the code + # ignored_data_array_paths: List[DataPath] = ... # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 19 +# Instantiate Filter +nx_filter = nx.ErodeDilateBadDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + num_iterations=2, + operation=0, + selected_image_geometry=nx.DataPath("DataContainer"), + x_dir_on=True, + y_dir_on=True, + z_dir_on=True, + ignored_data_array_paths=[] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 20 +# Instantiate Filter +nx_filter = nx.ErodeDilateBadDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + num_iterations=2, + operation=1, # Dilate operation + selected_image_geometry=nx.DataPath("DataContainer"), + x_dir_on=True, + y_dir_on=True, + z_dir_on=True, + ignored_data_array_paths=[] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 21 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("DataContainer/CellData/EulerAngles"), + cell_ipf_colors_array_name="IPFColors", + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 22 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/Reconstruction/SmallIN100_Final.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(filter_parameter.input_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py b/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py new file mode 100644 index 0000000000..0d26d7cfc8 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py @@ -0,0 +1,388 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadCtfDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("fw-ar-IF1-aptr12-corr"), + degrees_to_radians=True, + edax_hexagonal_alignment=True, + input_file=nxtest.GetDataDirectory() + "/T12-MAI-2010/fw-ar-IF1-aptr12-corr.ctf" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr"), + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix=[] + rotation_representation=0, + selected_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Set Threshold Conditions +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Error") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +# Create a Threshold Set +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="ThresholdArray", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/EulerAngles"), + input_type=0, + output_orientation_array_name="Quats", + output_type=2 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ReplaceElementAttributesWithNeighborValuesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + comparison_data_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Error"), + loop=False, + min_confidence=0.0, + selected_comparison=0, + selected_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_001", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/fw-ar-IF1-aptr12-corr_001.png", + image_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/IPF_001"), + image_geom_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_010", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + #mask_array_path=nx.DataPath("") + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/fw-ar-IF1-aptr12-corr_010.png", + image_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/IPF_010"), + image_geom_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 10 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_100", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + reference_dir=[1.0, 0.0, 0.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/fw-ar-IF1-aptr12-corr_100.png", + image_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/IPF_100"), + image_geom_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 12 +# Instantiate Filter +nx_filter = cxor.EBSDSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_name="Active", + cell_feature_attribute_matrix_name="CellFeatureData", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + feature_ids_array_name="FeatureIds", + grid_geometry_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + mask_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/ThresholdArray"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Quats"), + randomize_features=True, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 13 +# Instantiate Filter +nx_filter = nx.FillBadDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + min_allowed_defect_size=10, + selected_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr"), + store_as_new_phase=False + # cell_phases_array_path and ignored_data_array_paths parameters are not used in this context +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 14 +# Instantiate Filter +nx_filter = nx.CalculateFeatureSizesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + equivalent_diameters_path="EquivalentDiameters", + feature_attribute_matrix=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData"), + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + geometry_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + num_elements_path="NumElements", + save_element_sizes=False, + volumes_path="Volumes" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 15 +# Instantiate Filter +nx_filter = nx.RemoveMinimumSizeFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + apply_single_phase=False, + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + image_geom_path=nx.DataPath("fw-ar-IF1-aptr12-corr"), + min_allowed_features_size=5, + num_cells_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData/NumElements") + # feature_phases_path and phase_number parameters are not used in this context +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 16 +# Instantiate Filter +nx_filter = cxor.FindAvgOrientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_euler_angles_array_path="AvgEulerAngles", + avg_quats_array_path="AvgQuats", + cell_feature_attribute_matrix=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData"), + cell_feature_ids_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + cell_quats_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Quats"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 17 +# Instantiate Filter +nx_filter = cxor.FindKernelAvgMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + kernel_average_misorientations_array_name="KernelAverageMisorientations", + kernel_size=[1, 1, 1], + quats_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Quats"), + selected_image_geometry_path=nx.DataPath("fw-ar-IF1-aptr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 18 +# Instantiate Filter +nx_filter = nx.FindFeatureCentroidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path="Centroids", + feature_attribute_matrix=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData"), + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + selected_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 19 +# Instantiate Filter +nx_filter = nx.FindEuclideanDistMapFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calc_manhattan_dist=True, + do_boundaries=True, + do_quad_points=False, + do_triple_lines=False, + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + g_bdistances_array_name="GBManhattanDistances", + save_nearest_neighbors=False, + selected_image_geometry=nx.DataPath("fw-ar-IF1-aptr12-corr") + # Parameters for nearest_neighbors_array_name, q_pdistances_array_name, and t_jdistances_array_name are not used +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 20 +# Instantiate Filter +nx_filter = cxor.FindFeatureReferenceMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData/AvgQuats"), + cell_phases_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellEnsembleData/CrystalStructures"), + feature_avg_misorientations_array_name="FeatureAvgMisorientations", + feature_ids_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/FeatureIds"), + feature_reference_misorientations_array_name="FeatureReferenceMisorientations", + quats_array_path=nx.DataPath("fw-ar-IF1-aptr12-corr/Cell Data/Quats"), + reference_orientation=0 + # Parameters for cell_feature_attribute_matrix_path and g_beuclidean_distances_array_path are not used +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 21 +# Instantiate Filter +nx_filter = nx.WriteFeatureDataCSVFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_attribute_matrix_path=nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData"), + delimiter_choice_int=2, + feature_data_file=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/FeatureData.csv", + write_neighborlist_data=False, + write_num_features_line=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 22 +# Instantiate Filter +nx_filter = nx.CalculateArrayHistogramFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + histogram_suffix=" Histogram", + new_data_group=True, + new_data_group_name=nx.DataPath("fw-ar-IF1-aptr12-corr/Histograms"), + number_of_bins=256, + selected_array_paths=[nx.DataPath("fw-ar-IF1-aptr12-corr/CellFeatureData/EquivalentDiameters")], + user_defined_range=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 23 +# Instantiate Filter +nx_filter = nx.WriteASCIIDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + delimiter=2, + output_path=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/EqDiamHistogram.csv", + output_style=1, + selected_data_array_paths=[nx.DataPath("fw-ar-IF1-aptr12-corr/Histograms/EquivalentDiameters Histogram")] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 24 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/fw-ar-IF1-aptr12-corr.dream3d" + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-aptr12-corr/") +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py new file mode 100644 index 0000000000..14be9b1180 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py @@ -0,0 +1,388 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadCtfDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("fw-ar-IF1-avtr12-corr"), + degrees_to_radians=True, + edax_hexagonal_alignment=True, + input_file=nxtest.GetDataDirectory() + "/T12-MAI-2010/fw-ar-IF1-avtr12-corr.ctf" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr"), + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix=[] + rotation_representation=0, + selected_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Set Threshold Conditions +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Error") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +# Create a Threshold Set +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="ThresholdArray", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/EulerAngles"), + input_type=0, + output_orientation_array_name="Quats", + output_type=2 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ReplaceElementAttributesWithNeighborValuesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + comparison_data_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Error"), + loop=False, + min_confidence=0.0, + selected_comparison=0, + selected_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_001", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/fw-ar-IF1-avtr12-corr_001.png", + image_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/IPF_001"), + image_geom_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_010", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + #mask_array_path=nx.DataPath("") + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/fw-ar-IF1-avtr12-corr_010.png", + image_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/IPF_010"), + image_geom_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 10 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/EulerAngles"), + cell_ipf_colors_array_name="IPF_100", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + reference_dir=[1.0, 0.0, 0.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/fw-ar-IF1-avtr12-corr_100.png", + image_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/IPF_100"), + image_geom_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 12 +# Instantiate Filter +nx_filter = cxor.EBSDSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_name="Active", + cell_feature_attribute_matrix_name="CellFeatureData", + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + feature_ids_array_name="FeatureIds", + grid_geometry_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + mask_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/ThresholdArray"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Quats"), + randomize_features=True, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 13 +# Instantiate Filter +nx_filter = nx.FillBadDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + min_allowed_defect_size=10, + selected_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr"), + store_as_new_phase=False + # cell_phases_array_path and ignored_data_array_paths parameters are not used in this context +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 14 +# Instantiate Filter +nx_filter = nx.CalculateFeatureSizesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + equivalent_diameters_path="EquivalentDiameters", + feature_attribute_matrix=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData"), + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + geometry_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + num_elements_path="NumElements", + save_element_sizes=False, + volumes_path="Volumes" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 15 +# Instantiate Filter +nx_filter = nx.RemoveMinimumSizeFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + apply_single_phase=False, + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + image_geom_path=nx.DataPath("fw-ar-IF1-avtr12-corr"), + min_allowed_features_size=5, + num_cells_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData/NumElements") + # feature_phases_path and phase_number parameters are not used in this context +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 16 +# Instantiate Filter +nx_filter = cxor.FindAvgOrientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_euler_angles_array_path="AvgEulerAngles", + avg_quats_array_path="AvgQuats", + cell_feature_attribute_matrix=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData"), + cell_feature_ids_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + cell_quats_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Quats"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 17 +# Instantiate Filter +nx_filter = cxor.FindKernelAvgMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + kernel_average_misorientations_array_name="KernelAverageMisorientations", + kernel_size=[1, 1, 1], + quats_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Quats"), + selected_image_geometry_path=nx.DataPath("fw-ar-IF1-avtr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 18 +# Instantiate Filter +nx_filter = nx.FindFeatureCentroidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path="Centroids", + feature_attribute_matrix=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData"), + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + selected_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 19 +# Instantiate Filter +nx_filter = nx.FindEuclideanDistMapFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calc_manhattan_dist=True, + do_boundaries=True, + do_quad_points=False, + do_triple_lines=False, + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + g_bdistances_array_name="GBManhattanDistances", + save_nearest_neighbors=False, + selected_image_geometry=nx.DataPath("fw-ar-IF1-avtr12-corr") + # Parameters for nearest_neighbors_array_name, q_pdistances_array_name, and t_jdistances_array_name are not used +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 20 +# Instantiate Filter +nx_filter = cxor.FindFeatureReferenceMisorientationsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + avg_quats_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData/AvgQuats"), + cell_phases_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellEnsembleData/CrystalStructures"), + feature_avg_misorientations_array_name="FeatureAvgMisorientations", + feature_ids_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/FeatureIds"), + feature_reference_misorientations_array_name="FeatureReferenceMisorientations", + quats_array_path=nx.DataPath("fw-ar-IF1-avtr12-corr/Cell Data/Quats"), + reference_orientation=0 + # Parameters for cell_feature_attribute_matrix_path and g_beuclidean_distances_array_path are not used +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 21 +# Instantiate Filter +nx_filter = nx.WriteFeatureDataCSVFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_attribute_matrix_path=nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData"), + delimiter_choice_int=2, + feature_data_file=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/FeatureData.csv", + write_neighborlist_data=False, + write_num_features_line=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 22 +# Instantiate Filter +nx_filter = nx.CalculateArrayHistogramFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + histogram_suffix=" Histogram", + new_data_group=True, + new_data_group_name=nx.DataPath("fw-ar-IF1-avtr12-corr/Histograms"), + number_of_bins=256, + selected_array_paths=[nx.DataPath("fw-ar-IF1-avtr12-corr/CellFeatureData/EquivalentDiameters")], + user_defined_range=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 23 +# Instantiate Filter +nx_filter = nx.WriteASCIIDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + delimiter=2, + output_path=nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/EqDiamHistogram.csv", + output_style=1, + selected_data_array_paths=[nx.DataPath("fw-ar-IF1-avtr12-corr/Histograms/EquivalentDiameters Histogram")] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 24 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/fw-ar-IF1-avtr12-corr.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/fw-ar-IF1-avtr12-corr/") +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py new file mode 100644 index 0000000000..6c786be06d --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py @@ -0,0 +1,113 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 + +# Create the ReadH5EbsdFileParameter and assign values to it. +h5ebsdParameter = cxor.ReadH5EbsdFileParameter.ValueType() +h5ebsdParameter.euler_representation=0 +h5ebsdParameter.end_slice=117 +h5ebsdParameter.selected_array_names=["Confidence Index", "EulerAngles", "Fit", "Image Quality", "Phases", "SEM Signal", "X Position", "Y Position"] +h5ebsdParameter.input_file_path=nxtest.GetDataDirectory() + "/Output/Reconstruction/Small_IN100.h5ebsd" +h5ebsdParameter.start_slice=1 +h5ebsdParameter.use_recommended_transform=True + +# Instantiate Filter +nx_filter = cxor.ReadH5EbsdFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="CellData", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("DataContainer"), + read_h5_ebsd_parameter=h5ebsdParameter +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Set Up Thresholds and Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/CellData/Image Quality") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 120 + +threshold_2 = nx.ArrayThreshold() +threshold_2.array_path = nx.DataPath("DataContainer/CellData/Confidence Index") +threshold_2.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_2.value = 0.1 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1, threshold_2] +dt = nx.DataType.boolean + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("DataContainer/CellData/EulerAngles"), + input_type=0, + output_orientation_array_name="Quats", + output_type=2 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.AlignSectionsMutualInformationFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + alignment_shift_file_name=nxtest.GetDataDirectory() + "/Output/OrientationAnalysis/Alignment_By_Mutual_Information_Shifts.txt", + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + selected_image_geometry_path=nx.DataPath("DataContainer"), + use_mask=True, + write_alignment_shifts=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/AlignSectionsMutualInformation/SmallIN100_AlignSectionsMutualInformation.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py new file mode 100644 index 0000000000..d220ab9506 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py @@ -0,0 +1,58 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Set import parameters +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Reconstruction/SmallIN100_Final.dream3d" +import_data.data_paths = None +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.WriteAvizoUniformCoordinateFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/AzizoWriter/SmallIN100_AvizoUniform.am" +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + geometry_path=nx.DataPath("DataContainer"), + output_file=output_file_path, + units="meters", + write_binary_file=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.WriteAvizoUniformCoordinateFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/AzizoWriter/SmallIN100_AvizoRectilinear.am" + +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + geometry_path=nx.DataPath("DataContainer"), + output_file=output_file_path, + units="meters", + write_binary_file=False +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/AzizoWriter") +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py b/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py new file mode 100644 index 0000000000..b02e02c182 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py @@ -0,0 +1,129 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("CellEnsembleData"), + data_container_name=nx.DataPath("DataContainer"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang", +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.RotateEulerRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + rotation_axis=[0.0, 0.0, 1.0, 90.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_image_geometry=nx.DataPath("beans"), + remove_original_geometry=False, + rotate_slice_by_slice=True, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + rotation_representation=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Set Threshold Conditions +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/Cell Data/Confidence Index") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.LessThan +threshold_1.value = 0.1 + +# Create a Threshold Set +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ConditionalSetValue() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + conditional_array_path=nx.DataPath("DataContainer/Cell Data/Mask"), + invert_mask=False, + remove_value="0", + selected_array_path=nx.DataPath("DataContainer/Cell Data/Confidence Index"), + use_conditional=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.CalculateArrayHistogramFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #data_group_name=nx.DataPath("DataContainer/Statistics"), + histogram_suffix=" Histogram", + max_range=1.0, + min_range=0.0, + new_data_group=True, + new_data_group_name=nx.DataPath("DataContainer/Statistics"), + number_of_bins=25, + selected_array_paths=[nx.DataPath("DataContainer/Cell Data/Confidence Index")], + user_defined_range=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.WriteASCIIDataFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/OrientationAnalysis/Test/CI_Histogram.csv" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #file_extension: str = ..., + delimiter=2, + includes=1, + #max_val_per_line: int = ..., + #output_dir: PathLike = ..., + output_path=output_file_path, + output_style=1, + selected_data_array_paths=[nx.DataPath("DataContainer/Statistics/Confidence Index Histogram")] +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py b/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py new file mode 100644 index 0000000000..92172a0883 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py @@ -0,0 +1,111 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("CellEnsembleData"), + data_container_name=nx.DataPath("DataContainer"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.RotateEulerRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + rotation_axis=[0.0, 0.0, 1.0, 90.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + rotation_representation=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Thresholds +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/Cell Data/Confidence Index") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 0.1 + +# Instantiate Threshold Set +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + cell_ipf_colors_array_name=("IPFColors"), + cell_phases_array_path=nx.DataPath("DataContainer/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/Cell Data/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +output_file_path = nxtest.GetDataDirectory() + "/Output/Edax_IPF_Colors/Small_IN100_Slice_1.png" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=output_file_path, + image_array_path=nx.DataPath("DataContainer/Cell Data/IPFColors"), + image_geom_path=nx.DataPath("DataContainer"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/FindBiasedFeatures.py b/wrapping/python/examples/pipelines/OrientationAnalysis/FindBiasedFeatures.py new file mode 100644 index 0000000000..318d1ca4b7 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/FindBiasedFeatures.py @@ -0,0 +1,129 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Statistics/SmallIN100_CrystalStats.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.DeleteData() +# Execute Filter With Parameters +result = nx_filter.execute( + data_structure=data_structure, + removed_data_path=[nx.DataPath("DataContainer/CellFeatureData/Centroids"), + nx.DataPath("DataContainer/CellFeatureData/EquivalentDiameters"), + nx.DataPath("DataContainer/CellFeatureData/NumElements"), + nx.DataPath("DataContainer/CellFeatureData/Omega3s"), + nx.DataPath("DataContainer/CellFeatureData/AxisLengths"), + nx.DataPath("DataContainer/CellFeatureData/AxisEulerAngles"), + nx.DataPath("DataContainer/CellFeatureData/AspectRatios"), + nx.DataPath("DataContainer/CellFeatureData/Shape Volumes"), + nx.DataPath("DataContainer/CellFeatureData/NumNeighbors"), + nx.DataPath("DataContainer/CellFeatureData/NeighborList"), + nx.DataPath("DataContainer/CellFeatureData/SharedSurfaceAreaList"), + nx.DataPath("DataContainer/CellFeatureData/NeighborhoodList"), + nx.DataPath("DataContainer/CellFeatureData/SurfaceAreaVolumeRatio"), + nx.DataPath("DataContainer/CellFeatureData/AvgQuats"), + nx.DataPath("DataContainer/CellFeatureData/AvgEulerAngles")] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 2 +# Instantiate Filter +nx_filter = nx.FindNeighbors() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #boundary_cells: str = ..., + cell_feature_arrays=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geometry=nx.DataPath("DataContainer"), + neighbor_list="NeighborList", + number_of_neighbors="NumNeighbors", + shared_surface_area_list="SharedSurfaceAreaList", + store_boundary_cells=False, + store_surface_features=False + #surface_features: str = ... +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.FindFeatureCentroidsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_path="Centroids", + feature_attribute_matrix=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.FindSurfaceFeatures() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + feature_attribute_matrix_path=nx.DataPath("DataContainer/CellFeatureData"), + feature_geometry_path=nx.DataPath("DataContainer"), + feature_ids_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + mark_feature_0_neighbors=True, + surface_features_array_path="SurfaceFeatures" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.FindBiasedFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + biased_features_array_name="BiasedFeatures", + calc_by_phase=True, + centroids_array_path=nx.DataPath("DataContainer/CellFeatureData/Centroids"), + image_geometry_path=nx.DataPath("DataContainer"), + phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + surface_features_array_path=nx.DataPath("DataContainer/CellFeatureData/SurfaceFeatures") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Output file path for Filter 4 +output_file_path = nxtest.GetDataDirectory() + "/Output/FindBiasedFeatures/FindBiasedFeatures.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/FindBoundaryCells.py b/wrapping/python/examples/pipelines/OrientationAnalysis/FindBoundaryCells.py new file mode 100644 index 0000000000..11e8a77811 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/FindBoundaryCells.py @@ -0,0 +1,58 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data + +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Reconstruction/SmallIN100_Final.dream3d" +import_data.data_paths = None + +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.FindBoundaryCellsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + boundary_cells_array_name="BoundaryCells", + feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + ignore_feature_zero=True, + image_geometry_path=nx.DataPath("DataContainer"), + include_volume_boundary=True, +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Output file path for Filter 3 +output_file_path = nxtest.GetDataDirectory() + "/Output/FindBoundaryCells/SmallIN100_BoundaryCells.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/FindGBCD-GBPDMetricBased.py b/wrapping/python/examples/pipelines/OrientationAnalysis/FindGBCD-GBPDMetricBased.py new file mode 100644 index 0000000000..e1b0c32ede --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/FindGBCD-GBPDMetricBased.py @@ -0,0 +1,102 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Import Data +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SmallIN100_MeshStats.dream3d" +import_data.data_paths = None +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.SharedFeatureFaceFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + feature_face_ids_array_name=("FeatureFaceId"), + feature_face_labels_array_name=("FaceLabels"), + feature_num_triangles_array_name=("NumTriangles"), + grain_boundary_attribute_matrix_name=("FaceFeatureData"), + randomize_features=False, + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.FindGBCDMetricBasedFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + chosen_limit_dists=2, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + dist_output_file=nxtest.GetDataDirectory() + "/Output/GBPDMetricBased/gbcd_distribution.dat", + err_output_file=nxtest.GetDataDirectory() + "/Output/GBPDMetricBased/gbcd_distribution_errors.dat", + exclude_triple_lines=True, + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AxisEulerAngles"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + misorientation_rotation=[1.0, 1.0, 1.0, 17.9], + node_types_array_path=nx.DataPath("TriangleDataContainer/VertexData/NodeType"), + num_sampl_pts=3000, + phase_of_interest=1, + save_relative_err=True, + surface_mesh_face_areas_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals"), + surface_mesh_feature_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceFeatureData/FaceLabels"), + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.FindGBPDMetricBasedFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + dist_output_file=nxtest.GetDataDirectory() + "/Output/GBPDMetricBased/gbpd_distribution.dat", + err_output_file=nxtest.GetDataDirectory() + "/Output/GBPDMetricBased/gbpd_distribution_errors.dat", + exclude_triple_lines=False, + feature_euler_angles_array_path=nx.DataPath("DataContainer/CellFeatureData/AxisEulerAngles"), + feature_phases_array_path=nx.DataPath("DataContainer/CellFeatureData/Phases"), + limit_dist=7.0, + node_types_array_path=nx.DataPath("TriangleDataContainer/VertexData/NodeType"), + num_sampl_pts=3000, + phase_of_interest=1, + save_relative_err=False, + surface_mesh_face_areas_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceAreas"), + surface_mesh_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceLabels"), + surface_mesh_face_normals_array_path=nx.DataPath("TriangleDataContainer/FaceData/FaceNormals"), + surface_mesh_feature_face_labels_array_path=nx.DataPath("TriangleDataContainer/FaceFeatureData/FaceLabels"), + triangle_geometry_path=nx.DataPath("TriangleDataContainer") +) +nxtest.check_filter_result(nx_filter, result) + + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/GBPDMetricBased/") +# ***************************************************************************** + + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/FindLargestCrossSections.py b/wrapping/python/examples/pipelines/OrientationAnalysis/FindLargestCrossSections.py new file mode 100644 index 0000000000..9ecf66a790 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/FindLargestCrossSections.py @@ -0,0 +1,124 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadH5EbsdFilter() + +h5ebsdParameter = cxor.ReadH5EbsdFileParameter.ValueType() +h5ebsdParameter.euler_representation=0 +h5ebsdParameter.end_slice=117 +h5ebsdParameter.selected_array_names=["Confidence Index", "EulerAngles", "Fit", "Image Quality", "Phases", "SEM Signal", "X Position", "Y Position"] +h5ebsdParameter.input_file_path=nxtest.GetDataDirectory() + "/Output/Reconstruction/Small_IN100.h5ebsd" +h5ebsdParameter.start_slice=1 +h5ebsdParameter.use_recommended_transform=True + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="CellData", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("DataContainer"), + read_h5_ebsd_parameter=h5ebsdParameter +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/CellData/Image Quality") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 120 + +threshold_2 = nx.ArrayThreshold() +threshold_2.array_path = nx.DataPath("DataContainer/CellData/Confidence Index") +threshold_2.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_2.value = 0.1 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1, threshold_2] + +# Execute Filter with Parameters +result = nx.MultiThresholdObjects.execute(data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path = "Mask", + created_mask_type = nx.DataType.boolean, +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("DataContainer/CellData/EulerAngles"), + input_type=0, + output_orientation_array_name="Quats", + output_type=2 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.EBSDSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_name="Active", + cell_feature_attribute_matrix_name="CellFeatureData", + cell_phases_array_path=nx.DataPath("DataContainer/CellData/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + feature_ids_array_name="FeatureIds", + grid_geometry_path=nx.DataPath("DataContainer"), + mask_array_path=nx.DataPath("DataContainer/CellData/Mask"), + misorientation_tolerance=5.0, + quats_array_path=nx.DataPath("DataContainer/CellData/Quats"), + randomize_features=True, + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.FindLargestCrossSectionsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_feature_attribute_matrix_path=nx.DataPath("DataContainer/CellFeatureData"), + feature_ids_array_path=nx.DataPath("DataContainer/CellData/FeatureIds"), + image_geometry_path=nx.DataPath("DataContainer"), + largest_cross_sections_array_path="LargestCrossSections", + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 6 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Define output file path +output_file_path = nxtest.GetDataDirectory() + "/Output/Examples/SmallIN100_LargestCrossSections.dream3d" +# Execute WriteDREAM3DFilter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py new file mode 100644 index 0000000000..2615259088 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py @@ -0,0 +1,87 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("Cell Ensemble Data"), + data_container_name=nx.DataPath("DataContainer"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.RotateEulerRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + rotation_axis=[0.0, 0.0, 1.0, 90.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #created_image_geometry: DataPath = ..., + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix: Any = ..., + rotation_representation=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Define ArrayThreshold object +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/Cell Data/Confidence Index") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.LessThan +threshold_1.value = 0.1 + +# Define ArrayThresholdSet object +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + cell_ipf_colors_array_name=("IPFColors"), + cell_phases_array_path=nx.DataPath("DataContainer/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/Cell Ensemble Data/CrystalStructures"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py new file mode 100644 index 0000000000..199a3e338b --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py @@ -0,0 +1,79 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadCtfDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("CellEnsembleData"), + data_container_name=nx.DataPath("DataContainer"), + degrees_to_radians=True, + edax_hexagonal_alignment=False, + input_file=nxtest.GetDataDirectory() + "/T12-MAI-2010/fw-ar-IF1-aptr12-corr.ctf" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #created_image_geometry=nx.DataPath("DataContainer/"), + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix: List[List[float]] = ..., + rotation_representation=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Define ArrayThreshold object +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/Cell Data/Error") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +# Define ArrayThresholdSet object +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + cell_ipf_colors_array_name=("IPFColors"), + cell_phases_array_path=nx.DataPath("DataContainer/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/Cell Data/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py new file mode 100644 index 0000000000..801244f6c3 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py @@ -0,0 +1,135 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadCtfDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("EBSD Scan Data"), + cell_ensemble_attribute_matrix_name=("Phase Data"), + data_container_name=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2"), + degrees_to_radians=True, + edax_hexagonal_alignment=True, + input_file=nxtest.GetDataDirectory() + "/Textured_Copper/Cugrid_after 2nd_15kv_2kx_2.ctf" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix= + rotation_representation=0, + selected_image_geometry=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + max_voxel=[460, 399, 0], + min_voxel=[0, 0, 0], + remove_original_geometry=True, + renumber_features=False, + selected_image_geometry=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2") + # update_origin=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Error") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +result = nx.MultiThresholdObjects.execute(data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean) + +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/EulerAngles"), + cell_ipf_colors_array_name=("IPF_Exposed_001"), + cell_phases_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Phases"), + crystal_structures_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/CrystalStructures"), + mask_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/TexturedCopper/IPF_Exposed.png", + image_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/IPF_Exposed_001"), + image_geom_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.WritePoleFigureFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/EulerAngles"), + cell_phases_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Phases"), + crystal_structures_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/CrystalStructures"), + generation_algorithm=0, + mask_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Mask"), + image_geometry_path=nx.DataPath("PoleFigure"), + image_layout=2, + image_prefix="Cugrid_after 2nd_15kv_2kx_2_Exposed_", + image_size=1024, + lambert_size=64, + material_name_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/MaterialName"), + num_colors=32, + output_path=nxtest.GetDataDirectory() + "/Output/TexturedCopper", + save_as_image_geometry=True, + title="Cugrid_after 2nd_15kv_2kx_2 Exposed", + use_mask=True, + write_image_to_disk=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/TexturedCopper/") +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py new file mode 100644 index 0000000000..283c8514ae --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py @@ -0,0 +1,135 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadCtfDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("EBSD Scan Data"), + cell_ensemble_attribute_matrix_name=("Phase Data"), + data_container_name=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2"), + degrees_to_radians=True, + edax_hexagonal_alignment=True, + input_file=nxtest.GetDataDirectory() + "/Textured_Copper/Cugrid_after 2nd_15kv_2kx_2.ctf" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180.0], + #rotation_matrix= + rotation_representation=0, + selected_image_geometry=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + max_voxel=[549, 399, 0], + min_voxel=[488, 0, 0], + remove_original_geometry=True, + renumber_features=False, + selected_image_geometry=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Error") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +result = nx.MultiThresholdObjects.execute(data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean) + +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/EulerAngles"), + cell_ipf_colors_array_name=("IPF_Unexposed_001"), + cell_phases_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Phases"), + crystal_structures_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/CrystalStructures"), + mask_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=nxtest.GetDataDirectory() + "/Output/TexturedCopper/IPF_Unexposed.png", + image_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/IPF_Unexposed_001"), + image_geom_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2"), + index_offset=0, + plane=0 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.WritePoleFigureFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/EulerAngles"), + cell_phases_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Phases"), + crystal_structures_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/CrystalStructures"), + generation_algorithm=0, + mask_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/EBSD Scan Data/Mask"), + image_geometry_path=nx.DataPath("PoleFigure"), + image_layout=2, + image_prefix="Cugrid_after 2nd_15kv_2kx_2_Unexposed_", + image_size=1024, + lambert_size=64, + material_name_array_path=nx.DataPath("Cugrid_after 2nd_15kv_2kx_2/Phase Data/MaterialName"), + num_colors=32, + output_path=nxtest.GetDataDirectory() + "/Output/TexturedCopper", + save_as_image_geometry=True, + title="Cugrid_after 2nd_15kv_2kx_2 Unexposed", + use_mask=True, + write_image_to_disk=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/TexturedCopper/") +# ***************************************************************************** + + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py b/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py new file mode 100644 index 0000000000..aa9535c548 --- /dev/null +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py @@ -0,0 +1,69 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 + +import_data = nx.Dream3dImportParameter.ImportData() +import_data.file_path = nxtest.GetDataDirectory() + "/Output/Reconstruction/SmallIN100_Final.dream3d" +import_data.data_paths = None + +# Instantiate Filter +nx_filter = nx.ReadDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + import_file_data=import_data) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.DeleteData() +# Execute Filter +result = nx_filter.execute( + data_structure=data_structure, + removed_data_path=[nx.DataPath("DataContainer/CellEnsembleData/MaterialName"), + nx.DataPath("MergeTwins SeedValue")] +) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.WriteVtkRectilinearGridFilter() +output_file_path = nxtest.GetDataDirectory() + "/Output/Examples/SmallIN100_Final.vtk" +# Execute Filter +result = nx_filter.execute( + data_structure=data_structure, + image_geometry_path=nx.DataPath("DataContainer"), + output_file=output_file_path, + write_binary_file=True, + selected_data_array_paths=[ + nx.DataPath("DataContainer/CellData/Confidence Index"), + nx.DataPath("DataContainer/CellData/EulerAngles"), + nx.DataPath("DataContainer/CellData/FeatureIds"), + nx.DataPath("DataContainer/CellData/Fit"), + nx.DataPath("DataContainer/CellData/IPFColors"), + nx.DataPath("DataContainer/CellData/Image Quality"), + nx.DataPath("DataContainer/CellData/Mask"), + nx.DataPath("DataContainer/CellData/ParentIds"), + nx.DataPath("DataContainer/CellData/Phases"), + nx.DataPath("DataContainer/CellData/Quats"), + nx.DataPath("DataContainer/CellData/SEM Signal"), + nx.DataPath("DataContainer/CellData/X Position"), + nx.DataPath("DataContainer/CellData/Y Position")] +) +nxtest.check_filter_result(nx_filter, result) + + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + +print("===> Pipeline Complete") diff --git a/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometryZSlice.py b/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometryZSlice.py new file mode 100644 index 0000000000..310ac132f1 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometryZSlice.py @@ -0,0 +1,168 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Cell Data", + dimensions=[60, 80, 100], + geometry_data_path=nx.DataPath("[Image Geometry]"), + origin=[100.0, 100.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ConfidenceIndex.csv", + n_comp=1, + n_skip_lines=0, + n_tuples=[[480000.0]], + output_data_array=nx.DataPath("Confidence Index"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/FeatureIds.csv", + n_comp=1, + n_skip_lines=0, + n_tuples=[[480000.0]], + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/FeatureIds"), + scalar_type=nx.NumericType.int32 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ImageQuality.csv", + n_comp=1, + n_skip_lines=0, + n_tuples=[[480000.0]], + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/Image Quality"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) +# Filter 5 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/IPFColor.csv", + n_comp=3, + n_skip_lines=0, + n_tuples=[[480000.0]], + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/IPFColors"), + scalar_type=nx.NumericType.uint8 +) +nxtest.check_filter_result(nx_filter, result) +# Filter 6 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_image_geometry=nx.DataPath("CroppedBottomHalf"), + max_voxel=[59, 79, 50], + min_voxel=[0, 0, 0], + remove_original_geometry=False, + renumber_features=False, + selected_image_geometry=nx.DataPath("[Image Geometry]") + #update_origin=False + # cell_feature_attribute_matrix: DataPath = ..., # Not currently part of the code + # feature_ids: DataPath = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 7 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_image_geometry=nx.DataPath("CroppedTopHalf"), + max_voxel=[59, 79, 99], + min_voxel=[0, 0, 51], + remove_original_geometry=False, + renumber_features=False, + selected_image_geometry=nx.DataPath("[Image Geometry]") + # update_origin=True + # cell_feature_attribute_matrix: DataPath = ..., # Not currently part of the code + # feature_ids: DataPath = ..., # Not currently part of the code +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.AppendImageGeometryZSliceFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + check_resolution=True, + destination_geometry=nx.DataPath("CroppedBottomHalf"), + input_geometry=nx.DataPath("CroppedTopHalf"), + new_geometry=nx.DataPath("AppendedImageGeom"), + save_as_new_geometry=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/Examples/AppendImageGeometryZSlice.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py new file mode 100644 index 0000000000..09be9f1025 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py @@ -0,0 +1,94 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateDataGroup() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + data_object_path=nx.DataPath("Group 1") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CreateDataGroup() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + data_object_path=nx.DataPath("Group 1/Group 2") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CreateGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_handling=0, + cell_attribute_matrix_name="Cell Data", + dimensions=[10, 10 , 2], + #edge_attribute_matrix_name="Edge Data", (not used here) + #edge_list_name: DataPath = ..., (not used here) + #face_attribute_matrix_name="Face Data", (not used here) + geometry_name=nx.DataPath("Group 1/Group 2/[Geometry]"), + geometry_type=0, + #hexahedral_list_name: DataPath = ..., (not used here) + length_unit_type=7, + origin=[0.0, 0.0, 0.0], + #quadrilateral_list_name: DataPath = ..., (not used here) + spacing=[1.0, 1.0, 1.0], + #tetrahedral_list_name: DataPath = ..., (not used here) + #triangle_list_name: DataPath = ..., (not used here) + #vertex_attribute_matrix_name="Vertex Data", (not used here) + #vertex_list_name: DataPath = ..., (not used here) + warnings_as_errors=False + #x_bounds: DataPath = ..., (not used here) + #y_bounds: DataPath = ..., (not used here) + #z_bounds: DataPath = ... (not used here) +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + component_count=1, + data_format="", + initialization_value="2", + numeric_type=nx.NumericType.int32, + output_data_array=nx.DataPath("Group 1/Group 2/[Geometry]/Cell Data/Data"), + tuple_dimensions=[[2.0, 10.0, 10.0]] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Group 1/Group 2/[Geometry]/Cell Data"), + interpolation_type=1, + scale=[2.0, 2.0, 2.0], + selected_image_geometry=nx.DataPath("Group 1/Group 2/[Geometry]"), + transformation_type=5, + translate_geometry_to_global_origin=False +) +nxtest.check_filter_result(nx_filter, result) + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py new file mode 100644 index 0000000000..55dfae5edd --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py @@ -0,0 +1,207 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Small IN100"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Transform [Rotate]"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Transform [Rotate]/Cell Data"), + interpolation_type=1, + rotation=[0.0, 1.0, 0.0, 180.0], + selected_image_geometry=nx.DataPath("Transform [Rotate]"), + transformation_type=3, + translate_geometry_to_global_origin=False + # computed_transformation_matrix: DataPath = ..., # Not used here + # manual_transformation_matrix: List[List[float]] = ..., # Not used here + # scale: List[float] = ..., # Not used here + # translation: List[float] = ... # Not used here +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Transform [Scale]"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Transform [Scale]/Cell Data"), + interpolation_type=1, + scale=[2.0, 2.0, 1.0], # Scale transformation + selected_image_geometry=nx.DataPath("Transform [Scale]"), + transformation_type=5, # Type for scale transformation + translate_geometry_to_global_origin=False + # computed_transformation_matrix: DataPath = ..., + # manual_transformation_matrix: List[List[float]] = ..., + # rotation: List[float] = ..., + # translation: List[float] = ... +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Transform [Translate]"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Transform [Translate]/Cell Data"), + interpolation_type=1, + selected_image_geometry=nx.DataPath("Transform [Translate]"), + transformation_type=4, + translate_geometry_to_global_origin=False, + translation=[50.0, 0.0, 0.0] + # computed_transformation_matrix: DataPath = ..., # Not used here + # manual_transformation_matrix: List[List[float]] = ..., # Not used here + # rotation: List[float] = ..., # Not used here + # scale: List[float] = ... # Not used here +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Transform [Rotation-Interpolation]"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Transform [Rotation-Interpolation]/Cell Data"), + interpolation_type=0, + rotation=[0.0, 0.0, 1.0, 45.0], + selected_image_geometry=nx.DataPath("Transform [Rotation-Interpolation]"), + transformation_type=3, + translate_geometry_to_global_origin=False + # computed_transformation_matrix: DataPath = ..., + # manual_transformation_matrix: List[List[float]] = ..., + # scale: List[float] = ..., + # translation: List[float] = ... +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 10 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name="Cell Data", + cell_ensemble_attribute_matrix_name="CellEnsembleData", + data_container_name=nx.DataPath("Transform [Scale-Interpolation]"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 11 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_path=nx.DataPath("Transform [Scale-Interpolation]/Cell Data"), + interpolation_type=0, + scale=[3.0, 3.0, 1.0], + selected_image_geometry=nx.DataPath("Transform [Scale-Interpolation]"), + transformation_type=5, + translate_geometry_to_global_origin=False + # computed_transformation_matrix: DataPath = ..., + # manual_transformation_matrix: List[List[float]] = ..., + # rotation: List[float] = ..., + # translation: List[float] = ... +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 12 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/Transformation/ApplyTransformation_Image.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py new file mode 100644 index 0000000000..603acb5a12 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py @@ -0,0 +1,140 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + scale_output=False, + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/ASTMD638_specimen.stl", + triangle_geometry_name=nx.DataPath("Blade"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + #scale_factor: float = ..., + scale_output=False, + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/ASTMD638_specimen.stl", + triangle_geometry_name=nx.DataPath("Blade [Rotation]"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #cell_attribute_matrix_path: DataPath = ..., + #computed_transformation_matrix: DataPath = ..., + interpolation_type=2, + #manual_transformation_matrix: List[List[float]] = ..., + rotation=[1.0, 0.0, 0.0, 180], + #scale: List[float] = ..., + selected_image_geometry=nx.DataPath("Blade [Rotation]"), + transformation_type=3, + translate_geometry_to_global_origin=False + #translation: List[float] = ... +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + scale_output=False, + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/ASTMD638_specimen.stl", + triangle_geometry_name=nx.DataPath("Blade [Translation]"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + interpolation_type=2, + selected_image_geometry=nx.DataPath("Blade [Translation]"), + transformation_type=4, + translate_geometry_to_global_origin=False, + translation=[10.0, 10.0, 10.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + scale_output=False, + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/ASTMD638_specimen.stl", + triangle_geometry_name=nx.DataPath("Blade [Scale]"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.ApplyTransformationToGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + interpolation_type=2, + scale=[0.5, 0.5, 1.0], + selected_image_geometry=nx.DataPath("Blade [Scale]"), + transformation_type=5, + translate_geometry_to_global_origin=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output File Path +output_file_path = nxtest.GetDataDirectory() + "/Output/ApplyTransformation_Node.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py b/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py new file mode 100644 index 0000000000..cc84c86fe5 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py @@ -0,0 +1,133 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + component_count=1, + data_format="", + initialization_value="2", + numeric_type=nx.NumericType.int32, + output_data_array=nx.DataPath("TestArray"), + tuple_dimensions=[[10.0]] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + component_count=1, + data_format="", + initialization_value="1.23878", + numeric_type=nx.NumericType.float32, + output_data_array=nx.DataPath("Confidence Index"), + tuple_dimensions=[[10.0]] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + component_count=3, + data_format="", + initialization_value="1.23878", + numeric_type=nx.NumericType.float32, + output_data_array=nx.DataPath("EulerAngles"), + tuple_dimensions=[[10.0]] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ArrayCalculatorFilter() +calc_param = nx.CalculatorParameter.ValueType(nx.DataPath(""), "TestArray+TestArray", nx.CalculatorParameter.AngleUnits.Radians) +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calculated_array=nx.DataPath("Caclulated_TestArray"), + calculator_parameter=calc_param, + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ArrayCalculatorFilter() +calc_param = nx.CalculatorParameter.ValueType(nx.DataPath(""), "Confidence Index*100", nx.CalculatorParameter.AngleUnits.Radians) +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calculated_array=nx.DataPath("Caclulated_ConfidenceIndex"), + calculator_parameter=calc_param, + scalar_type=nx.NumericType.float64 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 6 +# Instantiate Filter +nx_filter = nx.ArrayCalculatorFilter() +calc_param = nx.CalculatorParameter.ValueType(nx.DataPath(""), "EulerAngles/2", nx.CalculatorParameter.AngleUnits.Radians) +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calculated_array=nx.DataPath("Caclulated_EulerAngles"), + calculator_parameter=calc_param, + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.ArrayCalculatorFilter() +calc_param = nx.CalculatorParameter.ValueType(nx.DataPath(""), "EulerAngles[0]+EulerAngles[1]", nx.CalculatorParameter.AngleUnits.Radians) +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + calculated_array=nx.DataPath("Caclulated_EulerAngles2"), + calculator_parameter=calc_param, + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Define output file path +output_file_path = nxtest.GetDataDirectory() + "//Output/ArrayCalculatorExampleResults.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py b/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py new file mode 100644 index 0000000000..89caa5d922 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py @@ -0,0 +1,43 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CombineStlFilesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix_name="Face Data", + face_normals_array_name="Face Normals", + stl_files_path=nxtest.GetDataDirectory() + "/STL_Models", + triangle_data_container_name=nx.DataPath("TriangleGeometry"), + vertex_attribute_matrix_name="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +output_file_path = nxtest.GetDataDirectory() + "/Output/CombinedStlFiles.dream3d" +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py b/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py new file mode 100644 index 0000000000..db93ae6269 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py @@ -0,0 +1,123 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name=("Cell Data"), + dimensions=[100, 100, 2], + geometry_data_path=nx.DataPath("[Image Geometry]"), + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.ReadRawBinaryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_attribute_array_path=nx.DataPath("[Image Geometry]/Cell Data/Quats"), + endian=0, + input_file=nxtest.GetDataDirectory() + "/OrientationAnalysis/quats.raw", + number_of_components=4, + scalar_type=nx.NumericType.float32, + skip_header_bytes=0, + tuple_dimensions=[[2.0, 100.0, 100.0]] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = cxor.ConvertOrientations() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + input_orientation_array_path=nx.DataPath("[Image Geometry]/Cell Data/Quats"), + input_type=2, + output_orientation_array_name="Eulers", + output_type=0 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + component_count=1, + data_format="", + initialization_value="1", + numeric_type=nx.NumericType.int32, + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/Phases"), + tuple_dimensions=[[2.0, 100.0, 100.0]] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = cxor.ReadEnsembleInfoFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_ensemble_attribute_matrix_name=("Cell Ensemble"), + crystal_structures_array_name=("CrystalStructures"), + data_container_name=nx.DataPath("[Image Geometry]"), + input_file=nxtest.GetDataDirectory() + "/OrientationAnalysis/Ensemble.ini", + phase_types_array_name=("PhaseTypes") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("[Image Geometry]/Cell Data/Eulers"), + cell_ipf_colors_array_name=("IPFColors"), + cell_phases_array_path=nx.DataPath("[Image Geometry]/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("[Image Geometry]/Cell Ensemble/CrystalStructures"), + #mask_array_path=nx.DataPath(), + reference_dir=[0.0, 0.0, 1.0], + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Set Output file path +output_file_path = nxtest.GetDataDirectory() + "/Output/Examples/EnsembleInfoReaderExample.dream3d" +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py b/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py new file mode 100644 index 0000000000..8ae9c25ff1 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py @@ -0,0 +1,159 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_handling=0, + cell_attribute_matrix_name="Cell Data", + dimensions=[60, 80, 100], + #edge_attribute_matrix_name: str = ..., + #edge_list_name: DataPath = ..., + #face_attribute_matrix_name: str = ..., + geometry_name=nx.DataPath("[Image Geometry]"), + geometry_type=0, + #hexahedral_list_name: DataPath = ..., + length_unit_type=7, + origin=[0, 0, 0], + #quadrilateral_list_name: DataPath = ..., + spacing=[1, 1, 1], + #tetrahedral_list_name: DataPath = ..., + #triangle_list_name: DataPath = ..., + #vertex_attribute_matrix_name: str = ..., + #vertex_list_name: DataPath = ..., + warnings_as_errors=False, + #x_bounds: DataPath = ..., + #y_bounds: DataPath = ..., + #z_bounds: DataPath = ... +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 + +# Define ReadCSVData parameters +read_csv_data = nx.ReadCSVDataParameter() +read_csv_data.input_file_path = nxtest.GetDataDirectory() + "/ASCIIData/EulersRotated.csv" +read_csv_data.start_import_row = 1 +read_csv_data.delimiters = [','] +read_csv_data.custom_headers = ['phi1', 'Phi', 'phi2'] +read_csv_data.column_data_types = [nx.DataType.float32, nx.DataType.float32, nx.DataType.float32] +read_csv_data.skipped_array_mask = [False, False, False] +read_csv_data.tuple_dims = [480_001] +read_csv_data.headers_line = 1 +read_csv_data.header_mode = nx.ReadCSVDataParameter.HeaderMode.Custom + +# Instantiate Filter +nx_filter = nx.ReadCSVFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_data_group=nx.DataPath("Imported Data"), + read_csv_data=read_csv_data, + selected_data_group=nx.DataPath("[Image Geometry]/Cell Data"), + use_existing_group=True, +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + component_count=1, + data_format="", + initialization_value="1", + numeric_type=nx.NumericType.int32, + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/Phase") + #tuple_dimensions=[] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.CombineAttributeArraysFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + move_values=True, + normalize_data=False, + selected_data_array_paths=[nx.DataPath("[Image Geometry]/Cell Data/phi1"), + nx.DataPath("[Image Geometry]/Cell Data/Phi"), + nx.DataPath("[Image Geometry]/Cell Data/phi2")], + stacked_data_array_name="Eulers" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Define ensemble info parameters + +ensemble_info_parameter = [] +ensemble_info_parameter.append(["Hexagonal-High 6/mmm", "Primary", "Phase 1"]) +ensemble_info_parameter.append(["Cubic-High m-3m", "Primary", "Phase 2"]) + +# Instantiate Filter +nx_filter = cxor.CreateEnsembleInfoFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_ensemble_attribute_matrix_name=nx.DataPath("[Image Geometry]/CellEnsembleData"), + crystal_structures_array_name="CrystalStructures", + phase_names_array_name="PhaseNames", + phase_types_array_name="PhaseTypes", + ensemble=ensemble_info_parameter + ) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("[Image Geometry]/Cell Data/Eulers"), + cell_ipf_colors_array_name="IPFColors", + cell_phases_array_path=nx.DataPath("[Image Geometry]/Cell Data/Phase"), + crystal_structures_array_path=nx.DataPath("[Image Geometry]/CellEnsembleData/CrystalStructures"), + #mask_array_path: DataPath = ..., + reference_dir=[0.0, 0.0, 1.0], + use_mask=False + ) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 7 +# Instantiate Filter +nx_filter = cxitk.ITKImageWriter() +# Output file path for Filter 7 +output_file_path = nxtest.GetDataDirectory() + "/Output/Import_ASCII/IPF.png" + +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + file_name=output_file_path, + image_array_path=nx.DataPath("[Image Geometry]/Cell Data/IPFColors"), + image_geom_path=nx.DataPath("[Image Geometry]"), + index_offset=0, + plane=0 + ) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_dir(nxtest.GetDataDirectory() + "/Output/Import_ASCII/") +# ***************************************************************************** + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_CSV_Data.py b/wrapping/python/examples/pipelines/Simplnx/Import_CSV_Data.py new file mode 100644 index 0000000000..2149768bc6 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/Import_CSV_Data.py @@ -0,0 +1,98 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.CreateImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Cell Data", + dimensions=[60, 80, 100], + geometry_data_path=nx.DataPath("[Image Geometry]"), + origin=[100.0, 100.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ConfidenceIndex.csv", + n_comp=1, + n_skip_lines=0, + #n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/Confidence Index"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/FeatureIds.csv", + n_comp=1, + n_skip_lines=0, + #n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/FeatureIds"), + scalar_type=nx.NumericType.int32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ImageQuality.csv", + n_comp=1, + n_skip_lines=0, + #n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/Image Quality"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/IPFColor.csv", + n_comp=3, + n_skip_lines=0, + #n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("[Image Geometry]/Cell Data/IPFColors"), + scalar_type=nx.NumericType.uint8 +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py b/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py new file mode 100644 index 0000000000..c73a5695c8 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py @@ -0,0 +1,54 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + #scale_factor: float = ..., + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/Cylinder.stl", + triangle_geometry_name=nx.DataPath("[Triangle Geometry]"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CalculateTriangleAreasFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + triangle_areas_array_path="Areas", + triangle_geometry_data_path=nx.DataPath("[Triangle Geometry]") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.CreateDataArray() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=True, + component_count=1, + data_format="", + initialization_value="0", + numeric_type=nx.NumericType.float32, + output_data_array=nx.DataPath("Node Type"), + tuple_dimensions=[[1.0]] +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py b/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py new file mode 100644 index 0000000000..bf8d20db78 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py @@ -0,0 +1,161 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = cxor.ReadAngDataFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_attribute_matrix_name=("Cell Data"), + cell_ensemble_attribute_matrix_name=("CellEnsembleData"), + data_container_name=nx.DataPath("DataContainer"), + input_file=nxtest.GetDataDirectory() + "/Small_IN100/Slice_1.ang" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate ArrayThreshold objects +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("DataContainer/Cell Data/Confidence Index") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_1.value = 0.1 + +threshold_2 = nx.ArrayThreshold() +threshold_2.array_path = nx.DataPath("DataContainer/Cell Data/Image Quality") +threshold_2.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold_2.value = 120 + +# Define ArrayThresholdSet object +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1, threshold_2] +dt = nx.DataType.boolean + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = nx.RotateSampleRefFrameFilter() +# Execute Filter +result = nx_filter.execute( + data_structure=data_structure, + remove_original_geometry=True, + rotate_slice_by_slice=False, + rotation_axis=[0.0, 1.0, 0.0, 180], + rotation_representation=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = cxor.RotateEulerRefFrameFilter() +# Execute Filter +result = nx_filter.execute( + data_structure=data_structure, + euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + rotation_axis=[0.0, 0.0, 1.0, 90.0] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Instantiate Filter +nx_filter = nx.SetImageGeomOriginScalingFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + change_origin=True, + change_resolution=True, + image_geom=nx.DataPath("DataContainer"), + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.CropImageGeometry() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #cell_feature_attribute_matrix: DataPath = ..., + #created_image_geometry: DataPath = ..., + #feature_ids: DataPath = ..., + max_voxel=[160, 175, 0], + min_voxel=[25, 25, 0], + remove_original_geometry=True, + renumber_features=False, + selected_image_geometry=nx.DataPath("DataContainer") + # update_origin=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 7 +# Instantiate Filter +nx_filter = cxor.GenerateIPFColorsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_euler_angles_array_path=nx.DataPath("DataContainer/Cell Data/EulerAngles"), + cell_ipf_colors_array_name=("IPFColors"), + cell_phases_array_path=nx.DataPath("DataContainer/Cell Data/Phases"), + crystal_structures_array_path=nx.DataPath("DataContainer/CellEnsembleData/CrystalStructures"), + mask_array_path=nx.DataPath("DataContainer/Cell Data/Mask"), + reference_dir=[0.0, 0.0, 1.0], + use_mask=True +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.ReplaceElementAttributesWithNeighborValuesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + comparison_data_path=nx.DataPath("DataContainer/Cell Data/Confidence Index"), + loop=True, + min_confidence=0.1, + selected_comparison=0, + selected_image_geometry=nx.DataPath("DataContainer") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 9 +output_file_path = nxtest.GetDataDirectory() + "/Output/Examples/ReplaceElementAttributesWithNeighbor.dream3d" +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True +) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py b/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py new file mode 100644 index 0000000000..858b414fe5 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py @@ -0,0 +1,121 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +#Filter 1 + +generated_file_list_value = nx.GeneratedFileListParameter.ValueType() +generated_file_list_value.input_path = nxtest.GetDataDirectory() + "/Porosity_Image" +generated_file_list_value.ordering = nx.GeneratedFileListParameter.Ordering.LowToHigh + +generated_file_list_value.file_prefix = "slice_" +generated_file_list_value.file_suffix = "" +generated_file_list_value.file_extension = ".tif" +generated_file_list_value.start_index = 11 +generated_file_list_value.end_index = 174 +generated_file_list_value.increment_index = 1 +generated_file_list_value.padding_digits = 2 + +# Instantiate Filter +nx_filter = cxitk.ITKImportImageStack() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Cell Data", + image_data_array_path="ImageData", + image_geometry_path=nx.DataPath("Porosity_Image"), + image_transform_choice=0, + input_file_list_info=generated_file_list_value, + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 2 +# Instantiate Filter +nx_filter = nx.ResampleImageGeomFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #cell_feature_attribute_matrix_path: DataPath = ..., + #exact_dimensions: List[int] = ..., + #feature_ids_path: DataPath = ..., + new_data_container_path=nx.DataPath("Porosity_Image_Resampled_Spacing"), + remove_original_geometry=False, + renumber_features=False, + resampling_mode=0, + #scaling: List[float] = ..., + selected_image_geometry=nx.DataPath("Porosity_Image"), + spacing=[2.0, 2.0, 2.0] +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ResampleImageGeomFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #cell_feature_attribute_matrix_path: DataPath = ..., + #exact_dimensions: List[int] = ..., + #feature_ids_path: DataPath = ..., + new_data_container_path=nx.DataPath("Porosity_Image_Resampled_Scaled"), + remove_original_geometry=False, + renumber_features=False, + resampling_mode=1, + scaling=[0.5, 0.5, 0.5], + selected_image_geometry=nx.DataPath("Porosity_Image") + #spacing: List[float] = ... +) +# Error/Result Handling for Filter +nxtest.check_filter_result(nx_filter, result) + + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ResampleImageGeomFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + #cell_feature_attribute_matrix_path: DataPath = ..., + exact_dimensions=[262, 195, 82], + #feature_ids_path: DataPath = ..., + new_data_container_path=nx.DataPath("Porosity_Image_Resampled_Exact_Dims"), + remove_original_geometry=False, + renumber_features=False, + resampling_mode=2, + #scaling: List[float] = ..., + selected_image_geometry=nx.DataPath("Porosity_Image") + #spacing: List[float] = ... +) +# Error/Result Handling for Filter +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Define output file path +output_file_path = nxtest.GetDataDirectory() + "/Output/ResamplePorosityImage.dream3d" +# Execute WriteDREAM3DFilter with Parameters +result = nx.WriteDREAM3DFilter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py b/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py new file mode 100644 index 0000000000..f23aed1f8e --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py @@ -0,0 +1,220 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 + +# Define ReadCSVData parameters + +read_csv_data = nx.ReadCSVDataParameter() +read_csv_data.input_file_path = nxtest.GetDataDirectory() + "/ASCIIData/RectilinearGrid.csv" +read_csv_data.start_import_row = 2 +read_csv_data.delimiters = [','] +read_csv_data.custom_headers = ['x', 'y', 'z'] +read_csv_data.column_data_types = [nx.DataType.float32, nx.DataType.float32, nx.DataType.float32] +read_csv_data.skipped_array_mask = [False, False, False] +read_csv_data.tuple_dims = [14] +read_csv_data.headers_line = 1 +read_csv_data.header_mode = nx.ReadCSVDataParameter.HeaderMode.Custom + +# Instantiate Filter +nx_filter = nx.ReadCSVFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + created_data_group=nx.DataPath("Bounds"), + read_csv_data=read_csv_data, + # selected_data_group: DataPath = ..., + use_existing_group=False, +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CreateGeometryFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_handling=1, + cell_attribute_matrix_name="CellData", + # dimensions: List[int] = ..., + # edge_attribute_matrix_name: str = ..., + # edge_list_name: DataPath = ..., + # face_attribute_matrix_name: str = ..., + geometry_name=nx.DataPath("RectGridGeometry"), + geometry_type=1, + # hexahedral_list_name: DataPath = ..., + length_unit_type=7, + # origin: List[float] = ..., + # quadrilateral_list_name: DataPath = ..., + # spacing: List[float] = ..., + # tetrahedral_list_name: DataPath = ..., + # triangle_list_name: DataPath = ..., + # vertex_attribute_matrix_name: str = ..., + # vertex_list_name: DataPath = ..., + warnings_as_errors=False, + x_bounds=nx.DataPath("Bounds/x"), + y_bounds=nx.DataPath("Bounds/y"), + z_bounds=nx.DataPath("Bounds/z") +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ConfidenceIndex.csv", + n_comp=1, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/ConfidenceIndex"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/ImageQuality.csv", + n_comp=1, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/ImageQuality"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 5 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/SEM Signal.csv", + n_comp=1, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/SEM Signal"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 6 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/Fit.csv", + n_comp=1, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/Fit"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 7 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/EulerAngles.csv", + n_comp=3, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/EulerAngles"), + scalar_type=nx.NumericType.float32 +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 8 +# Instantiate Filter +nx_filter = nx.ReadTextDataArrayFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + advanced_options=False, + data_format="", + delimiter_choice=0, + input_file=nxtest.GetDataDirectory() + "/ASCIIData/Phases.csv", + n_comp=1, + n_skip_lines=0, + # n_tuples: List[List[float]] = ..., + output_data_array=nx.DataPath("RectGridGeometry/CellData/Phases"), + scalar_type=nx.NumericType.int32 +) +nxtest.check_filter_result(nx_filter, result) + + +# Filter 9 +# Instantiate Filter +nx_filter = nx.ResampleRectGridToImageGeomFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + dimensions=[20, 20, 20], + image_geom_cell_attribute_matrix="CellData", + image_geometry_path=nx.DataPath("Image Geometry"), + rectilinear_grid_path=nx.DataPath("RectGridGeometry"), + selected_data_array_paths=[nx.DataPath("RectGridGeometry/CellData/ConfidenceIndex"), + nx.DataPath("RectGridGeometry/CellData/EulerAngles"), + nx.DataPath("RectGridGeometry/CellData/Fit"), + nx.DataPath("RectGridGeometry/CellData/ImageQuality"), + nx.DataPath("RectGridGeometry/CellData/Phases"), + nx.DataPath("RectGridGeometry/CellData/SEM Signal")] +) +nxtest.check_filter_result(nx_filter, result) + + +# Instantiate Filter +nx_filter = nx.WriteDREAM3DFilter() +# Execute Filter with Parameters +output_file_path = nxtest.GetDataDirectory() + "/Examples/ResampleRectGridToImageGeom.dream3d" +result = nx_filter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) + +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py b/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py new file mode 100644 index 0000000000..9a36a91e80 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py @@ -0,0 +1,119 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 + +generated_file_list_value = nx.GeneratedFileListParameter.ValueType() +generated_file_list_value.input_path = nxtest.GetDataDirectory() + "/Porosity_Image" +generated_file_list_value.ordering = nx.GeneratedFileListParameter.Ordering.LowToHigh + +generated_file_list_value.file_prefix = "slice_" +generated_file_list_value.file_suffix = "" +generated_file_list_value.file_extension = ".tif" +generated_file_list_value.start_index = 11 +generated_file_list_value.end_index = 174 +generated_file_list_value.increment_index = 1 +generated_file_list_value.padding_digits = 2 + +# Instantiate Filter +nx_filter = cxitk.ITKImportImageStack() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + cell_data_name="Optical Data", + image_data_array_path="Image Data", + image_geometry_path=nx.DataPath("RoboMet.3D Image Stack"), + image_transform_choice=0, + input_file_list_info=generated_file_list_value, + origin=[0.0, 0.0, 0.0], + spacing=[1.0, 1.0, 1.0] +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate ArrayThreshold objects +threshold_1 = nx.ArrayThreshold() +threshold_1.array_path = nx.DataPath("RoboMet.3D Image Stack/Optical Data/Image Data") +threshold_1.comparison = nx.ArrayThreshold.ComparisonType.Equal +threshold_1.value = 0.0 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold_1] +dt = nx.DataType.boolean + +# Instantiate Filter +nx_filter = nx.MultiThresholdObjects() +# Execute filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + array_thresholds=threshold_set, + created_data_path="Mask", + created_mask_type=nx.DataType.boolean +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.ScalarSegmentFeaturesFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + active_array_path="Active", + cell_feature_group_path="Pore Data", + feature_ids_path="FeatureIds", + grid_geometry_path=nx.DataPath("RoboMet.3D Image Stack"), + input_array_path=nx.DataPath("RoboMet.3D Image Stack/Optical Data/Image Data"), + mask_path=nx.DataPath("RoboMet.3D Image Stack/Optical Data/Mask"), + randomize_features=False, + scalar_tolerance=0, + use_mask=False +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.SurfaceNetsFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + apply_smoothing=True, + face_data_group_name="Face Data", + face_feature_attribute_matrix_name="Face Feature Data", + face_labels_array_name="FaceLabels", + feature_ids_path=nx.DataPath("RoboMet.3D Image Stack/Optical Data/FeatureIds"), + grid_geometry_data_path=nx.DataPath("RoboMet.3D Image Stack"), + max_distance_from_voxel=1.0, + node_types_array_name="NodeTypes", + relaxation_factor=0.5, + #selected_data_array_paths: List[DataPath] = ..., + smoothing_iterations=20, + triangle_geometry_name=nx.DataPath("TriangleDataContainer"), + vertex_data_group_name="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +output_file_path = nxtest.GetDataDirectory() + "/Output/SurfaceMesh/SurfaceNets_Demo.dream3d" +result = nx.WriteDREAM3DFilter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) + +nxtest.check_filter_result(nx_filter, result) + +# ***************************************************************************** +# THIS SECTION IS ONLY HERE FOR CLEANING UP THE CI Machines +# If you are using this code, you should COMMENT out the next line +nxtest.cleanup_test_file(output_file_path) +# ***************************************************************************** + + + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py b/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py new file mode 100644 index 0000000000..1d96f5bf37 --- /dev/null +++ b/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py @@ -0,0 +1,72 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +#Create a Data Structure +data_structure = nx.DataStructure() + +# Filter 1 +# Instantiate Filter +nx_filter = nx.ReadStlFileFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + face_attribute_matrix="Face Data", + face_normals_data_path="Face Normals", + scale_factor=1.0, + scale_output=False, + stl_file_path=nxtest.GetDataDirectory() + "/STL_Models/ASTMD638_specimen.stl", + triangle_geometry_name=nx.DataPath("[Triangle Geometry]"), + vertex_attribute_matrix="Vertex Data" +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 2 +# Instantiate Filter +nx_filter = nx.CalculateTriangleAreasFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + triangle_areas_array_path="Face Areas", + triangle_geometry_data_path=nx.DataPath("[Triangle Geometry]") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 3 +# Instantiate Filter +nx_filter = nx.TriangleNormalFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + surface_mesh_triangle_normals_array_path="Face Normals (Calculated)", + tri_geometry_data_path=nx.DataPath("[Triangle Geometry]") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 4 +# Instantiate Filter +nx_filter = nx.TriangleDihedralAngleFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + surface_mesh_triangle_dihedral_angles_array_name="Dihedral Angles", + tri_geometry_data_path=nx.DataPath("[Triangle Geometry]") +) +nxtest.check_filter_result(nx_filter, result) + +# Filter 5 +# Instantiate Filter +nx_filter = nx.TriangleCentroidFilter() +# Execute Filter with Parameters +result = nx_filter.execute( + data_structure=data_structure, + centroids_array_name="Centroids", + triangle_geometry_path=nx.DataPath("[Triangle Geometry]") +) +nxtest.check_filter_result(nx_filter, result) + +print("===> Pipeline Complete") \ No newline at end of file diff --git a/wrapping/python/examples/pipelines/SourceList.cmake b/wrapping/python/examples/pipelines/SourceList.cmake new file mode 100644 index 0000000000..d11139a299 --- /dev/null +++ b/wrapping/python/examples/pipelines/SourceList.cmake @@ -0,0 +1,86 @@ + + +set(ItkDirPrefix "${simplnx_SOURCE_DIR}/wrapping/python/examples/pipelines/ITKImageProcessing") +set(OrientationDirPrefix "${simplnx_SOURCE_DIR}/wrapping/python/examples/pipelines/OrientationAnalysis") +set(SimplnxDirPrefix "${simplnx_SOURCE_DIR}/wrapping/python/examples/pipelines/Simplnx") + +AddPythonTest(NAME "PY::ITKImageProcessing::02_Image_Segmentation" FILE "${ItkDirPrefix}/02_Image_Segmentation.py" PYTHONPATH "$") +AddPythonTest(NAME "PY::ITKImageProcessing::03_Porosity_Mesh_Export" FILE "${ItkDirPrefix}/03_Porosity_Mesh_Export.py" PYTHONPATH "$") + +#------------------------------------------------------------------------------ +# These pipelines do not have any outside file dependencies other than what is +# already decompressed at this point on the CI or local machine. Each test will +# clean up its output file(s) +#------------------------------------------------------------------------------ +set(SIMPLNX_PYTHON_TESTS + AppendImageGeometryZSlice + ApplyTransformation_Demo + ApplyTransformation_Image + ApplyTransformation_Node + ArrayCalculatorExample + CombineSTLFiles + EnsembleInfoReader + Import_ASCII + Import_CSV_Data + Import_STL_Model + ReplaceElementAttributesWithNeighbor + ResamplePorosityImage + ResampleRectGridToImageGeom + SurfaceNets_Demo + Triangle_Face_Data_Demo +) + +foreach(test ${SIMPLNX_PYTHON_TESTS}) + AddPythonTest(NAME "PY::Simplnx::${test}" FILE "${SimplnxDirPrefix}/${test}.py" PYTHONPATH "$") +endforeach(test ${}) + +set(SIMPLNX_PYTHON_TESTS + APTR12_Analysis + AVTR12_Analysis + CI_Histogram + Edax_IPF_Colors + ReadAng + ReadCTF + TxCopper_Exposed + TxCopper_Unexposed +) +foreach(test ${SIMPLNX_PYTHON_TESTS}) + AddPythonTest(NAME "PY::OrientationAnalysis::${test}" FILE "${OrientationDirPrefix}/${test}.py" PYTHONPATH "$") +endforeach(test ${}) + + +#------------------------------------------------------------------------------ +# Add the examples/pipelines/OrientationAnalysis folder +#------------------------------------------------------------------------------ +set(PYTHON_TEST_INPUT_DIR "${simplnx_SOURCE_DIR}/wrapping/python/examples/pipelines/OrientationAnalysis") + +set(SIMPLNX_PYTHON_TESTS + 01_Small_IN100_Archive + + AlignSectionsMutualInformation # Depends 01_Small_IN100_Archive + FindLargestCrossSections # Depends 01_Small_IN100_Archive + 08_Small_IN100_Full_Reconstruction # Depends 01_Small_IN100_Archive + + FindBoundaryCells # Depends on 08_Small_IN100_Full_Reconstruction + AvizoWriters # Depends on 08_Small_IN100_Full_Reconstruction + VtkRectilinearGridWriter # Depends on 08_Small_IN100_Full_Reconstruction + 01_Small_IN100_Morphological_Statistics # Depends on 08_Small_IN100_Full_Reconstruction Will delete both input and output file + + 05_Small_IN100_Crystallographic_Statistics + + FindBiasedFeatures # Depends 05_Small_IN100_Crystallographic_Statistics + 01_Small_IN100_Quick_Mesh + 02_Small_IN100_Smooth_Mesh + 03_Small_IN100_Mesh_Statistics + + FindGBCD-GBPDMetricBased # Depends 03_Small_IN100_Mesh_Statistics + 04_Small_IN100_GBCD # Depends 03_Small_IN100_Mesh_Statistics + 05_Small_IN100_GBCD_Metric # Depends 03_Small_IN100_Mesh_Statistics Will delete both input and output file +) + +CreatePythonTests( + PREFIX "PY::OrientationAnalysis" + INPUT_DIR ${PYTHON_TEST_INPUT_DIR} + TEST_NAMES ${SIMPLNX_PYTHON_TESTS} +) + diff --git a/wrapping/python/examples/scripts/Combine_STL_Files.py b/wrapping/python/examples/scripts/Combine_STL_Files.py new file mode 100644 index 0000000000..62cbfa520d --- /dev/null +++ b/wrapping/python/examples/scripts/Combine_STL_Files.py @@ -0,0 +1,43 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# ------------------------------------------------------------------------------ +# Create a DataArray that is as long as my CSV file (99 Rows in this case) +# ------------------------------------------------------------------------------ +# Create a Data Structure +data_structure = cx.DataStructure() + + +result = cx.CombineStlFilesFilter.execute(data_structure=data_structure , + face_attribute_matrix_name="Face Data" , + face_normals_array_name="FaceNormals" , + stl_files_path="/Users/alexjackson/DREAM3DNXData/Data/STL_Models" , + triangle_data_container_name=cx.DataPath(["TriangleGeometry"]), + vertex_attribute_matrix_name= "Vertex Data") + +if len(result.errors) != 0: + print('Errors: {}', result.errors) + print('Warnings: {}', result.warnings) +else: + print("No errors running CombinesFilesFilter filter") + + + + +output_file_path = nxtest.GetDataDirectory() + "/Output/CombinedStlFiles.dream3d" +result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +if len(result.errors) != 0: + print('Errors: {}', result.errors) + print('Warnings: {}', result.warnings) +else: + print("No errors running the filter") + + + \ No newline at end of file diff --git a/wrapping/python/examples/scripts/Import_STL_File.py b/wrapping/python/examples/scripts/Import_STL_File.py new file mode 100644 index 0000000000..57cb677abc --- /dev/null +++ b/wrapping/python/examples/scripts/Import_STL_File.py @@ -0,0 +1,37 @@ +import simplnx as nx + +import itkimageprocessing as cxitk +import orientationanalysis as cxor +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = cx.DataStructure() + +result = cx.ReadStlFileFilter.execute(data_structure=data_structure, + face_attribute_matrix="Face Data" , + face_normals_data_path="Face Normals", + scale_factor=1, + scale_output=False , + stl_file_path="Data/STL_Models/Cylinder.stl" , + triangle_geometry_name=cx.DataPath(["[Triangle Geomtry]"]) , + vertex_attribute_matrix="Vertex Data") + +if len(result.errors) != 0: + print('Errors: {}', result.errors) + print('Warnings: {}', result.warnings) +else: + print("No errors running ImportSTLFile filter") + + + +output_file_path = nxtest.GetDataDirectory() + "/Output/ImportSTLFile.dream3d" +result = cx.WriteDREAM3DFilter.execute(data_structure=data_structure, + export_file_path=output_file_path, + write_xdmf_file=True) +if len(result.errors) != 0: + print('Errors: {}', result.errors) + print('Warnings: {}', result.warnings) +else: + print("No errors running the filter") diff --git a/wrapping/python/examples/scripts/SourceList.cmake b/wrapping/python/examples/scripts/SourceList.cmake new file mode 100644 index 0000000000..bfb728ff8e --- /dev/null +++ b/wrapping/python/examples/scripts/SourceList.cmake @@ -0,0 +1,25 @@ + +set(PYTHON_TEST_INPUT_DIR "${simplnx_SOURCE_DIR}/wrapping/python/examples/scripts") + +set(SIMPLNX_PYTHON_TESTS + "angle_conversion" + "basic_arrays" + "basic_ebsd_ipf" + "basic_numpy" + "create_ensemble_info" + "generated_file_list" + "geometry_examples" + "import_d3d" # Dependent on 'basic_ebsd_ipf' running first + "import_hdf5" # Dependent on 'basic_ebsd_ipf' running first + "output_file" + "pipeline" + "read_csv_file" +# "read_esprit_data" +) + +CreatePythonTests(PREFIX "PY_SIMPLNX" + INPUT_DIR ${PYTHON_TEST_INPUT_DIR} + TEST_NAMES ${SIMPLNX_PYTHON_TESTS} +) + + diff --git a/wrapping/python/examples/angle_conversion.py b/wrapping/python/examples/scripts/angle_conversion.py similarity index 97% rename from wrapping/python/examples/angle_conversion.py rename to wrapping/python/examples/scripts/angle_conversion.py index f0267529f1..93c6172152 100644 --- a/wrapping/python/examples/angle_conversion.py +++ b/wrapping/python/examples/scripts/angle_conversion.py @@ -73,7 +73,7 @@ npdata = data_store.npview() # Read the CSV file into the DataArray using the numpy view -file_path = nxtest.GetSimplnxPythonSourceDir() + '/examples/angles.csv' +file_path = nxtest.GetSimplnxPythonSourceDir() + '/examples/data/angles.csv' npdata[:] = np.loadtxt(file_path, delimiter=',') # ------------------------------------------------------------------------------ @@ -94,3 +94,4 @@ npdata = data_store.npview() print(npdata) + diff --git a/wrapping/python/examples/basic_arrays.py b/wrapping/python/examples/scripts/basic_arrays.py similarity index 95% rename from wrapping/python/examples/basic_arrays.py rename to wrapping/python/examples/scripts/basic_arrays.py index 54bba9096f..0527e362b4 100644 --- a/wrapping/python/examples/basic_arrays.py +++ b/wrapping/python/examples/scripts/basic_arrays.py @@ -71,8 +71,8 @@ output_array_path = nx.DataPath(["Group", "1D Array"]) array_type = nx.NumericType.float32 tuple_dims = [[10]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", @@ -94,8 +94,8 @@ # Example, and Image where 5 wide x 2 High output_array_path = nx.DataPath(["2D Array"]) tuple_dims = [[2,5]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", @@ -123,8 +123,8 @@ # Example, and Image where 5 wide x 2 High output_array_path = nx.DataPath(["3D Array"]) tuple_dims = [[3, 2, 5]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", @@ -177,3 +177,4 @@ print(children_paths) print(f'data_structure.size: {data_structure.size}') + diff --git a/wrapping/python/examples/basic_ebsd_ipf.py b/wrapping/python/examples/scripts/basic_ebsd_ipf.py similarity index 99% rename from wrapping/python/examples/basic_ebsd_ipf.py rename to wrapping/python/examples/scripts/basic_ebsd_ipf.py index eca12cba88..8b39dfa4cb 100644 --- a/wrapping/python/examples/basic_ebsd_ipf.py +++ b/wrapping/python/examples/scripts/basic_ebsd_ipf.py @@ -199,3 +199,4 @@ export_file_path=output_file_path, write_xdmf_file=True) nxtest.check_filter_result(nx.WriteDREAM3DFilter, result) + diff --git a/wrapping/python/examples/basic_numpy.py b/wrapping/python/examples/scripts/basic_numpy.py similarity index 99% rename from wrapping/python/examples/basic_numpy.py rename to wrapping/python/examples/scripts/basic_numpy.py index 09f8014a4a..89c6fb9537 100644 --- a/wrapping/python/examples/basic_numpy.py +++ b/wrapping/python/examples/scripts/basic_numpy.py @@ -85,3 +85,4 @@ print(npdata) print('numpy:') print(radians_data) + diff --git a/wrapping/python/examples/create_ensemble_info.py b/wrapping/python/examples/scripts/create_ensemble_info.py similarity index 99% rename from wrapping/python/examples/create_ensemble_info.py rename to wrapping/python/examples/scripts/create_ensemble_info.py index 1bd25c1157..63183a5904 100644 --- a/wrapping/python/examples/create_ensemble_info.py +++ b/wrapping/python/examples/scripts/create_ensemble_info.py @@ -64,3 +64,4 @@ ensemble=ensemble_info_parameter ) nxtest.check_filter_result(nxor.CreateEnsembleInfoFilter, result) + diff --git a/wrapping/python/examples/generated_file_list.py b/wrapping/python/examples/scripts/generated_file_list.py similarity index 99% rename from wrapping/python/examples/generated_file_list.py rename to wrapping/python/examples/scripts/generated_file_list.py index 9bb7aad0f8..7d42bf44d1 100644 --- a/wrapping/python/examples/generated_file_list.py +++ b/wrapping/python/examples/scripts/generated_file_list.py @@ -74,3 +74,4 @@ origin=[0., 0., 0.], spacing=[1., 1.,1.]) nxtest.check_filter_result(nxitk.ITKImportImageStack, result) + diff --git a/wrapping/python/examples/geometry_examples.py b/wrapping/python/examples/scripts/geometry_examples.py similarity index 96% rename from wrapping/python/examples/geometry_examples.py rename to wrapping/python/examples/scripts/geometry_examples.py index 32a4b9e03e..7084e1f791 100644 --- a/wrapping/python/examples/geometry_examples.py +++ b/wrapping/python/examples/scripts/geometry_examples.py @@ -82,8 +82,8 @@ # AttributeMatrix that we generated in the last filter. output_array_path = nx.DataPath("Image Geometry/Cell Data/Float Cell Data") array_type = nx.NumericType.float32 -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, component_count=1, data_format="", +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", numeric_type=array_type, output_data_array=output_array_path) nxtest.check_filter_result(nx.CreateDataArray, result) @@ -104,8 +104,8 @@ output_array_path = nx.DataPath("RectGridCoords/X Coords") array_type = nx.NumericType.float32 tuple_dims = [[10]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="0", @@ -122,8 +122,8 @@ output_array_path = nx.DataPath("RectGridCoords/Y Coords") array_type = nx.NumericType.float32 tuple_dims = [[10]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="0", @@ -140,8 +140,8 @@ output_array_path = nx.DataPath("RectGridCoords/Z Coords") array_type = nx.NumericType.float32 tuple_dims = [[10]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="0", diff --git a/wrapping/python/examples/import_d3d.py b/wrapping/python/examples/scripts/import_d3d.py similarity index 100% rename from wrapping/python/examples/import_d3d.py rename to wrapping/python/examples/scripts/import_d3d.py diff --git a/wrapping/python/examples/import_hdf5.py b/wrapping/python/examples/scripts/import_hdf5.py similarity index 99% rename from wrapping/python/examples/import_hdf5.py rename to wrapping/python/examples/scripts/import_hdf5.py index 8c6e5f7cd3..9d78baf0ce 100644 --- a/wrapping/python/examples/import_hdf5.py +++ b/wrapping/python/examples/scripts/import_hdf5.py @@ -88,3 +88,4 @@ import_hd_f5_file=import_hdf5_param ) nxtest.check_filter_result(nx.ReadHDF5Dataset, result) + diff --git a/wrapping/python/examples/output_file.py b/wrapping/python/examples/scripts/output_file.py similarity index 93% rename from wrapping/python/examples/output_file.py rename to wrapping/python/examples/scripts/output_file.py index 4d900dcb34..0bd07e0480 100644 --- a/wrapping/python/examples/output_file.py +++ b/wrapping/python/examples/scripts/output_file.py @@ -58,8 +58,8 @@ output_array_path = nx.DataPath(["3D Array"]) array_type = nx.NumericType.float32 tuple_dims = [[3, 2,5]] -create_array_filter = nx.CreateDataArray() -result = create_array_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", +create_array_nx_filter = nx.CreateDataArray() +result = create_array_nx_filter.execute(data_structure=data_structure, component_count=1, data_format="", initialization_value="10", numeric_type=array_type, output_data_array=output_array_path, tuple_dimensions=tuple_dims) nxtest.check_filter_result(nx.CreateDataArray, result) @@ -72,3 +72,4 @@ export_file_path=output_file_path, write_xdmf_file=True) nxtest.check_filter_result(nx.WriteDREAM3DFilter, result) + diff --git a/wrapping/python/examples/pipeline.py b/wrapping/python/examples/scripts/pipeline.py similarity index 100% rename from wrapping/python/examples/pipeline.py rename to wrapping/python/examples/scripts/pipeline.py diff --git a/wrapping/python/examples/read_csv_file.py b/wrapping/python/examples/scripts/read_csv_file.py similarity index 98% rename from wrapping/python/examples/read_csv_file.py rename to wrapping/python/examples/scripts/read_csv_file.py index f7521fd9d5..b951a7a94a 100644 --- a/wrapping/python/examples/read_csv_file.py +++ b/wrapping/python/examples/scripts/read_csv_file.py @@ -51,7 +51,7 @@ data_structure = nx.DataStructure() # This file has 7 columns to import read_csv_data = nx.ReadCSVDataParameter() -read_csv_data.input_file_path = nxtest.GetSimplnxPythonSourceDir() + "/examples/test_csv_data.csv" +read_csv_data.input_file_path = nxtest.GetSimplnxPythonSourceDir() + "/examples/data/test_csv_data.csv" read_csv_data.start_import_row = 2 read_csv_data.delimiters = [','] read_csv_data.custom_headers = [] @@ -73,3 +73,4 @@ read_csv_data=read_csv_data # The ReadCSVData object with all member variables set. ) nxtest.check_filter_result(nx.ReadCSVFileFilter, result) + diff --git a/wrapping/python/examples/read_esprit_data.py b/wrapping/python/examples/scripts/read_esprit_data.py similarity index 99% rename from wrapping/python/examples/read_esprit_data.py rename to wrapping/python/examples/scripts/read_esprit_data.py index 6140b3ab3e..2723a8e17a 100644 --- a/wrapping/python/examples/read_esprit_data.py +++ b/wrapping/python/examples/scripts/read_esprit_data.py @@ -80,3 +80,4 @@ export_file_path=output_file_path, write_xdmf_file=True) nxtest.check_filter_result(nx.WriteDREAM3DFilter, result) + diff --git a/wrapping/python/examples/TestPlugin/CreateArray.py b/wrapping/python/plugins/TestPlugin/CreateArray.py similarity index 99% rename from wrapping/python/examples/TestPlugin/CreateArray.py rename to wrapping/python/plugins/TestPlugin/CreateArray.py index 148b27baa9..e1cfc4aebd 100644 --- a/wrapping/python/examples/TestPlugin/CreateArray.py +++ b/wrapping/python/plugins/TestPlugin/CreateArray.py @@ -88,3 +88,4 @@ def execute_impl(self, data_structure: nx.DataStructure, args: dict, message_han data[:] = value return nx.Result() + diff --git a/wrapping/python/examples/TestPlugin/InitializeData.py b/wrapping/python/plugins/TestPlugin/InitializeData.py similarity index 99% rename from wrapping/python/examples/TestPlugin/InitializeData.py rename to wrapping/python/plugins/TestPlugin/InitializeData.py index 92fd41efb5..9595f8b35e 100644 --- a/wrapping/python/examples/TestPlugin/InitializeData.py +++ b/wrapping/python/plugins/TestPlugin/InitializeData.py @@ -182,3 +182,4 @@ def execute_impl(self, data_structure: nx.DataStructure, args: dict, message_han data_slice[:] = rng.integers(range_min, range_max, size=data_slice.size).reshape(data_slice.shape) return nx.Result() + diff --git a/wrapping/python/examples/TestPlugin/Plugin.py b/wrapping/python/plugins/TestPlugin/Plugin.py similarity index 99% rename from wrapping/python/examples/TestPlugin/Plugin.py rename to wrapping/python/plugins/TestPlugin/Plugin.py index ad1422ab37..574a005246 100644 --- a/wrapping/python/examples/TestPlugin/Plugin.py +++ b/wrapping/python/plugins/TestPlugin/Plugin.py @@ -21,3 +21,4 @@ def vendor(self) -> str: def get_filters(self): return [CreateArrayFilter, InitializeDataPythonFilter, TemplateFilter] + diff --git a/wrapping/python/examples/TestPlugin/TemplateFilter.py b/wrapping/python/plugins/TestPlugin/TemplateFilter.py similarity index 99% rename from wrapping/python/examples/TestPlugin/TemplateFilter.py rename to wrapping/python/plugins/TestPlugin/TemplateFilter.py index b02cdc0e54..7795497228 100644 --- a/wrapping/python/examples/TestPlugin/TemplateFilter.py +++ b/wrapping/python/plugins/TestPlugin/TemplateFilter.py @@ -38,3 +38,4 @@ def execute_impl(self, data_structure: nx.DataStructure, args: dict, message_han value: float = args[TemplateFilter.TEST_KEY] message_handler(nx.IFilter.Message(nx.IFilter.Message.Type.Info, f'Execute: {value}')) return nx.Result() + diff --git a/wrapping/python/examples/TestPlugin/__init__.py b/wrapping/python/plugins/TestPlugin/__init__.py similarity index 99% rename from wrapping/python/examples/TestPlugin/__init__.py rename to wrapping/python/plugins/TestPlugin/__init__.py index 66169843bc..571dd08add 100644 --- a/wrapping/python/examples/TestPlugin/__init__.py +++ b/wrapping/python/plugins/TestPlugin/__init__.py @@ -7,3 +7,4 @@ def get_plugin(): return TestPythonPlugin() __all__ = ['TestPythonPlugin', 'CreateArrayFilter', 'InitializeDataPythonFilter', 'TemplateFilter', 'get_plugin'] + diff --git a/wrapping/python/testing/anaconda_test.bat b/wrapping/python/testing/anaconda_test.bat index f6e8772b42..1f26e42b99 100644 --- a/wrapping/python/testing/anaconda_test.bat +++ b/wrapping/python/testing/anaconda_test.bat @@ -1,16 +1,17 @@ @echo off -echo "complex_CONDA_EXECUTABLE: %complex_CONDA_EXECUTABLE%" -echo "complex_CONDA_ENV: %complex_CONDA_ENV%" +:: echo "complex_CONDA_EXECUTABLE: %complex_CONDA_EXECUTABLE%" +:: echo "complex_CONDA_ENV: %complex_CONDA_ENV%" echo "PYTHON_TEST_FILE: %PYTHON_TEST_FILE%" echo "PYTHONPATH: %PYTHONPATH%" +echo "Python3_EXECUTABLE: %Python3_EXECUTABLE%" -CALL "%complex_CONDA_EXECUTABLE%" activate "%complex_CONDA_ENV%" +:: CALL "%complex_CONDA_EXECUTABLE%" activate "%complex_CONDA_ENV%" echo "PATH: %PATH%" -echo "Where is Python: " -where python +:: echo "Where is Python: " +:: where python.exe echo "Python Version: " -python --version +%Python3_EXECUTABLE% --version -python "%PYTHON_TEST_FILE%" +%Python3_EXECUTABLE% "%PYTHON_TEST_FILE%" diff --git a/wrapping/python/simplnx_test_dirs.in.py b/wrapping/python/testing/simplnx_test_dirs.in.py similarity index 69% rename from wrapping/python/simplnx_test_dirs.in.py rename to wrapping/python/testing/simplnx_test_dirs.in.py index 932c16282a..e251799cf6 100644 --- a/wrapping/python/simplnx_test_dirs.in.py +++ b/wrapping/python/testing/simplnx_test_dirs.in.py @@ -6,10 +6,13 @@ ''' +import os +import shutil +from pathlib import Path -import simplnx as sx +import simplnx as nx -def check_filter_result(filter: sx.IFilter, result: sx.IFilter.ExecuteResult): +def check_filter_result(filter: nx.IFilter, result: nx.IFilter.ExecuteResult): if len(result.warnings) != 0: print(f'{filter.name()} :: Warnings: {result.warnings}') @@ -31,7 +34,7 @@ def GetTestTempDirectory(): return '${simplnx_BINARY_DIR}/Testing/Temporary' def GetDataDirectory(): - return '${DREAM3D_DATA_DIR}' + return '${DATA_DEST_DIR}' def GetSimplnxPythonSourceDir(): return '${simplnx_SOURCE_DIR}/wrapping/python' @@ -39,6 +42,7 @@ def GetSimplnxPythonSourceDir(): def GetSimplnxSourceDir(): return '${simplnx_SOURCE_DIR}' + def print_all_paths(): print(f'#### Important Filesystem Paths ####') print(f' GetBuildDirectory: {GetBuildDirectory()}') @@ -47,4 +51,18 @@ def print_all_paths(): print(f' GetDataDirectory: {GetDataDirectory()}') print(f' GetSimplnxPythonSourceDir: {GetSimplnxPythonSourceDir()}') print(f' GetSimplnxSourceDir: {GetSimplnxSourceDir()}') - print('#######################################') \ No newline at end of file + print('#######################################') + +def cleanup_test_file(file_path: str): + if os.path.exists(file_path): + os.remove(file_path) + + # Check if replace the extension with ".xdmf" the file exists and we can replace it + filename = Path(file_path) + filename_replace_ext = filename.with_suffix('.xdmf') + if os.path.exists(filename_replace_ext): + os.remove(filename_replace_ext) + +def cleanup_test_dir(dir_path: str): + if os.path.exists(dir_path): + shutil.rmtree(dir_path) \ No newline at end of file diff --git a/wrapping/python/fix_pyi_file.py b/wrapping/python/utils/fix_pyi_file.py similarity index 99% rename from wrapping/python/fix_pyi_file.py rename to wrapping/python/utils/fix_pyi_file.py index 740d3f577d..cf13c25f87 100644 --- a/wrapping/python/fix_pyi_file.py +++ b/wrapping/python/utils/fix_pyi_file.py @@ -18,3 +18,4 @@ def main() -> None: if __name__ == '__main__': main() +