17#ifndef __file_dicom_image_h__
18#define __file_dicom_image_h__
36 acq_dim[0] = acq_dim[1] = dim[0] = dim[1] = instance =
37 series_num = acq = sequence = echo_index = grad_number = UINT_MAX;
38 samples_per_pixel = 1;
39 position_vector[0] = position_vector[1] = position_vector[2] =
NaN;
40 orientation_x[0] = orientation_x[1] = orientation_x[2] =
NaN;
41 orientation_y[0] = orientation_y[1] = orientation_y[2] =
NaN;
42 orientation_z[0] = orientation_z[1] = orientation_z[2] =
NaN;
44 pixel_size[0] = pixel_size[1] = slice_thickness = slice_spacing =
NaN;
45 scale_intercept = 0.0;
47 bvalue = G[0] = G[1] = G[2] =
NaN;
48 data = bits_alloc = data_size = frame_offset = 0;
49 DW_scheme_wrt_image =
false;
50 transfer_syntax_supported =
true;
51 ignore_series_num =
false;
54 philips_orientation =
'\0';
55 pixel_bandwidth = bandwidth_per_pixel_phase_encode = echo_time = inversion_time = repetition_time = flip_angle = partial_fourier = time_after_start =
NaN;
56 echo_train_length = 0;
57 bipolar_flag = readoutmode_flag = 0;
60 size_t acq_dim[2], dim[2], series_num, instance, acq, sequence, echo_index, grad_number, samples_per_pixel;
61 Eigen::Vector3d position_vector, orientation_x, orientation_y, orientation_z, G;
62 default_type distance, pixel_size[2], slice_thickness, slice_spacing, scale_slope, scale_intercept, bvalue;
63 size_t data, bits_alloc, data_size, frame_offset;
64 std::string filename, image_type;
65 bool DW_scheme_wrt_image, transfer_syntax_supported, ignore_series_num;
68 char philips_orientation;
69 Time acquisition_time;
70 default_type pixel_bandwidth, bandwidth_per_pixel_phase_encode, echo_time, inversion_time, repetition_time, flip_angle, partial_fourier, time_after_start;
71 size_t echo_train_length;
72 size_t bipolar_flag, readoutmode_flag;
76 bool operator< (
const Frame& frame)
const {
77 if (!ignore_series_num && series_num != frame.series_num)
78 return series_num < frame.series_num;
79 if (image_type != frame.image_type)
80 return image_type < frame.image_type;
82 return acq < frame.acq;
83 if (std::isfinite (distance) && std::isfinite (frame.distance) && distance != frame.distance)
84 return distance < frame.distance;
85 for (
size_t n =
index.size(); n--;)
86 if (
index[n] != frame.index[n])
87 return index[n] < frame.index[n];
88 if (echo_index != frame.echo_index)
89 return echo_index < frame.echo_index;
90 if (std::isfinite (echo_time) && echo_time != frame.echo_time)
91 return echo_time < frame.echo_time;
92 if (grad_number != frame.grad_number)
93 return grad_number < frame.grad_number;
94 if (sequence != frame.sequence)
95 return sequence < frame.sequence;
96 if (instance != frame.instance)
97 return instance < frame.instance;
102 void calc_distance ()
104 if (!std::isfinite (orientation_z[0]))
105 orientation_z = orientation_x.cross (orientation_y);
107 if (!orientation_x.allFinite() || !orientation_y.allFinite())
108 throw Exception (
"slice orientation information missing from DICOM header!");
109 Eigen::Vector3d
normal = orientation_x.cross (orientation_y);
110 if (
normal.dot (orientation_z) < 0.0)
116 if (!position_vector.allFinite())
117 throw Exception (
"slice position information missing from DICOM header!");
119 orientation_z.normalize();
120 distance = orientation_z.dot (position_vector);
123 bool is_philips_iso ()
const {
124 if (philips_orientation ==
'\0')
126 return (philips_orientation ==
'I' && bvalue > 0.0);
132 static Eigen::MatrixXd get_PE_scheme (
const vector<Frame*>& frames,
const size_t nslices);
152 images_in_mosaic (0),
154 in_frames (
false) { }
157 size_t images_in_mosaic;
158 std::string sequence_name, manufacturer;
159 bool is_BE, in_frames;
167 void decode_csa (
const uint8_t* start,
const uint8_t* end);
170 bool operator< (
const Image& ima)
const {
171 return Frame::operator< (ima);
friend std::ostream & operator<<(std::ostream &stream, const Frame &item)
friend std::ostream & operator<<(std::ostream &stream, const Image &item)
std::string dirname(const std::string &name)
Vertex normal(const Vertex &one, const Vertex &two, const Vertex &three)
std::map< std::string, std::string > KeyValues
used in various places for storing key-value pairs
double default_type
the default type used throughout MRtrix
Eigen::Transform< default_type, 3, Eigen::AffineCompact > transform_type
the type for the affine transform of an image:
constexpr default_type NaN