def callScaFES(T_blood=T_blood): global count global params count += 1 print() print('##### ScaFES iteration: {} #####'.format(count)) case = params['NAME_CONFIGFILE_TEMPLATE'].split('.')[0] case = case.split('_')[0] params['NAME_CONFIGFILE'] = case + '-pymc-' + TESTED_VARIABLES + '.ini' params['NAME_RESULTFILE'] = '' config = configparser.ConfigParser() config.optionxform = str config.read(params['NAME_CONFIGFILE_TEMPLATE']) # T_blood. config['Brain']['T_BLOOD'] = str(T_blood) config['Tumor']['T_BLOOD'] = str(T_blood) with open(params['NAME_CONFIGFILE'], 'w') as configfile: config.write(configfile) # Call simulation. parse_config_file(params) check_variables(params) calc_variables(params) check_stability(params) if params['USE_MRI_FILE'] == False: create_region_file(params) create_init_file(params) set_environment_variables(params) call_simulation(params, params['RUN_SCRIPT']) if params['NAME_RESULTFILE'] != '': # Compute temperatures of normal, tumor, vessel tisue. temp = temperature_array_from_result(params['NAME_RESULTFILE']) tumor = region_array_from_file(params['NAME_REGION_FILE']) vessels = surface_vessels_array_from_file( params['NAME_VESSELS_FILE']) T_tumor, _, _, _ = calc_tumor_near_surface_temperatures( temp, tumor) if params['USE_VESSELS_SEGMENTATION'] == True: temp = temp[-1, :, :] T_vessel, _, _, _ = calc_vessels_temperatures(temp, vessels) T_normal, _, _, _ = calc_non_vessels_temperatures( temp, vessels) else: T_vessel = -1.0 T_normal = -1.0 else: print('* ERROR: No result file written.') print('Aborting.') exit() return [T_normal, T_tumor, T_vessel]
def callScaFES(omega_brain=omega_brain, omega_tumor=omega_tumor, omega_vessel=omega_vessel, T_blood=T_blood, q_brain=q_brain, q_tumor=q_tumor, lambda_bt=lambda_bt, rho_c_brain=rho_c_brain, rho_c_tumor=rho_c_tumor, h=h): global count global params count += 1 print() print('##### ScaFES iteration: {} #####'.format(count)) case = params['NAME_CONFIGFILE_TEMPLATE'].split('.')[0] case = case.split('_')[0] params['NAME_CONFIGFILE'] = case + '-pymc-' + TESTED_VARIABLES + '.ini' params['NAME_RESULTFILE'] = '' config = configparser.ConfigParser() config.optionxform = str config.read(params['NAME_CONFIGFILE_TEMPLATE']) # Omega. config['Brain']['OMEGA'] = str(omega_brain) config['Tumor']['OMEGA'] = str(omega_tumor) config['MRI']['USE_VESSELS_SEGMENTATION'] = 'True' config['MRI']['VARIABLES_VESSELS'] = 'omega' config['MRI']['VALUES_VESSELS'] = str(omega_vessel) config['MRI']['VALUES_NON_VESSELS'] = str(omega_brain) # T_blood. config['Brain']['T_BLOOD'] = str(T_blood) config['Tumor']['T_BLOOD'] = str(T_blood) # Q. config['Brain']['Q'] = str(q_brain) config['Tumor']['Q'] = str(q_tumor) # lambda. config['Brain']['LAMBDA'] = str(lambda_bt) config['Tumor']['LAMBDA'] = str(lambda_bt) # rho * c. config['Brain']['C'] = str(rho_c_brain) config['Brain']['RHO'] = str(1000.0) config['Tumor']['C'] = str(rho_c_tumor) config['Tumor']['RHO'] = str(1000.0) # h. config['Parameters']['H'] = str(h) with open(params['NAME_CONFIGFILE'], 'w') as configfile: config.write(configfile) # Call simulation. parse_config_file(params) check_variables(params) calc_variables(params) check_stability(params) if params['USE_MRI_FILE'] == False: create_region_file(params) create_init_file(params) set_environment_variables(params) call_simulation(params, params['RUN_SCRIPT']) if params['NAME_RESULTFILE'] != '': # Compute temperatures of normal, tumor, vessel tisue. temp = temperature_array_from_result(params['NAME_RESULTFILE']) tumor = region_array_from_file(params['NAME_REGION_FILE']) vessels = surface_vessels_array_from_file( params['NAME_VESSELS_FILE']) T_tumor, _, _, _ = calc_tumor_near_surface_temperatures( temp, tumor) if params['USE_VESSELS_SEGMENTATION'] == True: temp = temp[-1, :, :] T_vessel, _, _, _ = calc_vessels_temperatures(temp, vessels) T_normal, _, _, _ = calc_non_vessels_temperatures( temp, vessels) else: T_vessel = -1.0 T_normal = -1.0 else: print('* ERROR: No result file written.') print('Aborting.') exit() global dat_file_name with open(dat_file_name, 'a') as backupfile: backupfile.write(str(omega_brain) + '\t' \ + str(omega_tumor) + '\t' \ + str(omega_vessel) + '\t' \ + str(T_blood) + '\t' \ + str(q_brain) + '\t' \ + str(q_tumor) + '\t' \ + str(lambda_bt) + '\t' \ + str(rho_c_brain) + '\t' \ + str(rho_c_tumor) + '\t' \ + str(h) + '\t' \ + str(T_normal) + '\t' \ + str(T_tumor) + '\t' \ + str(T_vessel) + '\n') if (count % 25 == 0): searchpath = './' + params['NAME_EXECUTABLE'] + '-' + case + '-*.*' log_files = glob.glob(searchpath) for f in log_files: os.remove(f) return [T_normal, T_tumor, T_vessel]