MeshLib C++ Docs
Loading...
Searching...
No Matches
MRDicom.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4#ifndef MRVOXELS_NO_DICOM
5#include "MRVoxelsVolume.h"
6
7#include "MRMesh/MRAffineXf.h"
8#include "MRMesh/MRMatrix3.h"
10
11#include <filesystem>
12#include <optional>
13
14namespace MR
15{
18
19
20namespace VoxelsLoad
21{
22
23
24enum class DicomStatusEnum : int
25{
26 Ok = 0,
27 Invalid,
29};
30
32{
34 DicomStatus( DicomStatusEnum st, std::string_view rs = "" ):
35 status( st ),
36 reason( rs )
37 {}
38
39 explicit operator bool() const
40 { return status == DicomStatusEnum::Ok; }
41
43 { return status == s; }
44
46 std::string reason;
47};
48
52MRVOXELS_API DicomStatus isDicomFile( const std::filesystem::path& path, std::string* seriesUid = nullptr, Vector3i* dims = nullptr );
53
55MRVOXELS_API bool isDicomFolder( const std::filesystem::path& dirPath );
56
58MRVOXELS_API std::vector<std::filesystem::path> findDicomFoldersRecursively( const std::filesystem::path& path );
59
60template <typename T>
62{
63 T vol;
64 std::string name;
65 AffineXf3f xf;
66};
67
69MRVOXELS_API Expected<DicomVolume> loadDicomFile( const std::filesystem::path& file, const ProgressCallback& cb = {} );
70
72MRVOXELS_API Expected<DicomVolumeAsVdb> loadDicomFileAsVdb( const std::filesystem::path& file, const ProgressCallback& cb = {} );
73
75MRVOXELS_API Expected<DicomVolume> loadDicomFolder( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
76
78MRVOXELS_API Expected<DicomVolumeAsVdb> loadDicomFolderAsVdb( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
79
81MRVOXELS_API std::vector<Expected<DicomVolume>> loadDicomsFolder( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
82
84MRVOXELS_API std::vector<Expected<DicomVolumeAsVdb>> loadDicomsFolderAsVdb( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
85
87MRVOXELS_API std::vector<Expected<DicomVolumeAsVdb>> loadDicomsFolderTreeAsVdb( const std::filesystem::path& path,
88 unsigned maxNumThreads = 4, const ProgressCallback& cb = {} );
89
91MRVOXELS_API Expected<std::shared_ptr<ObjectVoxels>> createObjectVoxels( const DicomVolumeAsVdb & dcm, const ProgressCallback & cb = {} );
92
94MRVOXELS_API Expected<LoadedObjects> makeObjectVoxelsFromDicomFolder( const std::filesystem::path& folder, const ProgressCallback& callback = {} );
95
96}
97
98namespace VoxelsSave
99{
100
102MRVOXELS_API Expected<void> toDicom( const VdbVolume& vdbVolume, const std::filesystem::path& path, ProgressCallback cb = {} );
105template <typename T>
106MRVOXELS_API Expected<void> toDicom( const VoxelsVolume<Vector<T,VoxelId>>& volume, const std::filesystem::path& path, const std::optional<MinMaxf>& sourceScale = {}, const ProgressCallback& cb = {} );
107
108extern template MRVOXELS_API Expected<void> toDicom( const VoxelsVolume<Vector<std::uint16_t, VoxelId>>& volume, const std::filesystem::path& path, const std::optional<MinMaxf>& sourceScale, const ProgressCallback& cb );
109
110}
111
112}
113#endif
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
MRVOXELS_API Expected< LoadedObjects > makeObjectVoxelsFromDicomFolder(const std::filesystem::path &folder, const ProgressCallback &callback={})
Loads 3D volumetric data from dicom-files in given folder, and converts them into an ObjectVoxels.
std::string reason
Definition MRDicom.h:46
std::string name
Definition MRDicom.h:64
MRVOXELS_API Expected< std::shared_ptr< ObjectVoxels > > createObjectVoxels(const DicomVolumeAsVdb &dcm, const ProgressCallback &cb={})
converts DicomVolumeAsVdb in ObjectVoxels
DicomStatusEnum
Definition MRDicom.h:25
MRVOXELS_API Expected< DicomVolumeAsVdb > loadDicomFolderAsVdb(const std::filesystem::path &path, unsigned maxNumThreads, const ProgressCallback &cb={})
Loads one volume from DICOM files located in given folder as VdbVolume.
AffineXf3f xf
Definition MRDicom.h:65
MRVOXELS_API std::vector< std::filesystem::path > findDicomFoldersRecursively(const std::filesystem::path &path)
returns all the dicom folders in path, searching recursively
DicomStatusEnum status
Definition MRDicom.h:45
tl::expected< T, E > Expected
Definition MRExpected.h:31
DicomStatus(DicomStatusEnum st, std::string_view rs="")
implicit by design
Definition MRDicom.h:34
MRVOXELS_API std::vector< Expected< DicomVolume > > loadDicomsFolder(const std::filesystem::path &path, unsigned maxNumThreads, const ProgressCallback &cb={})
Loads all volumes from DICOM files located in given folder as a number of SimpleVolumeMinMax.
MRMESH_API double volume(const MeshTopology &topology, const VertCoords &points, const FaceBitSet *region=nullptr)
MRVOXELS_API Expected< void > toDicom(const VdbVolume &vdbVolume, const std::filesystem::path &path, ProgressCallback cb={})
Save voxels object to a single 3d DICOM file.
MRVOXELS_API Expected< DicomVolume > loadDicomFile(const std::filesystem::path &file, const ProgressCallback &cb={})
Loads full volume from single DICOM file (not a slice file) as SimpleVolumeMinMax.
bool operator==(DicomStatusEnum s) const
Definition MRDicom.h:42
T vol
Definition MRDicom.h:63
MRVOXELS_API Expected< DicomVolumeAsVdb > loadDicomFileAsVdb(const std::filesystem::path &file, const ProgressCallback &cb={})
Loads full volume from single DICOM file (not a slice file) as VdbVolume.
MRVOXELS_API Expected< DicomVolume > loadDicomFolder(const std::filesystem::path &path, unsigned maxNumThreads, const ProgressCallback &cb={})
Loads one volume from DICOM files located in given folder as SimpleVolumeMinMax.
MRVOXELS_API DicomStatus isDicomFile(const std::filesystem::path &path, std::string *seriesUid=nullptr, Vector3i *dims=nullptr)
MRVOXELS_API std::vector< Expected< DicomVolumeAsVdb > > loadDicomsFolderTreeAsVdb(const std::filesystem::path &path, unsigned maxNumThreads=4, const ProgressCallback &cb={})
Loads every subfolder with DICOM volume as new object.
MRVOXELS_API bool isDicomFolder(const std::filesystem::path &dirPath)
check if given folder contains at least one DICOM file
MRVOXELS_API std::vector< Expected< DicomVolumeAsVdb > > loadDicomsFolderAsVdb(const std::filesystem::path &path, unsigned maxNumThreads, const ProgressCallback &cb={})
Loads all volumes from DICOM files located in given folder as a number of VdbVolume.
@ Invalid
valid DICOM and we can open it
@ Unsupported
not a valid DICOM
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRDicom.h:32
Definition MRDicom.h:62
represents a box in 3D space subdivided on voxels stored in T
Definition MRVoxelsVolume.h:51