diff --git a/CMakeLists.txt b/CMakeLists.txt index 8841931bfe..4da036f5ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -819,7 +819,7 @@ list(APPEND SIMPLNX_GENERATED_HEADERS # Generate Python-Bindings Supporting Files set(SIMPLNX_GENERATED_PYTHON_HEADER ${SIMPLNX_GENERATED_HEADER_DIR}/SimplnxPython.hpp) set(SIMPLNX_PYTHON_MODULE "simplnx") -configure_file(${simplnx_SOURCE_DIR}/wrapping/python/CxPybind/SimplnxPython.hpp.in ${SIMPLNX_GENERATED_PYTHON_HEADER}) +configure_file(${simplnx_SOURCE_DIR}/wrapping/python/NxPybind/SimplnxPython.hpp.in ${SIMPLNX_GENERATED_PYTHON_HEADER}) list(APPEND SIMPLNX_GENERATED_HEADERS ${SIMPLNX_GENERATED_PYTHON_HEADER} diff --git a/scripts/generate_simpl_conversion_code.py b/scripts/generate_simpl_conversion_code.py index d063074960..dfceb674eb 100644 --- a/scripts/generate_simpl_conversion_code.py +++ b/scripts/generate_simpl_conversion_code.py @@ -28,7 +28,7 @@ def from_json(json_object): stripped_uuid = json_object['uuid'].strip('{}') return SIMPLFilterInfo(name=json_object['name'], uuid=stripped_uuid, parameters=parameters) -def create_filter_conversion(simpl_filter: SIMPLFilterInfo, complex_filter_name: str) -> List[str]: +def create_filter_conversion(simpl_filter: SIMPLFilterInfo, simplnx_filter_name: str) -> List[str]: converter_code: List[str] = [] converter_code.append('\n') converter_code.append('namespace\n') @@ -44,7 +44,7 @@ def create_filter_conversion(simpl_filter: SIMPLFilterInfo, complex_filter_name: converter_code.append('} // namespace SIMPL\n') converter_code.append('} // namespace\n') converter_code.append('\n') - converter_code.append(f'Result {complex_filter_name}::FromSIMPLJson(const nlohmann::json& json)\n') + converter_code.append(f'Result {simplnx_filter_name}::FromSIMPLJson(const nlohmann::json& json)\n') converter_code.append('{\n') converter_code.append(' Arguments args = CreateDataArrayFilter().getDefaultArguments();\n') converter_code.append('\n') @@ -136,14 +136,14 @@ def find_filter(mappings: Dict[str, Dict[str, str]], filter_uuid: str) -> Tuple[ return (plugin_name, plugin_mapping[filter_uuid]) raise RuntimeError(f'{filter_uuid} not found') -def get_filter_base_path(simplnx_source_dir: Path, plugin_name: str, complex_filter: str) -> Path: - return simplnx_source_dir / f'src/Plugins/{plugin_name}/src/{plugin_name}/Filters/{complex_filter}' +def get_filter_base_path(simplnx_source_dir: Path, plugin_name: str, simplnx_filter: str) -> Path: + return simplnx_source_dir / f'src/Plugins/{plugin_name}/src/{plugin_name}/Filters/{simplnx_filter}' -def get_filter_hpp_path(simplnx_source_dir: Path, plugin_name: str, complex_filter: str) -> Path: - return get_filter_base_path(simplnx_source_dir, plugin_name, complex_filter).with_suffix('.hpp') +def get_filter_hpp_path(simplnx_source_dir: Path, plugin_name: str, simplnx_filter: str) -> Path: + return get_filter_base_path(simplnx_source_dir, plugin_name, simplnx_filter).with_suffix('.hpp') -def get_filter_cpp_path(simplnx_source_dir: Path, plugin_name: str, complex_filter: str) -> Path: - return get_filter_base_path(simplnx_source_dir, plugin_name, complex_filter).with_suffix('.cpp') +def get_filter_cpp_path(simplnx_source_dir: Path, plugin_name: str, simplnx_filter: str) -> Path: + return get_filter_base_path(simplnx_source_dir, plugin_name, simplnx_filter).with_suffix('.cpp') def read_simpl_json(path: Path) -> Dict[str, SIMPLFilterInfo]: with open(path, 'r') as file: @@ -162,44 +162,44 @@ def update_hpp_lines(lines: List[str]) -> None: function_decl_lines = create_function_decl() lines[last_parameter_key_index:last_parameter_key_index] = function_decl_lines -def update_cpp_lines(lines: List[str], simpl_filter_info: SIMPLFilterInfo, complex_filter_name: str) -> None: +def update_cpp_lines(lines: List[str], simpl_filter_info: SIMPLFilterInfo, simplnx_filter_name: str) -> None: last_include_index = find_last_include(lines) include_lines = create_includes() lines[last_include_index:last_include_index] = include_lines - filter_conversion_lines = create_filter_conversion(simpl_filter_info, complex_filter_name) + filter_conversion_lines = create_filter_conversion(simpl_filter_info, simplnx_filter_name) lines.extend(filter_conversion_lines) -def update_filter_hpp(complex_filter_path: Path) -> None: - with open(complex_filter_path, 'r') as input_file: +def update_filter_hpp(simplnx_filter_path: Path) -> None: + with open(simplnx_filter_path, 'r') as input_file: lines = input_file.readlines() update_hpp_lines(lines) - with open(complex_filter_path, 'w') as output_file: + with open(simplnx_filter_path, 'w') as output_file: output_file.writelines(lines) -def update_filter_cpp(complex_filter_path: Path, simpl_filter_info: SIMPLFilterInfo, complex_filter_name: str) -> None: - with open(complex_filter_path, 'r') as input_file: +def update_filter_cpp(simplnx_filter_path: Path, simpl_filter_info: SIMPLFilterInfo, simplnx_filter_name: str) -> None: + with open(simplnx_filter_path, 'r') as input_file: lines = input_file.readlines() - update_cpp_lines(lines, simpl_filter_info, complex_filter_name) + update_cpp_lines(lines, simpl_filter_info, simplnx_filter_name) - with open(complex_filter_path, 'w') as output_file: + with open(simplnx_filter_path, 'w') as output_file: output_file.writelines(lines) -def update_mapping_lines(lines: List[str], simpl_uuid: str, complex_filter_name: str) -> None: +def update_mapping_lines(lines: List[str], simpl_uuid: str, simplnx_filter_name: str) -> None: index = find_mapping_line(lines, simpl_uuid) - lines[index] = lines[index].replace('{}', f'&{complex_filter_name}::FromSIMPLJson') + lines[index] = lines[index].replace('{}', f'&{simplnx_filter_name}::FromSIMPLJson') -def update_mapping_file(mapping_file_path: Path, simpl_uuid: str, complex_filter_name: str) -> None: +def update_mapping_file(mapping_file_path: Path, simpl_uuid: str, simplnx_filter_name: str) -> None: with open(mapping_file_path, 'r') as input_file: lines = input_file.readlines() - update_mapping_lines(lines, simpl_uuid, complex_filter_name) + update_mapping_lines(lines, simpl_uuid, simplnx_filter_name) with open(mapping_file_path, 'w') as output_file: output_file.writelines(lines) @@ -210,13 +210,13 @@ def generate_converter_code(simplnx_source_dir: Path, simpl_json_path: Path, sim for simpl_filter_uuid in simpl_filters: if simpl_filter_uuid not in simpl_filters_info: raise RuntimeError(f'SIMPL filter json does not contain {simpl_filter_uuid}') - plugin_name, complex_filter_name = find_filter(mappings, simpl_filter_uuid) + plugin_name, simplnx_filter_name = find_filter(mappings, simpl_filter_uuid) mapping_file_path = get_plugin_mapping_file_path_from_root_dir(simplnx_source_dir, plugin_name) - complex_filter_hpp_path = get_filter_hpp_path(simplnx_source_dir, plugin_name, complex_filter_name) - complex_filter_cpp_path = get_filter_cpp_path(simplnx_source_dir, plugin_name, complex_filter_name) - update_filter_hpp(complex_filter_hpp_path) - update_filter_cpp(complex_filter_cpp_path, simpl_filters_info[simpl_filter_uuid], complex_filter_name) - update_mapping_file(mapping_file_path, simpl_filter_uuid, complex_filter_name) + simplnx_filter_hpp_path = get_filter_hpp_path(simplnx_source_dir, plugin_name, simplnx_filter_name) + simplnx_filter_cpp_path = get_filter_cpp_path(simplnx_source_dir, plugin_name, simplnx_filter_name) + update_filter_hpp(simplnx_filter_hpp_path) + update_filter_cpp(simplnx_filter_cpp_path, simpl_filters_info[simpl_filter_uuid], simplnx_filter_name) + update_mapping_file(mapping_file_path, simpl_filter_uuid, simplnx_filter_name) # e.g. python generate_simpl_conversion_code.py . --simpl-filters "53df5340-f632-598f-8a9b-802296b3a95c" # simpl-json is assumed to be next to this file, but can be overriden diff --git a/src/Plugins/ITKImageProcessing/wrapping/python/itkimageprocessing.cpp b/src/Plugins/ITKImageProcessing/wrapping/python/itkimageprocessing.cpp index 9b02688cb1..6b82e7cbc8 100644 --- a/src/Plugins/ITKImageProcessing/wrapping/python/itkimageprocessing.cpp +++ b/src/Plugins/ITKImageProcessing/wrapping/python/itkimageprocessing.cpp @@ -1,10 +1,10 @@ -#include +#include #include "ITKImageProcessing/ITKImageProcessingFilterBinding.hpp" #include "ITKImageProcessing/ITKImageProcessingPlugin.hpp" using namespace nx::core; -using namespace nx::core::CxPybind; +using namespace nx::core::NxPybind; namespace py = pybind11; PYBIND11_MODULE(itkimageprocessing, mod) diff --git a/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp b/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp index 7a1e0f0ada..3cfb55a5fc 100644 --- a/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp +++ b/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -8,7 +8,7 @@ #include "OrientationAnalysis/OrientationAnalysisFilterBinding.hpp" using namespace nx::core; -using namespace nx::core::CxPybind; +using namespace nx::core::NxPybind; namespace py = pybind11; using namespace pybind11::literals; diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 239252013b..70db814e59 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -92,7 +92,7 @@ #include using namespace nx::core; -using namespace nx::core::CxPybind; +using namespace nx::core::NxPybind; namespace py = pybind11; namespace fs = std::filesystem; @@ -1638,6 +1638,21 @@ PYBIND11_MODULE(simplnx, mod) "set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); pipelineFilter.def( "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); + pipelineFilter.def( + "get_parameter_uuids", + [](const PipelineFilter& self) { + py::dict uuidDict; + const Parameters& params = self.getParameters(); + for(const auto& [name, value] : self.getArguments()) + { + if(params.contains(name)) + { + uuidDict[name.c_str()] = params.at(name).getRef().uuid().str(); + } + } + return uuidDict; + }, + "Returns a dict mapping argument names to their parameter type UUID strings"); pipelineFilter.def( "name", [](const PipelineFilter& self) { diff --git a/wrapping/python/CMakeLists.txt b/wrapping/python/CMakeLists.txt index 1747bce751..3cb46d8146 100644 --- a/wrapping/python/CMakeLists.txt +++ b/wrapping/python/CMakeLists.txt @@ -1,10 +1,10 @@ find_package(pybind11 2.10.0 CONFIG REQUIRED) -add_library(CxPybind INTERFACE) +add_library(NxPybind INTERFACE) -target_include_directories(CxPybind INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/CxPybind) +target_include_directories(NxPybind INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/NxPybind) -target_link_libraries(CxPybind +target_link_libraries(NxPybind INTERFACE simplnx pybind11::headers @@ -56,7 +56,7 @@ endif() target_link_libraries(simplnxpy PUBLIC SimplnxCore - CxPybind + NxPybind ) target_compile_options(simplnxpy @@ -199,6 +199,9 @@ if(SIMPLNX_PY_ENABLE_INSTALL) LIBRARY DESTINATION ${SIMPLNX_PY_INSTALL_DIR} ) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils/simplnx_utilities.py + DESTINATION ${SIMPLNX_PY_INSTALL_DIR} + ) if(SIMPLNX_PY_GENERATE_PYI) install(FILES $/simplnx.pyi DESTINATION ${SIMPLNX_PY_INSTALL_DIR} @@ -206,6 +209,16 @@ if(SIMPLNX_PY_ENABLE_INSTALL) endif() endif() +#------------------------------------------------------------------------------- +# Copy the Pipeline to Python Code utilities at build time +#------------------------------------------------------------------------------- +add_custom_target(CopySimplnxUtilities ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/utils/simplnx_utilities.py" + "$/simplnx_utilities.py" + COMMENT "Copying simplnx_utilities.py to build output" +) + #------------------------------------------------------------------------------- # FUNCTION: simplnx_add_python_plugin @@ -236,7 +249,7 @@ function(simplnx_add_python_plugin) target_link_libraries(${PYTHON_MODULE_NAME} PUBLIC ${ARGS_PLUGIN_NAME} - CxPybind + NxPybind ) target_compile_definitions(${PYTHON_MODULE_NAME} PUBLIC PYBIND11_DETAILED_ERROR_MESSAGES) diff --git a/wrapping/python/CxPybind/CxPybind/CxPybind.hpp b/wrapping/python/NxPybind/NxPybind/NxPybind.hpp similarity index 99% rename from wrapping/python/CxPybind/CxPybind/CxPybind.hpp rename to wrapping/python/NxPybind/NxPybind/NxPybind.hpp index 167ecbf8ec..aca189d52b 100644 --- a/wrapping/python/CxPybind/CxPybind/CxPybind.hpp +++ b/wrapping/python/NxPybind/NxPybind/NxPybind.hpp @@ -34,7 +34,7 @@ #define SIMPLNX_PY_BIND_CLASS_VARIADIC(scope, className, ...) pybind11::class_(scope, #className) #define SIMPLNX_PY_BIND_PARAMETER(scope, className) SIMPLNX_PY_BIND_CLASS_VARIADIC(scope, className, nx::core::IParameter) -namespace nx::core::CxPybind +namespace nx::core::NxPybind { namespace py = pybind11; @@ -751,4 +751,4 @@ void BindParameterConstructor(py::class_& object) object.def(py::init(), "name"_a, "human_name"_a, "help_text"_a, "default_value"_a); } -} // namespace nx::core::CxPybind +} // namespace nx::core::NxPybind diff --git a/wrapping/python/CxPybind/SimplnxPython.hpp.in b/wrapping/python/NxPybind/SimplnxPython.hpp.in similarity index 100% rename from wrapping/python/CxPybind/SimplnxPython.hpp.in rename to wrapping/python/NxPybind/SimplnxPython.hpp.in diff --git a/wrapping/python/ReadMe.md b/wrapping/python/ReadMe.md index 87b0f531fc..4da26da1e4 100644 --- a/wrapping/python/ReadMe.md +++ b/wrapping/python/ReadMe.md @@ -7,7 +7,7 @@ are developing new python bindings for `simplnx`. - cmake This directory holds various files used by CMake during the configuration of the python bindings -- CxPybind +- NxPybind This directory holds C++ implementation details for the python bindings - docs This directory holds the entirety of the python binding documentation diff --git a/wrapping/python/cmake/FilterBinding.cpp.in b/wrapping/python/cmake/FilterBinding.cpp.in index 5f30b2a9df..f62f3d5867 100644 --- a/wrapping/python/cmake/FilterBinding.cpp.in +++ b/wrapping/python/cmake/FilterBinding.cpp.in @@ -4,9 +4,9 @@ namespace nx::core::@PLUGIN_NAME@ { -void BindFilters(pybind11::handle scope, const nx::core::CxPybind::Internals& internals) +void BindFilters(pybind11::handle scope, const nx::core::NxPybind::Internals& internals) { - using namespace CxPybind; + using namespace NxPybind; @FILTER_BINDING_CODE@ } } // namespace nx::core diff --git a/wrapping/python/cmake/FilterBinding.hpp.in b/wrapping/python/cmake/FilterBinding.hpp.in index 73bbb31ebf..be690184d8 100644 --- a/wrapping/python/cmake/FilterBinding.hpp.in +++ b/wrapping/python/cmake/FilterBinding.hpp.in @@ -1,8 +1,8 @@ #pragma once -#include "CxPybind/CxPybind.hpp" +#include "NxPybind/NxPybind.hpp" namespace nx::core::@PLUGIN_NAME@ { -void BindFilters(pybind11::handle scope, const nx::core::CxPybind::Internals& internals); +void BindFilters(pybind11::handle scope, const nx::core::NxPybind::Internals& internals); } // namespace nx::core diff --git a/wrapping/python/examples/notebooks/angle_conversion.ipynb b/wrapping/python/examples/notebooks/angle_conversion.ipynb index a96597a0bd..95036bdee5 100644 --- a/wrapping/python/examples/notebooks/angle_conversion.ipynb +++ b/wrapping/python/examples/notebooks/angle_conversion.ipynb @@ -9,7 +9,7 @@ "# Import the DREAM3D Base library and Plugins\n", "import simplnx as nx\n", "\n", - "import orientationanalysis as cxor\n", + "import orientationanalysis as nxor\n", "\n", "import numpy as np" ] @@ -85,7 +85,7 @@ "outputs": [], "source": [ "quat_path = nx.DataPath(['Quaternions'])\n", - "result = cxor.ConvertOrientations.execute(data_structure=data_structure,\n", + "result = nxor.ConvertOrientations.execute(data_structure=data_structure,\n", " input_orientation_array_path=array_path,\n", " input_type=0,\n", " output_orientation_array_name='Quaternions',\n", diff --git a/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb b/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb index dbdcbd2cf5..742ee2d105 100644 --- a/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb +++ b/wrapping/python/examples/notebooks/basic_ebsd_ipf.ipynb @@ -9,8 +9,8 @@ "# Import the DREAM3D Base library and Plugins\n", "import simplnx as nx\n", "\n", - "import itkimageprocessing as cxitk\n", - "import orientationanalysis as cxor\n", + "import itkimageprocessing as nxitk\n", + "import orientationanalysis as nxor\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt" @@ -46,7 +46,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = cxor.ReadAngDataFilter.execute(data_structure=data_structure,\n", + "result = nxor.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=.nxDataPath(['Small IN100']),\n", @@ -72,7 +72,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = cxor.RotateEulerRefFrameFilter.execute(data_structure=data_structure,\n", + "result = nxor.RotateEulerRefFrameFilter.execute(data_structure=data_structure,\n", " cell_euler_angles_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", " rotation_axis=[0, 0, 1, 90],\n", ")\n", @@ -165,7 +165,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = cxor.ComputeIPFColorsFilter.execute(data_structure=data_structure,\n", + "result = nxor.ComputeIPFColorsFilter.execute(data_structure=data_structure,\n", " cell_euler_angles_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'EulerAngles']),\n", " cell_ipf_colors_array_name='IPFColors',\n", " cell_phases_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'Phases']),\n", @@ -194,7 +194,7 @@ "metadata": {}, "outputs": [], "source": [ - "result = cxitk.ITKImageWriter.execute(data_structure=data_structure, file_name='/tmp/Small_IN100_IPF_Z.png',\n", + "result = nxitk.ITKImageWriter.execute(data_structure=data_structure, file_name='/tmp/Small_IN100_IPF_Z.png',\n", " image_array_path=.nxDataPath(['Small IN100', 'Scan Data', 'IPFColors']),\n", " input_image_geometry_path=.nxDataPath(['Small IN100']),\n", " index_offset=0,\n", @@ -248,7 +248,7 @@ "outputs": [], "source": [ "prefix = 'Small_IN100_'\n", - "result = cxor.WritePoleFigureFilter.execute(data_structure=data_structure,\n", + "result = nxor.WritePoleFigureFilter.execute(data_structure=data_structure,\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", diff --git a/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py b/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py index 8df4ed453d..db627a3290 100644 --- a/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py +++ b/wrapping/python/examples/pipelines/ITKImageProcessing/02_Image_Segmentation.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -24,7 +24,7 @@ generated_file_list_value.padding_digits = 2 # Instantiate Filter -nx_filter = cxitk.ITKImportImageStackFilter() +nx_filter = nxitk.ITKImportImageStackFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py b/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py index a56561d50a..e5591f068b 100644 --- a/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py +++ b/wrapping/python/examples/pipelines/ITKImageProcessing/03_Porosity_Mesh_Export.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxitk.ITKImportImageStackFilter() +nx_filter = nxitk.ITKImportImageStackFilter() generated_file_list_value = nx.GeneratedFileListParameter.ValueType() generated_file_list_value.input_path = str(nxtest.get_data_directory() / "Porosity_Image/") diff --git a/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py b/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py index 17af165770..8cf0155fdb 100644 --- a/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py +++ b/wrapping/python/examples/pipelines/Incomplete/ImportBrukerNanoEspritData.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadH5OimDataFilter() +nx_filter = nxor.ReadH5OimDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py b/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py index 2bf785c89f..cde7441829 100644 --- a/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py +++ b/wrapping/python/examples/pipelines/Incomplete/ImportEdaxOIMData.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadH5OimDataFilter() +nx_filter = nxor.ReadH5OimDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -26,7 +26,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.RotateEulerRefFrameFilter() +nx_filter = nxor.RotateEulerRefFrameFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py index b0bae41dba..4b80e129c9 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Archive.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -24,7 +24,7 @@ generated_file_list_value.increment_index = 1 generated_file_list_value.padding_digits = 0 -nx_filter = cxor.EbsdToH5EbsdFilter() +nx_filter = nxor.EbsdToH5EbsdFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, 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 index 49e480ce47..965e910c5b 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Morphological_Statistics.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -68,7 +68,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeShapesFilter() +nx_filter = nxor.ComputeShapesFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, 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 index 837df2b07d..15bed955a9 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/01_Small_IN100_Quick_Mesh.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np 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 index 3a3b4f0e3c..77a7db007d 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/02_Small_IN100_Smooth_Mesh.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np 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 index 4d208e05b7..02d8559bea 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/03_Small_IN100_Mesh_Statistics.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -54,7 +54,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeFaceIPFColoringFilter() +nx_filter = nxor.ComputeFaceIPFColoringFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -70,7 +70,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeFeatureFaceMisorientationFilter() +nx_filter = nxor.ComputeFeatureFaceMisorientationFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py b/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py index cac01e234a..248384752e 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/04_Small_IN100_GBCD.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -21,7 +21,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.ComputeGBCDFilter() +nx_filter = nxor.ComputeGBCDFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -41,7 +41,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ComputeGBCDPoleFigureFilter() +nx_filter = nxor.ComputeGBCDPoleFigureFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -58,7 +58,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ComputeGBCDPoleFigureFilter() +nx_filter = nxor.ComputeGBCDPoleFigureFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -75,7 +75,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeGBCDPoleFigureFilter() +nx_filter = nxor.ComputeGBCDPoleFigureFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -92,7 +92,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.WriteGBCDGMTFileFilter() +nx_filter = nxor.WriteGBCDGMTFileFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -106,7 +106,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.WriteGBCDTriangleDataFilter() +nx_filter = nxor.WriteGBCDTriangleDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, 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 index ccaa7796a7..3ca319ffd5 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_Crystallographic_Statistics.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -42,7 +42,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ComputeAvgOrientationsFilter() +nx_filter = nxor.ComputeAvgOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -58,7 +58,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeFeatureNeighborMisorientationsFilter() +nx_filter = nxor.ComputeFeatureNeighborMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -74,7 +74,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeSchmidsFilter() +nx_filter = nxor.ComputeSchmidsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -96,7 +96,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.ComputeFeatureReferenceMisorientationsFilter() +nx_filter = nxor.ComputeFeatureReferenceMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -115,7 +115,7 @@ # Filter 8 # Instantiate Filter -nx_filter = cxor.ComputeKernelAvgMisorientationsFilter() +nx_filter = nxor.ComputeKernelAvgMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, 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 index 4397f3a889..14831eaee1 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/05_Small_IN100_GBCD_Metric.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -100,7 +100,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ComputeGBCDMetricBasedFilter() +nx_filter = nxor.ComputeGBCDMetricBasedFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, 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 index 540f73661c..7b1f038fbd 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/08_Small_IN100_Full_Reconstruction.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -12,7 +12,7 @@ # Filter 1 # Instantiate Filter -filter_parameter = cxor.ReadH5EbsdFileParameter.ValueType() +filter_parameter = nxor.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"] @@ -20,7 +20,7 @@ filter_parameter.start_slice=6 filter_parameter.use_recommended_transform=True -nx_filter = cxor.ReadH5EbsdFilter() +nx_filter = nxor.ReadH5EbsdFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -60,7 +60,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -74,7 +74,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.AlignSectionsMisorientationFilter() +nx_filter = nxor.AlignSectionsMisorientationFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -116,7 +116,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.BadDataNeighborOrientationCheckFilter() +nx_filter = nxor.BadDataNeighborOrientationCheckFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -132,7 +132,7 @@ # Filter 8 # Instantiate Filter -nx_filter = cxor.NeighborOrientationCorrelationFilter() +nx_filter = nxor.NeighborOrientationCorrelationFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -150,7 +150,7 @@ # Filter 9 # Instantiate Filter -nx_filter = cxor.EBSDSegmentFeaturesFilter() +nx_filter = nxor.EBSDSegmentFeaturesFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -184,7 +184,7 @@ # Filter 11 # Instantiate Filter -nx_filter = cxor.ComputeAvgOrientationsFilter() +nx_filter = nxor.ComputeAvgOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -220,7 +220,7 @@ # Filter 13 # Instantiate Filter -nx_filter = cxor.MergeTwinsFilter() +nx_filter = nxor.MergeTwinsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -361,7 +361,7 @@ # Filter 21 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py b/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py index b3ac07da06..107cdb4212 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/APTR12_Analysis.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadCtfDataFilter() +nx_filter = nxor.ReadCtfDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -64,7 +64,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -91,7 +91,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -106,7 +106,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -120,7 +120,7 @@ # Filter 8 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -136,7 +136,7 @@ # Filter 9 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -150,7 +150,7 @@ # Filter 10 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -165,7 +165,7 @@ # Filter 11 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -179,7 +179,7 @@ # Filter 12 # Instantiate Filter -nx_filter = cxor.EBSDSegmentFeaturesFilter() +nx_filter = nxor.EBSDSegmentFeaturesFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -244,7 +244,7 @@ # Filter 16 # Instantiate Filter -nx_filter = cxor.ComputeAvgOrientationsFilter() +nx_filter = nxor.ComputeAvgOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -260,7 +260,7 @@ # Filter 17 # Instantiate Filter -nx_filter = cxor.ComputeKernelAvgMisorientationsFilter() +nx_filter = nxor.ComputeKernelAvgMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -306,7 +306,7 @@ # Filter 20 # Instantiate Filter -nx_filter = cxor.ComputeFeatureReferenceMisorientationsFilter() +nx_filter = nxor.ComputeFeatureReferenceMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py index c38fd5743b..7f7c9530d6 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AVTR12_Analysis.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadCtfDataFilter() +nx_filter = nxor.ReadCtfDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -64,7 +64,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -91,7 +91,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -106,7 +106,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -120,7 +120,7 @@ # Filter 8 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -136,7 +136,7 @@ # Filter 9 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -150,7 +150,7 @@ # Filter 10 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -165,7 +165,7 @@ # Filter 11 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -179,7 +179,7 @@ # Filter 12 # Instantiate Filter -nx_filter = cxor.EBSDSegmentFeaturesFilter() +nx_filter = nxor.EBSDSegmentFeaturesFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -244,7 +244,7 @@ # Filter 16 # Instantiate Filter -nx_filter = cxor.ComputeAvgOrientationsFilter() +nx_filter = nxor.ComputeAvgOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -260,7 +260,7 @@ # Filter 17 # Instantiate Filter -nx_filter = cxor.ComputeKernelAvgMisorientationsFilter() +nx_filter = nxor.ComputeKernelAvgMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -306,7 +306,7 @@ # Filter 20 # Instantiate Filter -nx_filter = cxor.ComputeFeatureReferenceMisorientationsFilter() +nx_filter = nxor.ComputeFeatureReferenceMisorientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py index 485f2fff89..cab5ee1dd8 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AlignSectionsMutualInformation.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -12,7 +12,7 @@ # Filter 1 # Create the ReadH5EbsdFileParameter and assign values to it. -h5ebsdParameter = cxor.ReadH5EbsdFileParameter.ValueType() +h5ebsdParameter = nxor.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"] @@ -21,7 +21,7 @@ h5ebsdParameter.use_recommended_transform=True # Instantiate Filter -nx_filter = cxor.ReadH5EbsdFilter() +nx_filter = nxor.ReadH5EbsdFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -61,7 +61,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -74,7 +74,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.AlignSectionsMutualInformationFilter() +nx_filter = nxor.AlignSectionsMutualInformationFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py b/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py index 3e168ca532..3b2c816868 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/AvizoWriters.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py b/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py index 17296fb4c2..da3fe5ebf9 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/CI_Histogram.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -24,7 +24,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.RotateEulerRefFrameFilter() +nx_filter = nxor.RotateEulerRefFrameFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBiasedFeatures.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBiasedFeatures.py index de4cb3958b..70f664959f 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBiasedFeatures.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBiasedFeatures.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBoundaryCells.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBoundaryCells.py index bd7195f8b9..047712cca7 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBoundaryCells.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeBoundaryCells.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeGBCD-GBPDMetricBased.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeGBCD-GBPDMetricBased.py index 5fe34dbf76..595354ba0f 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeGBCD-GBPDMetricBased.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeGBCD-GBPDMetricBased.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -39,7 +39,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ComputeGBCDMetricBasedFilter() +nx_filter = nxor.ComputeGBCDMetricBasedFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -66,7 +66,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ComputeGBPDMetricBasedFilter() +nx_filter = nxor.ComputeGBPDMetricBasedFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeLargestCrossSections.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeLargestCrossSections.py index 5e1938f845..b04a556dac 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeLargestCrossSections.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ComputeLargestCrossSections.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,9 +11,9 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadH5EbsdFilter() +nx_filter = nxor.ReadH5EbsdFilter() -h5ebsdParameter = cxor.ReadH5EbsdFileParameter.ValueType() +h5ebsdParameter = nxor.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"] @@ -56,7 +56,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -69,7 +69,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.EBSDSegmentFeaturesFilter() +nx_filter = nxor.EBSDSegmentFeaturesFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py b/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py index f60059694c..1e05a4beb5 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/Edax_IPF_Colors.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -24,7 +24,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.RotateEulerRefFrameFilter() +nx_filter = nxor.RotateEulerRefFrameFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -73,7 +73,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -89,7 +89,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() output_file_path = nxtest.get_data_directory() / "Output/Edax_IPF_Colors/Small_IN100_Slice_1.png" # Execute Filter with Parameters result = nx_filter.execute( diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py index 0a512a997e..711f6b4d36 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadAng.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -24,7 +24,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.RotateEulerRefFrameFilter() +nx_filter = nxor.RotateEulerRefFrameFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -71,7 +71,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py index 17d338e8df..b1d90d1a75 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/ReadCTF.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadCtfDataFilter() +nx_filter = nxor.ReadCtfDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -62,7 +62,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py index b5f59a6706..ef53aac8e8 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Exposed.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadCtfDataFilter() +nx_filter = nxor.ReadCtfDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -73,7 +73,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -89,7 +89,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -103,7 +103,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.WritePoleFigureFilter() +nx_filter = nxor.WritePoleFigureFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py index a4e9a4be0e..69689fca58 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/TxCopper_Unexposed.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadCtfDataFilter() +nx_filter = nxor.ReadCtfDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -72,7 +72,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -88,7 +88,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -102,7 +102,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.WritePoleFigureFilter() +nx_filter = nxor.WritePoleFigureFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py b/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py index 22e79f95e4..1b16b6b35c 100644 --- a/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py +++ b/wrapping/python/examples/pipelines/OrientationAnalysis/VtkRectilinearGridWriter.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometry.py b/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometry.py index 821be6e4ac..40fdcc6b47 100644 --- a/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometry.py +++ b/wrapping/python/examples/pipelines/Simplnx/AppendImageGeometry.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py index f2a97ab919..42a30b3bef 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Demo.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py index b33de648fb..50d0834930 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Image.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -24,7 +24,7 @@ # Filter 2 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -57,7 +57,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -89,7 +89,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -121,7 +121,7 @@ # Filter 8 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -154,7 +154,7 @@ # Filter 10 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py index fbb6e46a3c..7be1edb006 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py +++ b/wrapping/python/examples/pipelines/Simplnx/ApplyTransformation_Node.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py b/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py index b3b04e8673..a3a7585f75 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py +++ b/wrapping/python/examples/pipelines/Simplnx/ArrayCalculatorExample.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py b/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py index f324404590..6f44bd6884 100644 --- a/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py +++ b/wrapping/python/examples/pipelines/Simplnx/CombineSTLFiles.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py b/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py index 3f96b39adb..131b0e11f9 100644 --- a/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py +++ b/wrapping/python/examples/pipelines/Simplnx/EnsembleInfoReader.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -41,7 +41,7 @@ # Filter 3 # Instantiate Filter -nx_filter = cxor.ConvertOrientationsFilter() +nx_filter = nxor.ConvertOrientationsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -71,7 +71,7 @@ # Filter 5 # Instantiate Filter -nx_filter = cxor.ReadEnsembleInfoFilter() +nx_filter = nxor.ReadEnsembleInfoFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -86,7 +86,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py b/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py index 371d37363d..32f1b3ebaa 100644 --- a/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py +++ b/wrapping/python/examples/pipelines/Simplnx/Import_ASCII.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -104,7 +104,7 @@ ensemble_info_parameter.append(["Cubic-High m-3m", "Primary", "Phase 2"]) # Instantiate Filter -nx_filter = cxor.CreateEnsembleInfoFilter() +nx_filter = nxor.CreateEnsembleInfoFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -118,7 +118,7 @@ # Filter 6 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -135,7 +135,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxitk.ITKImageWriterFilter() +nx_filter = nxitk.ITKImageWriterFilter() # Output file path for Filter 7 output_file_path = nxtest.get_data_directory() / "Output/Import_ASCII/IPF.png" diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_CSV_File.py b/wrapping/python/examples/pipelines/Simplnx/Import_CSV_File.py index 6c08097540..2268b43fe8 100644 --- a/wrapping/python/examples/pipelines/Simplnx/Import_CSV_File.py +++ b/wrapping/python/examples/pipelines/Simplnx/Import_CSV_File.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py b/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py index fa7e5fbb6d..d71ab351b9 100644 --- a/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py +++ b/wrapping/python/examples/pipelines/Simplnx/Import_STL_Model.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py b/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py index 32e505bc4d..55b97e92c8 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py +++ b/wrapping/python/examples/pipelines/Simplnx/ReplaceElementAttributesWithNeighbor.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -11,7 +11,7 @@ # Filter 1 # Instantiate Filter -nx_filter = cxor.ReadAngDataFilter() +nx_filter = nxor.ReadAngDataFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, @@ -67,7 +67,7 @@ # Filter 4 # Instantiate Filter -nx_filter = cxor.RotateEulerRefFrameFilter() +nx_filter = nxor.RotateEulerRefFrameFilter() # Execute Filter result = nx_filter.execute( data_structure=data_structure, @@ -112,7 +112,7 @@ # Filter 7 # Instantiate Filter -nx_filter = cxor.ComputeIPFColorsFilter() +nx_filter = nxor.ComputeIPFColorsFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py b/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py index 511ca3bc2c..a6cfa46139 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py +++ b/wrapping/python/examples/pipelines/Simplnx/ResamplePorosityImage.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -24,7 +24,7 @@ generated_file_list_value.padding_digits = 2 # Instantiate Filter -nx_filter = cxitk.ITKImportImageStackFilter() +nx_filter = nxitk.ITKImportImageStackFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py b/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py index db553c923d..5fe6413613 100644 --- a/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py +++ b/wrapping/python/examples/pipelines/Simplnx/ResampleRectGridToImageGeom.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py b/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py index 8e53d24949..69600d4270 100644 --- a/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py +++ b/wrapping/python/examples/pipelines/Simplnx/SurfaceNets_Demo.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np @@ -24,7 +24,7 @@ generated_file_list_value.padding_digits = 2 # Instantiate Filter -nx_filter = cxitk.ITKImportImageStackFilter() +nx_filter = nxitk.ITKImportImageStackFilter() # Execute Filter with Parameters result = nx_filter.execute( data_structure=data_structure, diff --git a/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py b/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py index f61a540f93..e0d5c8e5c5 100644 --- a/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py +++ b/wrapping/python/examples/pipelines/Simplnx/Triangle_Face_Data_Demo.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/scripts/Combine_STL_Files.py b/wrapping/python/examples/scripts/Combine_STL_Files.py index c16a9678d7..a09ecd61da 100644 --- a/wrapping/python/examples/scripts/Combine_STL_Files.py +++ b/wrapping/python/examples/scripts/Combine_STL_Files.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/scripts/Import_STL_File.py b/wrapping/python/examples/scripts/Import_STL_File.py index 0808ff0cf8..9ed310b606 100644 --- a/wrapping/python/examples/scripts/Import_STL_File.py +++ b/wrapping/python/examples/scripts/Import_STL_File.py @@ -1,7 +1,7 @@ import simplnx as nx -import itkimageprocessing as cxitk -import orientationanalysis as cxor +import itkimageprocessing as nxitk +import orientationanalysis as nxor import simplnx_test_dirs as nxtest import numpy as np diff --git a/wrapping/python/examples/scripts/SourceList.cmake b/wrapping/python/examples/scripts/SourceList.cmake index 8032e95a50..a4d985ca2c 100644 --- a/wrapping/python/examples/scripts/SourceList.cmake +++ b/wrapping/python/examples/scripts/SourceList.cmake @@ -15,6 +15,7 @@ set(SIMPLNX_PYTHON_TESTS "pipeline" "read_csv_file" "neighbor_list" + "pipeline_to_python" # "read_esprit_data" ) diff --git a/wrapping/python/examples/scripts/convert_pipeline.py b/wrapping/python/examples/scripts/convert_pipeline.py new file mode 100644 index 0000000000..1d40af08a2 --- /dev/null +++ b/wrapping/python/examples/scripts/convert_pipeline.py @@ -0,0 +1,8 @@ +import simplnx as nx +import itkimageprocessing as nxitk +import orientationanalysis as nxor +from pipeline_to_python import create_default_generator + +pipeline = nx.Pipeline.from_file("/Users/mjackson/Workspace1/simplnx/src/Plugins/OrientationAnalysis/pipelines/Small_IN100_Processing/(02) Small IN100 Full Reconstruction.d3dpipeline") +generator = create_default_generator() +print(generator.generate(pipeline)) \ No newline at end of file diff --git a/wrapping/python/examples/scripts/pipeline_to_python.py b/wrapping/python/examples/scripts/pipeline_to_python.py new file mode 100644 index 0000000000..a2c03fda68 --- /dev/null +++ b/wrapping/python/examples/scripts/pipeline_to_python.py @@ -0,0 +1,88 @@ +"""Test that simplnx_utilities generates valid, compilable Python code.""" + +import simplnx as nx +import simplnx_test_dirs as nxtest +import simplnx_utilities + +# --------------------------------------------------------------------------- +# Test 1: Generate a full script from a pipeline with basic filters +# --------------------------------------------------------------------------- +print("=== Test 1: generate_python_pipeline with basic filters ===") + +data_structure = nx.DataStructure() + +pipeline = nx.Pipeline() +pipeline.append(nx.CreateImageGeometryFilter(), { + "dimensions": [10, 10, 10], + "origin": [0.0, 0.0, 0.0], + "spacing": [1.0, 1.0, 1.0], + "output_image_geometry_path": nx.DataPath("ImageGeom"), + "cell_attribute_matrix_name": "CellData", +}) + +code = simplnx_utilities.generate_python_pipeline(pipeline) +print(code) + +# Verify the code is syntactically valid Python +compile(code, "", "exec") +print("Test 1 PASSED: generated code compiles successfully") + +# --------------------------------------------------------------------------- +# Test 2: Generate filter snippets +# --------------------------------------------------------------------------- +print("\n=== Test 2: generate_python_filters ===") + +filters = [pipeline[i] for i in range(len(pipeline))] +snippet = simplnx_utilities.generate_python_filters(filters) +print(snippet) + +# Snippets reference data_structure and check_filter_result, so wrap them +# in a function body to make them compile without executing +wrapped = ( + "def _snippet(data_structure, check_filter_result):\n" + + "\n".join(" " + line for line in snippet.splitlines()) +) +compile(wrapped, "", "exec") +print("Test 2 PASSED: generated snippet compiles successfully") + +# --------------------------------------------------------------------------- +# Test 3: Multi-filter pipeline with threshold parameter +# --------------------------------------------------------------------------- +print("\n=== Test 3: pipeline with ArrayThresholdSet parameter ===") + +pipeline2 = nx.Pipeline() +pipeline2.append(nx.CreateImageGeometryFilter(), { + "dimensions": [10, 10, 10], + "origin": [0.0, 0.0, 0.0], + "spacing": [1.0, 1.0, 1.0], + "output_image_geometry_path": nx.DataPath("ImageGeom"), + "cell_attribute_matrix_name": "CellData", +}) +pipeline2.append(nx.CreateDataArrayFilter(), { + "component_count": 1, + "initialization_value_str": "0", + "numeric_type_index": nx.NumericType.float32, + "output_array_path": nx.DataPath("ImageGeom/CellData/Quality"), + "tuple_dimensions": [[10, 10, 10]], +}) + +threshold = nx.ArrayThreshold() +threshold.array_path = nx.DataPath("ImageGeom/CellData/Quality") +threshold.comparison = nx.ArrayThreshold.ComparisonType.GreaterThan +threshold.value = 0.5 + +threshold_set = nx.ArrayThresholdSet() +threshold_set.thresholds = [threshold] + +pipeline2.append(nx.MultiThresholdObjectsFilter(), { + "array_thresholds_object": threshold_set, + "created_mask_type": nx.DataType.boolean, + "output_data_array_name": "Mask", +}) + +code2 = simplnx_utilities.generate_python_pipeline(pipeline2) +print(code2) +compile(code2, "", "exec") +print("Test 3 PASSED: threshold pipeline code compiles successfully") + +print("\n===> All pipeline_to_python tests passed") diff --git a/wrapping/python/utils/simplnx_utilities.py b/wrapping/python/utils/simplnx_utilities.py new file mode 100644 index 0000000000..0a8684a976 --- /dev/null +++ b/wrapping/python/utils/simplnx_utilities.py @@ -0,0 +1,483 @@ +"""Simplnx utilities for converting live Pipeline objects to runnable Python scripts. + +Usage: + import simplnx as nx + from simplnx_utilities import generate_python_pipeline, generate_python_filters + + pipeline = nx.Pipeline.from_file("path/to/pipeline.d3dpipeline") + print(generate_python_pipeline(pipeline)) +""" + +import importlib +import pathlib +from dataclasses import dataclass, field +from typing import Any + +import simplnx as nx + +# --------------------------------------------------------------------------- +# Module alias map +# --------------------------------------------------------------------------- + +MODULE_ALIASES: dict[str, str] = { + "simplnx": "nx", + "orientationanalysis": "nxor", + "itkimageprocessing": "nxitk", +} + +# Canonical import ordering for generated scripts +_MODULE_ORDER: tuple[str, ...] = ("simplnx", "orientationanalysis", "itkimageprocessing") + + +# --------------------------------------------------------------------------- +# CodeGenContext +# --------------------------------------------------------------------------- + +@dataclass +class CodeGenContext: + """State carried through code generation for variable naming.""" + + filter_index: int = 0 + variable_counter: dict[str, int] = field(default_factory=dict) + + def unique_name(self, prefix: str) -> str: + """Return a unique variable name like 'threshold_1', 'threshold_2'.""" + count = self.variable_counter.get(prefix, 0) + 1 + self.variable_counter[prefix] = count + return f"{prefix}_{count}" + + +# --------------------------------------------------------------------------- +# Enum and DataPath helpers +# --------------------------------------------------------------------------- + +def _is_pybind11_enum(value: Any) -> bool: + """Check if a value is a pybind11-bound enum.""" + t = type(value) + return hasattr(t, "__members__") and hasattr(value, "name") and hasattr(value, "value") + + +def _encode_enum(value: Any) -> str: + """Produce e.g. 'nx.DataType.boolean' or 'nx.ArrayThreshold.ComparisonType.GreaterThan'.""" + t = type(value) + module_name = t.__module__ + alias = MODULE_ALIASES.get(module_name, module_name) + qualname = t.__qualname__ + return f"{alias}.{qualname}.{value.name}" + + +def _is_datapath(value: Any) -> bool: + """Check if a value is a simplnx DataPath.""" + return isinstance(value, nx.DataPath) + + +def _encode_datapath(value: nx.DataPath) -> str: + """Produce e.g. 'nx.DataPath("DataContainer/Cell Data")'.""" + path_str = value.to_string("/") + return f"nx.DataPath({repr(path_str)})" + + +def _encode_simple_value(value: Any) -> str: + """Encode a single simple value to a Python expression string.""" + if _is_pybind11_enum(value): + return _encode_enum(value) + if _is_datapath(value): + return _encode_datapath(value) + if isinstance(value, pathlib.PurePath): + return repr(str(value)) + if isinstance(value, bool): + return repr(value) + if isinstance(value, float): + return _encode_float(value) + if isinstance(value, int): + return repr(value) + if isinstance(value, str): + return repr(value) + if isinstance(value, list): + return _encode_list(value) + return repr(value) + + +def _encode_float(value: float) -> str: + """Encode a float, rounding away float32 precision artifacts.""" + for digits in (6, 8, 10): + rounded = round(value, digits) + if abs(rounded - value) < abs(value) * 1e-7 or abs(rounded - value) < 1e-12: + s = f"{rounded:.{digits}f}".rstrip("0").rstrip(".") + if "." not in s: + s += ".0" + return s + return repr(value) + + +def _encode_list(values: list) -> str: + """Encode a list, handling DataPath and enum elements.""" + if not values: + return "[]" + items = [_encode_simple_value(v) for v in values] + joined = ", ".join(items) + if len(joined) > 80: + inner = ",\n ".join(items) + return f"[\n {inner}\n]" + return f"[{joined}]" + + +# --------------------------------------------------------------------------- +# Codec functions — each encodes a specific parameter value type +# --------------------------------------------------------------------------- + +def _encode_default(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Fallback encoder using repr() with special handling for DataPath and enums.""" + return [_encode_simple_value(value)] + + +def _encode_array_threshold_set(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode ArrayThresholdSet construction.""" + lines: list[str] = [] + threshold_vars: list[str] = [] + + for threshold in value.thresholds: + var = ctx.unique_name("threshold") + threshold_vars.append(var) + lines.append(f"{var} = nx.ArrayThreshold()") + lines.append(f"{var}.array_path = {_encode_datapath(threshold.array_path)}") + lines.append(f"{var}.comparison = {_encode_enum(threshold.comparison)}") + lines.append(f"{var}.value = {repr(threshold.value)}") + if threshold.component_index != 0: + lines.append(f"{var}.component_index = {threshold.component_index}") + if threshold.inverted: + lines.append(f"{var}.inverted = True") + if threshold.union_op.name != "And": + lines.append(f"{var}.union_op = {_encode_enum(threshold.union_op)}") + + set_var = ctx.unique_name("threshold_set") + lines.append(f"{set_var} = nx.ArrayThresholdSet()") + lines.append(f"{set_var}.thresholds = [{', '.join(threshold_vars)}]") + if value.inverted: + lines.append(f"{set_var}.inverted = True") + if value.union_op.name != "And": + lines.append(f"{set_var}.union_op = {_encode_enum(value.union_op)}") + + lines.append(set_var) # expression line + return lines + + +def _encode_generated_file_list(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode GeneratedFileListParameter.ValueType construction.""" + var = ctx.unique_name("file_list") + lines = [f"{var} = nx.GeneratedFileListParameter.ValueType()"] + lines.append(f"{var}.input_path = {repr(value.input_path)}") + lines.append(f"{var}.ordering = {_encode_enum(value.ordering)}") + lines.append(f"{var}.file_prefix = {repr(value.file_prefix)}") + lines.append(f"{var}.file_suffix = {repr(value.file_suffix)}") + lines.append(f"{var}.file_extension = {repr(value.file_extension)}") + lines.append(f"{var}.start_index = {repr(value.start_index)}") + lines.append(f"{var}.end_index = {repr(value.end_index)}") + lines.append(f"{var}.increment_index = {repr(value.increment_index)}") + lines.append(f"{var}.padding_digits = {repr(value.padding_digits)}") + lines.append(var) + return lines + + +def _encode_read_h5ebsd(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode ReadH5EbsdFileParameter.ValueType construction.""" + var = ctx.unique_name("h5ebsd_param") + lines = [f"{var} = nxor.ReadH5EbsdFileParameter.ValueType()"] + lines.append(f"{var}.input_file_path = {repr(value.input_file_path)}") + lines.append(f"{var}.start_slice = {repr(value.start_slice)}") + lines.append(f"{var}.end_slice = {repr(value.end_slice)}") + lines.append(f"{var}.euler_representation = {repr(value.euler_representation)}") + lines.append(f"{var}.selected_array_names = {repr(value.selected_array_names)}") + lines.append(f"{var}.use_recommended_transform = {repr(value.use_recommended_transform)}") + lines.append(var) + return lines + + +def _encode_calculator(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode CalculatorParameter.ValueType construction.""" + var = ctx.unique_name("calc_param") + selected_group = _encode_datapath(value.selected_group) if _is_datapath(value.selected_group) else repr(value.selected_group) + units = _encode_enum(value.units) if _is_pybind11_enum(value.units) else repr(value.units) + lines = [f"{var} = nx.CalculatorParameter.ValueType({selected_group}, {repr(value.equation)}, {units})"] + lines.append(var) + return lines + + +def _encode_dream3d_import(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode Dream3dImportParameter.ImportData construction.""" + var = ctx.unique_name("import_data") + lines = [f"{var} = nx.Dream3dImportParameter.ImportData()"] + lines.append(f"{var}.file_path = {repr(str(value.file_path))}") + if hasattr(value, "data_paths") and value.data_paths: + paths_str = _encode_list([dp for dp in value.data_paths]) + lines.append(f"{var}.data_paths = {paths_str}") + if hasattr(value, "import_policy") and _is_pybind11_enum(value.import_policy): + lines.append(f"{var}.import_policy = {_encode_enum(value.import_policy)}") + lines.append(var) + return lines + + +def _encode_read_hdf5_dataset(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode ReadHDF5DatasetParameter.ValueType construction.""" + var = ctx.unique_name("hdf5_param") + lines = [f"{var} = nx.ReadHDF5DatasetParameter.ValueType()"] + lines.append(f"{var}.input_file = {repr(value.input_file)}") + if hasattr(value, "parent") and value.parent is not None and _is_datapath(value.parent): + lines.append(f"{var}.parent = {_encode_datapath(value.parent)}") + if hasattr(value, "datasets"): + dataset_lines = [] + for ds in value.datasets: + ds_var = ctx.unique_name("dataset_info") + lines.append(f"{ds_var} = nx.DatasetImportInfo()") + lines.append(f"{ds_var}.data_set_path = {repr(ds.data_set_path)}") + lines.append(f"{ds_var}.component_dimensions = {repr(ds.component_dimensions)}") + lines.append(f"{ds_var}.tuple_dimensions = {repr(ds.tuple_dimensions)}") + dataset_lines.append(ds_var) + lines.append(f"{var}.datasets = [{', '.join(dataset_lines)}]") + lines.append(var) + return lines + + +def _encode_read_csv_data(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode ReadCSVData construction.""" + var = ctx.unique_name("csv_data") + lines = [f"{var} = nx.ReadCSVData()"] + lines.append(f"{var}.input_file_path = {repr(value.input_file_path)}") + lines.append(f"{var}.start_import_row = {repr(value.start_import_row)}") + lines.append(f"{var}.delimiters = {repr(value.delimiters)}") + lines.append(f"{var}.consecutive_delimiters = {repr(value.consecutive_delimiters)}") + if hasattr(value, "custom_headers"): + lines.append(f"{var}.custom_headers = {repr(value.custom_headers)}") + if hasattr(value, "data_types"): + dt_list = value.data_types + if dt_list and _is_pybind11_enum(dt_list[0]): + items = [_encode_enum(d) for d in dt_list] + lines.append(f"{var}.data_types = [{', '.join(items)}]") + else: + lines.append(f"{var}.data_types = {repr(dt_list)}") + if hasattr(value, "skipped_array_mask"): + lines.append(f"{var}.skipped_array_mask = {repr(value.skipped_array_mask)}") + if hasattr(value, "tuple_dims"): + lines.append(f"{var}.tuple_dims = {repr(value.tuple_dims)}") + if hasattr(value, "headers_line"): + lines.append(f"{var}.headers_line = {repr(value.headers_line)}") + if hasattr(value, "header_mode") and _is_pybind11_enum(value.header_mode): + lines.append(f"{var}.header_mode = {_encode_enum(value.header_mode)}") + lines.append(var) + return lines + + +def _encode_oem_ebsd_scan(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode OEMEbsdScanSelectionParameter.ValueType construction.""" + var = ctx.unique_name("oem_param") + lines = [f"{var} = nxor.OEMEbsdScanSelectionParameter.ValueType()"] + lines.append(f"{var}.input_file_path = {repr(str(value.input_file_path))}") + lines.append(f"{var}.stacking_order = {repr(value.stacking_order)}") + lines.append(f"{var}.scan_names = {repr(list(value.scan_names))}") + lines.append(var) + return lines + + +def _encode_crop_geometry(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode CropGeometryParameter.CropValues construction.""" + var = ctx.unique_name("crop_values") + lines = [f"{var} = nx.CropGeometryParameter.CropValues()"] + if hasattr(value, "type") and _is_pybind11_enum(value.type): + lines.append(f"{var}.type = {_encode_enum(value.type)}") + for attr in ("is_2d", "crop_x", "crop_y", "crop_z"): + if hasattr(value, attr): + lines.append(f"{var}.{attr} = {repr(getattr(value, attr))}") + for attr in ("x_bound_voxels", "y_bound_voxels", "z_bound_voxels", + "x_bound_physical", "y_bound_physical", "z_bound_physical"): + if hasattr(value, attr): + lines.append(f"{var}.{attr} = {repr(list(getattr(value, attr)))}") + lines.append(var) + return lines + + +def _encode_dynamic_table(name: str, value: Any, ctx: CodeGenContext) -> list[str]: + """Encode DynamicTableParameter values (2D list of floats).""" + if len(value) == 1 and len(value[0]) <= 5: + return [repr(value)] + lines_inner = ",\n ".join(repr(row) for row in value) + return [f"[\n {lines_inner}\n]"] + + +# --------------------------------------------------------------------------- +# Parameter UUID → codec mapping +# --------------------------------------------------------------------------- + +# Maps parameter type UUID → encoder function. +# Parameters not in this map use _encode_default. +_PARAMETER_CODECS: dict[str, Any] = { + "e93251bc-cdad-44c2-9332-58fe26aedfbe": _encode_array_threshold_set, # ArrayThresholdsParameter + "aac15aa6-b367-508e-bf73-94ab6be0058b": _encode_generated_file_list, # GeneratedFileListParameter + "fac15aa6-b367-508e-bf73-94ab6be0058b": _encode_read_h5ebsd, # ReadH5EbsdFileParameter + "4f6d6a33-48da-427a-8b17-61e07d1d5b45": _encode_read_csv_data, # ReadCSVFileParameter + "ba2d4937-dbec-5536-8c5c-c0a406e80f77": _encode_calculator, # CalculatorParameter + "170a257d-5952-4854-9a91-4281cd06f4f5": _encode_dream3d_import, # Dream3dImportParameter + "32e83e13-ee4c-494e-8bab-4e699df74a5a": _encode_read_hdf5_dataset, # ReadHDF5DatasetParameter + "3935c833-aa51-4a58-81e9-3a51972c05ea": _encode_oem_ebsd_scan, # OEMEbsdScanSelectionParameter + "32b03ebf-02a5-40c7-a41c-2380722caeb7": _encode_crop_geometry, # CropGeometryParameter + "eea76f1a-fab9-4704-8da5-4c21057cf44e": _encode_dynamic_table, # DynamicTableParameter +} + + +def _find_codec(param_uuid: str) -> Any: + """Look up encoder function by parameter UUID, falling back to default.""" + return _PARAMETER_CODECS.get(param_uuid.lower(), _encode_default) + + +# --------------------------------------------------------------------------- +# Module resolution helpers +# --------------------------------------------------------------------------- + +def _resolve_filter_module(filter_obj: Any) -> tuple[str, str, str]: + """Return (module_name, module_alias, class_name) for a filter object.""" + module_name = type(filter_obj).__module__ + class_name = type(filter_obj).__name__ + alias = MODULE_ALIASES.get(module_name, module_name) + return module_name, alias, class_name + + +def _ensure_modules_loaded(filters: list) -> set[str]: + """Import all plugin modules so their parameter types are registered. + + Returns the set of needed module names. + """ + needed_modules: set[str] = {"simplnx"} + for pf in filters: + f = pf.get_filter() + mod_name, _, _ = _resolve_filter_module(f) + needed_modules.add(mod_name) + + for mod_name in needed_modules: + importlib.import_module(mod_name) + + return needed_modules + + +def _build_import_lines(needed_modules: set[str]) -> list[str]: + """Build import statements for the generated script.""" + import_lines = [] + for mod in _MODULE_ORDER: + if mod in needed_modules: + alias = MODULE_ALIASES.get(mod, mod) + import_lines.append(f"import {mod} as {alias}") + # Any unknown modules not in the canonical order + for mod in sorted(needed_modules): + if mod not in MODULE_ALIASES: + import_lines.append(f"import {mod}") + return import_lines + + +# --------------------------------------------------------------------------- +# Single filter code generation +# --------------------------------------------------------------------------- + +def _generate_filter_block(pf: Any, index: int, ctx: CodeGenContext) -> list[str]: + """Generate code lines for a single PipelineFilter.""" + f = pf.get_filter() + _, alias, class_name = _resolve_filter_module(f) + human_name = pf.human_name() + args = pf.get_args() + param_uuids = pf.get_parameter_uuids() + + lines: list[str] = [] + lines.append(f"# Filter {index}: {human_name}") + + setup_lines: list[str] = [] + kwargs: list[tuple[str, str]] = [] + + for arg_name in sorted(args.keys()): + value = args[arg_name] + param_uuid = param_uuids.get(arg_name, "") + codec = _find_codec(param_uuid) + encoded = codec(arg_name, value, ctx) + + if len(encoded) == 1: + kwargs.append((arg_name, encoded[0])) + else: + setup_lines.extend(encoded[:-1]) + kwargs.append((arg_name, encoded[-1])) + + lines.extend(setup_lines) + + lines.append(f"result = {alias}.{class_name}.execute(") + lines.append(" data_structure=data_structure,") + for arg_name, expr in kwargs: + lines.append(f" {arg_name}={expr},") + lines.append(")") + lines.append(f"check_filter_result({alias}.{class_name}, result)") + + return lines + + +# --------------------------------------------------------------------------- +# Public API +# --------------------------------------------------------------------------- + +def generate_python_pipeline(pipeline: Any) -> str: + """Generate a full runnable Python script from a Pipeline object. + + Returns a string containing the complete script with imports, + DataStructure creation, filter execution blocks, and footer. + """ + filters = [pipeline[i] for i in range(len(pipeline))] + return _generate_full(filters) + + +def generate_python_filters(filters: list) -> str: + """Generate just the filter execution blocks for clipboard/UI use. + + No imports, DataStructure creation, or footer — just the filter blocks. + """ + _ensure_modules_loaded(filters) + ctx = CodeGenContext() + blocks: list[str] = [] + for i, pf in enumerate(filters): + ctx.filter_index = i + 1 + block = _generate_filter_block(pf, i + 1, ctx) + blocks.append("\n".join(block)) + return "\n\n".join(blocks) + "\n" + + +# --------------------------------------------------------------------------- +# Internal: full script assembly +# --------------------------------------------------------------------------- + +def _generate_full(filters: list) -> str: + """Assemble imports + boilerplate + filter blocks + footer.""" + ctx = CodeGenContext() + sections: list[str] = [] + + needed_modules = _ensure_modules_loaded(filters) + + # Imports + sections.append("\n".join(_build_import_lines(needed_modules))) + + # check_filter_result helper + sections.append("\n".join([ + "def check_filter_result(filter: nx.IFilter, result: nx.IFilter.ExecuteResult) -> None:", + " if len(result.warnings) != 0:", + " print(f'{filter.name()} :: Warnings: {result.warnings}')", + " has_errors = len(result.errors) != 0", + " if has_errors:", + " print(f'{filter.name()} :: Errors: {result.errors}')", + " raise RuntimeError(result)", + " print(f\"{filter.name()} :: No errors running the filter\")", + ])) + + # DataStructure creation + sections.append("\n\ndata_structure = nx.DataStructure()") + + # Filter blocks + for i, pf in enumerate(filters): + ctx.filter_index = i + 1 + block = _generate_filter_block(pf, i + 1, ctx) + sections.append("\n".join(block)) + + # Footer + sections.append('print("===> Pipeline Complete")') + + return "\n\n".join(sections) + "\n"