Exemple #1
0
def main():

    # locate the input data
    input_file = existing_filepath(data_path, data_file)
    acq_data = AcquisitionData(input_file)
    
    # create reconstruction object
    recon = Reconstructor([ \
        'NoiseAdjustGadget', \
        'PCACoilGadget', \
        'CoilReductionGadget(coils_out=16)', \
        'gpuRadialSensePrepGadget(' + \
            'mode=2,' + \
            'profiles_per_frame=16,' + \
            'rotations_per_reconstruction=16,' + \
            'buffer_frames_per_rotation=16,' + \
            'buffer_length_in_rotations=2,' + \
            'reconstruction_os_factor_x=1.5,' + \
            'reconstruction_os_factor_y=1.5' + \
        ')', \
        'slice0:gpuCgSenseGadget(' + \
            'number_of_iterations=10,' + \
            'oversampling_factor=1.25,' + \
            'output_convergence=true' + \
        ')', \
        'slice1:gpuCgSenseGadget(' + \
            'sliceno=1,' + \
            'number_of_iterations=10,' + \
            'oversampling_factor=1.25,' + \
            'output_convergence=true' + \
        ')', \
        'slice2:gpuCgSenseGadget(' + \
            'sliceno=2,' + \
            'number_of_iterations=10,' + \
            'oversampling_factor=1.25,' + \
            'output_convergence=true' + \
        ')', \
        'ExtractGadget', 'AutoScaleGadget'])

    # provide raw k-space data as input
    recon.set_input(acq_data)

    # perform reconstruction
    recon.process()

    # retrieve reconstructed image data
    image_data = recon.get_output()

    image_data.show(title = 'Images')
def main():

    # locate the input data
    input_file = existing_filepath(data_path, data_file)
    acq_data = AcquisitionData(input_file)
    
    # create reconstruction object
    # Rather than using a predefined image reconstruction object, here a new 
    # image reconstruction object is created by concatinating multiple gadgets 
    # (for more information on Gadgetron and its gadgets please see: 
    # https://github.com/gadgetron/.).
    # Parameters for individual gadgets can be defined either during the 
    # creation of the reconstruction object:
    #   e.g. AcquisitionAccumulateTriggerGadget(trigger_dimension=repetition)
    # or by giving a gadget a label (cf. label ex: for the last gadget)
    # and using set_gadget_property(label, propery, value).
    # The gadgets will be concatenated and will be executed as soon as 
    # process() is called.
    recon = Reconstructor([ \
        'NoiseAdjustGadget', \
        'AsymmetricEchoAdjustROGadget', \
        'RemoveROOversamplingGadget', \
        'AcquisitionAccumulateTriggerGadget(trigger_dimension=repetition)', \
        'BucketToBufferGadget(split_slices=true, verbose=false)', \
        'SimpleReconGadget', 'ImageArraySplitGadget', 'ex:ExtractGadget'])
##        'SimpleReconGadget', 'FatWaterGadget', 'ImageArraySplitGadget', \
##        'PhysioInterpolationGadget', 'ex:ExtractGadget'])
        
    # ExtractGadget defines which type of image should be returned:
    # none      0
    # magnitude 1
    # real      2
    # imag      4
    # phase     8
    # in this example '5' returns both magnitude and imaginary part
##    recon.set_gadget_property('ex', 'extract_mask', 5)
    recon.set_gadget_property('ex', 'extract_magnitude', True)
    recon.set_gadget_property('ex', 'extract_imag', True)
    
    # provide raw k-space data as input
    recon.set_input(acq_data)
    
    # perform reconstruction
    recon.process()
    
    # retrieve reconstructed image data
    image_data = recon.get_output()

    # show reconstructed image data
    for im in range(image_data.number()):
        image = image_data.image(im)
        # image types   series
        # magnitude 1       0
        # phase     2    3000
        # real      3    1000
        # imag      4    2000
        im_type = image.image_type()
        im_series = image.image_series_index()
        print('image: %d, type: %d, series: %d' % (im, im_type, im_series))
    image_data.show(title = 'Images magnitude and imaginary part')

    if output_file is not None:
        # write images to a new group in args.output
        # named after the current date and time
        time_str = time.asctime()
        print('writing to %s' % output_file)
        image_data.write(output_file) #, time_str)
