<commit_before>"""
@file
@brief Functions to handle data coming from
:epkg:`Cancer Imaging Archive`.
"""
import os
import pydicom
import pandas
import cv2
from pyquickhelper.filehelper.synchelper import explore_folder_iterfile


def _recurse_fill(obs, dataset, parent=""):
    for data_element in dataset:
        if isinstance(data_element.value, bytes):
            continue
        if data_element.VR == "SQ":   # a sequence
            name = data_element.name
            for i, ds in enumerate(data_element.value):
                _recurse_fill(obs, ds,
                              parent="{parent}.{name}[{i}]".format(
                                  parent=parent, name=name, i=i))
        else:
            text = str(data_element.value)
            name = str(data_element.name)
            key = name if parent == '' else parent + "." + name
            obs[key] = text
<commit_msg>Update data_medical.py<commit_after>"""
@file
@brief Functions to handle data coming from
:epkg:`Cancer Imaging Archive`.
"""
import os
import pydicom
import pandas
import cv2
from pyquickhelper.filehelper.synchelper import explore_folder_iterfile  # pylint: disable=C0411


def _recurse_fill(obs, dataset, parent=""):
    for data_element in dataset:
        if isinstance(data_element.value, bytes):
            continue
        if data_element.VR == "SQ":   # a sequence
            name = data_element.name
            for i, ds in enumerate(data_element.value):
                _recurse_fill(obs, ds,
                              parent="{parent}.{name}[{i}]".format(
                                  parent=parent, name=name, i=i))
        else:
            text = str(data_element.value)
            name = str(data_element.name)
            key = name if parent == '' else parent + "." + name
            obs[key] = text

{'fraction_non_alphanumeric': 0.10284463894967177, 'fraction_numerical': 0.0032822757111597373, 'mean_word_length': 2.1264957264957265, 'pattern_counts': {'":': 2, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '516456', 'n_tokens_mistral': 534, 'n_tokens_neox': 507, 'n_words': 139}