<commit_before>"""
Created on Jun 22, 2016

@author: <NAME> -- <EMAIL>
"""
import os
import numpy as np
import matplotlib.pyplot as plt
from time import time
import sys
import cProfile
import pstats
sys.path.append('../../../')
from pycroscopy.processing.image_processing import ImageWindow
from pycroscopy.processing.svd_utils import doSVD
from pycroscopy.viz.plot_utils import plotScree, plot_map_stack, plotSpectrograms
from pycroscopy.io.io_utils import uiGetFile

if __name__ == '__main__':
    '''
    Select the image file
    '''
    imagepath = uiGetFile(filter='Image File (*.tiff *.tif *.jpeg *.jpg *.png);;' +
                                 'DM3 or DM4 File (*.dm3 *.dm4);;' +
                                 'Image Text File (*.txt)',
                          caption='Select Image File')

    '''
    Set up parameters
    '''
    save_plots  = True
    show_plots  = False
    fit_win     = True
    num_peaks   = 2
    max_mem     = 1024*2
    num_comp    = None
    plot_comps  = 9
    clean_comps = None

    '''
    Parse the path
    '''
    folder, filename = os.path.split(os.path.abspath(imagepath))
    basename, _ = os.path.splitext(filename)

    h5_path = os.path.join(folder, basename+'.h5')

    '''
    Initialize the windowing
    '''
    iw = ImageWindow(imagepath, h5_path, reset=True, max_RAM_mb=max_mem)

    h5_file = iw.h5_file
    
    h5_raw = iw.h5_raw

    '''
    Extract an optimum window size from the image
    '''
    win_size = iw.window_size_extract(h5_raw,
                                      num_peaks,
                                      save_plots=save_plots,
                                      show_plots=show_plots)

    # win_size = 16
    '''
    Do the windowing
    '''
    t0 = time()
    h5_wins = iw.do_windowing(h5_raw,
                              win_x=win_size,
                              win_y=win_size,
                              # win_step_x=3,
                              # win_step_y=3,
                              save_plots=save_plots,<commit_msg>Updated ImageWindowing script to us ImageTranslator<commit_after>"""
Created on Jun 22, 2016

@author: <NAME> -- <EMAIL>
"""
import os
import numpy as np
import matplotlib.pyplot as plt
from time import time
import sys
import cProfile
import pstats
sys.path.append('../../../')
from pycroscopy import ImageTranslator
from pycroscopy.processing.image_processing import ImageWindow
from pycroscopy.processing.svd_utils import doSVD
from pycroscopy.viz.plot_utils import plotScree, plot_map_stack, plotSpectrograms
from pycroscopy.io.io_utils import uiGetFile

if __name__ == '__main__':
    '''
    Select the image file
    '''
    imagepath = uiGetFile(filter='Image File (*.tiff *.tif *.jpeg *.jpg *.png);;' +
                                 'DM3 or DM4 File (*.dm3 *.dm4);;' +
                                 'Image Text File (*.txt)',
                          caption='Select Image File')

    '''
    Set up parameters
    '''
    save_plots  = True
    show_plots  = False
    fit_win     = True
    num_peaks   = 2
    max_mem     = 1024*2
    num_comp    = None
    plot_comps  = 9
    clean_comps = None

    '''
    Parse the path
    '''
    folder, filename = os.path.split(os.path.abspath(imagepath))
    basename, _ = os.path.splitext(filename)

    tl = ImageTranslator()
    h5_raw = tl.translate(imagepath)
    h5_file = h5_raw.file

    '''
    Initialize the windowing
    '''
    iw = ImageWindow(h5_raw, max_RAM_mb=max_mem)

    '''
    Extract an optimum window size from the image
    '''
    win_size, psf_width = iw.window_size_extract(num_peaks,
                                                 save_plots=save_plots,
                                                 show_plots=show_plots)

    win_size = 16
    '''
    Do the windowing
    '''
    t0 = time()
    h5_wins = iw.do_windowing(win_x=win_size,
                              win_y=win_size,
                              save_plots=save_plots,
{'fraction_non_alphanumeric': 0.09861635220125786, 'fraction_numerical': 0.014339622641509434, 'mean_word_length': 1.8238636363636365, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359991', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1243, 'n_words': 292}