Exemplo n.º 1
0
    def OpenBitmapFiles(self, bmp_data, rec_data):
        name = rec_data[0]
        orientation = rec_data[1]
        sp_x = float(rec_data[2])
        sp_y = float(rec_data[3])
        sp_z = float(rec_data[4])
        interval = int(rec_data[5])

        interval += 1

        filelist = bmp_data.GetOnlyBitmapPath()[::interval]
        bits = bmp_data.GetFirstPixelSize()

        sx, sy = size = bmp_data.GetFirstBitmapSize()
        n_slices = len(filelist)
        resolution_percentage = utils.calculate_resizing_tofitmemory(
            int(sx), int(sy), n_slices, bits / 8)

        zspacing = sp_z * interval
        xyspacing = (sp_y, sp_x)

        if resolution_percentage < 1.0:

            re_dialog = dialog.ResizeImageDialog()
            re_dialog.SetValue(int(resolution_percentage * 100))
            re_dialog_value = re_dialog.ShowModal()
            re_dialog.Close()

            if re_dialog_value == wx.ID_OK:
                percentage = re_dialog.GetValue()
                resolution_percentage = percentage / 100.0
            else:
                return

        xyspacing = xyspacing[0] / resolution_percentage, xyspacing[
            1] / resolution_percentage

        self.matrix, scalar_range, self.filename = image_utils.bitmap2memmap(
            filelist, size, orientation, (sp_z, sp_y, sp_x),
            resolution_percentage)

        self.Slice = sl.Slice()
        self.Slice.matrix = self.matrix
        self.Slice.matrix_filename = self.filename

        if orientation == 'AXIAL':
            self.Slice.spacing = xyspacing[0], xyspacing[1], zspacing
        elif orientation == 'CORONAL':
            self.Slice.spacing = xyspacing[0], zspacing, xyspacing[1]
        elif orientation == 'SAGITTAL':
            self.Slice.spacing = zspacing, xyspacing[1], xyspacing[0]

        self.Slice.window_level = float(self.matrix.max() / 4)
        self.Slice.window_width = float(self.matrix.max())

        scalar_range = int(self.matrix.min()), int(self.matrix.max())
        Publisher.sendMessage('Update threshold limits list',
                              threshold_range=scalar_range)

        return self.matrix, self.filename  #, dicom
Exemplo n.º 2
0
    def OpenBitmapFiles(self, bmp_data, rec_data):
       name = rec_data[0]
       orientation = rec_data[1]
       sp_x = float(rec_data[2])
       sp_y = float(rec_data[3])
       sp_z = float(rec_data[4])
       interval = int(rec_data[5])
       
       interval += 1
       
       filelist = bmp_data.GetOnlyBitmapPath()[::interval]
       bits = bmp_data.GetFirstPixelSize()

       sx, sy = size =  bmp_data.GetFirstBitmapSize()
       n_slices = len(filelist)
       resolution_percentage = utils.calculate_resizing_tofitmemory(int(sx), int(sy), n_slices, bits/8)
       
       zspacing = sp_z * interval
       xyspacing = (sp_y, sp_x)

       if resolution_percentage < 1.0:

           re_dialog = dialog.ResizeImageDialog()
           re_dialog.SetValue(int(resolution_percentage*100))
           re_dialog_value = re_dialog.ShowModal()
           re_dialog.Close() 
           
           if re_dialog_value == wx.ID_OK:
               percentage = re_dialog.GetValue()
               resolution_percentage = percentage / 100.0
           else:
               return

       xyspacing = xyspacing[0] / resolution_percentage, xyspacing[1] / resolution_percentage
 

       
       self.matrix, scalar_range, self.filename = image_utils.bitmap2memmap(filelist, size,
                                                               orientation, (sp_z, sp_y, sp_x),resolution_percentage)


       self.Slice = sl.Slice()
       self.Slice.matrix = self.matrix
       self.Slice.matrix_filename = self.filename

       if orientation == 'AXIAL':
           self.Slice.spacing = xyspacing[0], xyspacing[1], zspacing
       elif orientation == 'CORONAL':
           self.Slice.spacing = xyspacing[0], zspacing, xyspacing[1]
       elif orientation == 'SAGITTAL':
           self.Slice.spacing = zspacing, xyspacing[1], xyspacing[0]
       
       self.Slice.window_level = float(self.matrix.max()/4)
       self.Slice.window_width = float(self.matrix.max())

       scalar_range = int(self.matrix.min()), int(self.matrix.max())
       Publisher.sendMessage('Update threshold limits list',
                             threshold_range=scalar_range)

       return self.matrix, self.filename#, dicom