Commit 4486c2065a7b13ed7c0527fff9a29c1573a4b10c

Authored by Paulo Henrique Junqueira Amorim
1 parent 8d148544

ENH: Returned dialog while generating MPR

invesalius/data/imagedata_utils.py
@@ -461,6 +461,9 @@ def dcm2memmap(files, slice_size, orientation): @@ -461,6 +461,9 @@ def dcm2memmap(files, slice_size, orientation):
461 From a list of dicom files it creates memmap file in the temp folder and 461 From a list of dicom files it creates memmap file in the temp folder and
462 returns it and its related filename. 462 returns it and its related filename.
463 """ 463 """
  464 + message = _("Generating multiplanar visualization...")
  465 + update_progress= vtk_utils.ShowProgress(len(files), dialog_type = "ProgressDialog")
  466 +
464 temp_file = tempfile.mktemp() 467 temp_file = tempfile.mktemp()
465 468
466 if orientation == 'SAGITTAL': 469 if orientation == 'SAGITTAL':
@@ -472,6 +475,7 @@ def dcm2memmap(files, slice_size, orientation): @@ -472,6 +475,7 @@ def dcm2memmap(files, slice_size, orientation):
472 print shape 475 print shape
473 matrix = numpy.memmap(temp_file, mode='w+', dtype='int16', shape=shape) 476 matrix = numpy.memmap(temp_file, mode='w+', dtype='int16', shape=shape)
474 dcm_reader = vtkgdcm.vtkGDCMImageReader() 477 dcm_reader = vtkgdcm.vtkGDCMImageReader()
  478 + cont = 0
475 for n, f in enumerate(files): 479 for n, f in enumerate(files):
476 dcm_reader.SetFileName(f) 480 dcm_reader.SetFileName(f)
477 dcm_reader.Update() 481 dcm_reader.Update()
@@ -486,6 +490,8 @@ def dcm2memmap(files, slice_size, orientation): @@ -486,6 +490,8 @@ def dcm2memmap(files, slice_size, orientation):
486 else: 490 else:
487 array.shape = matrix.shape[1], matrix.shape[2] 491 array.shape = matrix.shape[1], matrix.shape[2]
488 matrix[n] = array 492 matrix[n] = array
  493 + update_progress(cont,message)
  494 + cont += 1
489 495
490 matrix.flush() 496 matrix.flush()
491 return matrix, temp_file 497 return matrix, temp_file
invesalius/reader/dicom_reader.py
@@ -86,27 +86,21 @@ tag_labels = {} @@ -86,27 +86,21 @@ tag_labels = {}
86 main_dict = {} 86 main_dict = {}
87 dict_file = {} 87 dict_file = {}
88 88
89 -class LoadDicom:#(threading.Thread): 89 +class LoadDicom:
90 90
91 def __init__(self, grouper, filepath): 91 def __init__(self, grouper, filepath):
92 - #threading.Thread.__init__(self)  
93 self.grouper = grouper 92 self.grouper = grouper
94 if sys.platform == 'win32': 93 if sys.platform == 'win32':
95 self.filepath = filepath.encode(utils.get_system_encoding()) 94 self.filepath = filepath.encode(utils.get_system_encoding())
96 else: 95 else:
97 self.filepath = filepath 96 self.filepath = filepath
  97 +
98 self.run() 98 self.run()
99 99
100 def run(self): 100 def run(self):
101 101
102 grouper = self.grouper 102 grouper = self.grouper
103 103
104 - #while 1:  
105 -  
106 - #filepath = q.get()  
107 - #if not filepath:  
108 - # break  
109 -  
110 reader = gdcm.Reader() 104 reader = gdcm.Reader()
111 reader.SetFileName(self.filepath) 105 reader.SetFileName(self.filepath)
112 106