# Path: dicom2nifti/common.py
# def read_dicom_directory(dicom_directory, stop_before_pixels=False):
#     """
#     Read all dicom files in a given directory (stop before pixels)
# 
#     :type stop_before_pixels: bool
#     :type dicom_directory: str
#     :param stop_before_pixels: Should we stop reading before the pixeldata (handy if we only want header info)
#     :param dicom_directory: Directory with dicom data
#     :return: List of dicom objects
#     """
#     dicom_input = []
#     for root, _, files in os.walk(dicom_directory):
#         for dicom_file in files:
#             file_path = os.path.join(root, dicom_file)
#             if compressed_dicom.is_dicom_file(file_path):
#                 dicom_headers = compressed_dicom.read_file(file_path,
#                                                            defer_size="1 KB",
#                                                            stop_before_pixels=stop_before_pixels,
#                                                            force=dicom2nifti.settings.pydicom_read_force)
#                 if is_valid_imaging_dicom(dicom_headers):
#                     dicom_input.append(dicom_headers)
#     return dicom_input
# 
# def is_philips(dicom_input):
#     """
#     Use this function to detect if a dicom series is a philips dataset
# 
#     :param dicom_input: directory with dicom files for 1 scan of a dicom_header
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     # check if manufacturer is Philips
#     if 'PHILIPS' not in header.Manufacturer.upper():
#         return False
# 
#     return True
# 
# def is_siemens(dicom_input):
#     """
#     Use this function to detect if a dicom series is a siemens dataset
# 
#     :param dicom_input: directory with dicom files for 1 scan
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     # check if manufacturer is Siemens
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     if 'SIEMENS' not in header.Manufacturer.upper():
#         return False
# 
#     return True
# 
# def is_ge(dicom_input):
#     """
#     Use this function to detect if a dicom series is a GE dataset
# 
#     :param dicom_input: list with dicom objects
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     # check if manufacturer is GE
#     if 'GE MEDICAL SYSTEMS' not in header.Manufacturer.upper():
#         return False
# 
#     return True


import pydicom
import pydicom.uid
import pydicom.dataset
import logging
import numpy
import os
import datetime
import dicom2nifti.compressed_dicom as compressed_dicom
from dicom2nifti.common import read_dicom_directory, is_philips, is_siemens, is_ge
                      'Columns': None,
                      'PixelSpacing': None,
                      'BitsAllocated': None,
                      'BitsStored': None,
                      'HighBit': None,
                      'RescaleSlope': None,
                      'RescaleIntercept': None,
                      'PixelRepresentation': None,
                      'NumberOfFrames': None,
                      'SamplesPerPixel': None,
                      'SpacingBetweenSlices': None,
                      # Pixel Data must be specified with hex code as it will not work for compressed dicoms
                      (0x7fe0, 0x0010): None}

    if is_philips(read_dicom_directory(input_directory)):
        philips_fields = {
            (0x2001, 0x100a): None,
            (0x2001, 0x1003): None,
            (0x2001, 0x105f): None,
            (0x2005, 0x100d): None,
            (0x2005, 0x100e): None,
            (0x2005, 0x10b0): None,
            (0x2005, 0x10b1): None,
            (0x2005, 0x10b2): None,
            (0x0018, 0x9087): None,
            (0x0018, 0x9089): None,
            (0x5200, 0x9230): None,
            'SharedFunctionalGroupsSequence': None}
        fields_to_keep.update(philips_fields)


# Path: dicom2nifti/common.py
# def read_dicom_directory(dicom_directory, stop_before_pixels=False):
#     """
#     Read all dicom files in a given directory (stop before pixels)
# 
#     :type stop_before_pixels: bool
#     :type dicom_directory: str
#     :param stop_before_pixels: Should we stop reading before the pixeldata (handy if we only want header info)
#     :param dicom_directory: Directory with dicom data
#     :return: List of dicom objects
#     """
#     dicom_input = []
#     for root, _, files in os.walk(dicom_directory):
#         for dicom_file in files:
#             file_path = os.path.join(root, dicom_file)
#             if compressed_dicom.is_dicom_file(file_path):
#                 dicom_headers = compressed_dicom.read_file(file_path,
#                                                            defer_size="1 KB",
#                                                            stop_before_pixels=stop_before_pixels,
#                                                            force=dicom2nifti.settings.pydicom_read_force)
#                 if is_valid_imaging_dicom(dicom_headers):
#                     dicom_input.append(dicom_headers)
#     return dicom_input
# 
# def is_philips(dicom_input):
#     """
#     Use this function to detect if a dicom series is a philips dataset
# 
#     :param dicom_input: directory with dicom files for 1 scan of a dicom_header
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     # check if manufacturer is Philips
#     if 'PHILIPS' not in header.Manufacturer.upper():
#         return False
# 
#     return True
# 
# def is_siemens(dicom_input):
#     """
#     Use this function to detect if a dicom series is a siemens dataset
# 
#     :param dicom_input: directory with dicom files for 1 scan
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     # check if manufacturer is Siemens
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     if 'SIEMENS' not in header.Manufacturer.upper():
#         return False
# 
#     return True
# 
# def is_ge(dicom_input):
#     """
#     Use this function to detect if a dicom series is a GE dataset
# 
#     :param dicom_input: list with dicom objects
#     """
#     # read dicom header
#     header = dicom_input[0]
# 
#     if 'Manufacturer' not in header or 'Modality' not in header:
#         return False  # we try generic conversion in these cases
# 
#     # check if Modality is mr
#     if header.Modality.upper() != 'MR':
#         return False
# 
#     # check if manufacturer is GE
#     if 'GE MEDICAL SYSTEMS' not in header.Manufacturer.upper():
#         return False
# 
#     return True


# Path: scripts/anonymize_testdata.py
import pydicom
import pydicom.uid
import pydicom.dataset
import logging
import numpy
import os
import datetime
import dicom2nifti.compressed_dicom as compressed_dicom
from dicom2nifti.common import read_dicom_directory, is_philips, is_siemens, is_ge

                      'Columns': None,
                      'PixelSpacing': None,
                      'BitsAllocated': None,
                      'BitsStored': None,
                      'HighBit': None,
                      'RescaleSlope': None,
                      'RescaleIntercept': None,
                      'PixelRepresentation': None,
                      'NumberOfFrames': None,
                      'SamplesPerPixel': None,
                      'SpacingBetweenSlices': None,
                      # Pixel Data must be specified with hex code as it will not work for compressed dicoms
                      (0x7fe0, 0x0010): None}

    if is_philips(read_dicom_directory(input_directory)):
        philips_fields = {
            (0x2001, 0x100a): None,
            (0x2001, 0x1003): None,
            (0x2001, 0x105f): None,
            (0x2005, 0x100d): None,
            (0x2005, 0x100e): None,
            (0x2005, 0x10b0): None,
            (0x2005, 0x10b1): None,
            (0x2005, 0x10b2): None,
            (0x0018, 0x9087): None,
            (0x0018, 0x9089): None,
            (0x5200, 0x9230): None,
            'SharedFunctionalGroupsSequence': None}
        fields_to_keep.update(philips_fields)


    if is_siemens(read_dicom_directory(input_directory)):