<jupyter_start><jupyter_text>This python notebook display the modulus image after taking the complex sum across the image frames for each of the MR Fingerprinting reconstructions stored as a MATLAB .mat file Necessary imports<jupyter_code>import numpy as np
import scipy.io as sio
import scipy.misc
import matplotlib.pyplot as plt
import glob
import os<jupyter_output><empty_output><jupyter_text>Set path to parent folder of MATLAB .mat files containing the complex images of interest<jupyter_code>parent_folder = '/git/github.com/Hamburg_MRF_workshop_VUMC_results/data_input'
mat_file_list = glob.glob(parent_folder + '/*_images.mat')
mat_file_list<jupyter_output><empty_output><jupyter_text>Loop over .mat files and plot magnitude of complex sum across all fingerprinting frames<jupyter_code>for idx_file in range(len(mat_file_list)):
    
    this_filename = os.path.basename(mat_file_list[idx_file])
    this_filename_prefix = this_filename[:-11]
    
    # Load .mat file
    mat_contents = sio.loadmat(mat_file_list[idx_file])
    
    # Extract stack of complex images
    imgs_complex = mat_contents['imgs']
    
    # Sum across third axis
    img_sum_complex = np.sum(imgs_complex, axis=2)
    
    # Calculate magnitude (modulus) image
    # flip up-down and rotate 90 degrees to match orientation of Hamburg reconstructions
    img_sum_modulus = np.rot90( np.flipud( np.absolute(img_sum_complex) ), +1)
    
    # save image to PNG file
    this_filename_png = 'magnitude_of_complex_sum_' + this_filename_prefix + '.png'
    scipy.misc.imsave(this_filename_png, img_sum_modulus)
    print 'Saved ' + this_filename_png
    
    # Display image
    plt.imshow(img_sum_modulus, cmap='gray')
    plt.title(this_filename_prefix)
    plt.show()<jupyter_output>Saved magnitude_of_complex_sum_VUMC_MRF_1000_TE3.3_FSC.png
{'fraction_non_alphanumeric': 0.07456140350877193, 'fraction_numerical': 0.007675438596491228, 'mean_word_length': 4.830670926517572, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '318773', 'license': 'MIT', 'n_tokens_mistral': 627, 'n_tokens_neox': 605, 'n_words': 148, 'path': 'python_notebooks/VUMC_MRF_sum_images.ipynb', 'repo_name': 'welcheb/Hamburg_MRF_workshop_VUMC_results', 'size': '1824'}