MCPcopy Create free account
hub / github.com/Kitware/VTK / GetImagePositionPatientFilenamePairs

Method GetImagePositionPatientFilenamePairs

Utilities/DICOMParser/DICOMAppHelper.cxx:1142–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1140}
1141
1142void DICOMAppHelper::GetImagePositionPatientFilenamePairs(
1143 const std::string& seriesUID, std::vector<std::pair<float, std::string>>& v, bool ascending)
1144{
1145 v.clear();
1146
1147 std::map<std::string, std::vector<std::string>, ltstdstr>::iterator miter =
1148 this->Implementation->SeriesUIDMap.find(seriesUID);
1149
1150 if (miter == this->Implementation->SeriesUIDMap.end())
1151 {
1152 return;
1153 }
1154
1155 // grab the filenames for the specified series
1156 std::vector<std::string> files = (*miter).second;
1157
1158 for (std::vector<std::string>::iterator fileIter = files.begin(); fileIter != files.end();
1159 ++fileIter)
1160 {
1161 std::pair<float, std::string> p;
1162 p.second = std::string(*fileIter);
1163
1164 float image_position;
1165 float normal[3];
1166
1167 std::map<std::string, DICOMOrderingElements, ltstdstr>::iterator sn_iter =
1168 Implementation->SliceOrderingMap.find(*fileIter);
1169
1170 if (sn_iter != Implementation->SliceOrderingMap.end())
1171 {
1172 // compute the image patient position wrt to the slice image
1173 // plane normal
1174
1175 normal[0] = ((*sn_iter).second.ImageOrientationPatient[1] *
1176 (*sn_iter).second.ImageOrientationPatient[5]) -
1177 ((*sn_iter).second.ImageOrientationPatient[2] *
1178 (*sn_iter).second.ImageOrientationPatient[4]);
1179 normal[1] = ((*sn_iter).second.ImageOrientationPatient[2] *
1180 (*sn_iter).second.ImageOrientationPatient[3]) -
1181 ((*sn_iter).second.ImageOrientationPatient[0] *
1182 (*sn_iter).second.ImageOrientationPatient[5]);
1183 normal[2] = ((*sn_iter).second.ImageOrientationPatient[0] *
1184 (*sn_iter).second.ImageOrientationPatient[4]) -
1185 ((*sn_iter).second.ImageOrientationPatient[1] *
1186 (*sn_iter).second.ImageOrientationPatient[3]);
1187
1188 image_position = (normal[0] * (*sn_iter).second.ImagePositionPatient[0]) +
1189 (normal[1] * (*sn_iter).second.ImagePositionPatient[1]) +
1190 (normal[2] * (*sn_iter).second.ImagePositionPatient[2]);
1191 p.first = image_position;
1192 v.push_back(p);
1193 }
1194 }
1195 if (ascending)
1196 {
1197 std::sort(v.begin(), v.end(), lt_pair_float_string());
1198 }
1199 else

Callers 2

ExecuteInformationMethod · 0.80
GetPixelSpacingMethod · 0.80

Calls 10

stringClass · 0.50
sortFunction · 0.50
clearMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected