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{
16
17namespace VoxelsLoad
18{
19
20
21enum class DicomStatusEnum : int
22{
23 Ok = 0, // valid DICOM and we can open it
24 Invalid, // not a valid DICOM
25 Unsupported, // a valid DICOM, but we do not support it (e.g. some MediaStorages)
26};
27
28struct DicomStatus
29{
30 // implicit by design
31 DicomStatus( DicomStatusEnum st, std::string_view rs = "" ):
32 status( st ),
33 reason( rs )
34 {}
35
36 explicit operator bool() const
37 { return status == DicomStatusEnum::Ok; }
38
39 bool operator==( DicomStatusEnum s ) const
40 { return status == s; }
41
42 DicomStatusEnum status = DicomStatusEnum::Invalid;
43 std::string reason; // if status is Unsupported, specify reason why
44};
45
49MRVOXELS_API DicomStatus isDicomFile( const std::filesystem::path& path, std::string* seriesUid = nullptr, Vector3i* dims = nullptr );
50
52MRVOXELS_API bool isDicomFolder( const std::filesystem::path& dirPath );
53
55MRVOXELS_API std::vector<std::filesystem::path> findDicomFoldersRecursively( const std::filesystem::path& path );
56
57template <typename T>
59{
60 T vol;
61 std::string name;
63};
64
66MRVOXELS_API Expected<DicomVolume> loadDicomFile( const std::filesystem::path& file, const ProgressCallback& cb = {} );
67
69MRVOXELS_API Expected<DicomVolumeAsVdb> loadDicomFileAsVdb( const std::filesystem::path& file, const ProgressCallback& cb = {} );
70
72MRVOXELS_API Expected<DicomVolume> loadDicomFolder( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
73
75MRVOXELS_API Expected<DicomVolumeAsVdb> loadDicomFolderAsVdb( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
76
78MRVOXELS_API std::vector<Expected<DicomVolume>> loadDicomsFolder( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
79
81MRVOXELS_API std::vector<Expected<DicomVolumeAsVdb>> loadDicomsFolderAsVdb( const std::filesystem::path& path, unsigned maxNumThreads, const ProgressCallback& cb = {} );
82
84MRVOXELS_API std::vector<Expected<DicomVolumeAsVdb>> loadDicomsFolderTreeAsVdb( const std::filesystem::path& path,
85 unsigned maxNumThreads = 4, const ProgressCallback& cb = {} );
86
88MRVOXELS_API Expected<std::shared_ptr<ObjectVoxels>> createObjectVoxels( const DicomVolumeAsVdb & dcm, const ProgressCallback & cb = {} );
89
91MRVOXELS_API Expected<LoadedObjects> makeObjectVoxelsFromDicomFolder( const std::filesystem::path& folder, const ProgressCallback& callback = {} );
92
93} // namespace VoxelsLoad
94
95namespace VoxelsSave
96{
97
99MRVOXELS_API Expected<void> toDicom( const VdbVolume& vdbVolume, const std::filesystem::path& path, ProgressCallback cb = {} );
102template <typename T>
103MRVOXELS_API Expected<void> toDicom( const VoxelsVolume<Vector<T,VoxelId>>& volume, const std::filesystem::path& path, const std::optional<MinMaxf>& sourceScale = {}, const ProgressCallback& cb = {} );
104
105extern 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 );
106
107} // namespace VoxelsSave
108
109} // namespace MR
110#endif
#define MRVOXELS_API
Definition MRVoxelsFwd.h:14
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:19
Definition MRDicom.h:29
unsafe DicomStatus(MR.VoxelsLoad._ByValue_DicomStatus _other)
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.
MRVOXELS_API Expected< std::shared_ptr< ObjectVoxels > > createObjectVoxels(const DicomVolumeAsVdb &dcm, const ProgressCallback &cb={})
converts DicomVolumeAsVdb in ObjectVoxels
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.
MRVOXELS_API std::vector< std::filesystem::path > findDicomFoldersRecursively(const std::filesystem::path &path)
returns all the dicom folders in path, searching recursively
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.
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.
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.
MRVOXELS_API Expected< void > toDicom(const VdbVolume &vdbVolume, const std::filesystem::path &path, ProgressCallback cb={})
Save voxels object to a single 3d DICOM file.
Definition MRCameraOrientationPlugin.h:8
MRMESH_API double volume(const MeshTopology &topology, const VertCoords &points, const FaceBitSet *region=nullptr)
Definition MRDicom.h:59
std::string name
Definition MRDicom.h:61
AffineXf3f xf
Definition MRDicom.h:62
T vol
Definition MRDicom.h:60
represents a box in 3D space subdivided on voxels stored in T
Definition MRVoxelsVolume.h:48