Commit a061025c5234b4dd6c78c60ffbafef6b8c2aaba8

Authored by Paulo Henrique Junqueira Amorim
1 parent e58244f7

FIX: Fixed error in generate surface in the win32 and win64 ticket #271

invesalius/data/imagedata_utils.py
... ... @@ -546,39 +546,4 @@ def analyze2mmap(analyze):
546 546 matrix.flush()
547 547 return matrix, temp_file
548 548  
549   -def to_vtk(n_array, spacing, slice_number, orientation):
550   - try:
551   - dz, dy, dx = n_array.shape
552   - except ValueError:
553   - dy, dx = n_array.shape
554   - dz = 1
555   -
556   - v_image = numpy_support.numpy_to_vtk(n_array.flat)
557   -
558   - print orientation
559   - if orientation == 'AXIAL':
560   - extent = (0, dx -1, 0, dy -1, slice_number, slice_number + dz - 1)
561   - elif orientation == 'SAGITAL':
562   - dx, dy, dz = dz, dx, dy
563   - extent = (slice_number, slice_number + dx - 1, 0, dy - 1, 0, dz - 1)
564   - elif orientation == 'CORONAL':
565   - dx, dy, dz = dx, dz, dy
566   - extent = (0, dx - 1, slice_number, slice_number + dy - 1, 0, dz - 1)
567   -
568   - # Generating the vtkImageData
569   - image = vtk.vtkImageData()
570   - image.SetOrigin(0, 0, 0)
571   - image.SetSpacing(spacing)
572   - image.SetNumberOfScalarComponents(1)
573   - image.SetDimensions(dx, dy, dz)
574   - image.SetExtent(extent)
575   - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype))
576   - image.AllocateScalars()
577   - image.GetPointData().SetScalars(v_image)
578   - image.Update()
579   -
580   - image_copy = vtk.vtkImageData()
581   - image_copy.DeepCopy(image)
582   - image_copy.Update()
583   -
584   - return image_copy
  549 +
... ...
invesalius/data/slice_.py
... ... @@ -23,6 +23,7 @@ import vtk
23 23 import wx.lib.pubsub as ps
24 24  
25 25 import constants as const
  26 +import converters
26 27 import imagedata_utils as iu
27 28 import style as st
28 29 import session as ses
... ... @@ -358,7 +359,7 @@ class Slice(object):
358 359 image = self.buffer_slices[orientation].vtk_image
359 360 else:
360 361 n_image = self.get_image_slice(orientation, slice_number)
361   - image = iu.to_vtk(n_image, self.spacing, slice_number, orientation)
  362 + image = converters.to_vtk(n_image, self.spacing, slice_number, orientation)
362 363 ww_wl_image = self.do_ww_wl(image)
363 364 image = self.do_colour_image(ww_wl_image)
364 365 if self.current_mask and self.current_mask.is_shown:
... ... @@ -368,7 +369,7 @@ class Slice(object):
368 369 else:
369 370 print "Do not getting from buffer"
370 371 n_mask = self.get_mask_slice(orientation, slice_number)
371   - mask = iu.to_vtk(n_mask, self.spacing, slice_number, orientation)
  372 + mask = converters.to_vtk(n_mask, self.spacing, slice_number, orientation)
372 373 mask = self.do_colour_mask(mask)
373 374 self.buffer_slices[orientation].mask = n_mask
374 375 final_image = self.do_blend(image, mask)
... ... @@ -378,13 +379,13 @@ class Slice(object):
378 379 self.buffer_slices[orientation].vtk_image = image
379 380 else:
380 381 n_image = self.get_image_slice(orientation, slice_number)
381   - image = iu.to_vtk(n_image, self.spacing, slice_number, orientation)
  382 + image = converters.to_vtk(n_image, self.spacing, slice_number, orientation)
382 383 ww_wl_image = self.do_ww_wl(image)
383 384 image = self.do_colour_image(ww_wl_image)
384 385  
385 386 if self.current_mask and self.current_mask.is_shown:
386 387 n_mask = self.get_mask_slice(orientation, slice_number)
387   - mask = iu.to_vtk(n_mask, self.spacing, slice_number, orientation)
  388 + mask = converters.to_vtk(n_mask, self.spacing, slice_number, orientation)
388 389 mask = self.do_colour_mask(mask)
389 390 final_image = self.do_blend(image, mask)
390 391 else:
... ...
invesalius/data/surface_process.py
... ... @@ -6,8 +6,7 @@ import numpy
6 6 import vtk
7 7  
8 8 import i18n
9   -import imagedata_utils
10   -
  9 +import converters
11 10 from scipy import ndimage
12 11  
13 12 class SurfaceProcess(multiprocessing.Process):
... ... @@ -33,11 +32,12 @@ class SurfaceProcess(multiprocessing.Process):
33 32 self.flip_image = flip_image
34 33 self.q_in = q_in
35 34 self.q_out = q_out
36   -
37   - self.mask = numpy.memmap(filename, mode='r', dtype=dtype,
38   - shape=shape)
  35 + self.dtype = dtype
  36 + self.shape = shape
39 37  
40 38 def run(self):
  39 + self.mask = numpy.memmap(self.filename, mode='r', dtype=self.dtype,
  40 + shape=self.shape)
41 41 while 1:
42 42 roi = self.q_in.get()
43 43 print roi
... ... @@ -51,7 +51,7 @@ class SurfaceProcess(multiprocessing.Process):
51 51  
52 52 def CreateSurface(self, roi):
53 53 smoothed = numpy.array(self.mask[roi])
54   - image = imagedata_utils.to_vtk(smoothed, self.spacing, roi.start,
  54 + image = converters.to_vtk(smoothed, self.spacing, roi.start,
55 55 "AXIAL")
56 56 flip = vtk.vtkImageFlip()
57 57 flip.SetInput(image)
... ...
invesalius/session.py
  1 +#--------------------------------------------------------------------------
  2 +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas
  3 +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer
  4 +# Homepage: http://www.softwarepublico.gov.br
  5 +# Contact: invesalius@cti.gov.br
  6 +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt)
  7 +#--------------------------------------------------------------------------
  8 +# Este programa e software livre; voce pode redistribui-lo e/ou
  9 +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme
  10 +# publicada pela Free Software Foundation; de acordo com a versao 2
  11 +# da Licenca.
  12 +#
  13 +# Este programa eh distribuido na expectativa de ser util, mas SEM
  14 +# QUALQUER GARANTIA; sem mesmo a garantia implicita de
  15 +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM
  16 +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
  17 +# detalhes.
  18 +#--------------------------------------------------------------------------
  19 +
1 20 import ConfigParser
2 21 import os
3 22 import shutil
... ...