Commit 25ff6f47950a828f254489a58dc66af1c1000280
1 parent
95d3e337
Exists in
master
and in
68 other branches
FIX: Sorting the dicom list with the image number
Showing
1 changed file
with
7 additions
and
7 deletions
Show diff stats
invesalius/reader/dicom_grouper.py
... | ... | @@ -297,15 +297,16 @@ class DicomGroups: |
297 | 297 | else: |
298 | 298 | groups_dcm_[new_key] = [[information]] |
299 | 299 | |
300 | - for j in xrange(len(groups_dcm_.keys())): | |
301 | - key = groups_dcm_.keys()[j] | |
302 | - groups_dcm_[key][0].sort() | |
303 | 300 | #the number of previously existing number is |
304 | 301 | #greater or equal then the group keeps up, |
305 | 302 | #but maintains the same group of positions. |
306 | 303 | if len(self.groups_dcm.keys()) < len(groups_dcm_.keys()): |
307 | 304 | self.groups_dcm = groups_dcm_ |
308 | 305 | |
306 | + for j in xrange(len(self.groups_dcm.keys())): | |
307 | + key = self.groups_dcm.keys()[j] | |
308 | + self.groups_dcm[key][0].sort(key=lambda x: x.image.number) | |
309 | + | |
309 | 310 | |
310 | 311 | def __UpdateZSpacing(self): |
311 | 312 | """ |
... | ... | @@ -316,16 +317,15 @@ class DicomGroups: |
316 | 317 | |
317 | 318 | key = self.groups_dcm.keys()[x] |
318 | 319 | information = self.groups_dcm[key][0] |
319 | - | |
320 | 320 | if (len(self.groups_dcm[key][0]) > 1): |
321 | 321 | #Catch a slice of middle and the next to find the spacing. |
322 | 322 | center = len(self.groups_dcm[key][0])/2 |
323 | 323 | if (center == 1): |
324 | 324 | center = 0 |
325 | - | |
325 | + | |
326 | 326 | information = self.groups_dcm[key][0][center] |
327 | 327 | current_position = information.image.position |
328 | - | |
328 | + | |
329 | 329 | information = self.groups_dcm[key][0][center + 1] |
330 | 330 | next_position = information.image.position |
331 | 331 | |
... | ... | @@ -345,6 +345,6 @@ class DicomGroups: |
345 | 345 | |
346 | 346 | else: |
347 | 347 | spacing = None |
348 | - | |
348 | + | |
349 | 349 | for information in self.groups_dcm[key][0]: |
350 | 350 | information.image.spacing[2] = spacing | ... | ... |