<commit_before>import numpy as np
from skimage.measure import grid_points_in_poly
from dicom_tools.roiFileHandler import roiFileHandler


def myroi2roi(myrois, shape, verbose=False):
    if verbose:
        print("myroi2roi: called")
    outroi = np.full(shape,False,dtype=bool)
    if len(myrois) != len(outroi):
        print("error: len rois = ",len(rois)," but len dicom=",len(outroi))

    for n, myroi in enumerate(myrois):
        if not myroi is None:
            outroi[n] = grid_points_in_poly(outroi[n].shape, myroi['points'])
            if verbose:
                print("myroi2roi: layer",n,"tot true pixels",outroi[n].sum())
        elif verbose:
            print("myroi2roi: layer",n,"myroi is None")
        
    if verbose:
        print("myroi2roi: returning \n")
    return outroi<commit_msg>handle also one layer<commit_after>import numpy as np
from skimage.measure import grid_points_in_poly
from dicom_tools.roiFileHandler import roiFileHandler


def myroi2roi(myrois, shape, verbose=False):
    if verbose:
        print("myroi2roi: called")
    outroi = np.full(shape,False,dtype=bool)
  

    if outroi.ndim > 2:
        if len(myrois) != len(outroi):
            print("error: len rois = ",len(myrois)," but len dicom=",len(outroi))
        for n, myroi in enumerate(myrois):
            if not myroi is None:
                outroi[n] = grid_points_in_poly(outroi[n].shape, myroi['points'])
                if verbose:
                    print("myroi2roi: layer",n,"tot true pixels",outroi[n].sum())
            elif verbose:
                print("myroi2roi: layer",n,"myroi is None")
    else:
        outroi = grid_points_in_poly(outroi.shape, myrois['points'])
        
    if verbose:
        print("myroi2roi: returning \n")
    return outroi
{'fraction_non_alphanumeric': 0.11754780652418448, 'fraction_numerical': 0.006186726659167604, 'mean_word_length': 2.7690677966101696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '84333', 'n_tokens_mistral': 639, 'n_tokens_neox': 620, 'n_words': 137}