source/dcm_transform.py
def draw_rectangle(dataset, args):
    """ Draws a rectangular region of interest"""
    # assign custom tags
    if args == '':
        return
    try:
        pixel_editor = PixelEditor(dataset.pixel_array)
        n_vals = 7
        pix_len = len(args)
        # if pix_len > 1:
        #    print()
        for i in range(0, int(pix_len / n_vals) * n_vals, n_vals):
            pos_x = float(args[i + 0])  # x pos
            pos_y = float(args[i + 1])  # y pos
            width = float(args[i + 2])  # rect width
            height = float(args[i + 3])  # rect height
            stepping = int(args[i + 4])  # stepping (for dash lines purpose)
            pixel_intensity = int(args[i + 5])  # pixel intensity
            alpha = float(args[i + 6])  # pixel alpha transparency

            if pixel_editor.buffer_length() == 0:
                print("  Could not find a pixel array, value won't be set ...")
            else:
                try:
                    pixel_editor.draw_rect(pos_x, pos_y,
                                           width, height, stepping, pixel_intensity, alpha)
                except Exception as exc:
                    print('  Error while trying to draw the rect, pixel values wont  be set ...')
                    print(exc)
        if pix_len % n_vals != 0:
            print("  Warning: list of triplets expected, but odd count was found instead, found ending: <" +
                  args[pix_len - 1] + '>')

        dataset.PixelData = pixel_editor.buffer_to_string()
    except Exception as exc:
        print(exc)
 Draws a rectangular region of interest
Draws a rectangular region of interest
Draws a rectangular region of interest
def draw_rectangle(dataset, args):
    if args == '':
        return
    try:
        pixel_editor = PixelEditor(dataset.pixel_array)
        n_vals = 7
        pix_len = len(args)
        for i in range(0, int(pix_len / n_vals) * n_vals, n_vals):
            pos_x = float(args[i + 0])  
            pos_y = float(args[i + 1])  
            width = float(args[i + 2])  
            height = float(args[i + 3])  
            stepping = int(args[i + 4])  
            pixel_intensity = int(args[i + 5])  
            alpha = float(args[i + 6])  
            if pixel_editor.buffer_length() == 0:
                print("  Could not find a pixel array, value won't be set ...")
            else:
                try:
                    pixel_editor.draw_rect(pos_x, pos_y,
                                           width, height, stepping, pixel_intensity, alpha)
                except Exception as exc:
                    print('  Error while trying to draw the rect, pixel values wont  be set ...')
                    print(exc)
        if pix_len % n_vals != 0:
            print("  Warning: list of triplets expected, but odd count was found instead, found ending: <" +
                  args[pix_len - 1] + '>')
        dataset.PixelData = pixel_editor.buffer_to_string()
    except Exception as exc:
        print(exc)
def draw_rectangle ( dataset , args ) : if args == '' : return try : pixel_editor = PixelEditor ( dataset . pixel_array ) n_vals = 7 pix_len = len ( args ) for i in range ( 0 , int ( pix_len / n_vals ) * n_vals , n_vals ) : pos_x = float ( args [ i + 0 ] ) pos_y = float ( args [ i + 1 ] ) width = float ( args [ i + 2 ] ) height = float ( args [ i + 3 ] ) stepping = int ( args [ i + 4 ] ) pixel_intensity = int ( args [ i + 5 ] ) alpha = float ( args [ i + 6 ] ) if pixel_editor . buffer_length ( ) == 0 : print ( "  Could not find a pixel array, value won't be set ..." ) else : try : pixel_editor . draw_rect ( pos_x , pos_y , width , height , stepping , pixel_intensity , alpha ) except Exception as exc : print ( '  Error while trying to draw the rect, pixel values wont  be set ...' ) print ( exc ) if pix_len % n_vals != 0 : print ( "  Warning: list of triplets expected, but odd count was found instead, found ending: <" + args [ pix_len - 1 ] + '>' ) dataset . PixelData = pixel_editor . buffer_to_string ( ) except Exception as exc : print ( exc )
Draws a rectangular region of interest
Draws a rectangular region of interest
""" Draws a rectangular region of interest""" # assign custom tags # if pix_len > 1: #    print() # x pos # y pos # rect width # rect height # stepping (for dash lines purpose) # pixel intensity # pixel alpha transparency
dataset
args