#!/usr/bin/env python# Copyright 2016-2023 Biomedical Imaging Group Rotterdam, Departments of# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.importconfigparserimportosimportWORC.addexceptionsasae
[docs]defload_config(config_file_path):""" Load the config ini, parse settings to WORC Args: config_file_path (String): path of the .ini config file Returns: settings_dict (dict): dict with the loaded settings """ifnotos.path.exists(config_file_path):e=f'File {config_file_path} does not exist!'raiseae.WORCKeyError(e)settings=configparser.ConfigParser()settings.read(config_file_path)settings_dict={'ComBat':dict()}# Convert settingssettings_dict['ComBat']['batch']=\
[str(item).strip()foriteminsettings['ComBat']['batch'].split(',')]settings_dict['ComBat']['mod']=\
[str(item).strip()foriteminsettings['ComBat']['mod'].split(',')]settings_dict['ComBat']['par']=\
settings['ComBat'].getint('par')settings_dict['ComBat']['eb']=\
settings['ComBat'].getint('eb')settings_dict['ComBat']['language']=\
str(settings['ComBat']['language'])settings_dict['ComBat']['matlab']=\
str(settings['ComBat']['matlab'])settings_dict['ComBat']['per_feature']=\
int(settings['ComBat']['per_feature'])settings_dict['ComBat']['excluded_features']=\
[str(item).strip()foriteminsettings['ComBat']['excluded_features'].split(',')]returnsettings_dict