├── PluginSDK ├── PythonRecon │ ├── Python │ │ ├── ExtractFeatures.py │ │ ├── my_utility │ │ │ ├── __init__.py │ │ │ ├── classTree.py │ │ │ ├── reloadall.py │ │ │ ├── AttrDisplay.py │ │ │ └── AttrDisplay1.py │ │ ├── ReadNiiPathFiles.py │ │ ├── Radiomics_assist.py │ │ ├── TransferListDimensionOrder.py │ │ ├── excel_helper.py │ │ ├── demo_test.py │ │ └── Radiomics_ExtractFeatures.py │ ├── NiiReader.cpp │ ├── FileIterator.cpp │ ├── FolderIterator.cpp │ ├── ExtractFeatures.cpp │ ├── RFeaturesCollector.cpp │ ├── PythonRecon.cpp │ ├── packages.config │ ├── stdafx.cpp │ ├── targetver.h │ ├── stdafx.h │ ├── FolderCollector.h │ ├── FileIterator.h │ ├── RFeaturesCollector.h │ ├── PyClassification.h │ ├── FolderIterator.h │ ├── ExtractFeatures.h │ ├── dllmain.cpp │ ├── FolderCollector.cpp │ └── ReadMe.txt ├── BasicRecon │ ├── Fft2D.cpp │ ├── IcePeFt.h │ ├── FineCF.cpp │ ├── IcePeFt.cpp │ ├── SimpleGrid.cpp │ ├── DeOversampling.cpp │ ├── DrawlineOnImage.cpp │ ├── RadialSampling.cpp │ ├── SliceSelector.cpp │ ├── SampleDataProtocol.cpp │ ├── ChanneIImageDataCollector.cpp │ ├── BasicRecon.cpp │ ├── packages.config │ ├── stdafx.cpp │ ├── targetver.h │ ├── SliceMerger.cpp.rej │ ├── ChannelIterator.h │ ├── Flip.h │ ├── stdafx.h │ ├── FineCF.h │ ├── imageProcessing.h │ ├── CalcuArea.h │ ├── LinesSelector.h │ ├── SliceIterator.h │ ├── Difference.h │ ├── SliceSelector.h │ ├── ModulePhase.h │ ├── SliceMerger.h │ ├── ChannelSelector.h │ ├── GrayScaleUnifier.h │ ├── NiumagPFFTConjugator.h │ ├── PhaseCorrector.h │ ├── SubSampling.h │ ├── NiumagFidWriter.h │ ├── JpegExporter.h │ ├── NiuMriImageWriter.h │ ├── DeOversampling.h │ ├── NLM.h │ ├── SimpleGrid.h │ ├── ZeroFilling.h │ ├── NiumagFidReader.h │ ├── NiumagImgReader.h │ ├── NiuMriImageReader.h │ ├── ComplexSplitter.h │ ├── RadialSampling.h │ ├── ChannelDataCollector.h │ ├── DataTypeConvertor.h │ ├── Fft2D.h │ ├── Fft3D.h │ ├── CalcuArea.cpp │ ├── ChannelMerger.h │ ├── ChannelImageDataCollector.h │ ├── Nlmeans.h │ ├── Fft1D.h │ ├── CmrDataReader.h │ ├── DrawlineOnImage.h │ ├── GrayScaleUnifier.cpp │ ├── ChannelIterator.cpp │ ├── SubSampling.cpp │ ├── SliceMerger.cpp │ ├── Flip.cpp │ ├── LinesSelector.cpp │ └── ChannelSelector.cpp └── PluginSDK.sln ├── API ├── PipelineTest │ ├── daub2.flt │ ├── Pipelines │ │ ├── NiumagFidWriter.pipeline │ │ ├── NiumagImgReader.pipeline │ │ ├── NiuMriImageReader.pipeline │ │ ├── NiumagImgWriterReader.pipeline │ │ ├── FineCF.pipeline │ │ ├── ImgPythonShow.pipeline │ │ ├── demoNiiReader.pipeline │ │ ├── demoRadiomics.pipeline │ │ ├── NiumagFidWriterReader.pipeline │ │ ├── NiumagFidReader.pipeline │ │ ├── Test_niumag_recon_yaplocal.pipeline │ │ ├── NiuMriImageWriter.pipeline │ │ ├── niumag_recon.pipeline │ │ ├── test_niumag_recon.pipeline │ │ ├── grappa.pipeline │ │ ├── Test0.pipeline │ │ ├── CompressedSensing.pipeline │ │ ├── FFT3DTest.pipeline │ │ ├── Radiomics_test2.pipeline │ │ ├── Test1b.pipeline │ │ ├── Test0_FFT3D.pipeline │ │ ├── Test1-pjf.pipeline │ │ ├── Radiomics_test.pipeline │ │ ├── Test0b.pipeline │ │ ├── Test.pipeline │ │ ├── Test0_simple.pipeline │ │ ├── PartialFFT.pipeline │ │ ├── Test0_RadialSampling.pipeline │ │ ├── demo.pipeline │ │ ├── CompressedSensing2.pipeline │ │ ├── CompressedSensing2test.pipeline │ │ └── Test0_qt.pipeline │ ├── packages.config │ ├── stdafx.cpp │ ├── targetver.h │ ├── ProcessorDebugger.h │ ├── stdafx.h │ ├── YapDebugger.h │ ├── ReadMe.txt │ └── PipelineTest.vcxproj.filters ├── Yap │ ├── ScanFileParser.cpp │ ├── packages.config │ ├── ModuleAgent.h │ ├── PipelineCompiler.h │ ├── ProcessorAgent.h │ ├── ScanFileParser.h │ ├── VdfParser.h │ ├── ModuleAgent.cpp │ ├── YapClient.pro │ └── Yap.vcxproj.filters └── UnitTests │ ├── VdfUnitTests.cpp │ ├── ScanFileParserUnitTest.cpp │ ├── packages.config │ ├── stdafx.cpp │ ├── targetver.h │ ├── stdafx.h │ ├── PipelineUnitTests.vcxproj.filters │ └── ReadMe.txt ├── Pipelines - 快捷方式.lnk ├── GrappaRecon ├── Grappa.cpp ├── stdafx.cpp ├── targetver.h ├── stdafx.h ├── dllmain.cpp ├── Grappa.h └── GrappaRecon.vcxproj.filters ├── Shared ├── Interface │ ├── IData.h │ ├── packages.config │ ├── Interfaces.h │ ├── IPython.h │ ├── ILog.h │ ├── IPythonUser.h │ ├── IContainer.h │ ├── Interface.vcxproj.filters │ └── IProcessor.h ├── Utilities │ ├── stdafx.h │ ├── xml.cpp │ ├── FileSystem.h │ ├── FileSystem.cpp │ ├── CommonMethod.cpp │ ├── packages.config │ ├── Clipboard.h │ ├── stdafx.cpp │ ├── targetver.h │ ├── CommonMethod.h │ ├── Clipboard.cpp │ ├── macros.h │ ├── StringHelper.h │ └── Utilities.vcxproj.filters ├── Client │ ├── DataHelper.cpp │ ├── packages.config │ ├── stdafx.cpp │ ├── targetver.h │ ├── stdafx.h │ ├── Client.vcxproj.filters │ └── DataHelper.h ├── Implement │ ├── Implement.rc │ ├── README.md │ ├── ProcessorImpl.cpp │ ├── packages.config │ ├── resource.h │ ├── TypeManager.h │ ├── LogImpl.h │ ├── details │ │ └── variableShared.h │ ├── YapImplement.h │ ├── CompositeProcessor.h │ ├── VariableSpace.h │ ├── PythonUserImpl.cpp │ ├── LogUserImpl.h │ ├── PythonUserImpl.h │ └── LogUserImpl.cpp └── PythonImplement │ ├── PythonImpl.cpp │ ├── packages.config │ ├── PythonImpl.h │ ├── dllmain.cpp │ ├── PythonImplement.vcxproj.filters │ └── ReadMe.txt ├── README.md ├── BasicRecon_GPU ├── BasicRecon_GPU.cpp ├── stdafx.cpp ├── targetver.h ├── cuFft2D.h ├── stdafx.h ├── dllmain.cpp ├── cuFft2D.cpp ├── BasicRecon_GPU.vcxproj.filters └── ReadMe.txt ├── PluginSdk └── BasicRecon │ ├── DcRemover.h │ └── SamplingMaskCreator.h └── LICENSE /PluginSDK/PythonRecon/Python/ExtractFeatures.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /API/PipelineTest/daub2.flt: -------------------------------------------------------------------------------- 1 | 0.482962913145 0.836516303738 0.224143868042 -0.129409522551 -------------------------------------------------------------------------------- /Pipelines - 快捷方式.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Pipelines - 快捷方式.lnk -------------------------------------------------------------------------------- /GrappaRecon/Grappa.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/GrappaRecon/Grappa.cpp -------------------------------------------------------------------------------- /Shared/Interface/IData.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Interface/IData.h -------------------------------------------------------------------------------- /Shared/Utilities/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Utilities/stdafx.h -------------------------------------------------------------------------------- /Shared/Utilities/xml.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Utilities/xml.cpp -------------------------------------------------------------------------------- /API/Yap/ScanFileParser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/API/Yap/ScanFileParser.cpp -------------------------------------------------------------------------------- /API/UnitTests/VdfUnitTests.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/API/UnitTests/VdfUnitTests.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Fft2D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/Fft2D.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/IcePeFt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/IcePeFt.h -------------------------------------------------------------------------------- /Shared/Client/DataHelper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Client/DataHelper.cpp -------------------------------------------------------------------------------- /Shared/Implement/Implement.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Implement/Implement.rc -------------------------------------------------------------------------------- /Shared/Implement/README.md: -------------------------------------------------------------------------------- 1 | # YAP 2 | Yet Another Pipeline for medical image reconstruction and processing. 3 | -------------------------------------------------------------------------------- /Shared/Utilities/FileSystem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Utilities/FileSystem.h -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/FineCF.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/FineCF.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/IcePeFt.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/IcePeFt.cpp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YAP 2 | Yet Another Pipeline for medical image reconstruction and processing. 3 | 本项目为Yap主代码,路径名为Yap2. 4 | -------------------------------------------------------------------------------- /Shared/Utilities/FileSystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Utilities/FileSystem.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SimpleGrid.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/SimpleGrid.cpp -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/NiiReader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/PythonRecon/NiiReader.cpp -------------------------------------------------------------------------------- /Shared/Implement/ProcessorImpl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Implement/ProcessorImpl.cpp -------------------------------------------------------------------------------- /Shared/Utilities/CommonMethod.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/Utilities/CommonMethod.cpp -------------------------------------------------------------------------------- /Shared/PythonImplement/PythonImpl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/Shared/PythonImplement/PythonImpl.cpp -------------------------------------------------------------------------------- /API/UnitTests/ScanFileParserUnitTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/API/UnitTests/ScanFileParserUnitTest.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/DeOversampling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/DeOversampling.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/DrawlineOnImage.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/DrawlineOnImage.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/RadialSampling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/RadialSampling.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceSelector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/SliceSelector.cpp -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FileIterator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/PythonRecon/FileIterator.cpp -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FolderIterator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/PythonRecon/FolderIterator.cpp -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/ExtractFeatures.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/PythonRecon/ExtractFeatures.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SampleDataProtocol.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/SampleDataProtocol.cpp -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/RFeaturesCollector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/PythonRecon/RFeaturesCollector.cpp -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChanneIImageDataCollector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MR-algorithms/YAP/HEAD/PluginSDK/BasicRecon/ChanneIImageDataCollector.cpp -------------------------------------------------------------------------------- /BasicRecon_GPU/BasicRecon_GPU.cpp: -------------------------------------------------------------------------------- 1 | // BasicRecon_GPU.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/BasicRecon.cpp: -------------------------------------------------------------------------------- 1 | // BasicRecon.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/PythonRecon.cpp: -------------------------------------------------------------------------------- 1 | // PythonRecon.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/my_utility/__init__.py: -------------------------------------------------------------------------------- 1 | # init start utility 2 | print('my_utility starting...') 3 | 4 | 5 | # end 6 | print('my_utility start success!') 7 | -------------------------------------------------------------------------------- /API/Yap/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiumagFidWriter.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidWriter writer(ExportFolder = "d:\\Output"); 4 | NiumagFidReader reader(DataPath = "D:\\test_data\\UU.img.fid"); 5 | 6 | reader->writer; 7 | 8 | self.Input->reader.Input; 9 | -------------------------------------------------------------------------------- /API/UnitTests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/Client/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiumagImgReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagImgReader reader(DataPath = "D:\\test_data\\1.img"); 4 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 5 | 6 | reader->jpeg_exporter; 7 | 8 | self.Input->reader.Input; 9 | -------------------------------------------------------------------------------- /API/PipelineTest/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/Implement/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/Interface/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/Utilities/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiuMriImageReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiuMriImageReader reader(DataPath = "D:\\Output\\2.niuimg"); 4 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 5 | 6 | reader->jpeg_exporter; 7 | 8 | self.Input->reader.Input; 9 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/PythonImplement/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Shared/PythonImplement/PythonImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef PythonImpl_H_20171020 2 | #define PythonImpl_H_20171020 3 | 4 | #pragma once 5 | #include "Interface\IPython.h" 6 | 7 | // struct IPython; 8 | 9 | namespace Yap 10 | { 11 | class PythonFactory 12 | { 13 | public: 14 | static IPython* GetPython(); 15 | }; 16 | } 17 | #endif -------------------------------------------------------------------------------- /GrappaRecon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicRecon.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Shared/Client/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Client.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Shared/Interface/Interfaces.h: -------------------------------------------------------------------------------- 1 | #ifndef Interface_h__20160825 2 | #define Interface_h__20160825 3 | 4 | #include "idata.h" 5 | #include "IVariable.h" 6 | #include "smartptr.h" 7 | #include "IProcessor.h" 8 | #include "ILog.h" 9 | #include "IPythonUser.h" 10 | #include "IPython.h" 11 | 12 | #endif // Interface_h__20160825 13 | -------------------------------------------------------------------------------- /API/PipelineTest/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // PipelineTest.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /API/UnitTests/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // PipelineUnitTests.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /BasicRecon_GPU/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicRecon_GPU.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicRecon.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiumagImgWriterReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagImgReader reader(DataPath = "D:\\Output\\1.img"); 4 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 5 | SliceIterator slice_iterator; 6 | 7 | reader->slice_iterator; 8 | slice_iterator->jpeg_exporter; 9 | 10 | self.Input->reader.Input; 11 | -------------------------------------------------------------------------------- /API/UnitTests/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /GrappaRecon/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Shared/Client/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /API/PipelineTest/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /BasicRecon_GPU/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicRecon.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | 8 | // TODO: reference any additional headers you need in STDAFX.H 9 | // and not in this file 10 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceMerger.cpp.rej: -------------------------------------------------------------------------------- 1 | diff a/PluginSDK/BasicRecon/SliceMerger.cpp b/PluginSDK/BasicRecon/SliceMerger.cpp (rejected hunks) 2 | @@ -0,6 +0,7 @@ 3 | AddInput(L"Input", 2, DataTypeAll); 4 | AddOutput(L"Output", 3, DataTypeAll); 5 | 6 | + AddProperty(PropertyInt, L"SliceCount", L"Slice count."); 7 | } 8 | 9 | SliceMerger::SliceMerger(const SliceMerger& rhs) 10 | -------------------------------------------------------------------------------- /API/UnitTests/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/FineCF.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\Projects\\Data\\FineCF_fid\\lwj.fid"); 4 | Fft1D fft; 5 | ModulePhase module_phase; 6 | FineCF fine_cf(O1 = 21290, SW = 100); 7 | 8 | fine_cf.CF ==> SFO1; 9 | 10 | reader->fft; 11 | fft->module_phase; 12 | module_phase.Module->fine_cf; 13 | 14 | self.Input->reader.Input; 15 | 16 | -------------------------------------------------------------------------------- /API/PipelineTest/ProcessorDebugger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Interface/Interfaces.h" 4 | 5 | namespace Yap 6 | { 7 | class YapDebugger 8 | { 9 | public: 10 | void DebugPort(IPortIter& ports); 11 | 12 | void DebugOutput(IProcessor& processor); 13 | 14 | bool DebugProperties(IVariableIter& properties); 15 | 16 | bool DebugPlugin(const wchar_t * path); 17 | 18 | }; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /API/PipelineTest/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /BasicRecon_GPU/cuFft2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | 4 | namespace Yap 5 | { 6 | class cuFft2D : 7 | public ProcessorImpl 8 | { 9 | IMPLEMENT_SHARED(cuFft2D) 10 | public: 11 | cuFft2D(); 12 | virtual ~cuFft2D(); 13 | 14 | //virtual IProcessor * Clone() override; 15 | 16 | virtual bool Input(const wchar_t * name, IData * data) override; 17 | 18 | }; 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/ImgPythonShow.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagImgReader reader(DataPath = "D:\\Output\\1.img"); 4 | Python2DUSUS pyUSimshow(ScriptPath = 5 | "D:\\Projects\\YAP\\PluginSDK\\BasicRecon\\Python\\example.py", 6 | MethodName = "ShowImage"); 7 | SliceIterator slice_iterator; 8 | 9 | reader->slice_iterator; 10 | slice_iterator->pyUSimshow; 11 | 12 | self.Input->reader.Input; 13 | -------------------------------------------------------------------------------- /Shared/Client/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | 12 | 13 | 14 | // TODO: reference additional headers your program requires here 15 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/demoNiiReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiiReader ref_reader(FilePath = "D:\\data\\test_data\\Brats17_2013_11_1_t1ce.nii"); 4 | SliceSelector selector(SliceIndex = 40); 5 | DataTypeConvertor convertor; 6 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 7 | 8 | ref_reader->selector; 9 | selector->convertor; 10 | convertor.UnsignedShort->jpeg_exporter; 11 | 12 | self.Input->ref_reader.Input; -------------------------------------------------------------------------------- /API/PipelineTest/YapDebugger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Interface/IProperty.h" 4 | #include "Interface/IProcessor.h" 5 | 6 | namespace Yap 7 | { 8 | class CProcessorDebugger 9 | { 10 | public: 11 | void DebugPort(IPortIter& ports); 12 | 13 | void DebugOutput(IProcessor& processor); 14 | 15 | bool DebugProperties(IPropertyIter& properties); 16 | 17 | bool DebugPlugin(const wchar_t * path); 18 | 19 | }; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement/ProcessorImpl.h" 3 | namespace Yap 4 | { 5 | class ChannelIterator : 6 | public ProcessorImpl 7 | { 8 | IMPLEMENT_SHARED(ChannelIterator) 9 | public: 10 | ChannelIterator(); 11 | ChannelIterator(const ChannelIterator& rhs); 12 | 13 | protected: 14 | ~ChannelIterator(); 15 | 16 | virtual bool Input(const wchar_t * name, IData * data) override; 17 | }; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Flip.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Flip_h__20160814 4 | #define Flip_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class Flip : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(Flip) 14 | public: 15 | Flip(); 16 | Flip(const Flip& rhs); 17 | 18 | protected: 19 | ~Flip(); 20 | virtual bool Input(const wchar_t * port, IData * data) override; 21 | 22 | }; 23 | } 24 | #endif // Flip_h__ 25 | -------------------------------------------------------------------------------- /Shared/Implement/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Implement.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /GrappaRecon/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | #define NOMINMAX 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | 13 | 14 | #include 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | #define NOMINMAX 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | 13 | 14 | #include 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /BasicRecon_GPU/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #define NOMINMAX 9 | #include "targetver.h" 10 | 11 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 12 | // Windows Header Files: 13 | 14 | 15 | #include 16 | 17 | // TODO: reference additional headers your program requires here 18 | 19 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/FineCF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | #include "Interface\smartptr.h" 4 | 5 | namespace Yap 6 | { 7 | class FineCF : 8 | public ProcessorImpl 9 | { 10 | IMPLEMENT_SHARED(FineCF) 11 | public: 12 | FineCF(); 13 | FineCF(const FineCF& rhs); 14 | 15 | protected: 16 | ~FineCF(); 17 | 18 | virtual bool Input(const wchar_t * port, IData * data) override; 19 | 20 | // property input O1, SW 21 | // property output CF; 22 | private: 23 | }; 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | #define NOMINMAX 8 | 9 | #include "targetver.h" 10 | 11 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 12 | // Windows Header Files: 13 | 14 | 15 | 16 | #include 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /PluginSdk/BasicRecon/DcRemover.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef RemoveDC_h__20160814 4 | #define RemoveDC_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class DcRemover : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(DcRemover) 14 | public: 15 | DcRemover(); 16 | DcRemover(const DcRemover& rhs); 17 | 18 | protected: 19 | ~DcRemover(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | }; 23 | } 24 | 25 | #endif // RemoveDC_h__ 26 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/imageProcessing.h: -------------------------------------------------------------------------------- 1 | #ifndef imageProcessing_h__20160814 2 | #define imageProcessing_h__20160814 3 | 4 | #pragma once 5 | 6 | template 7 | void hflip(T * image, size_t width, size_t height) 8 | { 9 | T temp; 10 | for (size_t row = 0; row < height; ++row) 11 | { 12 | T * begin = image + width * row; 13 | T * end = image + width * (row + 1) - 1; 14 | while (begin < end) 15 | { 16 | temp = *begin; 17 | *begin++ = *end; 18 | *end-- = temp; 19 | } 20 | } 21 | } 22 | #endif // imageProcessing_h__ -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/CalcuArea.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef CALCEAREA_h__20170526 3 | #define CALCEAREA_h__20170526 4 | 5 | #include "Implement\ProcessorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class CalcuArea : 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(CalcuArea) 13 | public: 14 | CalcuArea(); 15 | CalcuArea(const CalcuArea& rhs); 16 | 17 | private: 18 | virtual ~CalcuArea(); 19 | 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | }; 22 | 23 | } 24 | #endif CALCEAREA_h__ 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/LinesSelector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef LINESSELECTOR_H_20171031 4 | #define LINESSELECTOR_H_20171031 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class LinesSelector : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(LinesSelector) 14 | public: 15 | LinesSelector(); 16 | LinesSelector(const LinesSelector& rhs); 17 | 18 | protected: 19 | virtual ~LinesSelector(); 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | }; 22 | } 23 | 24 | 25 | #endif // !LINESSELECTOR_H_ -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef SliceIterator_h__20160814 3 | #define SliceIterator_h__20160814 4 | 5 | #include "Implement/ProcessorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class SliceIterator : 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(SliceIterator) 13 | public: 14 | SliceIterator(void); 15 | SliceIterator(const SliceIterator& rhs); 16 | 17 | protected: 18 | ~SliceIterator(void); 19 | 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | 22 | }; 23 | } 24 | #endif // SliceIterator_h__ 25 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/demoRadiomics.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiiReader img_reader(FilePath = "D:\\test_data\\Brats17_2013_11_1_t1ce.nii"); 4 | Radiomics radiomicshandle(ScriptPath = 5 | "D:\\Projects\\Demo_Cplus_extend_python\\PythonScripts\\Py2C.py", 6 | MethodName = "test2d", ReturnDataType = 8); 7 | SliceSelector selector(SliceIndex = 40); 8 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 9 | 10 | img_reader->selector; 11 | selector->radiomicshandle.Input; 12 | radiomicshandle->jpeg_exporter; 13 | 14 | self.Input->img_reader.Input; 15 | 16 | 17 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Difference.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Difference_h__20160816 4 | #define Difference_h__20160816 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class Difference : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(Difference) 14 | public: 15 | Difference(); 16 | Difference(const Difference& rhs); 17 | 18 | protected: 19 | ~Difference(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | 23 | SmartPtr _reference_data; 24 | }; 25 | } 26 | 27 | #endif // Difference_h__ 28 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceSelector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef SliceSelector_h__20160814 4 | #define SliceSelector_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class SliceSelector : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(SliceSelector) 14 | public: 15 | SliceSelector(void); 16 | SliceSelector(const SliceSelector& rhs); 17 | 18 | protected: 19 | ~SliceSelector(); 20 | 21 | virtual bool Input(const wchar_t * name, IData * data) override; 22 | 23 | 24 | }; 25 | } 26 | #endif // SliceSelector_h__ 27 | 28 | 29 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ModulePhase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ModulePhase_h__20160814 4 | #define ModulePhase_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class ModulePhase : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(ModulePhase) 14 | public: 15 | ModulePhase(void); 16 | ModulePhase(const ModulePhase& rhs); 17 | 18 | protected: 19 | ~ModulePhase(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | void TestChannelOnSlice(IData *output); 23 | }; 24 | } 25 | #endif // ModulePhase_h__ 26 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceMerger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef SliceMerger_h__20161221 4 | #define SliceMerger_h__20161221 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | namespace Yap 8 | { 9 | class SliceMerger: 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(SliceMerger) 13 | public: 14 | SliceMerger(void); 15 | SliceMerger(const SliceMerger& rhs); 16 | 17 | protected: 18 | ~SliceMerger(); 19 | 20 | virtual bool Input(const wchar_t * port, IData * data) override; 21 | 22 | SmartPtr _data; 23 | }; 24 | } 25 | #endif // SliceMerger_h__ 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelSelector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ChannelSelector_h__20160814 4 | #define ChannelSelector_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class ChannelSelector : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(ChannelSelector) 14 | public: 15 | ChannelSelector(void); 16 | ChannelSelector(const ChannelSelector& rhs); 17 | 18 | protected: 19 | ~ChannelSelector(); 20 | 21 | virtual bool Input(const wchar_t * name, IData * data) override; 22 | 23 | 24 | }; 25 | } 26 | #endif // ChannelSelector_h__ 27 | 28 | 29 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/GrayScaleUnifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef GRAYSCALEUNIFIER_H_20171102 4 | #define GRAYSCALEUNIFIER_H_20171102 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class GrayScaleUnifier : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(GrayScaleUnifier) 14 | public: 15 | GrayScaleUnifier(); 16 | GrayScaleUnifier(const GrayScaleUnifier& rhs); 17 | 18 | protected: 19 | ~GrayScaleUnifier(); 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | 22 | }; 23 | } 24 | #endif // !GRAYSCALEUNIFIER_H_ 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiumagPFFTConjugator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CONJUGATOR_H_20171101 4 | #define CONJUGATOR_H_20171101 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class NiumagPFFTConjugator : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(NiumagPFFTConjugator) 14 | public: 15 | NiumagPFFTConjugator(); 16 | NiumagPFFTConjugator(const NiumagPFFTConjugator& rhs); 17 | 18 | protected: 19 | ~NiumagPFFTConjugator(); 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | }; 22 | } 23 | #endif // !CONJUGATOR_H_ 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiumagFidWriterReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\Output\\1.img.fid"); 4 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 5 | SliceIterator slice_iterator; 6 | ModulePhase module_phase; 7 | Fft2D fft; 8 | RemoveDC dc_remover; 9 | ZeroFilling zero_filling(DestWidth = 1024, DestHeight = 1024); 10 | HFlipFloat hflip; 11 | 12 | reader->slice_iterator; 13 | slice_iterator->dc_remover; 14 | dc_remover->zero_filling; 15 | zero_filling->fft; 16 | fft->module_phase; 17 | module_phase.Module->jpeg_exporter; 18 | 19 | self.Input->reader.Input; -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/PhaseCorrector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef PHASECORRECTOR_H_20171101 4 | #define PHASECORRECTOR_H_20171101 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class PhaseCorrector : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(PhaseCorrector) 14 | public: 15 | PhaseCorrector(); 16 | PhaseCorrector(const PhaseCorrector& rhs); 17 | 18 | protected: 19 | ~PhaseCorrector(); 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | 22 | SmartPtr _phase; 23 | }; 24 | 25 | } 26 | #endif // !PHASECORRECTOR_H_ 27 | 28 | 29 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SubSampling.h: -------------------------------------------------------------------------------- 1 | 2 | #include "Implement/ProcessorImpl.h" 3 | 4 | namespace Yap 5 | { 6 | class SubSampling : 7 | public ProcessorImpl 8 | { 9 | IMPLEMENT_SHARED(SubSampling) 10 | public: 11 | SubSampling(); 12 | SubSampling(const SubSampling& rhs); 13 | 14 | protected: 15 | ~SubSampling(); 16 | 17 | virtual bool Input(const wchar_t * port, IData * data) override; 18 | 19 | void GetSubSampledData(std::complex * input_data, float * mask, std::complex * output_data, unsigned int width, unsigned int height); 20 | 21 | private: 22 | SmartPtr _mask; 23 | 24 | }; 25 | } -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiumagFidReader.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\test_data\\UU.img.fid"); 4 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 5 | SliceIterator slice_iterator; 6 | ModulePhase module_phase; 7 | Fft2D fft; 8 | RemoveDC dc_remover; 9 | ZeroFilling zero_filling(DestWidth = 1024, DestHeight = 1024); 10 | HFlipFloat hflip; 11 | 12 | reader->slice_iterator; 13 | slice_iterator->dc_remover; 14 | dc_remover->zero_filling; 15 | zero_filling->fft; 16 | fft->module_phase; 17 | module_phase.Module->jpeg_exporter; 18 | 19 | self.Input->reader.Input; 20 | 21 | -------------------------------------------------------------------------------- /GrappaRecon/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Interface/Implement/ContainerImpl.h" 3 | #include "Interface\Implement\YapImplement.h" 4 | #include "Grappa.h" 5 | 6 | 7 | using namespace Yap; 8 | 9 | BEGIN_DECL_PROCESSORS 10 | ADD_PROCESSOR(Grappa) 11 | END_DECL_PROCESSORS 12 | 13 | BOOL APIENTRY DllMain(HMODULE hModule, 14 | DWORD ul_reason_for_call, 15 | LPVOID lpReserved 16 | ) 17 | { 18 | switch (ul_reason_for_call) 19 | { 20 | case DLL_PROCESS_ATTACH: 21 | 22 | break; 23 | case DLL_THREAD_ATTACH: 24 | case DLL_THREAD_DETACH: 25 | case DLL_PROCESS_DETACH: 26 | break; 27 | } 28 | return TRUE; 29 | } 30 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/ReadNiiPathFiles.py: -------------------------------------------------------------------------------- 1 | """ 2 | return the names of path included files and the 3 | included-dir files' name. 4 | 5 | """ 6 | 7 | import os 8 | 9 | 10 | def walk_dir(paths,topdown=True): 11 | files_name = [] 12 | for root, dirs, files in os.walk(paths, topdown): 13 | for name in files: 14 | files_name.append(os.path.join(root,name)) 15 | return files_name 16 | 17 | 18 | if __name__ == "__main__": 19 | dir = input('please input the path:') 20 | dir = r'D:\数据\MICCAI_BraTS17_Data_Training_for_TGuo_2017modified\Brats17TrainingData\HGG' 21 | files = walk_dir(dir) 22 | -------------------------------------------------------------------------------- /BasicRecon_GPU/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Interface/Implement/ContainerImpl.h" 3 | #include "Interface\Implement\YapImplement.h" 4 | #include "cuFft2D.h" 5 | 6 | 7 | using namespace Yap; 8 | 9 | BEGIN_DECL_PROCESSORS 10 | ADD_PROCESSOR(cuFft2D) 11 | END_DECL_PROCESSORS 12 | 13 | BOOL APIENTRY DllMain(HMODULE hModule, 14 | DWORD ul_reason_for_call, 15 | LPVOID lpReserved 16 | ) 17 | { 18 | switch (ul_reason_for_call) 19 | { 20 | case DLL_PROCESS_ATTACH: 21 | 22 | break; 23 | case DLL_THREAD_ATTACH: 24 | case DLL_THREAD_DETACH: 25 | case DLL_PROCESS_DETACH: 26 | break; 27 | } 28 | return TRUE; 29 | } 30 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test_niumag_recon_yaplocal.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\Projects\\Yap2\\API\\ReconDemo\\data\\UU.img.fid"); 4 | SliceIterator slice_iterator; 5 | DcRemover dc_remover; 6 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 7 | Fft2D fft; 8 | ModulePhase module_phase; 9 | JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\test_Niuimg\\1"); 10 | 11 | reader->slice_iterator; 12 | slice_iterator->dc_remover; 13 | dc_remover->zero_filling; 14 | zero_filling->fft; 15 | fft->module_phase; 16 | module_phase.Module->jpeg_exporter; 17 | 18 | 19 | self.Input->reader.Input; 20 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/NiuMriImageWriter.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\test_data\\UU.img.fid"); 4 | SliceIterator slice_iterator; 5 | RemoveDC dc_remover; 6 | ZeroFilling zero_filling(DestWidth = 1024, DestHeight = 1024); 7 | Fft2D fft; 8 | ModulePhase module_phase; 9 | DataTypeConvertor convertor; 10 | NiuMriImageWriter writer(ExportFolder = "d:\\Output"); 11 | 12 | reader->slice_iterator; 13 | slice_iterator->dc_remover; 14 | dc_remover->zero_filling; 15 | zero_filling->fft; 16 | fft->module_phase; 17 | module_phase.Module->convertor; 18 | convertor.UnsignedShort->writer; 19 | 20 | self.Input->reader.Input; 21 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiumagFidWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef NiumagFidWriter_h__ 3 | #define NiumagFidWriter_h__ 4 | 5 | #include "Implement/processorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class NiumagFidWriter : 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(NiumagFidWriter) 13 | public: 14 | NiumagFidWriter(void); 15 | NiumagFidWriter(const NiumagFidWriter& rhs); 16 | 17 | private: 18 | ~NiumagFidWriter(); 19 | 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | std::wstring GetFilePath(const wchar_t * output_folder, const wchar_t * ouput_name); 22 | }; 23 | } 24 | 25 | #endif // NiumagFidWriter_h__ 26 | 27 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/JpegExporter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef JpegExporter_h__20160814 4 | #define JpegExporter_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | namespace details { class JpegExporterImp; } 11 | 12 | class JpegExporter : 13 | public ProcessorImpl 14 | { 15 | IMPLEMENT_SHARED(JpegExporter) 16 | public: 17 | JpegExporter(); 18 | JpegExporter(const JpegExporter& rhs); 19 | 20 | protected: 21 | ~JpegExporter(); 22 | 23 | virtual bool Input(const wchar_t * name, IData * data) override; 24 | 25 | std::shared_ptr _impl; 26 | }; 27 | } 28 | 29 | #endif // JpegExporter_h__ 30 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FolderCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef FolderCollector_h__20180117 3 | #define FolderCollector_h__20180117 4 | 5 | #include "Implement\ProcessorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class FolderCollector : public ProcessorImpl 10 | { 11 | IMPLEMENT_SHARED(FolderCollector) 12 | public: 13 | FolderCollector(); 14 | FolderCollector(const FolderCollector&); 15 | 16 | virtual bool Input(const wchar_t * name, IData * data) override; 17 | 18 | private: 19 | ~FolderCollector(); 20 | 21 | std::map> _collector; 22 | unsigned int _count = 0; 23 | 24 | }; 25 | } 26 | #endif // !FolderCollector_h__20180117 27 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiuMriImageWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef NiuMriImageWriter_h__ 3 | #define NiuMriImageWriter_h__ 4 | 5 | #include "Implement/processorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class NiuMriImageWriter : 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(NiuMriImageWriter) 13 | public: 14 | NiuMriImageWriter(void); 15 | NiuMriImageWriter(const NiuMriImageWriter& rhs); 16 | 17 | private: 18 | ~NiuMriImageWriter(); 19 | 20 | virtual bool Input(const wchar_t * name, IData * data) override; 21 | 22 | std::wstring GetFilePath(const wchar_t * output_folder, const wchar_t * ouput_name); 23 | }; 24 | } 25 | 26 | #endif // NiuMriImageWriter_h__ 27 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/niumag_recon.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader; 4 | SliceIterator slice_iterator; 5 | DcRemover dc_remover; 6 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 7 | Fft2D fft; 8 | ModulePhase module_phase; 9 | //JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\2"); 10 | DataTypeConvertor convertor; 11 | Display2D display2d; 12 | 13 | reader->slice_iterator; 14 | slice_iterator->dc_remover; 15 | dc_remover->zero_filling; 16 | zero_filling->fft; 17 | fft->module_phase; 18 | //module_phase.Module->jpeg_exporter; 19 | module_phase.Module->convertor; 20 | convertor.UnsignedShort->display2d; 21 | 22 | self.Input->reader.Input; 23 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/DeOversampling.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef DeOversampling_h__20160814 4 | #define DeOversampling_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class DeOversampling : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(DeOversampling) 14 | public: 15 | DeOversampling(); 16 | DeOversampling(const DeOversampling& rhs); 17 | 18 | protected: 19 | ~DeOversampling(); 20 | virtual bool Input(const wchar_t * port, IData * data) override; 21 | bool FreqInput(const wchar_t * port, IData * data); 22 | bool ProcessOverSampling(const wchar_t * port, IData * data); 23 | 24 | }; 25 | } 26 | #endif // DeOversampling_h__ 27 | -------------------------------------------------------------------------------- /Shared/Interface/IPython.h: -------------------------------------------------------------------------------- 1 | #ifndef _IPython_h__ 2 | #define _IPython_h__ 3 | #pragma once 4 | 5 | #ifndef OUT 6 | #define OUT 7 | #endif 8 | 9 | namespace Yap { 10 | 11 | struct IPython 12 | { 13 | virtual void* Process(const wchar_t* module_name, const wchar_t* method_name, int data_type, int out_data_type, 14 | size_t input_dimensions, void * data, OUT size_t &output_dimensions, size_t input_size[], 15 | OUT size_t output_size[], bool is_need_ref_data = 0) = 0; 16 | 17 | virtual void SetRefData(void * roi_data, int data_type, size_t dimension_count, size_t size[]) = 0; 18 | 19 | virtual void DeleteRefData() = 0; 20 | virtual ~IPython() = 0 {}; 21 | }; 22 | 23 | }; 24 | 25 | #endif -------------------------------------------------------------------------------- /Shared/PythonImplement/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "PythonImpl.h" 2 | #include 3 | 4 | // dllmain.cpp : Defines the entry point for the DLL application. 5 | 6 | using namespace Yap; 7 | 8 | extern "C" { 9 | _declspec(dllexport) IPython * GetPython() 10 | { 11 | return PythonFactory::GetPython(); 12 | } 13 | }; 14 | 15 | BOOL APIENTRY DllMain(HMODULE hModule, 16 | DWORD ul_reason_for_call, 17 | LPVOID lpReserved 18 | ) 19 | { 20 | switch (ul_reason_for_call) 21 | { 22 | case DLL_PROCESS_ATTACH: 23 | 24 | break; 25 | case DLL_THREAD_ATTACH: 26 | break; 27 | case DLL_THREAD_DETACH: 28 | break; 29 | case DLL_PROCESS_DETACH: 30 | break; 31 | } 32 | return TRUE; 33 | } 34 | -------------------------------------------------------------------------------- /Shared/Interface/ILog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ILog_h__ 3 | #define ILog_h__ 4 | 5 | namespace Yap 6 | { 7 | enum LogLevel 8 | { 9 | LevelTrace, 10 | LevelDebug, 11 | LevelInfo, 12 | LevelWarn, 13 | LevelError, 14 | LevelFatal, 15 | }; 16 | 17 | struct ILogUser; 18 | struct ILog 19 | { 20 | virtual void Log(const wchar_t * module, const wchar_t * info, LogLevel level, const wchar_t * log_name = L"", bool flush = false) = 0; 21 | virtual void AddUser(ILogUser * user) = 0; 22 | virtual void RemoveUser(ILogUser * user) = 0; 23 | }; 24 | 25 | struct ILogUser 26 | { 27 | virtual void SetLog(ILog * log) = 0; 28 | }; 29 | } 30 | 31 | #endif // ILog_h__ -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FileIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef FileIterator_h__20171228 4 | #define FileIterator_h__20171228 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class FileIterator : public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(FileIterator) 13 | public: 14 | FileIterator(); 15 | 16 | FileIterator(const FileIterator &); 17 | 18 | bool Input(const wchar_t * name, IData * data); 19 | 20 | private: 21 | ~FileIterator(); 22 | 23 | void NotifyIterationFinished(IData * data); 24 | 25 | void GetFiles(std::vector& folders, std::wstring path, bool is_subfolder, std::wstring regular_exp); 26 | 27 | }; 28 | } 29 | 30 | #endif // !FileIterator_h__20171228 31 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NLM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | #include "Client/DataHelper.h" 4 | #include 5 | 6 | namespace Yap 7 | { 8 | class NLM : 9 | public ProcessorImpl 10 | { 11 | IMPLEMENT_SHARED(NLM) 12 | public: 13 | NLM(void); 14 | NLM(const NLM& rhs); 15 | 16 | protected: 17 | ~NLM(); 18 | 19 | virtual bool Input(const wchar_t * name, IData * data) override; 20 | 21 | void nlmeans(float * input_img, float * output_img, unsigned int pl_r, 22 | unsigned int sw_r, float sigma, float h, unsigned int width, unsigned int height); 23 | arma::fmat GetGaussianKernel(int pl, float sigma); 24 | 25 | float GetSigma(float * input_img, unsigned int width, unsigned int height); 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SimpleGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef SimpleGrid_h__20160814 4 | #define SimpleGrid_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class SimpleGrid : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(SimpleGrid) 14 | public: 15 | SimpleGrid(); 16 | SimpleGrid(const SimpleGrid& rhs); 17 | 18 | protected: 19 | ~SimpleGrid(); 20 | virtual bool Input(const wchar_t * port, IData * data) override; 21 | void TestSetup(IData *data); 22 | void FillKSpace(std::complex * slice, int width, int height, 23 | std::complex * radial, int columns, float angle, float center, float delta_k, bool OnlykPosition); 24 | 25 | }; 26 | } 27 | #endif // SimpleGrid_h__ 28 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ZeroFilling.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ZeroFilling_h__20160814 4 | #define ZeroFilling_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class ZeroFilling : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(ZeroFilling) 14 | public: 15 | ZeroFilling(); 16 | ZeroFilling(const ZeroFilling& rhs); 17 | 18 | protected: 19 | ~ZeroFilling(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | unsigned int GetFillingCount(IData* data, int dest_width, int dest_height, int dest_depth); 23 | void UpdateStartLength(const int input_length, int &dest_start, int &dest_length, bool same = false); 24 | 25 | }; 26 | } 27 | #endif // ZeroFilling_h__ 28 | -------------------------------------------------------------------------------- /Shared/Interface/IPythonUser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _IPythonUser_h__ 3 | #define _IPythonUser_h__ 4 | 5 | #include "IPython.h" 6 | 7 | namespace Yap { 8 | 9 | struct IPythonUser 10 | { 11 | virtual void SetPython(IPython& python) = 0; 12 | 13 | virtual void SetReferenceData(void * data, int data_type, int input_dimensions, size_t * input_size) = 0; 14 | 15 | virtual void * PythonProcess(const wchar_t* module, const wchar_t* method, 16 | int data_type, int out_data_type, size_t input_dimensions, 17 | void * data, OUT size_t& output_dimensions, 18 | size_t input_size[], OUT size_t output_size[], 19 | bool is_need_ref_data) = 0; 20 | 21 | virtual void DeleteRefData() = 0; 22 | }; 23 | } 24 | 25 | #endif // !_IPythonUser_h__ 26 | 27 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/my_utility/classTree.py: -------------------------------------------------------------------------------- 1 | """ 2 | Check Class or object class-tree and show in screen 3 | """ 4 | 5 | import types 6 | 7 | 8 | def subtree(classes, tab): 9 | print('.' * tab + classes.__name__) 10 | for super in classes.__bases__: 11 | subtree(super,tab + 3) 12 | 13 | def tree(object): 14 | if type(object) == type(int): # check is not class type 15 | object = object() 16 | 17 | print('Tree of %s' % object) 18 | subtree(object.__class__,3) 19 | 20 | 21 | if __name__ == '__main__': 22 | class A: pass 23 | class B(A): pass 24 | class C(A): pass 25 | class D(B,C): pass 26 | class E: pass 27 | class F(D,E): pass 28 | tree(B()) 29 | tree(F()) 30 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/test_niumag_recon.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\Projects\\Niumag\\data\\UU.img.fid"); 4 | SliceIterator slice_iterator; 5 | DcRemover dc_remover; 6 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 7 | Fft2D fft; 8 | ModulePhase module_phase; 9 | DataTypeConvertor convertor; 10 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output\\test_niuman"); 11 | //NiuMriDisplay2D display2d; 12 | 13 | reader->slice_iterator; 14 | slice_iterator->dc_remover; 15 | dc_remover->zero_filling; 16 | zero_filling->fft; 17 | fft->module_phase; 18 | module_phase.Module->convertor; 19 | //convertor.UnsignedShort->display2d; 20 | convertor.UnsignedShort->jpeg_exporter; 21 | 22 | self.Input->reader.Input; 23 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/RFeaturesCollector.h: -------------------------------------------------------------------------------- 1 | /* Radiomics Features Collector */ 2 | #pragma once 3 | 4 | #ifndef RadiomicsFeaturesCollector_h__20171229 5 | #define RadiomicsFeaturesCollector_h__20171229 6 | 7 | #include "Implement\ProcessorImpl.h" 8 | 9 | namespace Yap 10 | { 11 | class RFeaturesCollector : public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(RFeaturesCollector) 14 | public: 15 | RFeaturesCollector(); 16 | RFeaturesCollector(const RFeaturesCollector&); 17 | 18 | virtual bool Input(const wchar_t * name, IData * data) override; 19 | 20 | private: 21 | ~RFeaturesCollector(); 22 | 23 | std::map> _collector; 24 | unsigned int _count = 0; 25 | 26 | }; 27 | } 28 | #endif // !ExtractFeaturesFeaturesCollector_h__20171229 29 | -------------------------------------------------------------------------------- /Shared/Utilities/Clipboard.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | Filename: Clipboard.h 3 | Created: 2011/02/14 4 | Author: Yang Guang, gyang@phy.ecnu.edu.cn 5 | Purpose: 6 | 7 | All right reserved. 2009 - 8 | 9 | Shanghai Key Laboratory of Magnetic Resonance, 10 | East China Normal University 11 | *********************************************************************/ 12 | 13 | #ifndef Clipboard_h__20110214 14 | #define Clipboard_h__20110214 15 | 16 | #include 17 | 18 | #pragma once 19 | namespace Utilities 20 | { 21 | class CClipboard 22 | { 23 | public: 24 | static CString GetClipboardText(); 25 | static bool SetClipboardText(const TCHAR * text); 26 | }; 27 | 28 | } 29 | 30 | 31 | #endif // Clipboard_h__20110214 -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiumagFidReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef NiumagFidReader_h__ 3 | #define NiumagFidReader_h__ 4 | 5 | #include "Implement/processorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | /// Class used to read fid data file created by Niumag. 10 | /** 11 | Feel nullptr to the "Input" port to trigger file reading. 12 | "Output" data will be of type Unsigned Int. 13 | */ 14 | class NiumagFidReader : 15 | public ProcessorImpl 16 | { 17 | IMPLEMENT_SHARED(NiumagFidReader) 18 | public: 19 | NiumagFidReader(void); 20 | NiumagFidReader(const NiumagFidReader& rhs); 21 | 22 | private: 23 | ~NiumagFidReader(); 24 | 25 | virtual bool Input(const wchar_t * name, IData * data) override; 26 | 27 | bool ReadNiumagFidData(); 28 | }; 29 | } 30 | 31 | #endif // NiumagFidReader_h__ -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/grappa.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | import "GrappaRecon.dll"; 3 | 4 | CmrRawDataReader reader(DataPath = "D:\\test_data\\RawData_256\\RawData", 5 | ChannelCount = 4, ChannelSwitch = 15); 6 | SliceSelector slice_selector; 7 | Fft2D fft; 8 | ModulePhase module_phase; 9 | Grappa grappa; 10 | ChannelDataCollector data_collector; 11 | ChannelMerger channel_merger; 12 | ChannelIterator channel_iterator; 13 | 14 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 15 | 16 | reader->slice_selector; 17 | 18 | slice_selector->data_collector; 19 | data_collector->grappa; 20 | grappa->channel_iterator; 21 | channel_iterator->fft; 22 | fft->module_phase; 23 | module_phase.Module->channel_merger; 24 | channel_merger->jpeg_exporter; 25 | 26 | self.Input->reader.Input; -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiumagImgReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef NiumagImgReader_h__ 3 | #define NiumagImgReader_h__ 4 | 5 | #include "Implement/processorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | /// Class used to read img data file created by Niumag. 10 | /** 11 | Feel nullptr to the "Input" port to trigger file reading. 12 | "Output" data will be of type Unsigned Int. 13 | */ 14 | class NiumagImgReader : 15 | public ProcessorImpl 16 | { 17 | IMPLEMENT_SHARED(NiumagImgReader) 18 | public: 19 | NiumagImgReader(void); 20 | NiumagImgReader(const NiumagImgReader& rhs); 21 | 22 | private: 23 | ~NiumagImgReader(); 24 | 25 | virtual bool Input(const wchar_t * name, IData * data) override; 26 | 27 | bool ReadNiumagImgData(); 28 | }; 29 | } 30 | 31 | 32 | #endif // NiumagImgReader_h__ -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/NiuMriImageReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef NiuMriImageReader_h__ 3 | #define NiuMriImageReader_h__ 4 | 5 | #include "Implement/processorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | /// Class used to read .niuimg data file created by Niumag. 10 | /** 11 | Feel nullptr to the "Input" port to trigger file reading. 12 | "Output" data will be of type Unsigned Int. 13 | */ 14 | class NiuMriImageReader : 15 | public ProcessorImpl 16 | { 17 | IMPLEMENT_SHARED(NiuMriImageReader) 18 | public: 19 | NiuMriImageReader(void); 20 | NiuMriImageReader(const NiuMriImageReader& rhs); 21 | 22 | private: 23 | ~NiuMriImageReader(); 24 | 25 | virtual bool Input(const wchar_t * name, IData * data) override; 26 | 27 | bool ReadNiuMriImageData(); 28 | }; 29 | } 30 | 31 | 32 | #endif // NiuMriImageReader_h__ -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader(DataPath = "D:\\Data\\cmr_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 15); 5 | 6 | //SliceIterator slice_iterator; 7 | SliceSelector slice_selector(SliceIndex = 3); 8 | DcRemover dc_remover; 9 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 10 | 11 | Fft2D fft; 12 | ModulePhase module_phase; 13 | ChannelMerger channel_merge(ChannelCount = 4 ); 14 | JpegExporter jpeg_exporter(ExportFolder = "D:\\output\\test_cmr"); 15 | 16 | reader->slice_selector; 17 | slice_selector->dc_remover; 18 | dc_remover->zero_filling; 19 | zero_filling->fft; 20 | fft->module_phase; 21 | //module_phase.Module->jpeg_exporter; 22 | module_phase.Module->channel_merge; 23 | channel_merge->jpeg_exporter; 24 | 25 | 26 | self.Input->reader.Input; 27 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/my_utility/reloadall.py: -------------------------------------------------------------------------------- 1 | """ 2 | reloadall.py: reload all modules in the load line 3 | """ 4 | 5 | import types 6 | from imp import reload 7 | 8 | 9 | def status(module): 10 | print('reloading ' + module.__name__) 11 | 12 | 13 | def transitive_reload(module,visited): 14 | if not module in visited: 15 | status(module) 16 | reload(module) 17 | visited[module] = None 18 | for attrobj in module.__dict__.values(): 19 | if type(attrobj) == types.ModuleType : 20 | transitive_reload(attrobj, visited) 21 | 22 | 23 | def reload_all(*args): 24 | visited = {} 25 | for arg in args: 26 | if type(arg) == types.ModuleType: 27 | transitive_reload(arg, visited) 28 | 29 | 30 | if __name__ == '__main__': 31 | import reloadall 32 | reload_all(reloadall) 33 | -------------------------------------------------------------------------------- /Shared/Utilities/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 2 | // (the "Fluent UI") and is provided only as referential material to supplement the 3 | // Microsoft Foundation Classes Reference and related electronic documentation 4 | // included with the MFC C++ library software. 5 | // License terms to copy, use or distribute the Fluent UI are available separately. 6 | // To learn more about our Fluent UI licensing program, please visit 7 | // http://go.microsoft.com/fwlink/?LinkId=238214. 8 | // 9 | // Copyright (C) Microsoft Corporation 10 | // All rights reserved. 11 | 12 | // stdafx.cpp : source file that includes just the standard includes 13 | // Painter.pch will be the pre-compiled header 14 | // stdafx.obj will contain the pre-compiled type information 15 | 16 | #include "stdafx.h" 17 | 18 | 19 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ComplexSplitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ComplexSplitter_h__20160813 4 | #define ComplexSplitter_h__20160813 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | #include "Client/DataHelper.h" 8 | 9 | namespace Yap 10 | { 11 | class ComplexSplitter :public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(ComplexSplitter) 14 | public: 15 | ComplexSplitter(); 16 | ComplexSplitter(const ComplexSplitter& rhs); 17 | 18 | protected: 19 | ~ComplexSplitter(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | 23 | void Split(std::complex * data, double * real, double * imaginary, size_t size); 24 | void ExtractReal(std::complex * data, double * real, size_t size); 25 | void ExtractImaginary(std::complex * data, double * imaginary, size_t size); 26 | }; 27 | } 28 | #endif // ComplexSplitter_h__ 29 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/RadialSampling.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef RadiaolSampling_h__20160814 3 | #define RadiaolSampling_h__20160814 4 | 5 | #include "Implement/ProcessorImpl.h" 6 | #include 7 | #include 8 | 9 | namespace Yap 10 | { 11 | class RadialSampling : 12 | public ProcessorImpl 13 | { 14 | IMPLEMENT_SHARED(RadialSampling) 15 | public: 16 | RadialSampling(); 17 | RadialSampling(const RadialSampling& rhs); 18 | 19 | protected: 20 | ~RadialSampling(); 21 | 22 | virtual bool Input(const wchar_t * port, IData * data) override; 23 | 24 | boost::shared_array> 25 | GetRadialLine(std::complex * input_data2D, 26 | unsigned int width, unsigned int height, 27 | int columns, float angle, int center, float delta_k); 28 | 29 | private: 30 | //SmartPtr _mask; 31 | 32 | }; 33 | } 34 | 35 | #endif //RadiaolSampling_h__ -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/CompressedSensing.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | import "CompressedSensing.dll"; 3 | 4 | CmrRawDataReader reader(DataPath = "D:\\test_data\\RawData_256\\RawData", 5 | ChannelCount = 4, ChannelSwitch = 15); 6 | SliceSelector slice_selector1; 7 | SliceSelector slice_selector2; 8 | 9 | 10 | Fft2D fft; 11 | SamplingMaskCreator mask_creator; 12 | SubSampling sub_sampling; 13 | ModulePhase module_phase; 14 | CompressedSensing compressed_sensing; 15 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 16 | 17 | reader->slice_selector1; 18 | reader->slice_selector2; 19 | 20 | slice_selector1->mask_creator; 21 | mask_creator->sub_sampling.Mask; 22 | mask_creator->compressed_sensing.Mask; 23 | slice_selector2->sub_sampling.Input; 24 | sub_sampling->compressed_sensing.Input; 25 | 26 | compressed_sensing->fft; 27 | fft->module_phase; 28 | module_phase.Module->jpeg_exporter; 29 | 30 | self.Input->reader.Input; -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/FFT3DTest.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\TestData\\3DSE\\rat.fid"); 4 | ZeroFilling zero_filling(DestWidth = 256, DestHeight = 256, DestDepth = 20); 5 | SliceIterator slice_iterator; 6 | Fft3D fft; 7 | ModulePhase module_phase; 8 | GrayScaleUnifier gray_scale_unifier; 9 | DataTypeConvertor data_type_convertor; 10 | JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\3DRecon", StretchPixelData = false); 11 | //NiuMriImageWriter img_writer(ExportFolder = "d:\\Output"); 12 | 13 | reader->zero_filling; 14 | zero_filling->fft; 15 | fft->module_phase; 16 | module_phase.Module->gray_scale_unifier; 17 | gray_scale_unifier->data_type_convertor; 18 | //module_phase.Module->data_type_convertor; 19 | data_type_convertor.UnsignedShort->slice_iterator; 20 | slice_iterator->jpeg_exporter; 21 | //data_type_convertor.UnsignedShort->img_writer; 22 | 23 | self.Input->reader.Input; -------------------------------------------------------------------------------- /Shared/Implement/TypeManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef TypeManager_h__20180129 3 | #define TypeManager_h__20180129 4 | 5 | #include 6 | #include 7 | #include "interface/smartptr.h" 8 | #include "interface/IVariable.h" 9 | 10 | namespace Yap 11 | { 12 | class TypeManager 13 | { 14 | public: 15 | TypeManager(); 16 | ~TypeManager(); 17 | 18 | void Reset(); 19 | bool AddType(const wchar_t * type_id, IVariable * type); 20 | bool AddType(const wchar_t * type_id, IVariableContainer * variables); 21 | bool TypeExists(const wchar_t * type) const; 22 | IVariable * CreateInstance(const wchar_t * type, const wchar_t * id) const; 23 | IVariable * CreateArray(const wchar_t * element_type_id, const wchar_t * id, size_t size); 24 | protected: 25 | bool InitTypes(); 26 | 27 | std::map> _types; 28 | }; 29 | } 30 | 31 | #endif // TypeManager_h__20180129 32 | 33 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/PyClassification.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef PyClassification_h_20180319 4 | #define PyClassification_h_20180319 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | 11 | class PyClassification: public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(PyClassification) 14 | public: 15 | PyClassification(); 16 | ~PyClassification(); 17 | virtual bool Input(const wchar_t * name, IData * data) override; 18 | 19 | private: 20 | void* PythonRunScript(IData * data, OUT int & output_type, Dimensions& dimensions, 21 | OUT size_t & output_dims, size_t output_size[]); 22 | 23 | void CreateDimension(Dimensions & dimensions, size_t output_dims, size_t * output_size); 24 | 25 | bool FeedOut(IData * inut_data, void* out_data, Dimensions dimensions, int data_type, size_t size); 26 | 27 | size_t GetTotalSize(size_t dimension_count, size_t size[]); 28 | 29 | }; 30 | } 31 | #endif // !PyClassification_h_20180319 32 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FolderIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _FolderIterator_h__20171227 4 | #define _FolderIterator_h__20171227 5 | 6 | #include "Implement\ProcessorImpl.h" 7 | #include 8 | 9 | #ifndef _MAX_PATH 10 | #define _MAX_PATH 260 // max. length of full pathname 11 | #endif // !_MAX_PATH 12 | 13 | #ifndef _MAX_FNAME 14 | #define _MAX_FNAME 256 // max. length of file name component 15 | #endif // !_MAX_FNAME 16 | 17 | 18 | namespace Yap 19 | { 20 | class FolderIterator : public ProcessorImpl { 21 | IMPLEMENT_SHARED(FolderIterator) 22 | public: 23 | FolderIterator(); 24 | FolderIterator(const FolderIterator&); 25 | 26 | virtual bool Input(const wchar_t * name, IData * data) override; 27 | 28 | private: 29 | ~FolderIterator(); 30 | 31 | void GetFolders(std::vector& folder,std::wstring path, bool recursive, std::wstring regex); 32 | 33 | void NotifyIterationFinished(); 34 | 35 | }; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Shared/Utilities/targetver.h: -------------------------------------------------------------------------------- 1 | // This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 2 | // (the "Fluent UI") and is provided only as referential material to supplement the 3 | // Microsoft Foundation Classes Reference and related electronic documentation 4 | // included with the MFC C++ library software. 5 | // License terms to copy, use or distribute the Fluent UI are available separately. 6 | // To learn more about our Fluent UI licensing program, please visit 7 | // http://go.microsoft.com/fwlink/?LinkId=238214. 8 | // 9 | // Copyright (C) Microsoft Corporation 10 | // All rights reserved. 11 | 12 | #pragma once 13 | 14 | // Including SDKDDKVer.h defines the highest available Windows platform. 15 | 16 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 17 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 18 | 19 | #include 20 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Radiomics_test2.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | import "PythonRecon.dll"; 3 | 4 | FolderIterator folders(Path = "D:\\BRATS2017\\Brats17TrainingData\\HGG", 5 | RecursiveSearch = false); 6 | FilesIterator files(FileRegEx = "*.nii", RecursiveSearch = false, ReferenceRegEx = ".*seg.nii"); 7 | NiiReader ref_reader; 8 | NiiReader img_reader; 9 | Radiomics radiomicshandle(ScriptPath = 10 | "D:\\Projects\\YAP\\PluginSDK\\PythonRecon\\Python\\demo_test.py", 11 | MethodName = "test_radiomics", ReturnDataType = 16); //16-Double 12 | RFeaturesCollector rf_collector; 13 | CaseCollector case; 14 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output2"); 15 | 16 | folders->files; 17 | files.Reference->ref_reader; 18 | files.Output->img_reader; 19 | ref_reader->radiomicshandle.Reference; 20 | img_reader->radiomicshandle.Input; 21 | radiomicshandle->rf_collector; 22 | rf_collector->case; 23 | case->jpeg_exporter; 24 | 25 | 26 | self.Input->folders.Input; 27 | 28 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test1b.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | IceReceiver receiver; 3 | ChannelMerger channel_merger(ChannelCount = 4, ChannelSwitch = 15); 4 | SliceSelector slice_selector(SliceIndex =1); 5 | 6 | DcRemover dc_remover; 7 | 8 | ZeroFilling zero_filling(DestWidth = 256, DestHeight = 256); 9 | 10 | 11 | Fft2D fft; 12 | 13 | IcePeFt peft; 14 | ChannelMerger cha_mer; 15 | ModulePhase module_phase; 16 | 17 | JpegExporter jpeg_exporter(ExportFolder = "d:\\output\\test_pipeline"); 18 | 19 | 20 | //receiver->slice_selector; 21 | 22 | //slice_selector->dc_remover; 23 | 24 | //receiver->dc_remover; 25 | //dc_remover->zero_filling; 26 | 27 | //zero_filling->channel_merger; 28 | //channel_merger->module_phase; 29 | //module_phase.Module->jpeg_exporter; 30 | 31 | 32 | 33 | //self.Input->receiver.Input; 34 | 35 | 36 | receiver->zero_filling; 37 | 38 | zero_filling->peft; 39 | peft->module_phase; 40 | module_phase.Module->jpeg_exporter; 41 | 42 | 43 | 44 | self.Input->receiver.Input; 45 | 46 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelDataCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | 4 | namespace Yap 5 | { 6 | class ChannelDataCollector : 7 | public ProcessorImpl 8 | { 9 | IMPLEMENT_SHARED(ChannelDataCollector) 10 | public: 11 | ChannelDataCollector(void); 12 | ChannelDataCollector(const ChannelDataCollector& rhs); 13 | 14 | protected: 15 | ~ChannelDataCollector(void); 16 | 17 | virtual bool Input(const wchar_t * name, IData * data) override; 18 | struct CollectorBuffer 19 | { 20 | SmartPtr buffer; 21 | unsigned int count; 22 | 23 | CollectorBuffer() : count(0) {} 24 | CollectorBuffer(CollectorBuffer& rhs) : count(rhs.count), buffer(rhs.buffer) {} 25 | CollectorBuffer(CollectorBuffer&& rhs) : count(rhs.count), buffer(rhs.buffer) {} 26 | 27 | ~CollectorBuffer() {} 28 | }; 29 | 30 | std::vector GetKey(IDimensions * dimensions); 31 | std::map, CollectorBuffer> _collector_buffers; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0_FFT3D.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader(DataPath = "D:\\Data\\cmr_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 13); 5 | 6 | ChannelSelector channel_selector(ChannelIndex=2); 7 | ZeroFilling zero_filling(DestWidth = 256, DestHeight = 256, DestDepth = 20); 8 | 9 | Fft3D fft; 10 | ModulePhase module_phase; 11 | ChannelImageDataCollector data_collector; 12 | ChannelMerger channel_merge; 13 | DataTypeConvertor convertor; 14 | SliceIterator slice_iterator; 15 | JpegExporter jpeg_exporter(ExportFolder = "D:\\output\\test0_fft3d"); 16 | 17 | //-------------- 18 | reader->channel_selector; 19 | channel_selector->fft;//zero_filling; 20 | //zero_filling->fft; 21 | fft->module_phase; 22 | 23 | //merge. 24 | module_phase.Module->data_collector; 25 | data_collector->channel_merge; 26 | channel_merge->convertor; 27 | convertor.UnsignedShort->slice_iterator; 28 | slice_iterator->jpeg_exporter; 29 | 30 | self.Input->reader.Input; 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/DataTypeConvertor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef DataTypeConvertor_h__201609 4 | #define DataTypeConvertor_h__201609 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | class DataTypeConvertor : 11 | public ProcessorImpl 12 | { 13 | IMPLEMENT_SHARED(DataTypeConvertor) 14 | public: 15 | DataTypeConvertor(void); 16 | DataTypeConvertor(const DataTypeConvertor& rhs); 17 | 18 | protected: 19 | ~DataTypeConvertor(); 20 | 21 | virtual bool Input(const wchar_t * port, IData * data) override; 22 | 23 | template 24 | bool ConvertAndFeed(IData * input_data); 25 | 26 | template 27 | Yap::SmartPtr GetConvertedData(IData* input_object); 28 | template 29 | Yap::SmartPtr Convert(IData * input, int output_type); 30 | 31 | const wchar_t * GetPortName(int data_type); 32 | static std::map s_data_type_to_port; 33 | }; 34 | } 35 | 36 | #endif // DataTypeConvertor_h__ -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test1-pjf.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | IceReceiver receiver(ListenPort = 8888); 3 | ChannelMerger channel_merger(ChannelCount = 4, ChannelSwitch = 15); 4 | SliceSelector slice_selector(SliceIndex =1); 5 | 6 | DcRemover dc_remover; 7 | 8 | ZeroFilling zero_filling(DestWidth = 256, DestHeight = 256); 9 | 10 | 11 | Fft2D fft; 12 | 13 | IcePeFt peft; 14 | ChannelMerger cha_mer; 15 | ModulePhase module_phase; 16 | 17 | JpegExporter jpeg_exporter(ExportFolder = "d:\\output\\test_pipeline"); 18 | 19 | 20 | //receiver->slice_selector; 21 | 22 | //slice_selector->dc_remover; 23 | 24 | //receiver->dc_remover; 25 | //dc_remover->zero_filling; 26 | 27 | //zero_filling->channel_merger; 28 | //channel_merger->module_phase; 29 | //module_phase.Module->jpeg_exporter; 30 | 31 | 32 | 33 | //self.Input->receiver.Input; 34 | 35 | 36 | receiver->zero_filling; 37 | 38 | zero_filling->peft; 39 | peft->module_phase; 40 | module_phase.Module->jpeg_exporter; 41 | 42 | 43 | 44 | self.Input->receiver.Input; 45 | 46 | -------------------------------------------------------------------------------- /Shared/Interface/IContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef IContainer_h__20170803 3 | #define IContainer_h__20170803 4 | 5 | namespace Yap 6 | { 7 | template 8 | struct IIterator : public IDynamicObject 9 | { 10 | virtual ELEMENT_TYPE * GetFirst() = 0; 11 | virtual ELEMENT_TYPE * GetNext() = 0; 12 | }; 13 | 14 | template 15 | struct IPtrContainer : public ISharedObject 16 | { 17 | typedef IIterator Iterator; 18 | 19 | virtual ELEMENT_TYPE * Find(const wchar_t * name) = 0; 20 | virtual Iterator * GetIterator() = 0; 21 | virtual bool Add(const wchar_t * name, ELEMENT_TYPE * element) = 0; 22 | virtual bool Delete(const wchar_t * name) = 0; 23 | virtual void Clear() = 0; 24 | }; 25 | 26 | template 27 | struct IPtrArray : public ISharedObject 28 | { 29 | virtual unsigned int GetSize() const = 0; 30 | virtual ELEMENT_TYPE *& Element(unsigned int index) = 0; 31 | }; 32 | 33 | } 34 | 35 | #endif // IContainer_h__ -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/ExtractFeatures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ExtractFeatures_h__20171223 3 | #define ExtractFeatures_h__20171223 4 | 5 | #include "Implement\ProcessorImpl.h" 6 | 7 | namespace Yap 8 | { 9 | class ExtractFeatures : 10 | public ProcessorImpl 11 | { 12 | IMPLEMENT_SHARED(ExtractFeatures) 13 | public: 14 | 15 | explicit ExtractFeatures(); 16 | 17 | ExtractFeatures(const ExtractFeatures& rhs); 18 | 19 | virtual bool Input(const wchar_t * port, IData * data) override; 20 | 21 | private: 22 | ~ExtractFeatures(); 23 | 24 | void CreateDimension(Dimensions& dimensions, size_t output_dims, size_t * output_size); 25 | 26 | bool FeedOut(IData * data, void* out_data, Dimensions dimensions, int data_type, size_t size); 27 | 28 | size_t GetTotalSize(size_t dimension_count, size_t size[]); 29 | 30 | bool SetRefData(IData * data); 31 | 32 | void* PythonRunScript(IData * data, OUT int & output_type, Dimensions& dimensions, 33 | OUT size_t & output_dims, size_t output_size[]); 34 | 35 | SmartPtr _ref_data; 36 | }; 37 | 38 | } 39 | #endif -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/my_utility/AttrDisplay.py: -------------------------------------------------------------------------------- 1 | # SubTest how to get the attribution attr1 & attr2 ??? 2 | # ( instance y can get x attribution) 3 | # Is superclass's instance inherited to the subclass's instance ? 4 | 5 | class AttrDisplay: 6 | 7 | def __init__(self): 8 | self.name = 'base class' 9 | 10 | def gatherAttrs(self): 11 | attr = [] 12 | for key in sorted(self.__dict__): 13 | attr.append('%s=%s'% (key,getattr(self,key))) 14 | return ','.join(attr) 15 | 16 | def __str__(self): 17 | return '[%s : %s]' %(self.__class__.__name__, self.gatherAttrs()) 18 | 19 | 20 | if __name__ == '__main__': 21 | class TopTest(AttrDisplay): 22 | count = 0 23 | def __init__(self): 24 | self.lastname = AttrDisplay().name 25 | self.attr1 = TopTest.count 26 | self.attr2 = TopTest.count + 1 27 | TopTest.count += 2 28 | 29 | 30 | class SubTest(TopTest): 31 | pass 32 | 33 | 34 | x,y = TopTest(), SubTest() 35 | print(x) 36 | print(y) 37 | 38 | -------------------------------------------------------------------------------- /Shared/Implement/LogImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGIMPL_H_20170425 2 | #define LOGIMPL_H_20170425 3 | #pragma once 4 | 5 | #include "Interface/Interfaces.h" 6 | 7 | #define USE_LOG4CPLUS_V1 8 | 9 | #include 10 | #include 11 | 12 | #ifndef USE_LOG4CPLUS_V1 13 | #include 14 | #endif 15 | 16 | namespace log4cplus { class Logger; } 17 | 18 | namespace Yap 19 | { 20 | class LogImpl : 21 | public ILog 22 | { 23 | public: 24 | ~LogImpl(); 25 | 26 | virtual void Log(const wchar_t * module, const wchar_t * info, LogLevel level, const wchar_t * log_name = L"", bool flush = true) override; 27 | virtual void AddUser(ILogUser * user) override; 28 | virtual void RemoveUser(ILogUser * user) override; 29 | 30 | 31 | static LogImpl& GetInstance(); 32 | protected: 33 | LogImpl(); 34 | static bool Init(); 35 | static std::shared_ptr s_instance; 36 | #ifndef USE_LOG4CPLUS_V1 37 | log4cplus::Initializer initializer; 38 | #endif 39 | std::map _loggers; 40 | std::vector _users; 41 | }; 42 | } 43 | 44 | #endif // LOGIMPL_H_ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 MR-algorithms 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Fft2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef fft2d_h_20160813 4 | #define fft2d_h_20160813 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | #include "Client/DataHelper.h" 8 | #include 9 | #include 10 | 11 | namespace Yap 12 | { 13 | class Fft2D : 14 | public ProcessorImpl 15 | { 16 | IMPLEMENT_SHARED(Fft2D) 17 | public: 18 | Fft2D(); 19 | Fft2D(const Fft2D& rhs); 20 | 21 | protected: 22 | ~Fft2D(); 23 | 24 | virtual bool Input(const wchar_t * port, IData * data) override; 25 | 26 | void FftShift(std::complex* data, size_t width, size_t height); 27 | void SwapBlock(std::complex * block1, std::complex * block2, size_t width, size_t height, size_t line_stride); 28 | 29 | unsigned int _plan_data_width; 30 | unsigned int _plan_data_height; 31 | bool _plan_inverse; 32 | bool _plan_in_place; 33 | fftwf_plan _fft_plan; 34 | 35 | bool Fft(std::complex * data, std::complex * result, size_t width, size_t height, bool inverse = false); 36 | void Plan(size_t width, size_t height, bool inverse, bool in_place); 37 | void Log(float ms); 38 | }; 39 | } 40 | 41 | #endif // !fft2d_h_20160813 42 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Fft3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef FFT3D_H_20171026 4 | #define FFT3D_H_20171026 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | #include 8 | #include 9 | 10 | namespace Yap 11 | { 12 | class Fft3D : 13 | public ProcessorImpl 14 | { 15 | IMPLEMENT_SHARED(Fft3D) 16 | public: 17 | Fft3D(); 18 | Fft3D(const Fft3D& rhs); 19 | 20 | protected: 21 | ~Fft3D(); 22 | 23 | virtual bool Input(const wchar_t * port, IData * data) override; 24 | 25 | bool Fft(std::complex * data, std::complex * result, 26 | size_t width, size_t height, size_t depth, bool inverse = false); 27 | void Plan(size_t width, size_t height, size_t depth, bool inverse, bool in_place); 28 | void FftShift(std::complex* data, size_t width, size_t height, size_t depth); 29 | void SwapBlock(std::complex * block1, std::complex * block2, size_t width, size_t height, size_t line_stride); 30 | 31 | unsigned int _plan_data_width; 32 | unsigned int _plan_data_height; 33 | unsigned int _plan_data_depth; 34 | bool _plan_inverse; 35 | bool _plan_in_place; 36 | fftwf_plan _fft_plan; 37 | }; 38 | } 39 | 40 | #endif // FFT3D_H_ 41 | -------------------------------------------------------------------------------- /API/Yap/ModuleAgent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ProcessorManagerAgent_h__20160813 4 | #define ProcessorManagerAgent_h__20160813 5 | 6 | #include "Interface/Interfaces.h" 7 | #include 8 | 9 | #include "PythonImplement\PythonImpl.h" 10 | #ifdef _DEFINE_PYTHON 11 | #define SET_PYTHON_2USER(_module) \ 12 | { \ 13 | auto python_func = (Yap::IPythonUser*(*)())::GetProcAddress(_module, "GetPythonUser"); \ 14 | if (python_func != nullptr)\ 15 | {\ 16 | auto python_user = python_func(); \ 17 | if (python_user != nullptr)\ 18 | {\ 19 | python_user->SetPython(PythonFactory::GetPython()); \ 20 | }\ 21 | }\ 22 | } 23 | #else 24 | #define SET_PYTHON_2USER(_module) 25 | #endif // _DEFINE_PYTHON 26 | 27 | namespace Yap 28 | { 29 | class ModuleAgent 30 | { 31 | public: 32 | ModuleAgent(); 33 | 34 | bool Load(const wchar_t * plugin_path); 35 | IProcessor * Find(const wchar_t * name); 36 | IProcessorIter * GetIterator(); 37 | bool Add(const wchar_t * name, IProcessor * processor); 38 | 39 | ~ModuleAgent(); 40 | 41 | protected: 42 | 43 | HINSTANCE _module; 44 | SmartPtr _manager; 45 | }; 46 | 47 | } 48 | #endif // ProcessorManagerAgent_h__ 49 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/CalcuArea.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CalcuArea.h" 3 | #include "Implement/LogUserImpl.h" 4 | #include "Client/DataHelper.h" 5 | 6 | #include 7 | 8 | 9 | using namespace Yap; 10 | CalcuArea::CalcuArea() : 11 | ProcessorImpl(L"CalcuArea") 12 | { 13 | AddInput(L"Input", 1, DataTypeDouble); 14 | AddProperty(L"Area", 0, L"Area of function or sum of data"); 15 | } 16 | 17 | CalcuArea::CalcuArea(const CalcuArea& rhs) : 18 | ProcessorImpl(rhs) 19 | { 20 | } 21 | 22 | CalcuArea::~CalcuArea() 23 | { 24 | } 25 | 26 | bool Yap::CalcuArea::Input(const wchar_t * name, IData * data) 27 | { 28 | if (data == nullptr && _wcsicmp(name, L"Input") != 0) 29 | return false; 30 | if (data->GetDataType() != DataTypeDouble) 31 | return false; 32 | 33 | DataHelper input_data(data); 34 | if (input_data.GetActualDimensionCount() != 1) 35 | return false; 36 | 37 | unsigned int width = input_data.GetWidth(); 38 | 39 | std::vector temp_data(width, 0); 40 | std::memcpy(temp_data.data(), GetDataArray(data), width * sizeof(double)); 41 | double area = accumulate(temp_data.begin(), temp_data.end(), 0.0); 42 | SetProperty(L"Area", area); 43 | 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Radiomics_test.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | import "PythonRadiomics.dll"; 3 | 4 | FolderIterator folders(Path1 = "D:\\test_data\\braTS17_test\\HGG", 5 | Path2 = "D:\\test_data\\braTS17_test\\LGG", 6 | RecursiveSearch = false); 7 | 8 | FileIterator files(FileRegEx = ".*.nii", RecursiveSearch = false, ReferenceRegEx = ".*seg.nii"); 9 | 10 | NiiReader ref_reader; 11 | NiiReader img_reader; 12 | 13 | ExtractFeatures extractor(ScriptPath = 14 | "D:\\Projects\\YAP\\PluginSDK\\PythonRecon\\Python\\demo_test.py", 15 | MethodName = "extract_feature", ReturnDataType = 16); //16-Double 16 | 17 | RFeaturesCollector rf_collector; 18 | FolderCollector foldercollect; 19 | PyClassification classify(ScriptPath = 20 | "D:\\Projects\\YAP\\PluginSDK\\PythonRecon\\Python\\classify.py", 21 | MethodName = "classified", ReturnDataType = 16); 22 | // JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 23 | 24 | folders->files; 25 | files.Reference->ref_reader; 26 | files.Output->img_reader; 27 | ref_reader->extractor.Reference; 28 | img_reader->extractor.Input; 29 | extractor->rf_collector; 30 | rf_collector->foldercollect; 31 | foldercollect->classify; 32 | 33 | 34 | self.Input->folders.Input; 35 | 36 | -------------------------------------------------------------------------------- /Shared/Implement/details/variableShared.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "interface/interfaces.h" 3 | #include "interface/smartptr.h" 4 | #include "interface/IVariable.h" 5 | 6 | #include 7 | #include 8 | 9 | #define IMPLEMENT_VARIABLE_NO_ENABLE public: \ 10 | virtual int GetType() const override { return _type;} \ 11 | virtual const wchar_t * GetId() const override { return _id.c_str(); }\ 12 | virtual void SetId(const wchar_t * id) override { _id = id; } \ 13 | virtual const wchar_t * GetTitle() const override { return _title.c_str();}\ 14 | virtual void SetTitle(const wchar_t * title) override { _title = title;}\ 15 | virtual const wchar_t * GetDescription() const override { return _description.c_str(); } \ 16 | virtual void SetDescription(const wchar_t * description) override { _description = description; }\ 17 | protected: \ 18 | std::wstring _id; \ 19 | std::wstring _description; \ 20 | std::wstring _title;\ 21 | int _type; 22 | 23 | #define IMPLEMENT_VARIABLE IMPLEMENT_VARIABLE_NO_ENABLE \ 24 | public: \ 25 | virtual void Enable(bool enable) { _enabled = enable;} \ 26 | virtual bool IsEnabled() const override { return _enabled;} \ 27 | protected: \ 28 | bool _enabled; 29 | 30 | -------------------------------------------------------------------------------- /API/Yap/PipelineCompiler.h: -------------------------------------------------------------------------------- 1 | #ifndef PipelineCompiler_h__ 2 | #define PipelineCompiler_h__ 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Implement/CompositeProcessor.h" 13 | #include "Preprocessor.h" 14 | 15 | namespace Yap 16 | { 17 | class CompositeProcessor; 18 | class PipelineConstructor; 19 | 20 | class PipelineCompiler 21 | { 22 | public: 23 | PipelineCompiler(); 24 | ~PipelineCompiler(); 25 | 26 | SmartPtr CompileFile(const wchar_t * path); 27 | SmartPtr Compile(const wchar_t * text); 28 | 29 | protected: 30 | SmartPtr DoCompile(std::wistream& input); 31 | 32 | bool ProcessImport(Tokens& statement); 33 | bool ProcessPortLink(Tokens& statement); 34 | bool ProcessDeclaration(Tokens& statement); 35 | bool ProcessPropertyMapping(Tokens& statement); 36 | bool ProcessAssignment(Tokens& statement); 37 | 38 | std::shared_ptr _preprocessor; 39 | std::shared_ptr _constructor; 40 | 41 | bool Process(); 42 | }; 43 | } 44 | 45 | #endif // PipelineCompiler_h__ 46 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/my_utility/AttrDisplay1.py: -------------------------------------------------------------------------------- 1 | class ListInherited: 2 | """if __repr__ insteaded of __str__, it will happen recursion 3 | For 'attr' in for-circle is string, it will call __repr__ again""" 4 | def __str__(self): 5 | return '' % (self.__class__.__name__, id(self), self.__attrnames()) 6 | 7 | def __attrnames(self): 8 | result = '' 9 | for attr in sorted(dir(self)): 10 | if attr[:2] == '__' and attr[-2:] == '__': 11 | result += '\tname %s = <>\n' % attr 12 | else: 13 | result += '\tname %s = %s\n' % (attr,getattr(self, attr)) 14 | 15 | return result 16 | 17 | 18 | 19 | if __name__== '__main__': 20 | class Super: 21 | def __init__(self): 22 | self.data1 = 'super data1' 23 | def ham(self): 24 | pass 25 | def getIt(name): 26 | print(name) 27 | 28 | class Sub(Super, ListInherited): 29 | def __init__(self): 30 | Super.__init__(self) 31 | self.data2 = 'sub data2' 32 | self.data3 = 42 33 | 34 | def spam(self): 35 | pass 36 | 37 | 38 | x = Sub() 39 | print(x) 40 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelMerger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ChannelMerger_h__20160813 4 | #define ChannelMerger_h__20160813 5 | 6 | #include "Implement/processorimpl.h" 7 | #include "Client/DataHelper.h" 8 | 9 | namespace Yap 10 | { 11 | class ChannelMerger : 12 | public ProcessorImpl 13 | { 14 | IMPLEMENT_SHARED(ChannelMerger) 15 | public: 16 | ChannelMerger(void); 17 | ChannelMerger(const ChannelMerger& rhs); 18 | 19 | protected: 20 | ~ChannelMerger(void); 21 | 22 | virtual bool Input(const wchar_t * name, IData * data) override; 23 | virtual bool OnTimer() override; 24 | 25 | void Log(float ms); 26 | /* 27 | struct MergeBuffer 28 | { 29 | SmartPtr buffer; 30 | unsigned int count; 31 | 32 | MergeBuffer() : count(0){} 33 | MergeBuffer(MergeBuffer& rhs) : count(rhs.count), buffer(rhs.buffer) {} 34 | MergeBuffer(MergeBuffer&& rhs) : count(rhs.count), buffer(rhs.buffer) {} 35 | 36 | virtual ~MergeBuffer() {} 37 | }; 38 | bool HasChannelDimension(IDimensions *dimensions) const; 39 | std::vector GetKey(IDimensions * dimensions); 40 | std::map, MergeBuffer> _merge_buffers; 41 | */ 42 | 43 | }; 44 | } 45 | 46 | #endif // ChannelMerger_h__ 47 | 48 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0b.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader(DataPath = "D:\\Data\\cpptest_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 15); 5 | // property mapping can also be used in named property initialization. such as: 6 | // CmrRawDataReader reader(DataPath <== data_path, 7 | // ChannelCount = 4, ChannelSwitch = 15); 8 | // where data_path is the variable id in global variable space, reference a variable holding the data file path. 9 | 10 | SliceSelector slice_selector(SliceIndex = 3); 11 | DcRemover dc_remover; 12 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 13 | 14 | //zero_filling.DestWidth <== ImageWidth; // from variable space to property 15 | // zero_filling.DestWidth ==> ImageWidth; // from property to variable space. Only for demo, meaning-less in this context. 16 | // zero_filling.DestWidth <=> ImageWidth; // bi-directional 17 | 18 | Fft2D fft; 19 | ModulePhase module_phase; 20 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output\\test_pipeline"); 21 | 22 | reader->slice_selector; 23 | slice_selector->dc_remover; 24 | dc_remover->zero_filling; 25 | zero_filling->fft; 26 | fft->module_phase; 27 | module_phase.Module->jpeg_exporter; 28 | 29 | 30 | self.Input->reader.Input; 31 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelImageDataCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | 4 | namespace Yap 5 | { 6 | class ChannelImageDataCollector : 7 | public ProcessorImpl 8 | { 9 | IMPLEMENT_SHARED(ChannelImageDataCollector) 10 | public: 11 | ChannelImageDataCollector(void); 12 | ChannelImageDataCollector(const ChannelImageDataCollector& rhs); 13 | 14 | protected: 15 | ~ChannelImageDataCollector(void); 16 | 17 | virtual bool Input(const wchar_t * name, IData * data) override; 18 | 19 | void Log(int channel_index, int slice_index, int ready_phasesteps); 20 | 21 | struct CollectorBuffer 22 | { 23 | SmartPtr buffer; 24 | unsigned int count; 25 | int ready_phasesteps; 26 | 27 | CollectorBuffer() : count(0), ready_phasesteps(-1) {} 28 | CollectorBuffer(CollectorBuffer& rhs) : count(rhs.count), ready_phasesteps(rhs.ready_phasesteps), buffer(rhs.buffer) {} 29 | CollectorBuffer(CollectorBuffer&& rhs) : count(rhs.count), ready_phasesteps(rhs.ready_phasesteps), buffer(rhs.buffer) {} 30 | 31 | ~CollectorBuffer() {} 32 | }; 33 | 34 | std::vector GetKey(IDimensions * dimensions); 35 | std::map, CollectorBuffer> _collector_buffers; 36 | 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Nlmeans.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Implement\ProcessorImpl.h" 3 | #include 4 | 5 | #define MAX(i, j) ((i) < (j) ? (j) : (i)) 6 | #define MIN(i, j) ((i) < (j) ? (i) : (j)) 7 | 8 | #define dTiny 1e-10 9 | #define fTiny 0.00000001f 10 | #define fLarge 100000000.0f 11 | 12 | #define LUTMAX 30.0 13 | #define LUTMAXM1 29.0 14 | #define LUTPRECISION 1000.0 15 | 16 | namespace Yap 17 | { 18 | class Nlmeans : 19 | public ProcessorImpl 20 | { 21 | IMPLEMENT_SHARED(Nlmeans) 22 | public: 23 | Nlmeans(void); 24 | Nlmeans(const Nlmeans& rhs); 25 | 26 | protected: 27 | ~Nlmeans(); 28 | 29 | virtual bool Input(const wchar_t * name, IData * data) override; 30 | 31 | void nlmeans_ipol(unsigned int iDWin, unsigned int iDBloc, float Sigma, float fFiltPar, 32 | float * fpI, float * fpO, unsigned int iWidth, unsigned int iHeight); 33 | 34 | float fiL2FloatDist(float * u0, float *u1, unsigned int i0, unsigned int j0, 35 | unsigned int i1, unsigned int j1, int radius, unsigned int width0, unsigned int width1); 36 | 37 | void wxFillExpLut(float *lut, unsigned int size); 38 | 39 | float wxSLUT(float dif, float *lut); 40 | 41 | float GetSigma(float * input_img, unsigned int width, unsigned int height); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/Radiomics_assist.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | 4 | 5 | def ReplaceSlash(paths): 6 | for path_list_name in paths: 7 | index = 0 8 | if type(paths[path_list_name]) == list: 9 | for item in paths[path_list_name]: 10 | paths[path_list_name][index] = str(item.replace('/', '\\')) 11 | index += 1 12 | return paths 13 | 14 | 15 | def ExtractFiles(folder_path, keys): 16 | paths = {} 17 | paths['t2_path'] = glob.glob(folder_path + keys['T2']) 18 | paths['adc_path'] = glob.glob(folder_path + keys['ADC']) 19 | dwi_path = glob.glob(folder_path + keys['DWI']) 20 | paths['dwi_path'] = [x for x in dwi_path if not (x in paths['adc_path'])] 21 | paths['ca_path'] = glob.glob(folder_path + keys['malignant']) 22 | non_ca_path = glob.glob(folder_path + keys['allROI']) 23 | paths['non_ca_path']= [x for x in non_ca_path if not (x in paths['ca_path'])] 24 | return ReplaceSlash(paths) 25 | 26 | 27 | def ShowResults(result): 28 | for x in result.items(): 29 | print(x) 30 | 31 | def CatchFileName(file_path): 32 | files = file_path.split('\\') 33 | command = 'echo ' + files[-1] + '| clip' 34 | os.system(command) 35 | return files[-1] 36 | 37 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrRawDataReader reader(DataPath = "C:\\ThirdProject\\YAP-master\\API\\PipelineTest\\test_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 15); 5 | // property mapping can also be used in named property initialization. such as: 6 | // CmrRawDataReader reader(DataPath <== data_path, 7 | // ChannelCount = 4, ChannelSwitch = 15); 8 | // where data_path is the variable id in global variable space, reference a variable holding the data file path. 9 | 10 | SliceSelector slice_selector; 11 | DcRemover dc_remover; 12 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 13 | 14 | //zero_filling.DestWidth <== ImageWidth; // from variable space to property 15 | // zero_filling.DestWidth ==> ImageWidth; // from property to variable space. Only for demo, meaning-less in this context. 16 | // zero_filling.DestWidth <=> ImageWidth; // bi-directional 17 | 18 | Fft2D fft; 19 | ModulePhase module_phase; 20 | JpegExporter jpeg_exporter(ExportFolder = "d:\\Output"); 21 | 22 | reader->slice_selector; 23 | slice_selector->dc_remover; 24 | dc_remover->zero_filling; 25 | zero_filling->fft; 26 | fft->module_phase; 27 | module_phase.Module->jpeg_exporter; 28 | 29 | 30 | self.Input->reader.Input; 31 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Fft1D.h: -------------------------------------------------------------------------------- 1 | #ifndef Fft1D_h__20160813 2 | #define Fft1D_h__20160813 3 | 4 | #pragma once 5 | #include "Implement/ProcessorImpl.h" 6 | #include "Client/DataHelper.h" 7 | #include "fftw3.h" 8 | #include 9 | #include 10 | 11 | namespace Yap 12 | { 13 | class Fft1D : 14 | public ProcessorImpl 15 | { 16 | IMPLEMENT_SHARED(Fft1D) 17 | public: 18 | Fft1D(); 19 | Fft1D(const Fft1D& rhs); 20 | 21 | protected: 22 | ~Fft1D(); 23 | 24 | virtual bool Input(const wchar_t * port, IData * data) override; 25 | 26 | template 27 | void FFTShift(std::complex* data, size_t size); 28 | 29 | template 30 | void SwapBlock(std::complex * block1, std::complex * block2, 31 | size_t width); 32 | 33 | unsigned int _plan_data_size; 34 | bool _plan_inverse; 35 | bool _plan_in_place; 36 | 37 | fftwf_plan _fft_plan_float; 38 | fftw_plan _fft_plan_double; 39 | 40 | template bool DoFft(IData * data, size_t size); 41 | 42 | template 43 | bool Fft(std::complex * data, std::complex * result, 44 | size_t size, bool inverse = false); 45 | 46 | template 47 | void Plan(size_t size, bool inverse, bool in_place); 48 | }; 49 | } 50 | 51 | #endif // Fft1D_h__ 52 | -------------------------------------------------------------------------------- /Shared/Implement/YapImplement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef YapImplement_h_20160831 4 | #define YapImplement_h_20160831 5 | 6 | #include "ContainerImpl.h" 7 | 8 | #define BEGIN_DECL_PROCESSORS PtrContainerImpl * g_processor_manager;\ 9 | extern "C" {\ 10 | __declspec(dllexport) void ReleaseProcessManager(){\ 11 | if (g_processor_manager) {\ 12 | ISharedObject* obj = g_processor_manager;\ 13 | obj->Release();\ 14 | g_processor_manager = nullptr;\ 15 | }\ 16 | }\ 17 | __declspec(dllexport) IProcessorContainer * GetProcessorManager()\ 18 | {\ 19 | if (g_processor_manager)\ 20 | return g_processor_manager;\ 21 | g_processor_manager = new (std::nothrow) PtrContainerImpl;\ 22 | if (!g_processor_manager) return nullptr;\ 23 | ((ISharedObject*) g_processor_manager)->Lock(); 24 | 25 | #define ADD_PROCESSOR(class_name) try{\ 26 | auto * my##class_name = new class_name; \ 27 | g_processor_manager->Add(my##class_name->GetClassId(), my##class_name);\ 28 | }\ 29 | catch(...){\ 30 | return nullptr;\ 31 | }\ 32 | 33 | #define ADD(a, b) {auto pb = b; \ 34 | g_processor_manager->Add((a), pb);}\ 35 | 36 | #define END_DECL_PROCESSORS return g_processor_manager;\ 37 | }\ 38 | } //end extern "C" 39 | 40 | #endif -------------------------------------------------------------------------------- /Shared/Utilities/CommonMethod.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | namespace CommonMethod 8 | { 9 | void split_index(const int index, const int width, const int height, int& column, int& row); 10 | int GetChannelCountUsed(unsigned int channel_switch); 11 | bool IsChannelOn(int channel_switch, int channel_index); 12 | template 13 | bool IsComplexelementZero(ElementType *data, int data_count) 14 | { 15 | 16 | std::vector temp; 17 | temp.resize(data_count); 18 | //method1: 19 | for (int i = 0; i < data_count; i++) 20 | { 21 | temp[i] = abs(data[i]); 22 | 23 | } 24 | auto result = std::minmax_element(temp.data(), temp.data() + data_count); 25 | float min_data = *result.first; 26 | float max_data = *result.second; 27 | 28 | bool result1; 29 | if (max_data < FLT_EPSILON) 30 | result1 = true; 31 | else 32 | result1 = false; 33 | 34 | //method2: 35 | bool result2 = true; 36 | for (ElementType *iterater = data; iterater != data + data_count; ++iterater) 37 | { 38 | if (abs(*iterater)> FLT_EPSILON) 39 | { 40 | 41 | result2 = false; 42 | break; 43 | } 44 | 45 | } 46 | assert(result1 == result2); 47 | return result2; 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/CmrDataReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CmrDataReader_h__20160813 4 | #define CmrDataReader_h__20160813 5 | 6 | #include "Implement/processorImpl.h" 7 | 8 | namespace Yap 9 | { 10 | /// Class used to read raw data file created by CMR. 11 | /** 12 | \remarks Properties: 13 | DataPath: specifies the path of the folder containing raw data file. 14 | ChannelCount: specifies the number of the total channels. 15 | ChannelSwitch: specifies which channels are used. 16 | GroupCount: specifies how many groups are used in the scan. 17 | 18 | Feel nullptr to the "Input" port to trigger file reading. 19 | "Output" data will be of type ComplexFloat. 20 | */ 21 | class CmrDataReader : 22 | public ProcessorImpl 23 | { 24 | IMPLEMENT_SHARED(CmrDataReader) 25 | public: 26 | CmrDataReader(void); 27 | CmrDataReader(const CmrDataReader& rhs); 28 | 29 | private: 30 | ~CmrDataReader(); 31 | 32 | virtual bool Input(const wchar_t * name, IData * data) override; 33 | virtual bool OnTimer() override; 34 | 35 | bool ReadRawData(unsigned int channel_index, int channel_dimension_index); 36 | float* ReadEcnuFile(const wchar_t * file_path, unsigned int& width, unsigned int& height, 37 | unsigned int& slices, unsigned int& dim4); 38 | }; 39 | } 40 | 41 | 42 | #endif // CmrDataReader_h__ 43 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0_simple.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader2(DataPath = "D:\\Data\\cmr_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 13); 5 | 6 | SliceIterator slice_iterator; 7 | ChannelSelector channel_selector(ChannelIndex=2); 8 | DcRemover dc_remover; 9 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 10 | Fft2D fft; 11 | DeOversampling de_oversampling(FreqOverSampling = true, PhaseOverSampling = true); 12 | ModulePhase module_phase; 13 | DataTypeConvertor convertor; 14 | ChannelImageDataCollector data_collector; 15 | ChannelMerger channel_merge; 16 | JpegExporter jpeg_exporter(ExportFolder = "D:\\output\\test0_qt_pipeline"); 17 | Flip flip; 18 | DrawlineOnImage draw_line(ScaleY=0.8); 19 | //----------------------------------------------- 20 | reader2->channel_selector; 21 | channel_selector->slice_iterator; 22 | slice_iterator->dc_remover; 23 | 24 | //FT. 25 | dc_remover->zero_filling; 26 | zero_filling->fft; 27 | fft->module_phase; 28 | //de_oversampling->module_phase; 29 | 30 | //merge. 31 | module_phase.Module->data_collector; 32 | data_collector->channel_merge; 33 | //channel_merge->jpeg_exporter; 34 | channel_merge->convertor; 35 | convertor.UnsignedShort->flip; 36 | flip->draw_line; 37 | draw_line->jpeg_exporter; 38 | 39 | // 40 | self.Input->reader2.Input; 41 | 42 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/PartialFFT.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | NiumagFidReader reader(DataPath = "D:\\TestData\\PartialFft.fid"); 4 | SliceIterator slice_iterator; 5 | LinesSelector lines_selector1(FirstLineIndex = 0, LinesCount = 118); 6 | LinesSelector lines_selector2(FirstLineIndex = 145, LinesCount = 40); 7 | ZeroFilling zero_filling1(DestWidth = 256, DestHeight = 256); 8 | ZeroFilling zero_filling2(DestWidth = 256, DestHeight = 256); 9 | Fft2D fft2d_1; 10 | Fft2D fft2d_2; 11 | Fft2D fft2d_3(Inverse = true); 12 | Fft2D fft2d_4; 13 | Fft2D fft2d_5(Inverse = true); 14 | Fft2D fft2d_6; 15 | ModulePhase module_phase1; 16 | ModulePhase module_phase2; 17 | PhaseCorrector phase_corrector; 18 | Conjugator conjugator; 19 | JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\PartialFFT"); 20 | 21 | reader->slice_iterator; 22 | slice_iterator->lines_selector1; 23 | lines_selector1->zero_filling1; 24 | 25 | zero_filling1->lines_selector2; 26 | lines_selector2->zero_filling2; 27 | zero_filling2->fft2d_1; 28 | fft2d_1->module_phase1; 29 | module_phase1.Phase->phase_corrector.Phase; 30 | 31 | zero_filling1->fft2d_2; 32 | fft2d_2->phase_corrector; 33 | phase_corrector->fft2d_3; 34 | fft2d_3->conjugator; 35 | conjugator->fft2d_4; 36 | fft2d_4->fft2d_5; 37 | fft2d_5->fft2d_6; 38 | fft2d_6->module_phase2; 39 | module_phase2.Module->jpeg_exporter; 40 | 41 | self.Input->reader.Input; -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0_RadialSampling.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader2(DataPath = "D:\\Data\\cmr_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 13); 5 | 6 | ChannelSelector channel_selector(ChannelIndex=2); 7 | DcRemover dc_remover; 8 | //SliceIterator slice_iterator; 9 | SliceSelector slice_selector(SliceIndex=3); 10 | RadialSampling radial_sampling(RadialColumns=256, LineCount=100); 11 | SimpleGrid simple_grid(DestWidth = 512, DestHeight = 512, RadialData = true); 12 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 13 | Fft2D fft; 14 | DeOversampling de_oversampling(FreqOverSampling = true, PhaseOverSampling=true); 15 | ModulePhase module_phase; 16 | DataTypeConvertor convertor; 17 | Flip flip; 18 | JpegExporter jpeg_exporter(ExportFolder = "D:\\output\\test0_qt_pipeline"); 19 | //--------------------------------------------------------------- 20 | reader2->channel_selector; 21 | //channel_selector->slice_iterator; 22 | //slice_iterator->radial_sampling; 23 | 24 | channel_selector->slice_selector; 25 | slice_selector->radial_sampling; 26 | 27 | radial_sampling->simple_grid; 28 | simple_grid->zero_filling; 29 | zero_filling->fft; 30 | fft->de_oversampling; 31 | de_oversampling->module_phase; 32 | 33 | module_phase.Module->convertor; 34 | convertor.UnsignedShort->flip; 35 | flip->jpeg_exporter; 36 | 37 | self.Input->reader2.Input; 38 | 39 | -------------------------------------------------------------------------------- /GrappaRecon/Grappa.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Grappa_h__20160814 4 | #define Grappa_h__20160814 5 | 6 | #include "Interface/Implement/ProcessorImpl.h" 7 | #include "Interface/Client/DataHelper.h" 8 | #include 9 | #include 10 | 11 | 12 | namespace Yap 13 | { 14 | class Grappa : 15 | public ProcessorImpl 16 | { 17 | public: 18 | Grappa(void); 19 | Grappa(const Grappa& rhs); 20 | virtual ~Grappa(); 21 | 22 | virtual IProcessor * Clone() override; 23 | virtual bool Input(const wchar_t * port, IData * data) override; 24 | 25 | protected: 26 | bool Recon(std::complex * subsampled_data, 27 | unsigned int r, unsigned int acs, unsigned int Block, unsigned int width, unsigned int height, unsigned int num_coil); 28 | 29 | std::complex * MakeFidelity(std::complex * recon_data, std::vector> acs_data, 30 | unsigned int r, unsigned int acs, unsigned int width, unsigned int height, unsigned int num_coil); 31 | arma::cx_fmat FitCoef(std::complex * subsampled_data, 32 | unsigned int R, unsigned int acs, unsigned int Block, unsigned int Width, unsigned int height, unsigned int Num_coil); 33 | 34 | std::vector> GetAcsData(std::complex * data, 35 | unsigned int r, unsigned int acs, unsigned int width, unsigned int height, unsigned int num_coil); 36 | }; 37 | } 38 | #endif // Grappa_h__ 39 | 40 | 41 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/DrawlineOnImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef DrawlineOnImage_h__20160814 3 | #define DrawlineOnImage_h__20160814 4 | 5 | #include "Implement/ProcessorImpl.h" 6 | #include 7 | #include 8 | 9 | namespace Yap 10 | { 11 | template 12 | struct SimplePoint 13 | { 14 | T x; 15 | T y; 16 | SimplePoint(T _x, T _y) { x = _x; y = _y; } 17 | ~SimplePoint() {}; 18 | }; 19 | 20 | class DrawlineOnImage : 21 | public ProcessorImpl 22 | { 23 | IMPLEMENT_SHARED(DrawlineOnImage) 24 | public: 25 | DrawlineOnImage(); 26 | DrawlineOnImage(const DrawlineOnImage& rhs); 27 | 28 | protected: 29 | ~DrawlineOnImage(); 30 | 31 | virtual bool Input(const wchar_t * port, IData * data) override; 32 | template 33 | void Drawline(IN_TYPE* input_data2D, unsigned int width, unsigned int height, 34 | double* line1D, unsigned int size, double scaley); 35 | template 36 | void SetPixel(IN_TYPE* input_data2D, unsigned int width, unsigned int height, unsigned int x, unsigned int y, IN_TYPE value); 37 | template 38 | void LineTo(IN_TYPE* input_data2D, unsigned int width, unsigned int height, int x1, int y1, int x2, int y2); 39 | 40 | private: 41 | //SmartPtr _mask; 42 | boost::shared_array GetTestline(int size); 43 | 44 | 45 | }; 46 | } 47 | 48 | #endif //DrawlineOnImage_h__ -------------------------------------------------------------------------------- /API/Yap/ProcessorAgent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ProcessorAgent_h__20160813 4 | #define ProcessorAgent_h__20160813 5 | 6 | #include "Interface/Interfaces.h" 7 | 8 | namespace Yap 9 | { 10 | class VariableSpace; 11 | 12 | class ProcessorAgent 13 | { 14 | public: 15 | ProcessorAgent(IProcessor * processor); 16 | virtual ~ProcessorAgent(); 17 | 18 | public: 19 | const wchar_t * GetClassId() const; 20 | void SetClassId(const wchar_t * id); 21 | const wchar_t * GetInstanceId() const; 22 | void SetInstanceId(const wchar_t * instance_id); 23 | 24 | IPortContainer * Inputs(); 25 | IPortContainer * Outputs(); 26 | IVariableContainer * GetProperties(); 27 | 28 | bool LinkProperty(const wchar_t * property_id, const wchar_t * param_id, bool input, bool output); 29 | bool UpdateProperties(IVariableContainer * params); 30 | bool Link(const wchar_t * output, IProcessor * next, const wchar_t * next_input); 31 | bool Input(const wchar_t * name, IData * data); 32 | 33 | bool SetInt(const wchar_t * property_name, int value); 34 | bool SetBool(const wchar_t * property_name, bool value); 35 | bool SetFloat(const wchar_t * property_name, double value); 36 | bool SetString(const wchar_t* property_name, const wchar_t* value); 37 | 38 | operator bool(); 39 | protected: 40 | SmartPtr _processor; 41 | std::shared_ptr _variables; 42 | }; 43 | } 44 | 45 | #endif // ProcessorAgent_h__ 46 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | #include "Implement\LogUserImpl.h" 5 | #include "Implement\YapImplement.h" 6 | 7 | #include "FileIterator.h" 8 | #include "FolderIterator.h" 9 | #include "NiiReader.h" 10 | #include "ExtractFeatures.h" 11 | #include "RFeaturesCollector.h" 12 | #include "Implement\PythonUserImpl.h" 13 | #include "FolderCollector.h" 14 | #include "PyClassification.h" 15 | 16 | using namespace Yap; 17 | extern "C" { 18 | _declspec(dllexport) IPythonUser * GetPythonUser() 19 | { 20 | return &PythonUserImpl::GetInstance(); 21 | } 22 | _declspec(dllexport) ILogUser* GetLogUser() 23 | { 24 | return (ILogUser*)&LogUserImpl::GetInstance(); 25 | } 26 | }; 27 | 28 | BEGIN_DECL_PROCESSORS 29 | ADD_PROCESSOR(FolderCollector) 30 | ADD_PROCESSOR(FileIterator) 31 | ADD_PROCESSOR(FolderIterator) 32 | ADD_PROCESSOR(NiiReader) 33 | ADD_PROCESSOR(ExtractFeatures) 34 | ADD_PROCESSOR(RFeaturesCollector) 35 | ADD_PROCESSOR(PyClassification) 36 | END_DECL_PROCESSORS 37 | 38 | BOOL APIENTRY DllMain(HMODULE hModule, 39 | DWORD ul_reason_for_call, 40 | LPVOID lpReserved 41 | ) 42 | { 43 | switch (ul_reason_for_call) 44 | { 45 | case DLL_PROCESS_ATTACH: 46 | 47 | break; 48 | case DLL_THREAD_ATTACH: 49 | break; 50 | case DLL_THREAD_DETACH: 51 | break; 52 | case DLL_PROCESS_DETACH: 53 | break; 54 | } 55 | return TRUE; 56 | } 57 | -------------------------------------------------------------------------------- /Shared/PythonImplement/PythonImplement.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Shared/PythonImplement/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | STATIC LIBRARY : PythonImplement Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this PythonImplement library project for you. 6 | 7 | No source files were created as part of your project. 8 | 9 | 10 | PythonImplement.vcxproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | PythonImplement.vcxproj.filters 17 | This is the filters file for VC++ projects generated using an Application Wizard. 18 | It contains information about the association between the files in your project 19 | and the filters. This association is used in the IDE to show grouping of files with 20 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 21 | "Source Files" filter). 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | Other notes: 25 | 26 | AppWizard uses "TODO:" comments to indicate parts of the source code you 27 | should add to or customize. 28 | 29 | ///////////////////////////////////////////////////////////////////////////// 30 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/demo.pipeline: -------------------------------------------------------------------------------- 1 | import "systemReconModule.dll"; 2 | 3 | RawDataReader raw_data_reader; 4 | raw_data_reader.DataPath = "d:\temp\2"; 5 | raw_data_reader.ChannelCount = 4; 6 | 7 | SliceIterator slice_iterator; 8 | 9 | RemoveDC2D remove_dc_2d; 10 | remove_dc_2d.InPlace = true; 11 | 12 | ZeroFilling2D zero_filling; 13 | zero_filling.CenterFilling = true; 14 | zero_filling.DestHeight = 512; 15 | zero_filling.DestWidth = 512; 16 | 17 | FFT2D fft_2d; 18 | fft_2d.Forward = false; 19 | fft_2d.InPlace = true; 20 | fft_2d.FFtShift = true; 21 | fft_2d.PhaseShift = true; 22 | fft_2d.ActualFovY = 192.0; 23 | fft_2d.Chop <=> scan.sequence_options.chop; 24 | 25 | ModulationComplex2D module; 26 | 27 | Interpolate2D interpolate2d; 28 | interpolate2d.DestWidth <=> recon.resolution.x; 29 | interpolate2d.DestHeight <=> recon.resolution.y; 30 | interpolate2d.Fov <=> localization.fov; 31 | interpolate2d.FovyRatio <=> localization.fov_y_ratio; 32 | 33 | ImageTransform image_transform; 34 | image_transform.InPlace = false; 35 | 36 | ChannelMerger channel_merger; 37 | channel_merger.ChannelCount = 4; 38 | 39 | JpegExporter jpeg_exporter; 40 | jpeg_exporter.ExportPath = "D:\\temp\\2"; 41 | 42 | raw_data_reader.Output->slice_iterator.Input; 43 | slice_iterator->remove_dc_2d; 44 | remove_dc_2d->zero_filling; 45 | zero_filling->fft_2d; 46 | fft_2d->module; 47 | module->interpolate2d; 48 | interpolate2d->image_transform; 49 | image_transform->channel_merger; 50 | channel_merger->jpeg_exporter; 51 | 52 | self.Input->raw_data_reader.Input; 53 | 54 | -------------------------------------------------------------------------------- /Shared/Implement/CompositeProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CompositeProcessor_h__20160813 4 | #define CompositeProcessor_h__20160813 5 | 6 | #include "ProcessorImpl.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Yap 14 | { 15 | class CompositeProcessor : 16 | public ProcessorImpl 17 | { 18 | IMPLEMENT_LOCK_RELEASE 19 | public: 20 | explicit CompositeProcessor(const wchar_t * class_id); 21 | CompositeProcessor(const CompositeProcessor& rhs); 22 | 23 | virtual IProcessor * Clone() const override; 24 | 25 | virtual bool SetGlobalVariables(IVariableContainer * params) override; 26 | 27 | virtual bool Link(const wchar_t * output, IProcessor * next, const wchar_t * next_input) override; 28 | virtual bool Input(const wchar_t * port, IData * data) override; 29 | virtual bool ProcessTimer() override; 30 | 31 | bool MapInput(const wchar_t * port, const wchar_t * inner_processor, const wchar_t * inner_port); 32 | bool MapOutput(const wchar_t * port, const wchar_t * inner_processor, const wchar_t * inner_port); 33 | 34 | bool AddProcessor(IProcessor * processor); 35 | IProcessor * Find(const wchar_t * instance_id); 36 | protected: 37 | virtual ~CompositeProcessor(); 38 | 39 | std::map> _processors; 40 | std::map _output; 41 | std::map _inputs; 42 | 43 | }; 44 | 45 | typedef CompositeProcessor Pipeline; 46 | } 47 | 48 | #endif // CompositeProcessor_h__ 49 | -------------------------------------------------------------------------------- /PluginSdk/BasicRecon/SamplingMaskCreator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef SamplingMaskCreator_h__20160814 4 | #define SamplingMaskCreator_h__20160814 5 | 6 | #include "Implement/ProcessorImpl.h" 7 | #include "Client/DataHelper.h" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Yap 13 | { 14 | class SamplingMaskCreator : 15 | public ProcessorImpl 16 | { 17 | IMPLEMENT_SHARED(SamplingMaskCreator) 18 | public: 19 | SamplingMaskCreator(); 20 | SamplingMaskCreator(const SamplingMaskCreator& rhs); 21 | 22 | protected: 23 | ~SamplingMaskCreator(); 24 | 25 | virtual bool Input(const wchar_t * name, IData * data) override; 26 | 27 | std::vector GetRandomSamplingPattern(unsigned int row_count, 28 | float pow, float sample_percent, float radius); 29 | std::vector GetEqualSamplingPattern(unsigned int height, unsigned int acs, unsigned int rate); 30 | 31 | // Pdf 数据类型有待补充。 32 | std::vector GeneratePdf(unsigned int row_count, float p, float sample_percent, float radius); 33 | std::vector LineSpace(float begin, float end, unsigned int count); 34 | std::vector GenerateRandomMask(unsigned int width, unsigned int height, float pow, float sample_percent, float radius); 35 | std::vector GenerateEqualMask(unsigned int width, unsigned int height, unsigned int acs, unsigned int rate); 36 | 37 | private: 38 | unsigned int _try_count; 39 | unsigned int _tolerance; 40 | }; 41 | } 42 | 43 | #endif // SamplingMaskCreator_h__ 44 | 45 | 46 | -------------------------------------------------------------------------------- /Shared/Implement/VariableSpace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "interface/interfaces.h" 3 | #include "interface/smartptr.h" 4 | #include "TypeManager.h" 5 | #include "VariableTable.h" 6 | 7 | namespace Yap { 8 | class VariableSpace : public VariableTable 9 | { 10 | public: 11 | VariableSpace(); 12 | explicit VariableSpace(IVariableContainer * variables); 13 | VariableSpace(const VariableSpace& rhs); 14 | VariableSpace(VariableSpace&& rhs); 15 | 16 | ~VariableSpace(); 17 | 18 | const VariableSpace& operator = (const VariableSpace& rhs); 19 | const VariableSpace& operator = (VariableSpace&& rhs); 20 | 21 | bool AddVariable(int type, const wchar_t * name, const wchar_t * description); 22 | bool AddVariable(const wchar_t * type, const wchar_t * name, const wchar_t * description); 23 | 24 | /// Enable or disable a variable in variable space. 25 | bool Enable(const wchar_t * id, bool enable); 26 | 27 | /// Check to see if a variable is enabled. 28 | bool IsEnabled(const wchar_t * id) const; 29 | bool AddArray(const wchar_t * element_type_id, 30 | const wchar_t * id, 31 | const wchar_t * description); 32 | 33 | // static std::shared_ptr Load(const wchar_t * path); 34 | 35 | void Reset(); 36 | std::shared_ptr GetTypes() { 37 | return _types; 38 | } 39 | 40 | void SetTypes(std::shared_ptr types) { 41 | _types = types; 42 | } 43 | 44 | protected: 45 | 46 | std::shared_ptr _types; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /Shared/Client/Client.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/CompressedSensing2.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | import "CompressedSensing.dll"; 3 | CmrDataReader reader(DataPath = "D:\\Data\\cmr_data\\RawData_512\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 15); 5 | SliceSelector slice_selector1(SliceIndex = 8); 6 | SliceSelector slice_selector2(SliceIndex = 8); 7 | //ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 8 | //ZeroFilling zero_filling2(DestWidth = 512, DestHeight = 512); 9 | Fft2D fft; 10 | //Fft2D fft2; 11 | 12 | 13 | //JpegExporter jpeg_exporter2(ExportFolder = "D:\\Output"); 14 | 15 | 16 | SamplingMaskCreator mask_creator(SamplePercent = 0.35f); 17 | 18 | 19 | SubSampling sub_sampling; 20 | 21 | 22 | ModulePhase module_phase; 23 | 24 | 25 | //ModulePhase module_phase2; 26 | 27 | 28 | CompressedSensing compressed_sensing; 29 | 30 | 31 | JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\CompressedSensing"); 32 | 33 | 34 | 35 | 36 | reader->slice_selector1; 37 | 38 | 39 | reader->slice_selector2; 40 | 41 | 42 | 43 | slice_selector1->mask_creator; 44 | 45 | 46 | mask_creator->sub_sampling.Mask; 47 | 48 | 49 | mask_creator->compressed_sensing.Mask; 50 | 51 | 52 | slice_selector2->sub_sampling.Input; 53 | 54 | 55 | sub_sampling->compressed_sensing.Input; 56 | 57 | 58 | //sub_sampling->fft; 59 | 60 | 61 | //fft->module_phase; 62 | 63 | 64 | //module_phase.Module->jpeg_exporter; 65 | 66 | 67 | 68 | compressed_sensing->fft; 69 | 70 | 71 | fft->module_phase; 72 | 73 | module_phase.Module->jpeg_exporter; 74 | 75 | 76 | 77 | 78 | self.Input->reader.Input; -------------------------------------------------------------------------------- /BasicRecon_GPU/cuFft2D.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "cuFft2D.h" 3 | #include "Client/DataHelper.h" 4 | #include "Implement/DataObject.h" 5 | 6 | 7 | using namespace std; 8 | using namespace Yap; 9 | 10 | extern "C" void pre_cuFft2D(std::complex * h_kspace, std::complex * h_image, bool fft_forward, unsigned int width, unsigned int height); 11 | 12 | cuFft2D::cuFft2D(): 13 | ProcessorImpl(L"cuFft2D") 14 | { 15 | AddProperty(L"fft_forward", true, L"The direction of cuFFT2D."); 16 | 17 | AddInput(L"Input", 2, DataTypeComplexFloat); 18 | AddOutput(L"Output", 2, DataTypeComplexFloat); 19 | } 20 | 21 | 22 | cuFft2D::~cuFft2D() 23 | { 24 | } 25 | 26 | //IProcessor * Yap::cuFft2D::Clone() 27 | //{ 28 | // return new (nothrow) cuFft2D(*this); 29 | //} 30 | 31 | bool Yap::cuFft2D::Input(const wchar_t * port, IData * data) 32 | { 33 | if (wstring(port) != L"Input") 34 | return false; 35 | 36 | DataHelper input_data(data); 37 | if (input_data.GetDataType() != DataTypeComplexFloat) 38 | return false; 39 | 40 | if (input_data.GetActualDimensionCount() != 2) 41 | return false; 42 | 43 | auto width = input_data.GetWidth(); 44 | auto height = input_data.GetHeight(); 45 | auto data_array = GetDataArray>(data); 46 | //auto out_data = YapShared(new ComplexFloatData(data->GetDimensions()));//xhb-> 47 | auto output = CreateData>(data); 48 | pre_cuFft2D(data_array, GetDataArray>(output.get()), GetProperty(L"fft_forward"), width, height); 49 | 50 | Feed(L"Output", output.get()); 51 | return true; 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /GrappaRecon/GrappaRecon.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/TransferListDimensionOrder.py: -------------------------------------------------------------------------------- 1 | ''' 2 | modify list order 3 | from time -> slice -> height -> width 4 | to width -> height -> slice -> time 5 | ''' 6 | import numpy as np 7 | import matplotlib as ptl 8 | from PIL import Image 9 | import SimpleITK as itk 10 | 11 | 12 | def ReverseOrder2d(image,width,height): 13 | reverse_image = []; 14 | for x in range(width): 15 | reverse_image.append([]) 16 | for y in range(height): 17 | reverse_image[x].append(image[y][x]) 18 | return reverse_image 19 | 20 | 21 | def ReverseOrder3d(image,width,height,slice): 22 | reverse_image = [] 23 | for w in range(width): 24 | reverse_image.append([]) 25 | for h in range(height): 26 | reverse_image[w].append([]) 27 | for s in range(slice): 28 | reverse_image[w][h].append(image[s][h][w]) 29 | return reverse_image 30 | 31 | 32 | def ReverseOrder4d(image, width, height, slice, time): 33 | reverse_image = [] 34 | for w in range(width): 35 | reverse_image.append([]) 36 | for h in range(height): 37 | reverse_image[w].append([]) 38 | for s in range(slice): 39 | reverse_image[w][h].append([]) 40 | for t in range(time): 41 | reverse_image[w][h][s].append(image[t][s][h][w]) 42 | return reverse_image 43 | 44 | -------------------------------------------------------------------------------- /Shared/Client/DataHelper.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAHELPER_H_20160813 2 | #define DATAHELPER_H_20160813 3 | 4 | #include "Interface/Interfaces.h" 5 | 6 | namespace Yap 7 | { 8 | class DataHelper 9 | { 10 | public: 11 | DataHelper(IData * data) : _data_object(*data) {} 12 | 13 | int GetDataType(); 14 | unsigned int GetDimensionCount(); 15 | 16 | /// Return the actual number of dimensions of the data. 17 | /** 18 | \remarks 19 | For example, if dimension information is: 20 | \li Readout 0, 255; 21 | \li phaseencoding 0, 255; 22 | \li slice 0, 1; 23 | \li channel 0,1; 24 | 25 | then the actual number of dimensions is 2。If we change the slice to 26 | 0, 2 while keeping all other dimensions unchanged, then the actual 27 | number of dimensions is 3. 28 | */ 29 | unsigned int GetActualDimensionCount() const; 30 | 31 | Dimension GetDimension(DimensionType dimension_type); 32 | unsigned int GetWidth(); 33 | unsigned int GetHeight(); 34 | 35 | size_t GetDataSize() const; 36 | unsigned int GetBlockSize(DimensionType type) const; 37 | 38 | unsigned int GetSliceCount(); 39 | unsigned int GetCoilCount(); 40 | unsigned int GetDim4(); 41 | IData * GetData(); 42 | 43 | protected: 44 | IData & _data_object; 45 | }; 46 | 47 | template 48 | T * GetDataArray(IData * data) 49 | { 50 | IDataArray * data_array = dynamic_cast *>(data); 51 | return (data_array != nullptr) ? data_array->GetData() : nullptr; 52 | } 53 | 54 | } // namespace Yap. 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/GrayScaleUnifier.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "GrayScaleUnifier.h" 3 | #include "Implement/LogUserImpl.h" 4 | #include "Client/DataHelper.h" 5 | 6 | #include 7 | 8 | using namespace Yap; 9 | using namespace std; 10 | 11 | Yap::GrayScaleUnifier::GrayScaleUnifier(): 12 | ProcessorImpl(L"GrayScaleUnifier") 13 | { 14 | AddInput(L"Input", YAP_ANY_DIMENSION, DataTypeFloat); 15 | AddOutput(L"Output", YAP_ANY_DIMENSION, DataTypeFloat); 16 | } 17 | 18 | Yap::GrayScaleUnifier::GrayScaleUnifier(const GrayScaleUnifier& rhs) : 19 | ProcessorImpl(rhs) 20 | { 21 | } 22 | 23 | Yap::GrayScaleUnifier::~GrayScaleUnifier() 24 | { 25 | } 26 | 27 | bool Yap::GrayScaleUnifier::Input(const wchar_t * name, IData * data) 28 | { 29 | if (wstring(name) != L"Input") 30 | return false; 31 | 32 | DataHelper input(data); 33 | 34 | if (input.GetDataType() != DataTypeFloat) 35 | return false; 36 | 37 | auto size = input.GetDataSize(); 38 | vector temp_data(size, 0); 39 | memcpy(temp_data.data(), GetDataArray(data), size * sizeof(float)); 40 | auto max_val = *max_element(temp_data.begin(), temp_data.end()); 41 | auto min_val = *min_element(temp_data.begin(), temp_data.end()); 42 | 43 | auto output = CreateData(data); 44 | auto input_data = GetDataArray(data); 45 | auto output_data = GetDataArray(output.get()); 46 | auto input_end = input_data + size; 47 | 48 | auto rate = 255.0 / (max_val - min_val); 49 | while (input_data != input_end) 50 | { 51 | *(output_data++) = static_cast((*(input_data++) - min_val) * rate); 52 | } 53 | 54 | return Feed(L"Output", output.get()); 55 | } 56 | -------------------------------------------------------------------------------- /API/Yap/ScanFileParser.h: -------------------------------------------------------------------------------- 1 | #ifndef SCAN_FILE_PARSER_H 2 | #define SCAN_FILE_PARSER_H 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Preprocessor.h" 13 | 14 | namespace Yap 15 | { 16 | class VariableSpace; 17 | 18 | class ScanFileParser 19 | { 20 | public: 21 | ScanFileParser(); 22 | ~ScanFileParser() = default; 23 | 24 | void SetVariableSpace(std::shared_ptr variables); 25 | std::shared_ptr GetVariableSpace(); 26 | 27 | bool Load(const wchar_t * scan_file_path); 28 | bool Compile(const wchar_t * text); 29 | 30 | protected: 31 | bool Process(); 32 | bool ProcessAssignment(); 33 | bool ProcessSimpleAssignment(const wchar_t* variable_id, Tokens& tokens); 34 | bool ProcessStructAssignment(const wchar_t* variable_id, Tokens& tokens); 35 | bool ProcessArrayAssignment(const wchar_t* variable_id, Tokens& tokens); 36 | bool ProcessStructArrayAssignment(const wchar_t* variable_id, Tokens& tokens); 37 | bool ProcessArrayResizeOperator(const wchar_t* variable_id, Tokens& tokens); 38 | bool ProcessArrayElementAssignment(const wchar_t* variable_id, Tokens& tokens); 39 | bool ProcessSimpleArrayElementAssignment(const wchar_t* variable_id, int type, Tokens& tokens); 40 | bool ProcessAllSimpleArrayElementAssighment(const wchar_t* variable_id, Tokens& tokens); 41 | bool OperatorAssignment(IVariable* varaible, Tokens& tokens); 42 | std::shared_ptr _preprocessor; 43 | std::shared_ptr _variables; 44 | }; 45 | } 46 | #endif //SCAN_DEFINITION_PARSER_H -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/CompressedSensing2test.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | 4 | import "CompressedSensing.dll"; 5 | 6 | 7 | 8 | 9 | CmrDataReader reader(DataPath = "D:\\test_data\\RawData_512\\RawData", 10 | ChannelCount = 4, ChannelSwitch = 15); 11 | 12 | 13 | SliceSelector slice_selector1(SliceIndex = 8); 14 | 15 | 16 | SliceSelector slice_selector2(SliceIndex = 8); 17 | 18 | // 19 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 20 | 21 | 22 | //ZeroFilling zero_filling2(DestWidth = 512, DestHeight = 512); 23 | 24 | 25 | 26 | Fft2D fft; 27 | 28 | 29 | 30 | //Fft2D fft2; 31 | 32 | 33 | //JpegExporter jpeg_exporter2(ExportFolder = "D:\\Output"); 34 | 35 | 36 | SamplingMaskCreator mask_creator(SamplePercent = 0.35f); 37 | 38 | 39 | SubSampling sub_sampling; 40 | 41 | 42 | ModulePhase module_phase; 43 | 44 | 45 | //ModulePhase module_phase2; 46 | 47 | 48 | CompressedSensing compressed_sensing; 49 | 50 | 51 | JpegExporter jpeg_exporter(ExportFolder = "D:\\Output\\CompressedSensing"); 52 | 53 | 54 | 55 | JpegExporter jpeg_temp(ExportFolder = "D:\\output\\temp"); 56 | 57 | 58 | 59 | reader->slice_selector1; 60 | reader->slice_selector2; 61 | 62 | 63 | 64 | slice_selector1->mask_creator; 65 | 66 | mask_creator->sub_sampling.Mask; 67 | mask_creator->compressed_sensing.Mask; 68 | 69 | slice_selector2->sub_sampling.Input; 70 | 71 | sub_sampling->compressed_sensing.Input; 72 | 73 | compressed_sensing->module_phase; 74 | module_phase.Module->jpeg_temp; 75 | 76 | 77 | //slice_selector2->fft; 78 | 79 | 80 | //fft->module_phase; 81 | 82 | 83 | //module_phase.Module->jpeg_exporter; 84 | 85 | 86 | 87 | 88 | self.Input->reader.Input; 89 | -------------------------------------------------------------------------------- /Shared/Implement/PythonUserImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "PythonUserImpl.h" 2 | #include "Utilities\macros.h" 3 | #include "Implement\LogUserImpl.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace Yap; 10 | 11 | std::shared_ptr PythonUserImpl::s_instance; 12 | 13 | Yap::PythonUserImpl::~PythonUserImpl() 14 | { 15 | 16 | } 17 | 18 | Yap::PythonUserImpl& Yap::PythonUserImpl::GetInstance() 19 | { 20 | if (!s_instance) 21 | { 22 | s_instance = std::shared_ptr(new (std::nothrow)PythonUserImpl()); 23 | } 24 | return *s_instance.get(); 25 | } 26 | 27 | void Yap::PythonUserImpl::SetPython(IPython& python) 28 | { 29 | _python = &python; 30 | } 31 | 32 | void Yap::PythonUserImpl::SetReferenceData(void * data, int data_type, int input_dimensions, size_t * input_size) 33 | { 34 | assert(_python != nullptr && "Python Server can not get!"); 35 | _python->SetRefData(data, data_type, input_dimensions, input_size); 36 | } 37 | 38 | void * Yap::PythonUserImpl::PythonProcess( 39 | const wchar_t* module, const wchar_t* method, 40 | int data_type, int out_data_type, size_t input_dimensions, 41 | void * data, OUT size_t& output_dimensions, 42 | size_t input_size[], OUT size_t output_size[], 43 | bool is_need_ref_data) 44 | { 45 | assert(_python != nullptr && "Python Server can not get!"); 46 | return _python->Process(module, method, data_type, out_data_type, 47 | input_dimensions, data, output_dimensions, input_size, output_size, is_need_ref_data); 48 | } 49 | 50 | void Yap::PythonUserImpl::DeleteRefData() 51 | { 52 | assert(_python != nullptr && "Python Server can not get!"); 53 | _python->DeleteRefData(); 54 | } 55 | 56 | Yap::PythonUserImpl::PythonUserImpl() : _python{ nullptr } 57 | { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /API/Yap/VdfParser.h: -------------------------------------------------------------------------------- 1 | #ifndef VARIABLE_DEFINITION_PARSER_H 2 | #define VARIABLE_DEFINITION_PARSER_H 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Preprocessor.h" 13 | 14 | namespace Yap 15 | { 16 | class VariableSpace; 17 | class NamespaceManager; 18 | class TypeManager; 19 | 20 | /// Variable definition file. 21 | class VdfParser 22 | { 23 | public: 24 | VdfParser(); 25 | ~VdfParser(); 26 | 27 | std::shared_ptr CompileFile(const wchar_t * path); 28 | std::shared_ptr Compile(const wchar_t * text); 29 | 30 | protected: 31 | std::shared_ptr DoCompile(std::wistream& input); 32 | bool Process(); 33 | bool ProcessStatement(Tokens& tokens); 34 | bool ProcessSimpleDeclaration(Tokens& tokens); 35 | bool ProcessEnumDeclaration(Tokens& tokens); 36 | bool ProcessArrayDeclaration(Tokens& tokens, VariableTable& variables); 37 | bool ProcessStructDeclaration(Tokens& tokens); 38 | bool ProcessNamespace(Tokens& tokens); 39 | bool ProcessUsing(Tokens& tokens); 40 | 41 | std::wstring ResolveFqId(const wchar_t * const id, bool is_type_id, Tokens& tokens) const; 42 | std::wstring GetFqId(const wchar_t * const id) const; 43 | 44 | bool IdExists(const wchar_t * const id, bool is_type_id) const; 45 | std::wstring OuterNamespace(const std::wstring& inner_namespace) const; 46 | 47 | std::shared_ptr _preprocessor; 48 | std::shared_ptr _variables; 49 | std::shared_ptr _types; 50 | 51 | std::wstring _current_namespace; 52 | std::set _namespace_in_use; 53 | }; 54 | } 55 | 56 | #endif // VARIABLE_DEFINITION_PARSER_H 57 | -------------------------------------------------------------------------------- /API/UnitTests/PipelineUnitTests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Shared/Utilities/Clipboard.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | Filename: Clipboard.cpp 3 | Created: 2011/02/14 4 | Author: Yang Guang, gyang@phy.ecnu.edu.cn 5 | Purpose: 6 | 7 | All right reserved. 2009 - 8 | 9 | Shanghai Key Laboratory of Magnetic Resonance, 10 | East China Normal University 11 | *********************************************************************/ 12 | 13 | #include "StdAfx.h" 14 | #include "Clipboard.h" 15 | #include "macros.h" 16 | #include 17 | 18 | using Utilities::CClipboard; 19 | 20 | bool CClipboard::SetClipboardText(const TCHAR* str) 21 | { 22 | size_t text_length = _tcslen(str); 23 | GLOBALHANDLE hGlobal = GlobalAlloc(GHND | GMEM_SHARE, (text_length + 1) * 2); 24 | if (hGlobal == 0) 25 | { 26 | // TRACEX(_T("Failed to allocate memory while copying text to clipboard.")); 27 | return false; 28 | } 29 | 30 | char* p = reinterpret_cast (GlobalLock(hGlobal)); 31 | if (p == NULL) 32 | { 33 | // TRACEX(_T("Failed to lock memory while copying text to clipboard.")); 34 | return false; 35 | } 36 | 37 | strcpy_s(p, text_length * 2 + 2, CT2CA(str)); 38 | GlobalUnlock(hGlobal); 39 | 40 | if (!OpenClipboard(NULL)) 41 | { 42 | // TRACEX(_T("Failed to open clipboard while copying text to clipboard.")); 43 | return false; 44 | } 45 | 46 | EmptyClipboard(); 47 | SetClipboardData(CF_TEXT, hGlobal); 48 | CloseClipboard(); 49 | 50 | return true; 51 | } 52 | 53 | CString CClipboard::GetClipboardText() 54 | { 55 | if (!IsClipboardFormatAvailable(CF_TEXT) || !OpenClipboard(NULL)) 56 | return _T(""); 57 | 58 | GLOBALHANDLE hGlobal = GetClipboardData(CF_TEXT); 59 | char * pGlobal = reinterpret_cast(GlobalLock(hGlobal)); 60 | 61 | CString str = CA2CT(pGlobal); 62 | 63 | GlobalUnlock(hGlobal); 64 | CloseClipboard(); 65 | 66 | return str; 67 | } -------------------------------------------------------------------------------- /BasicRecon_GPU/BasicRecon_GPU.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Shared/Utilities/macros.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | Filename: macros.h 3 | Created: 2009/06/15 4 | Author: Yang Guang, gyang@phy.ecnu.edu.cn 5 | 6 | Purpose: 7 | 8 | All right reserved. 2009 - 9 | *********************************************************************/ 10 | #ifndef macros_h__ 11 | #define macros_h__ 12 | 13 | #include 14 | 15 | 16 | 17 | #ifdef _UNICODE 18 | #define TRACEX(A) setlocale(LC_ALL, "chs"); TRACE(_T("%S: ")A _T("\n"), __FUNCTION__ ) 19 | #define TRACEX1(A, B) setlocale(LC_ALL, "chs"); TRACE(_T("%S: ") A _T("\n"), __FUNCTION__, B) 20 | #define TRACEX2(A, B, C) setlocale(LC_ALL, "chs"); TRACE(_T("%S: ") A _T("\n"), __FUNCTION__, B, C) 21 | #define TRACEX3(A, B, C, D) setlocale(LC_ALL, "chs"); TRACE(_T("%S: ") A _T("\n"), __FUNCTION__, B, C, D) 22 | #else 23 | #define TRACEX(A) setlocale(LC_ALL, "chs"); TRACE(_T("%s: ")A _T("\n"), __FUNCTION__ ) 24 | #define TRACEX1(A, B) setlocale(LC_ALL, "chs"); TRACE(_T("%s: ") A _T("\n"), __FUNCTION__, B) 25 | #define TRACEX2(A, B, C) setlocale(LC_ALL, "chs"); TRACE(_T("%s: ") A _T("\n"), __FUNCTION__, B, C) 26 | #define TRACEX3(A, B, C, D) setlocale(LC_ALL, "chs"); TRACE(_T("%s: ") A _T("\n"), __FUNCTION__, B, C, D) 27 | #endif 28 | 29 | #define __STR2__(x) #x 30 | #define __STR1__(x) __STR2__(x) 31 | #define __LOC2__ __FILE__ "("__STR1__(__LINE__)") : " 32 | 33 | // #define BUG(x) __pragma(message(__LOC2__ "Known bug in " __FUNCTION__ "() - [" __STR1__(x) "]")) 34 | #define BUG(x) __pragma(message(__LOC2__ "[BUG] " __STR1__(x) )) 35 | #define TODO(x) __pragma(message(__LOC2__ "[TODO] " __STR1__(x) )) 36 | #define NOT_IMPLEMENTED TODO(Not implemented.) 37 | 38 | // ;TRACEX(_T("Error, function called has not been implemented.")) 39 | 40 | #define TRACE_CALL_COUNT static int count = 0; TRACEX1(_T("%d"), count++); 41 | 42 | #endif // macros_h__ 43 | -------------------------------------------------------------------------------- /API/PipelineTest/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : PipelineTest Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this PipelineTest application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your PipelineTest application. 9 | 10 | 11 | PipelineTest.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | PipelineTest.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | PipelineTest.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named PipelineTest.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /BasicRecon_GPU/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : BasicRecon_GPU Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this BasicRecon_GPU application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your BasicRecon_GPU application. 9 | 10 | 11 | BasicRecon_GPU.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | BasicRecon_GPU.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | BasicRecon_GPU.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named BasicRecon_GPU.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /API/UnitTests/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : PipelineUnitTests Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this PipelineUnitTests application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your PipelineUnitTests application. 9 | 10 | 11 | PipelineUnitTests.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | PipelineUnitTests.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | PipelineUnitTests.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named PipelineUnitTests.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /Shared/Implement/LogUserImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGUSERIMPL_H_20170426 2 | #define LOGUSERIMPL_H_20170426 3 | 4 | #pragma once 5 | #include 6 | #include "Interface\ILog.h" 7 | #include 8 | 9 | #define LOG_TRACE(info, module) LogUserImpl::GetInstance().Trace(info, module) 10 | #define LOG_DEBUG(info, module) LogUserImpl::GetInstance().Debug(info, module) 11 | #define LOG_INFO(info, module) LogUserImpl::GetInstance().Info(info, module) 12 | #define LOG_WARN(info, module) LogUserImpl::GetInstance().Warn(info, module) 13 | #define LOG_ERROR(info, module) LogUserImpl::GetInstance().Error(info, module) 14 | #define LOG_FATAL(info, module) LogUserImpl::GetInstance().Fatal(info, module) 15 | 16 | struct Yap::ILogUser; 17 | 18 | namespace Yap 19 | { 20 | class LogUserImpl : public ILogUser 21 | { 22 | public: 23 | ~LogUserImpl(); 24 | 25 | bool Init(const wchar_t * default_log, const wchar_t * default_module); 26 | virtual void SetLog(ILog * log) override; 27 | 28 | void Trace(const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 29 | void Debug(const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 30 | void Info (const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 31 | void Warn (const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 32 | void Error(const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 33 | void Fatal(const wchar_t * info, const wchar_t * module = nullptr, const wchar_t * log_name = nullptr); 34 | 35 | static LogUserImpl& GetInstance(); 36 | protected: 37 | LogUserImpl(); 38 | 39 | static std::shared_ptr s_instance; 40 | 41 | ILog * _log; 42 | std::wstring _module; 43 | std::wstring _log_name; 44 | bool _flush; 45 | }; 46 | } 47 | 48 | #endif // LOGUSERIMPL_H_ -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelIterator.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ChannelIterator.h" 3 | #include "Client/DataHelper.h" 4 | #include 5 | #include "Implement/LogUserImpl.h" 6 | 7 | using namespace std; 8 | using namespace Yap; 9 | 10 | ChannelIterator::ChannelIterator(): 11 | ProcessorImpl(L"ChannelIterator") 12 | { 13 | AddInput(L"Input", YAP_ANY_DIMENSION, DataTypeComplexFloat); 14 | AddOutput(L"Output", 2, DataTypeComplexFloat); 15 | 16 | AddProperty(L"SliceIndex", 0, L"The index of the slice you want to get."); 17 | } 18 | 19 | ChannelIterator::ChannelIterator(const ChannelIterator& rhs) 20 | : ProcessorImpl(rhs) 21 | { 22 | } 23 | 24 | ChannelIterator::~ChannelIterator() 25 | { 26 | } 27 | 28 | bool Yap::ChannelIterator::Input(const wchar_t * name, IData * data) 29 | { 30 | assert((data != nullptr) && (Yap::GetDataArray>(data) != nullptr)); 31 | assert(Inputs()->Find(name) != nullptr); 32 | 33 | DataHelper helper(data); 34 | 35 | unsigned int slice_block_size = helper.GetBlockSize(DimensionSlice); 36 | unsigned int slice_index = GetProperty(L"SliceIndex"); 37 | 38 | Dimension channel_dimension = helper.GetDimension(DimensionChannel); 39 | assert(channel_dimension.type == DimensionChannel); 40 | 41 | for (unsigned int i = channel_dimension.start_index; i < channel_dimension.start_index + channel_dimension.length; ++i) 42 | { 43 | Dimensions channel_slice_data_dimensions(data->GetDimensions()); 44 | channel_slice_data_dimensions.SetDimensionInfo2(DimensionSlice, slice_index, 1); 45 | channel_slice_data_dimensions.SetDimensionInfo2(DimensionChannel, i, 1); 46 | 47 | auto output = CreateData>(data, 48 | Yap::GetDataArray>(data) + i * slice_block_size, channel_slice_data_dimensions); 49 | 50 | Feed(L"Output", output.get()); 51 | } 52 | 53 | return true; 54 | } 55 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SubSampling.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SubSampling.h" 3 | #include "Client/DataHelper.h" 4 | #include "Implement/LogUserImpl.h" 5 | 6 | using namespace std; 7 | using namespace Yap; 8 | 9 | 10 | SubSampling::SubSampling(): 11 | ProcessorImpl(L"SubSampling") 12 | { 13 | AddInput(L"Input", YAP_ANY_DIMENSION, DataTypeComplexDouble | DataTypeComplexFloat); 14 | AddInput(L"Mask", 2, DataTypeFloat); 15 | AddOutput(L"Output", YAP_ANY_DIMENSION, DataTypeComplexDouble | DataTypeComplexFloat); 16 | } 17 | 18 | SubSampling::SubSampling(const SubSampling& rhs) 19 | :ProcessorImpl(rhs) 20 | { 21 | } 22 | 23 | SubSampling::~SubSampling() 24 | { 25 | } 26 | 27 | bool Yap::SubSampling::Input(const wchar_t * port, IData * data) 28 | { 29 | if (wstring(port) == L"Mask") 30 | { 31 | _mask = YapShared(data); 32 | } 33 | else if (wstring(port) == L"Input") 34 | { 35 | if (!_mask) 36 | return false; 37 | DataHelper input_data(data); 38 | DataHelper mask(_mask.get()); 39 | 40 | auto width = input_data.GetWidth(); 41 | auto height = input_data.GetHeight(); 42 | 43 | Dimensions dimensions; 44 | dimensions(DimensionReadout, 0U, width) 45 | (DimensionPhaseEncoding, 0U, height) 46 | (DimensionSlice, 0U, 1) 47 | (Dimension4, 0U, 1) 48 | (DimensionChannel, 0U, 1); 49 | 50 | auto outdata = CreateData>(data, &dimensions); 51 | 52 | GetSubSampledData(GetDataArray>(data), GetDataArray(_mask.get()), 53 | GetDataArray>(outdata.get()), width, height); 54 | 55 | Feed(L"Output", outdata.get()); 56 | } 57 | 58 | return true; 59 | } 60 | 61 | void Yap::SubSampling::GetSubSampledData(std::complex * input_data, float * mask, std::complex * output_data, 62 | unsigned int width, unsigned int height) 63 | { 64 | for (unsigned int i = 0; i < width * height; ++i) 65 | { 66 | *(output_data + i) = *(input_data + i) * *(mask + i); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/SliceMerger.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SliceMerger.h" 3 | 4 | #include 5 | #include "Client/DataHelper.h" 6 | #include "Implement/LogUserImpl.h" 7 | 8 | using namespace Yap; 9 | using namespace std; 10 | 11 | SliceMerger::SliceMerger(void) : 12 | ProcessorImpl(L"SliceMerger") 13 | { 14 | AddInput(L"Input", 2, DataTypeAll); 15 | AddOutput(L"Output", 3, DataTypeAll); 16 | 17 | AddProperty(L"SliceCount", 0, L"Slice count"); 18 | } 19 | 20 | SliceMerger::SliceMerger(const SliceMerger& rhs) 21 | : ProcessorImpl(rhs) 22 | { 23 | } 24 | 25 | SliceMerger::~SliceMerger() 26 | { 27 | } 28 | 29 | bool SliceMerger::Input(const wchar_t * port, IData * data) 30 | { 31 | if (wstring(port) != L"Input") 32 | return false; 33 | 34 | static int slice_num = 0; 35 | auto slice_count = GetProperty(L"SliceCount"); 36 | assert(slice_count > 0); 37 | 38 | if (slice_num == 0) 39 | { 40 | DataHelper helper(data); 41 | auto width = helper.GetWidth(); 42 | auto height = helper.GetHeight(); 43 | 44 | Yap::Dimensions dims; 45 | dims(DimensionReadout, 0, width) 46 | (DimensionPhaseEncoding, 0, height) 47 | (DimensionSlice, 0, slice_count); 48 | 49 | TODO(让SliceMerger适应不同数据类型); 50 | _data = CreateData(data, &dims); 51 | 52 | ++slice_num; 53 | } 54 | 55 | assert(slice_num != 0); 56 | DataHelper helper(data); 57 | auto width = helper.GetWidth(); 58 | auto height = helper.GetHeight(); 59 | auto input_array = GetDataArray(data); 60 | auto output_array = GetDataArray(_data.get()); 61 | 62 | auto slice_start = output_array + width * height * (slice_num++ - 1); 63 | for (unsigned int row = 0; row < height; ++row) 64 | { 65 | memcpy(slice_start + row * width, input_array + row * width, width * sizeof(unsigned short)); 66 | } 67 | 68 | if (slice_num > slice_count) 69 | { 70 | Feed(L"Output", _data.get()); 71 | } 72 | 73 | return true; 74 | } -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/excel_helper.py: -------------------------------------------------------------------------------- 1 | from openpyxl import Workbook 2 | from openpyxl.utils import get_column_letter 3 | import numbers 4 | 5 | wb = Workbook() 6 | 7 | 8 | def XL_Location(row, column): 9 | return get_column_letter(column) + str(row) 10 | 11 | 12 | def Save_Column_Title(file_dir, features, row_index, column_start): 13 | ws = wb.active 14 | keys = [x[0] for x in features.items()] 15 | try: 16 | for index in range(len(keys)): 17 | loc = XL_Location(index + row_index, column_start) 18 | if ws[loc].value is None: 19 | ws[loc] = keys[index] 20 | else: 21 | assert (ws[loc].value == keys[index]) 22 | wb.save(file_dir) 23 | except: 24 | return False 25 | return True 26 | 27 | 28 | # save to excel data 29 | def Save_Column_Exel(file_dir, features, row_index, column_start): 30 | ws = wb.active 31 | vals = [x[1] for x in features.items()] 32 | try: 33 | for index in range(len(vals)): 34 | loc = XL_Location(index + row_index, column_start) 35 | if isinstance(vals[index], numbers.Number): 36 | ws[XL_Location(index + row_index, column_start)] = vals[index] 37 | else: 38 | ws[XL_Location(index + row_index, column_start)] = str(vals[index]) 39 | wb.save(file_dir) 40 | except: 41 | return False 42 | return True 43 | 44 | 45 | def Save_Row_Exel(file_dir, features, row_index, column_start): 46 | ws = wb.active 47 | vals = [x[1] for x in features.items()] 48 | try: 49 | for index in range(len(vals)): 50 | loc = XL_Location(index + row_index, column_start) 51 | if isinstance(vals[index], numbers.Number): 52 | ws[XL_Location(row_index, index + column_start)] = vals[index] 53 | else: 54 | ws[XL_Location(row_index, index + column_start)] = str(vals[index]) 55 | wb.save(file_dir) 56 | except: 57 | return False 58 | return True -------------------------------------------------------------------------------- /Shared/Interface/Interface.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /API/PipelineTest/PipelineTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {d59196e2-aaec-4f64-bff2-367b1dee6763} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Header Files 27 | 28 | 29 | Header Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | 47 | 48 | Data Files 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Shared/Implement/PythonUserImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef PythonUserImpl_H_20171020 4 | #define PythonUserImpl_H_20171020 5 | 6 | #include "Interface\IPythonUser.h" 7 | #include 8 | 9 | // PYTHON_SET_REF_DATA(void * data, int data_type, int input_dimensions, size_t *input_size) 10 | #define PYTHON_SET_REF_DATA(data, data_type, input_dimensions, input_size) \ 11 | PythonUserImpl::GetInstance().SetReferenceData(data, data_type, input_dimensions, input_size) 12 | 13 | /* 14 | PYTHON_PROCESS(const wchar_t *module, const wchar_t *method, int data_type, 15 | int out_data_type, size_t input_dimensions, void *data, 16 | size_t output_dimensions, size_t input_size[], 17 | size_t output_size[], bool is_need_ref_data) 18 | */ 19 | #define PYTHON_PROCESS(module, method, data_type, out_data_type, input_dimensions, data, \ 20 | output_dimensions, input_size, output_size, is_need_ref_data) \ 21 | PythonUserImpl::GetInstance().PythonProcess(module, method, data_type, out_data_type,\ 22 | input_dimensions, data, output_dimensions, \ 23 | input_size, output_size, is_need_ref_data) 24 | 25 | #define PYTHON_DELETE_REF_DATA() PythonUserImpl::GetInstance().DeleteRefData() 26 | 27 | namespace Yap 28 | { 29 | class PythonUserImpl : public IPythonUser { 30 | 31 | public: 32 | ~PythonUserImpl(); 33 | 34 | static PythonUserImpl& GetInstance(); 35 | 36 | virtual void SetPython(IPython& python) override; 37 | 38 | virtual void SetReferenceData(void * data, int data_type, int input_dimensions, size_t * input_size) override; 39 | 40 | virtual void * PythonProcess(const wchar_t* module, const wchar_t* method, 41 | int data_type, int out_data_type, size_t input_dimensions, 42 | void * data, OUT size_t& output_dimensions, 43 | size_t input_size[], OUT size_t output_size[], 44 | bool is_need_ref_data) override; 45 | 46 | virtual void DeleteRefData() override; 47 | 48 | private: 49 | 50 | PythonUserImpl(); 51 | static std::shared_ptr s_instance; 52 | IPython* _python; 53 | }; 54 | 55 | 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /API/PipelineTest/Pipelines/Test0_qt.pipeline: -------------------------------------------------------------------------------- 1 | import "BasicRecon.dll"; 2 | 3 | CmrDataReader reader2(DataPath = "D:\\Data\\cmr_data\\RawData_256\\RawData", 4 | ChannelCount = 4, ChannelSwitch = 13); 5 | 6 | //select iteraotr or selector. 7 | SliceIterator slice_iterator; 8 | //SliceSelector slice_selector(SliceIndex = 3); 9 | ChannelSelector channel_selector(ChannelIndex=2); 10 | DcRemover dc_remover; 11 | ZeroFilling zero_filling(DestWidth = 512, DestHeight = 512); 12 | SimpleGrid simple_grid(DestWidth = 256, DestHeight = 256, RadialData = false); 13 | 14 | 15 | Fft2D fft; 16 | DeOversampling de_oversampling(FreqOverSampling = false); 17 | ModulePhase module_phase; 18 | DataTypeConvertor convertor; 19 | Flip flip; 20 | 21 | 22 | ChannelImageDataCollector data_collector; 23 | //switch or not Merge processor. 24 | ChannelMerger channel_merge; 25 | 26 | //select jpeg or display2d. 27 | JpegExporter jpeg_exporter(ExportFolder = "D:\\output\\test0_qt_pipeline"); 28 | //Display2D display2d; 29 | 30 | reader2->channel_selector; 31 | channel_selector->slice_iterator; 32 | //slice_iterator->dc_remover; 33 | //switch on convention FT. 34 | //dc_remover->zero_filling; 35 | //zero_filling->fft; 36 | //fft->over_sampling; 37 | //de_oversampling->module_phase; 38 | 39 | //switch on SimpleGrid 40 | slice_iterator->simple_grid; 41 | simple_grid->module_phase; 42 | //end of SimpleGrid. 43 | 44 | 45 | //choose one of the following 3 items. 46 | 47 | //1: jpeg. 48 | //module_phase.Module->jpeg_exporter; 49 | 50 | //merge. 51 | module_phase.Module->data_collector; 52 | data_collector->channel_merge; 53 | //channel_merge->jpeg_exporter; 54 | channel_merge->convertor; 55 | convertor.UnsignedShort->flip; 56 | flip->jpeg_exporter; 57 | 58 | //2: display. 59 | //module_phase.Module->display 60 | //module_phase.Module->convertor; 61 | //convertor.UnsignedShort->display2d; 62 | //merge. 63 | //module_phase.Module->channel_merge; 64 | //channel_merge->convertor; 65 | //convertor.UnsignedShort->display2d; 66 | // 67 | self.Input->reader2.Input; 68 | //self.SelfA->reader.ReadA; 69 | //self.SelfB->convertor.Input; 70 | 71 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/FolderCollector.cpp: -------------------------------------------------------------------------------- 1 | #include "FolderCollector.h" 2 | #include "Implement\LogUserImpl.h" 3 | #include "Client\DataHelper.h" 4 | #include 5 | 6 | using namespace std; 7 | 8 | Yap::FolderCollector::FolderCollector() : ProcessorImpl(L"FolderCollector") 9 | { 10 | AddInput(L"Input", 2, DataTypeFloat); 11 | AddOutput(L"Output", 2, DataTypeFloat); 12 | } 13 | 14 | Yap::FolderCollector::FolderCollector(const FolderCollector& rhs): 15 | ProcessorImpl(rhs) 16 | { 17 | } 18 | 19 | Yap::FolderCollector::~FolderCollector() 20 | { 21 | } 22 | 23 | bool Yap::FolderCollector::Input(const wchar_t * name, IData * data) 24 | { 25 | assert(data != nullptr); 26 | assert(Inputs()->Find(name) != nullptr); 27 | assert(data->GetDataType() == DataTypeFloat); 28 | 29 | VariableSpace variable(data->GetVariables()); 30 | if (!variable.Get(L"FolderFinished")) 31 | { 32 | _collector.insert(make_pair(_count++, CreateData(data))); // 33 | } 34 | else 35 | { 36 | // add labels data to last column of every row in a feature matrix. 37 | DataHelper helper(_collector[0].get()); 38 | auto dim = helper.GetDimension(DimensionReadout); 39 | unsigned int row_size =unsigned int(_collector.size()); 40 | Dimensions dimension; 41 | dimension(DimensionReadout, 0U, dim.length + 1) 42 | (DimensionPhaseEncoding, 0U, row_size); 43 | float * collect_data; 44 | try 45 | { 46 | collect_data = new float[(dim.length + 1)* row_size]; 47 | } 48 | catch (const std::bad_alloc&) 49 | { 50 | return false; 51 | } 52 | size_t count = 0; 53 | for (unsigned int i = 0; i < _count; ++i) 54 | { 55 | memcpy(collect_data + count, GetDataArray(_collector[i].get()), (dim.length) * sizeof(float)); 56 | count += (dim.length + 1); 57 | VariableSpace var(_collector[i]->GetVariables()); 58 | *(collect_data + count) = float(var.Get(L"FolderLabel")); 59 | } 60 | 61 | auto out_data = CreateData(nullptr, collect_data, dimension, nullptr); 62 | Feed(L"Output", out_data.get()); 63 | _count = 0; 64 | _collector.clear(); 65 | } 66 | 67 | return true; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/demo_test.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PIL import Image 3 | from radiomics import featureextractor 4 | import sys 5 | import nipy 6 | import SimpleITK as sitk 7 | import xlwt 8 | 9 | 10 | 11 | radiomics_parameter_path = r'C:\projects\pyradiomics\examples\exampleSettings\Params.yaml' 12 | extractor = featureextractor.RadiomicsFeaturesExtractor(radiomics_parameter_path) 13 | extractor.disableAllFeatures() 14 | extractor.enableFeatureClassByName('glcm') 15 | extractor.enableFeatureClassByName('glrlm') 16 | extractor.enableFeatureClassByName('glszm') 17 | extractor.enableFeatureClassByName('gldm') 18 | extractor.enableFeatureClassByName('ngtdm') 19 | extractor.enableFeatureClassByName('firstorder') 20 | extractor.enableFeatureClassByName('shape') 21 | 22 | workbook = xlwt.Workbook(encoding='utf-8') 23 | booksheet = workbook.add_sheet('features', cell_overwrite_ok=True) 24 | 25 | def extract_feature(image, roi, width, height, slice): 26 | print('Invoking Method: [test_radiomics].') 27 | image1 = sitk.GetImageFromArray(np.array(image)) 28 | nproi = np.array(roi) 29 | numb = np.unique(nproi) 30 | nproi[nproi!=0] = 1 31 | # if numb.size==4: # some data roi label-4 for tumour, no label-4, then label-2 for tumour 32 | # nproi[nproi==2] = 0 33 | # nproi[nproi==4] = 1 34 | # if numb.size==3: 35 | # nproi[nproi==1] = 0 36 | # nproi[nproi==2] = 1 37 | image2 = sitk.GetImageFromArray(nproi) 38 | features = extractor.execute(image1,image2) 39 | features.pop('general_info_BoundingBox'); 40 | features.pop('general_info_EnabledImageTypes'); 41 | features.pop('general_info_GeneralSettings'); 42 | features.pop('general_info_ImageHash'); 43 | features.pop('general_info_ImageSpacing'); 44 | features.pop('general_info_MaskHash'); 45 | features.pop('general_info_Version'); 46 | f_value = list(features.values()) 47 | f_name = list(features.keys()) 48 | for i,j in enumerate(f_name): 49 | booksheet.write(0,i,j) 50 | workbook.save('test.xls') 51 | f_size = len(f_value) 52 | return [1, f_value, f_size] 53 | # pil_image = Image.fromarray(np.array(images)) 54 | # pil_image.show() 55 | 56 | -------------------------------------------------------------------------------- /Shared/Interface/IProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef IProcessor_h__20170803 3 | #define IProcessor_h__20170803 4 | 5 | #include "IContainer.h" 6 | #include "smartptr.h" 7 | #include "IVariable.h" 8 | 9 | namespace Yap 10 | { 11 | struct IData; 12 | 13 | struct IPort : public ISharedObject 14 | { 15 | virtual const wchar_t * GetId() const = 0; 16 | virtual unsigned int GetDimensionCount() const = 0; 17 | virtual int GetDataType() const = 0; 18 | }; 19 | 20 | typedef IPtrContainer IPortContainer; 21 | typedef IPortContainer::Iterator IPortIter; 22 | 23 | struct IProcessor : public ISharedObject 24 | { 25 | virtual ISharedObject * Clone() const override = 0; 26 | virtual const wchar_t * GetClassId() const = 0; 27 | virtual void SetClassId(const wchar_t * id) = 0; 28 | 29 | virtual const wchar_t * GetInstanceId() const = 0; 30 | virtual void SetInstanceId(const wchar_t * instance_id) = 0; 31 | 32 | virtual IPortContainer * Inputs() = 0; 33 | virtual IPortContainer * Outputs() = 0; 34 | 35 | /// Return all properties of the processor. 36 | virtual IVariableContainer * GetProperties() = 0; 37 | 38 | /// Map a global variable to a processor property. 39 | virtual bool MapProperty(const wchar_t * property_id, const wchar_t * variable_id, 40 | bool input, bool output) = 0; 41 | 42 | /// Set the global variable space. 43 | virtual bool SetGlobalVariables(IVariableContainer * params) = 0; 44 | 45 | /// Line the output port to an input port of another processor. 46 | virtual bool Link(const wchar_t * output, IProcessor * next, const wchar_t * next_input) = 0; 47 | 48 | /// Feed data into the processor via the specified port. 49 | virtual bool Input(const wchar_t * name, IData * data) = 0; 50 | virtual bool ProcessTimer() = 0; 51 | virtual bool OnTimer() = 0; 52 | 53 | /** @brief Specifies the module that hosts this processor. @p 54 | The module should be locked till the processor is no longer used. */ 55 | virtual void SetModule(ISharedObject * module) = 0; 56 | }; 57 | 58 | typedef IPtrContainer IProcessorContainer; 59 | typedef IProcessorContainer::Iterator IProcessorIter; 60 | } 61 | 62 | #endif // IProcessor_h__ -------------------------------------------------------------------------------- /Shared/Utilities/StringHelper.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | Filename: StringHelper.h 3 | Created: 2009/11/27 4 | Author: Yang Guang, gyang@phy.ecnu.edu.cn 5 | Zhang Chengxiu, angcx@126.com 6 | Purpose: 7 | 8 | All right reserved. 2009 - 9 | 10 | Shanghai Key Laboratory of Magnetic Resonance, 11 | East China Normal University 12 | *********************************************************************/ 13 | 14 | #ifndef StringHelper_h__20091127 15 | #define StringHelper_h__20091127 16 | 17 | #include 18 | 19 | template 20 | const StringType& make_upper(StringType& my_string) 21 | { 22 | for (StringType::size_type i = 0; i < my_string.length(); ++i) 23 | { 24 | if (my_string[i] >= L'a' && my_string[i] <= L'z') 25 | my_string[i] -= L'a' - L'A'; 26 | } 27 | 28 | return my_string; 29 | } 30 | 31 | template 32 | const StringType& make_lower(StringType& my_string) 33 | { 34 | for (StringType::size_type i = 0; i < my_string.length(); ++i) 35 | { 36 | if (my_string[i] >= L'A' && my_string[i] <= L'Z') 37 | my_string[i] += L'a' - L'A'; 38 | } 39 | 40 | return my_string; 41 | } 42 | 43 | inline const std::wstring& trim_left(std::wstring& my_string, const wchar_t * white_spaces = L" \t\n\r") 44 | { 45 | auto begin = my_string.find_first_not_of(white_spaces); 46 | if (begin != std::wstring::npos) 47 | { 48 | my_string = my_string.substr(begin); 49 | } 50 | 51 | return my_string; 52 | } 53 | 54 | inline const std::wstring& trim_right(std::wstring& my_string, const wchar_t * white_spaces = L" \t\n\r") 55 | { 56 | auto end = my_string.find_last_not_of(white_spaces); 57 | if (end != std::wstring::npos) 58 | { 59 | my_string = my_string.substr(0, end + 1); 60 | } 61 | 62 | return my_string; 63 | } 64 | 65 | inline const std::wstring& trim(std::wstring& my_string, const wchar_t * white_spaces = L" \t\n\r") 66 | { 67 | auto begin = my_string.find_first_not_of(white_spaces); 68 | if (begin != std::wstring::npos) 69 | { 70 | auto end = my_string.find_last_not_of(white_spaces); 71 | my_string = my_string.substr(begin, end - begin + 1); 72 | } 73 | 74 | return my_string; 75 | } 76 | 77 | #endif // StringHelper_h__20091127 78 | 79 | -------------------------------------------------------------------------------- /API/Yap/ModuleAgent.cpp: -------------------------------------------------------------------------------- 1 | #include "ModuleAgent.h" 2 | #include 3 | #include "Implement\LogImpl.h" 4 | #include 5 | 6 | #ifdef _USE_PYTHON 7 | #include "Interface\IPython.h" 8 | #endif 9 | 10 | using namespace Yap; 11 | 12 | ModuleAgent::ModuleAgent() : 13 | _module(0) 14 | { 15 | } 16 | 17 | 18 | ModuleAgent::~ModuleAgent() 19 | { 20 | _manager.reset(); 21 | if (_module) 22 | { 23 | ::FreeModule(_module); 24 | } 25 | } 26 | 27 | bool Yap::ModuleAgent::Load(const wchar_t * plugin_path) 28 | { 29 | if (_module != 0) 30 | { 31 | return true; 32 | } 33 | 34 | _module = ::LoadLibrary(plugin_path); 35 | 36 | if (_module == 0) 37 | { 38 | return false; 39 | } 40 | 41 | #ifdef _USE_PYTHON 42 | auto python_func = (Yap::IPythonUser*(*)())::GetProcAddress(_module, "GetPythonUser"); 43 | if (python_func != nullptr) 44 | { 45 | auto python_user = python_func(); 46 | if (python_user != nullptr) 47 | { 48 | python_user->SetPython(PythonFactory::GetPython()); 49 | } 50 | } 51 | #endif 52 | 53 | auto log_func = (Yap::ILogUser*(*)()) ::GetProcAddress(_module, "GetLogUser"); 54 | if (log_func != nullptr) 55 | { 56 | auto log_user = log_func(); 57 | if (log_user != nullptr) 58 | { 59 | log_user->SetLog(&LogImpl::GetInstance()); 60 | } 61 | } 62 | 63 | auto create_func = (Yap::IProcessorContainer*(*)())::GetProcAddress( 64 | _module, "GetProcessorManager"); 65 | if (create_func == nullptr) 66 | { 67 | ::FreeLibrary(_module); 68 | _module = 0; 69 | return false; 70 | } 71 | 72 | _manager = YapShared(create_func()); 73 | if (!_manager) 74 | { 75 | ::FreeLibrary(_module); 76 | _module = 0; 77 | return false; 78 | } 79 | 80 | return true; 81 | } 82 | 83 | Yap::IProcessorIter * Yap::ModuleAgent::GetIterator() 84 | { 85 | assert(_manager); 86 | return _manager ? _manager->GetIterator() : nullptr; 87 | } 88 | 89 | bool Yap::ModuleAgent::Add(const wchar_t * name, IProcessor * processor) 90 | { 91 | assert(_manager); 92 | return _manager ? _manager->Add(name, processor) : false; 93 | } 94 | 95 | Yap::IProcessor * Yap::ModuleAgent::Find(const wchar_t * name) 96 | { 97 | assert(_manager); 98 | return _manager ? _manager->Find(name) : nullptr; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /PluginSDK/PluginSDK.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicRecon", "BasicRecon\BasicRecon.vcxproj", "{230C76EE-C0FE-4F6D-B567-9629019003F1}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88} = {E16DDA60-3E14-4E06-92DC-2F28832E7D88} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utilities", "..\Shared\Utilities\Utilities.vcxproj", "{E16DDA60-3E14-4E06-92DC-2F28832E7D88}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Debug|x64.ActiveCfg = Debug|x64 22 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Debug|x64.Build.0 = Debug|x64 23 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Debug|x86.ActiveCfg = Debug|Win32 24 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Debug|x86.Build.0 = Debug|Win32 25 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Release|x64.ActiveCfg = Release|x64 26 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Release|x64.Build.0 = Release|x64 27 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Release|x86.ActiveCfg = Release|Win32 28 | {230C76EE-C0FE-4F6D-B567-9629019003F1}.Release|x86.Build.0 = Release|Win32 29 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Debug|x64.ActiveCfg = Debug|x64 30 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Debug|x64.Build.0 = Debug|x64 31 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Debug|x86.ActiveCfg = Debug|Win32 32 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Debug|x86.Build.0 = Debug|Win32 33 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Release|x64.ActiveCfg = Release|x64 34 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Release|x64.Build.0 = Release|x64 35 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Release|x86.ActiveCfg = Release|Win32 36 | {E16DDA60-3E14-4E06-92DC-2F28832E7D88}.Release|x86.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : PythonRecon Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this PythonRecon DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your PythonRecon application. 9 | 10 | 11 | PythonRecon.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | PythonRecon.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | PythonRecon.cpp 25 | This is the main DLL source file. 26 | 27 | When created, this DLL does not export any symbols. As a result, it 28 | will not produce a .lib file when it is built. If you wish this project 29 | to be a project dependency of some other project, you will either need to 30 | add code to export some symbols from the DLL so that an export library 31 | will be produced, or you can set the Ignore Input Library property to Yes 32 | on the General propert page of the Linker folder in the project's Property 33 | Pages dialog box. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other standard files: 37 | 38 | StdAfx.h, StdAfx.cpp 39 | These files are used to build a precompiled header (PCH) file 40 | named PythonRecon.pch and a precompiled types file named StdAfx.obj. 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | Other notes: 44 | 45 | AppWizard uses "TODO:" comments to indicate parts of the source code you 46 | should add to or customize. 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /API/Yap/YapClient.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-09-18T16:46:46 4 | # 5 | #------------------------------------------------- 6 | 7 | QT -= gui 8 | 9 | QT += widgets 10 | 11 | TARGET = YapClient 12 | TEMPLATE = lib 13 | CONFIG += staticlib 14 | 15 | INCLUDEPATH += $$PWD/.. \ 16 | D:/ThirdParty/boost \ 17 | $$PWD/../../shared 18 | 19 | DEPENDPATH += $$PWD/.. 20 | 21 | SOURCES += ModuleManager.cpp \ 22 | PipelineCompiler.cpp \ 23 | PipelineConstructor.cpp \ 24 | ProcessorAgent.cpp \ 25 | ../../shared/Client/DataHelper.cpp \ 26 | ../../shared/Client/stdafx.cpp \ 27 | ../../shared/Implement/CompositeProcessor.cpp \ 28 | ../../shared/Implement/DataObject.cpp \ 29 | ../../shared/Implement/ProcessorImpl.cpp \ 30 | ../../shared/Implement/VariableSpace.cpp \ 31 | ../../shared/Implement/LogImpl.cpp \ 32 | ../../shared/Implement/LogUserImpl.cpp \ 33 | Preprocessor.cpp \ 34 | VdfParser.cpp \ 35 | ScanFileParser.cpp 36 | 37 | HEADERS += ModuleManager.h \ 38 | PipelineCompiler.h \ 39 | PipelineConstructor.h \ 40 | ProcessorAgent.h \ 41 | ../../shared/Client/DataHelper.h \ 42 | ../../shared/Client/stdafx.h \ 43 | ../../shared/Client/targetver.h \ 44 | ../../shared/Implement/CompositeProcessor.h \ 45 | ../../shared/Implement/ContainerImpl.h \ 46 | ../../shared/Implement/DataObject.h \ 47 | ../../shared/Implement/ProcessorImpl.h \ 48 | ../../shared/Implement/YapImplement.h \ 49 | ../../shared/Implement/VariableSpace.h \ 50 | ../../shared/Implement/LogImpl.h \ 51 | ../../shared/Implement/LogUserImpl.h \ 52 | Preprocessor.h \ 53 | VdfParser.h \ 54 | ScanFileParser.h \ 55 | ../../shared/Interface/Interfaces.h \ 56 | ../../shared/Interface/smartptr.h 57 | unix { 58 | target.path = /usr/lib 59 | INSTALLS += target 60 | } 61 | 62 | DISTFILES += \ 63 | 64 | ../../shared/Interface/Implement/README.md 65 | 66 | win32:CONFIG(release, debug|release): LIBS += -L/ThirdParty/log4cplus2/lib/ -llog4cplus 67 | else:win32:CONFIG(debug, debug|release): LIBS += -L/ThirdParty/log4cplus2/lib/ -llog4cplusu 68 | else:unix: LIBS += -L/ThirdParty/log4cplus2/lib/ -llog4cplus 69 | 70 | INCLUDEPATH += d:/ThirdParty/log4cplus2/include 71 | DEPENDPATH += d:/ThirdParty/log4cplus2/include 72 | -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/Flip.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Flip.h" 3 | 4 | #include "Client/DataHelper.h" 5 | #include "Implement/LogUserImpl.h" 6 | 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | using namespace Yap; 12 | 13 | Flip::Flip() : ProcessorImpl(L"Flip") 14 | { 15 | AddInput(L"Input", 2, DataTypeUnsignedShort | DataTypeShort); 16 | AddOutput(L"Output", 2, DataTypeUnsignedShort | DataTypeShort); 17 | AddProperty(L"FlipH", false, L"Flip Horizontal."); 18 | AddProperty(L"FlipV", true, L"Flip Vertical."); 19 | 20 | } 21 | 22 | Flip::Flip(const Flip& rhs) 23 | :ProcessorImpl(rhs) 24 | { 25 | } 26 | 27 | Flip::~Flip() 28 | { 29 | } 30 | /** 31 | \remark backup function. 32 | */ 33 | 34 | bool Flip::Input(const wchar_t * port, IData * data) 35 | { 36 | 37 | if (std::wstring(port) != L"Input") 38 | { 39 | LOG_ERROR(L" Error input port name!", L"BasicRecon"); 40 | return false; 41 | } 42 | 43 | DataHelper helper(data); 44 | 45 | 46 | Dimensions data_dimensions(data->GetDimensions()); 47 | int width{ 1 }, height{ 1 }; 48 | width = helper.GetWidth(); 49 | height = helper.GetHeight(); 50 | assert(1 == helper.GetSliceCount()); 51 | 52 | bool FlipH( GetProperty(L"FlipH") ); 53 | bool FlipV( GetProperty(L"FlipV") ); 54 | 55 | // 56 | 57 | 58 | 59 | if (data->GetDataType() == DataTypeShort) 60 | { 61 | assert(0, L"Not Implemented."); 62 | } 63 | 64 | unsigned short* buffer = Yap::GetDataArray(data); 65 | 66 | if (FlipH) 67 | { 68 | 69 | for (int row_index = 0; row_index < width; ++row_index) 70 | { 71 | unsigned short * line = buffer + row_index * width; 72 | 73 | for (int i = 0; i < width / 2; i++) 74 | { 75 | swap(*(line + i), *(line + width - 1 - i)); 76 | } 77 | } 78 | 79 | } 80 | 81 | 82 | if (FlipV) 83 | { 84 | unsigned short * temp = new unsigned short[width]; 85 | 86 | for (int j = 0; j < height/2; ++j) 87 | { 88 | unsigned short * line1 = buffer + j * width; 89 | unsigned short * line2 = buffer + (height - 1 - j) * width; 90 | 91 | memcpy(temp, line1, sizeof(unsigned short) * width); 92 | memcpy(line1, line2, sizeof(unsigned short) * width); 93 | memcpy(line2, temp, sizeof(unsigned short) * width); 94 | 95 | } 96 | delete[]temp; 97 | 98 | 99 | } 100 | return Feed(L"Output", data); 101 | 102 | } -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/LinesSelector.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "LinesSelector.h" 3 | #include "Implement/LogUserImpl.h" 4 | #include "Client/DataHelper.h" 5 | 6 | using namespace std; 7 | using namespace Yap; 8 | 9 | Yap::LinesSelector::LinesSelector(): 10 | ProcessorImpl(L"LinesSelector") 11 | { 12 | AddInput(L"Input", 2, DataTypeComplexFloat); 13 | AddOutput(L"Output", 2, DataTypeComplexFloat); 14 | 15 | AddProperty(L"FirstLineIndex", 0, L"The index of the first line you want to get."); 16 | AddProperty(L"LinesCount", 1, L"The count of lines you want to get."); 17 | } 18 | 19 | Yap::LinesSelector::LinesSelector(const LinesSelector& rhs): 20 | ProcessorImpl(rhs) 21 | { 22 | } 23 | 24 | Yap::LinesSelector::~LinesSelector() 25 | { 26 | } 27 | 28 | bool Yap::LinesSelector::Input(const wchar_t * name, IData * data) 29 | { 30 | // Do some check. 31 | if (data == nullptr) 32 | { 33 | LOG_ERROR(L" Invalid input data!", L"BasicRecon"); 34 | return false; 35 | } 36 | if (_wcsicmp(name, L"Input") != 0) 37 | { 38 | LOG_ERROR(L" Error input port name!", L"BasicRecon"); 39 | return false; 40 | } 41 | 42 | DataHelper input_data(data); 43 | if (input_data.GetActualDimensionCount() != 2) 44 | { 45 | LOG_ERROR(L" Error input data dimention!(2D data is available)!", L"BasicRecon"); 46 | return false; 47 | } 48 | if (input_data.GetDataType() != DataTypeComplexFloat) 49 | { 50 | LOG_ERROR(L" Error input data type!(DataTypeComplexFloat are available)!", L"BasicRecon"); 51 | return false; 52 | } 53 | 54 | int first_line_index = GetProperty(L"FirstLineIndex"); 55 | int lines_count = GetProperty(L"LinesCount"); 56 | 57 | if (unsigned int(first_line_index + lines_count) > input_data.GetHeight() || 58 | first_line_index < 0 || lines_count <= 0) 59 | { 60 | LOG_ERROR(L" Improper properties(FirstLineIndex, LineCount) value.", L"BasicRecon"); 61 | return false; 62 | } 63 | 64 | Yap::Dimensions dims; 65 | dims(DimensionReadout, 0, input_data.GetWidth()) 66 | (DimensionPhaseEncoding, 0, lines_count); 67 | auto output = CreateData>(data, &dims); 68 | 69 | memset(Yap::GetDataArray>(output.get()), 0, 70 | input_data.GetWidth() * lines_count * sizeof(complex)); 71 | 72 | memcpy(Yap::GetDataArray>(output.get()), 73 | Yap::GetDataArray>(data) + first_line_index * input_data.GetWidth(), 74 | input_data.GetWidth() * lines_count * sizeof(complex)); 75 | 76 | return Feed(L"Output", output.get()); 77 | } -------------------------------------------------------------------------------- /PluginSDK/BasicRecon/ChannelSelector.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ChannelSelector.h" 3 | #include "Client/DataHelper.h" 4 | #include "Implement/LogUserImpl.h" 5 | 6 | #include 7 | 8 | using namespace std; 9 | using namespace Yap; 10 | 11 | ChannelSelector::ChannelSelector(void): 12 | ProcessorImpl(L"ChannelSelector") 13 | { 14 | AddInput(L"Input", YAP_ANY_DIMENSION, DataTypeComplexFloat); 15 | AddOutput(L"Output", YAP_ANY_DIMENSION, DataTypeComplexFloat); 16 | 17 | AddProperty(L"ChannelIndex", 3, L"The index of the channel you want to get."); 18 | 19 | } 20 | 21 | Yap::ChannelSelector::ChannelSelector(const ChannelSelector & rhs) 22 | : ProcessorImpl(rhs) 23 | { 24 | } 25 | 26 | ChannelSelector::~ChannelSelector() 27 | { 28 | } 29 | 30 | 31 | bool Yap::ChannelSelector::Input(const wchar_t * name, IData * data) 32 | { 33 | 34 | bool is_type_complexf = (Yap::GetDataArray>(data) != nullptr); 35 | bool is_type_short = (Yap::GetDataArray(data) != nullptr); 36 | 37 | assert((data != nullptr) && (is_type_complexf || is_type_short)); 38 | assert(Inputs()->Find(name) != nullptr); 39 | 40 | int selected_index = GetProperty(L"ChannelIndex"); 41 | 42 | DataHelper input_data(data); 43 | Dimensions data_dimensions(data->GetDimensions()); 44 | // 45 | unsigned int channel_dimension_count; 46 | unsigned int channel_index; 47 | data_dimensions.GetDimensionInfo2(Yap::DimensionChannel, channel_index, channel_dimension_count); 48 | // 49 | if (channel_dimension_count == 1) 50 | { 51 | if (channel_index == selected_index) 52 | { 53 | {//log 54 | 55 | wstring info = wstring(L"") + 56 | L"-----selected channel index = " + to_wstring(selected_index); 57 | 58 | LOG_TRACE(info.c_str(), L"BasicRecon"); 59 | } 60 | 61 | if (is_type_complexf) 62 | { 63 | auto output = CreateData>(data, 64 | Yap::GetDataArray>(data), 65 | data_dimensions, data); 66 | //Parameter "channel_count" cannot be saved in dimension. 67 | AddASingleVarible(output.get(), L"channel_count", 1, DataHelper(output.get()).GetDataType()); 68 | Feed(L"Output", output.get()); 69 | } 70 | if (is_type_short) 71 | { 72 | auto output = CreateData(data, 73 | Yap::GetDataArray(data), 74 | data_dimensions, data); 75 | AddASingleVarible(output.get(), L"channel_count", 1, DataHelper(output.get()).GetDataType()); 76 | Feed(L"Output", output.get()); 77 | } 78 | } 79 | 80 | } 81 | else 82 | { 83 | assert(0 && L"Not Impemented!"); 84 | } 85 | return true; 86 | } -------------------------------------------------------------------------------- /API/Yap/Yap.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Shared/Utilities/Utilities.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Shared/Implement/LogUserImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "LogUserImpl.h" 2 | 3 | #include 4 | 5 | using namespace Yap; 6 | using namespace std; 7 | 8 | std::shared_ptr Yap::LogUserImpl::s_instance; 9 | 10 | LogUserImpl::LogUserImpl():_log(nullptr) 11 | { 12 | _log_name = L"sys.log"; 13 | _module = L""; 14 | _flush = true; 15 | } 16 | 17 | LogUserImpl::~LogUserImpl() 18 | { 19 | if (_log != nullptr) 20 | { 21 | _log->RemoveUser(this); 22 | } 23 | } 24 | 25 | LogUserImpl& LogUserImpl::GetInstance() 26 | { 27 | if (!s_instance) 28 | { 29 | s_instance = shared_ptr(new LogUserImpl()); 30 | } 31 | return *s_instance; 32 | } 33 | 34 | bool LogUserImpl::Init(const wchar_t * default_log, const wchar_t * default_module) 35 | { 36 | _module = default_module; 37 | _log_name = default_log; 38 | 39 | return true; 40 | } 41 | 42 | void LogUserImpl::SetLog(ILog* log) 43 | { 44 | _log = log; 45 | } 46 | 47 | void Yap::LogUserImpl::Trace(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 48 | { 49 | if (_log != nullptr) 50 | { 51 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelTrace, 52 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 53 | } 54 | } 55 | 56 | void Yap::LogUserImpl::Debug(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 57 | { 58 | if (_log != nullptr) 59 | { 60 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelDebug, 61 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 62 | } 63 | } 64 | 65 | void Yap::LogUserImpl::Info(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 66 | { 67 | if (_log != nullptr) 68 | { 69 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelInfo, 70 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 71 | } 72 | } 73 | 74 | void Yap::LogUserImpl::Warn(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 75 | { 76 | if (_log != nullptr) 77 | { 78 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelWarn, 79 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 80 | } 81 | } 82 | 83 | void Yap::LogUserImpl::Error(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 84 | { 85 | if (_log != nullptr) 86 | { 87 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelError, 88 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 89 | } 90 | } 91 | 92 | void Yap::LogUserImpl::Fatal(const wchar_t * info, const wchar_t * module, const wchar_t * log_name) 93 | { 94 | if (_log != nullptr) 95 | { 96 | _log->Log(module != nullptr ? module : _module.c_str(), info, LevelFatal, 97 | log_name != nullptr ? log_name : _log_name.c_str(), _flush); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /PluginSDK/PythonRecon/Python/Radiomics_ExtractFeatures.py: -------------------------------------------------------------------------------- 1 | from radiomics import featureextractor 2 | from excel_helper import Save_Column_Exel, Save_Column_Title, Save_Row_Exel 3 | import numpy as np 4 | ## import h5py 5 | import SimpleITK as sitk 6 | import nibabel as nib 7 | 8 | 9 | # f_train = h5py.File(r'Z:\Radiomics_ZhangJing\ProstateX\new_data\training_2D_101x101_box_center.h5') 10 | # f_test = h5py.File(r'Z:\Radiomics_ZhangJing\ProstateX\new_data\testing_2D_101x101_box_center_no_label.h5') 11 | # f_val = h5py.File(r'Z:\Radiomics_ZhangJing\ProstateX\new_data\validation_2D_101x101_box_center.h5') 12 | 13 | 14 | # extract features from data 15 | 16 | param_path = r'C:\projects\pyradiomics\examples\exampleSettings\Params.yaml'; 17 | extractor = featureextractor.RadiomicsFeaturesExtractor(param_path) 18 | # extractor.disableAllFeatures() 19 | # extractor.enableFeatureClassByName('glcm') 20 | # extractor.enableFeatureClassByName('glrlm') 21 | # extractor.enableFeatureClassByName('glszm') 22 | # extractor.e# nableFeatureClassByName('gldm') 23 | # extractor.enableFeatureClassByName('ngtdm') 24 | # # extractor.enableFeatureClassByName('firstorder') 25 | # extractor.enableFeatureClassByName('shape') 26 | 27 | root = 'D:\\test_data\\MR0309928\\' 28 | image_roi_name = [(r'3 T2_tra.nii', r'3T2_tra_seg.nii'), 29 | (r'4 t1_fl2d_tra.nii', r'4t1_fl2d_tra_seg.nii'), 30 | (r'5 T2_FLAIR_tra.nii', r'5T2_FLAIR_tra_seg.nii'), 31 | (r'7 resolve_4scan_trace_tra_p2_192_ADC.nii', r'7resolve_4scan_trace_tra_p2_192_ADC_seg.nii'), 32 | (r'12 ep2d_diff_mddw_20_p2_FA.nii', r'12ep2d_diff_mddw_20_p2_FA_seg.nii'), 33 | (r'15 Mag_Images.nii', r'15Mag_Images_seg.nii'), 34 | (r'16 Pha_Images.nii', r'16Pha_Images_seg.nii'), 35 | (r'17 mIP_Images(SW).nii', r'17mIP_Images(SW)_seg.nii'), 36 | (r'18 SWI_Images.nii', r'18SWI_Images_seg.nii'), 37 | (r'23 T1_Images_B1corr.nii', r'23T1_Images_B1corr_seg.nii'), 38 | (r'60 t1_fl2d_tra.nii', r'60t1_fl2d_tra_seg.nii')] 39 | 40 | image_name = {x[1]: x[0] for x in image_roi_name} 41 | set_title = True 42 | column_start = 1 43 | row_start = 2 44 | for img_n, roi_n in image_roi_name: 45 | img = nib.load(root + img_n) 46 | img = sitk.GetImageFromArray(np.array(img.get_data(), np.float32)) 47 | roi = nib.load(root + roi_n) 48 | roi = sitk.GetImageFromArray(np.array(roi.get_data(), np.uint16)) 49 | feature = extractor.execute(img, roi) 50 | if set_title: 51 | if Save_Column_Title(r'D:\test_data\test_result.xlsx', feature, 2, 1) | Save_Row_Exel(r'D:\test_data\test_result.xlsx', image_name, 1, 2) is False: 52 | assert (0 & r'error') 53 | set_title = False 54 | column_start += 1 55 | if Save_Column_Exel(r'D:\test_data\test_result.xlsx', feature, row_start, column_start) is False: 56 | assert 0 57 | --------------------------------------------------------------------------------