Exemple #3
0
def main():

    # locate the input data
    input_file = existing_filepath(data_path, data_file)
    acq_data = AcquisitionData(input_file)

    if algorithm == 'SimpleReconGadget':
        extra_gadgets = [algorithm]
    else:
        extra_gadgets = [algorithm, 'GenericReconFieldOfViewAdjustmentGadget']

    # create reconstruction object
    # Rather than using a predefined image reconstruction object, here a new
    # image reconstruction object is created by concatinating multiple gadgets
    # (for more information on Gadgetron and its gadgets please see:
    # https://github.com/gadgetron/.).
    # Parameters for individual gadgets can be defined either during the
    # creation of the reconstruction object:
    #   e.g. AcquisitionAccumulateTriggerGadget(trigger_dimension=repetition)
    # or by giving a gadget a label (cf. label ex: for the last gadget)
    # and using set_gadget_property(label, propery, value).
    # The gadgets will be concatenated and will be executed as soon as
    # process() is called.
    recon_gadgets = ['NoiseAdjustGadget',
        'AsymmetricEchoAdjustROGadget',
        'RemoveROOversamplingGadget',
        'AcquisitionAccumulateTriggerGadget(trigger_dimension=repetition)',
        'BucketToBufferGadget(split_slices=true, verbose=false)'] \
        + extra_gadgets + \
        ['ImageArraySplitGadget',
        'ex:ExtractGadget'
        ]

    recon = Reconstructor(recon_gadgets)

    # ExtractGadget defines which type of image should be returned:
    # none      0
    # magnitude 1
    # real      2
    # imag      4
    # phase     8
    # in this example '5' returns both magnitude and imaginary part
    ##    recon.set_gadget_property('ex', 'extract_mask', 5)
    # === THE ABOVE IS OBSOLETE, NOW SHOULD USE ===>
    if type_to_save == 'mag' or type_to_save == 'all':
        recon.set_gadget_property('ex', 'extract_magnitude', True)
    if type_to_save == 'imag' or type_to_save == 'all':
        recon.set_gadget_property('ex', 'extract_imag', True)

    # provide raw k-space data as input
    recon.set_input(acq_data)

    # optionally set Gadgetron server host and port
    recon.set_host('localhost')
    # On VM you can try a port other than the default 9002, e.g. 9003, by taking
    # the following steps:
    # 1) in ~/devel/install/share/gadgetron/config/gadgetron.xml replace
    #    <port>9002</port> with <port>9003</port>
    # 2) go to Settings->Network->Advanced->Port Forwarding and add new rule
    #    (click on green + in the upper right corner) with Host and Guest ports
    #    set to 9003
    # 3) uncomment the next line
    #recon.set_port('9003')
    # Note: each gadget chain can run on a different VM - to try, start two VMs
    # and do the above steps 1 and 2 on one of them, then add
    # recon.set_port('9003') before recon.process in grappa_detail.py
    # (where preprocessing will still run on default port 9002).

    # perform reconstruction
    recon.process()

    # retrieve reconstructed image data
    image_data = recon.get_output()

    # show reconstructed image data
    if show_plot:
        for im in range(image_data.number()):
            image = image_data.image(im)
            # image types   series
            # magnitude 1       0
            # phase     2    3000
            # real      3    1000
            # imag      4    2000
            im_type = image.image_type()
            im_series = image.image_series_index()
            print('image: %d, type: %d, series: %d' % (im, im_type, im_series))
        image_data.show(title='Images magnitude and imaginary part')

    if output_file is not None:
        filename = output_file
        i = filename.find('.')
        if i < 0:
            ext = 'h5'
        else:
            ext = filename[i + 1:]
            filename = filename[:i]
        print('writing to %s' % (filename + '.' + ext))
        image_data.write(filename, ext=ext)