<commit_before>import numpy as np
from skimage.filters.rank import entropy as skim_entropy
from skimage.morphology import disk as skim_disk
from skimage.morphology import square as skim_square
from skimage import exposure
from skimage import img_as_uint, img_as_ubyte
import ROOT
from dicom_tools.histFromArray import histFromArray
from dicom_tools.rescale import rescale16bit, rescale8bit

def getEntropy(image, ROI=None, square_size=5, verbose=False):
    # image = img_as_ubyte(exposure.rescale_intensity(image, in_range='uint8'))
    image = rescale8bit(image)
    # image = exposure.rescale_intensity(image, in_range='uint8')
    # image = image.astype(np.uint8)
    
    if ROI is None:
        entropyImg = skim_entropy(image,skim_square(square_size))
    else:
        entropyImg = skim_entropy(image,skim_square(square_size), mask=ROI)
    return entropyImg


def make_histo_entropy(data, ROI, suffix="", verbose=False):
    entropy3D = np.zeros( tuple([len(data)])+data[0,:,:].shape)<commit_msg>exp rescale<commit_after>import numpy as np
from skimage.filters.rank import entropy as skim_entropy
from skimage.morphology import disk as skim_disk
from skimage.morphology import square as skim_square
from skimage import exposure
from skimage import img_as_uint, img_as_ubyte
import ROOT
from dicom_tools.histFromArray import histFromArray
from dicom_tools.rescale import rescale16bit, rescale8bit

def getEntropy(image, ROI=None, square_size=5, verbose=False):
    # image = img_as_ubyte(exposure.rescale_intensity(image, in_range='uint8'))
    # image = rescale8bit(image)
    image = exposure.rescale_intensity(image, in_range='uint16')
    # image = image.astype(np.uint8)
    
    if ROI is None:
        entropyImg = skim_entropy(image,skim_square(square_size))
    else:
        entropyImg = skim_entropy(image,skim_square(square_size), mask=ROI)
    return entropyImg


def make_histo_entropy(data, ROI, suffix="", verbose=False):
    entropy3D = np.zeros( tuple([len(data)])+data[0,:,:].shape)
{'fraction_non_alphanumeric': 0.09258337481333997, 'fraction_numerical': 0.010452961672473868, 'mean_word_length': 5.483870967741935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '4118444', 'n_tokens_mistral': 694, 'n_tokens_neox': 669, 'n_words': 154}