coseda.initialize package¶
Submodules¶
coseda.initialize.insfiles module¶
INI scaffolding helpers for new datasets.
- coseda.initialize.insfiles.create_insfiles(input_path, input_type, target=None)[source]¶
Dispatch creation of INI scaffolds based on raw input type (DM4 vs EMD).
- coseda.initialize.insfiles.create_insfiles_emd(input_path, target)[source]¶
Create per-file INI scaffolding for .emd inputs (folder, list, or file).
Builds timestamped run folders, initializes plots/log files, and fills AcquisitionDetails/Paths from Velox metadata when available.
- coseda.initialize.insfiles.create_plain_insfile(hdf5_file_path, output_folder, acquisition_details, parameters)[source]¶
Create a plain .ins file for an existing HDF5 file with manually provided inputs.
Parameters: - hdf5_file_path (str): Path to the existing HDF5 file. - output_folder (str): Path to the folder where the .ins file will be saved. - acquisition_details (dict): Dictionary containing the acquisition details. - parameters (dict): Dictionary containing the parameters.
Returns: - str: Path to the created .ins file.
coseda.initialize.project_files module¶
Helpers for project-level INI organization and index lists.
- coseda.initialize.project_files.find_configfiles(input_path)[source]¶
Return child INIs (excluding parent configs) resolved from file/folder/list input.
- coseda.initialize.project_files.generate_parent_ini_file(folder_path, parent_ini_filename=None)[source]¶
- coseda.initialize.project_files.get_parent_ini_file(input_path)[source]¶
Accepts an input path which is either a parent INI file or a folder containing one parent INI file. Returns the path to the parent INI file.
coseda.initialize.settings module¶
Write processing parameters to INI files.
- coseda.initialize.settings.write_centerfindersettings(input_path, tolerance, min_peaks, resolution_limit, min_samples_fraction, dbscan_eps=None, force_linear_fit=False, skip_linear_fit=False, x0=None, y0=None)[source]¶
Persist center-finding thresholds and initial center guess into each INI.
- coseda.initialize.settings.write_centerrefinementsettings(input_path, tolerance, min_peaks, resolution_limit, min_samples_fraction=None, max_iterations=None, convergence_threshold=None, deviation_aggregation=None, lowess_frac=None, lowess_window=None)[source]¶
Persist iterative center refinement settings (tolerance, samples, LOWESS) into INIs.
- coseda.initialize.settings.write_gandalfiteratorsettings(configfile, geomfile_path=None, cellfile_path=None, output_file_base=None, threads=None, max_radius=None, step=None, peakfinder_method=None, peakfinder_params=None, min_peaks=None, cell_tolerance=None, sampling_pitch=None, grad_desc_iterations=None, xgandalf_tolerance=None, int_radius=None, other_flags=None)[source]¶
Update the parent INI file with Gandalf-iterator settings under [Parameters]. Does NOT require input folder (list file is used instead).
- coseda.initialize.settings.write_h5conversionsettings(input_path, limit_frames, bin_factor, sample_class)[source]¶
Persist HDF5 conversion limits/binning and sample class into each INI.
- coseda.initialize.settings.write_icisettings(input_path, **params)[source]¶
Write ICI orchestrator key parameters into the [Parameters] section of each config file. Keys are stored with the ‘ici_’ prefix to avoid collisions.
- coseda.initialize.settings.write_mergingsettings(input_path, hkl_filename, pointgroup, min_res, iterations, threads=None, model='offset', polarisation='none', min_measurements=2, max_adu='inf', push_res='inf', no_Bscale=True, output_every_cycle=True, save_partialator_logs=False, unique_axis=None, streamfile=None)[source]¶
Write merging parameters into the INI file. ‘hkl_filename’ is saved under [Paths], all other parameters under [Parameters] with keys prefixed by ‘merging_’.
- coseda.initialize.settings.write_peakfindersettings(input_path, threshold, min_snr, min_pix_count, max_pix_count, local_bg_radius, min_res, max_res, x0=None, y0=None, num_threads=None)[source]¶
Write Diffractem peakfinder_8 parameters and geometry hints into each INI.
- coseda.initialize.settings.write_stripsettings(input, strip_threshold, strip_force)[source]¶
Persist strip-empty-frame settings.
- coseda.initialize.settings.write_xgandalfsettings(input_path, tolerance, sampling_pitch, min_lattice_vector_length, max_lattice_vector_length, grad_desc_iterations, tolerance_5d, fix_profile_radius)[source]¶
Writes Xgandalf settings to the [Parameters] section of each config file determined by handle_input. Logs the new settings if [Paths] logfile is present.
Module contents¶
INI scaffolding and settings helpers.
- coseda.initialize.config_to_paths(configfile)[source]¶
Given the path to a .ini configfile, determine and return: outputfolder, outputfolder_path, logfile, logfile_path, h5file, h5file_path
- Path A: if <basename>.h5 exists in the same directory as the .ini:
outputfolder: basename of the ini (without extension)
outputfolder_path: same directory as ini
logfile: <basename>.log
logfile_path: same directory as ini
h5file: <basename>.h5
h5file_path: same directory as ini
- Path B: otherwise, read the [Paths] section of the INI:
outputfolder: config.get(‘Paths’,’outputfolder’)
outputfolder_path: parent_dir/outputfolder
logfile: config.get(‘Paths’,’logfile’)
logfile_path: parent_dir/logfile
h5file: config.get(‘Paths’,’h5file’)
h5file_path: outputfolder_path/h5file
- Parameters:
configfile (str)
- coseda.initialize.create_insfiles(input_path, input_type, target=None)[source]¶
Dispatch creation of INI scaffolds based on raw input type (DM4 vs EMD).
- coseda.initialize.create_insfiles_emd(input_path, target)[source]¶
Create per-file INI scaffolding for .emd inputs (folder, list, or file).
Builds timestamped run folders, initializes plots/log files, and fills AcquisitionDetails/Paths from Velox metadata when available.
- coseda.initialize.create_plain_insfile(hdf5_file_path, output_folder, acquisition_details, parameters)[source]¶
Create a plain .ins file for an existing HDF5 file with manually provided inputs.
Parameters: - hdf5_file_path (str): Path to the existing HDF5 file. - output_folder (str): Path to the folder where the .ins file will be saved. - acquisition_details (dict): Dictionary containing the acquisition details. - parameters (dict): Dictionary containing the parameters.
Returns: - str: Path to the created .ins file.
- coseda.initialize.find_configfiles(input_path)[source]¶
Return child INIs (excluding parent configs) resolved from file/folder/list input.
- coseda.initialize.get_parent_ini_file(input_path)[source]¶
Accepts an input path which is either a parent INI file or a folder containing one parent INI file. Returns the path to the parent INI file.
- coseda.initialize.handle_input(input_path)[source]¶
Normalize user input (folder, INI file, or list of INIs) into child INI paths.
Rejects hidden files and parent configs
Enforces a single directory when a list is provided
Returns (configfiles, base_path) where base_path is the containing folder
Raises ValueError when the input is invalid or yields no child INIs.
- coseda.initialize.is_parent_config_file(file_path)[source]¶
Return True if the INI declares [General] config_type = parent.
- coseda.initialize.log_result(logfile_path, message, error)[source]¶
Log a success or failure message to stdout and, when available, to the logfile.
- coseda.initialize.log_start(logfile_path, message)[source]¶
Print a message and append it (timestamped) to the logfile if a path is provided.
- coseda.initialize.parse_config(configfile)[source]¶
Parse an INI file (UTF-8 with latin-1 fallback) and resolve common paths.
Returns: (config, outputfolder, originalfile, logfile, path, outputfolder_path, originalfile_path, logfile_path, framepath, h5file, h5file_path)
- coseda.initialize.read_config(configfile)[source]¶
Read an INI file and return the ConfigParser, tolerating legacy encodings.
Attempts UTF-8 first, then falls back to latin-1 so older datasets do not fail early when metadata contains non-UTF characters.
- coseda.initialize.resume_processing(input_path)[source]¶
Refresh stored configfile paths in INIs and log the environment header.
- coseda.initialize.shoutout(configfile_path)[source]¶
Print which config file is being processed (tiny UX helper for loops).
- coseda.initialize.write_centerfindersettings(input_path, tolerance, min_peaks, resolution_limit, min_samples_fraction, dbscan_eps=None, force_linear_fit=False, skip_linear_fit=False, x0=None, y0=None)[source]¶
Persist center-finding thresholds and initial center guess into each INI.
- coseda.initialize.write_centerrefinementsettings(input_path, tolerance, min_peaks, resolution_limit, min_samples_fraction=None, max_iterations=None, convergence_threshold=None, deviation_aggregation=None, lowess_frac=None, lowess_window=None)[source]¶
Persist iterative center refinement settings (tolerance, samples, LOWESS) into INIs.
- coseda.initialize.write_gandalfiteratorsettings(configfile, geomfile_path=None, cellfile_path=None, output_file_base=None, threads=None, max_radius=None, step=None, peakfinder_method=None, peakfinder_params=None, min_peaks=None, cell_tolerance=None, sampling_pitch=None, grad_desc_iterations=None, xgandalf_tolerance=None, int_radius=None, other_flags=None)[source]¶
Update the parent INI file with Gandalf-iterator settings under [Parameters]. Does NOT require input folder (list file is used instead).
- coseda.initialize.write_h5conversionsettings(input_path, limit_frames, bin_factor, sample_class)[source]¶
Persist HDF5 conversion limits/binning and sample class into each INI.
- coseda.initialize.write_icisettings(input_path, **params)[source]¶
Write ICI orchestrator key parameters into the [Parameters] section of each config file. Keys are stored with the ‘ici_’ prefix to avoid collisions.
- coseda.initialize.write_index_file(input_path)[source]¶
Build a CrystFEL-compatible .list file from all HDF5 paths in the inputs.
- coseda.initialize.write_mergingsettings(input_path, hkl_filename, pointgroup, min_res, iterations, threads=None, model='offset', polarisation='none', min_measurements=2, max_adu='inf', push_res='inf', no_Bscale=True, output_every_cycle=True, save_partialator_logs=False, unique_axis=None, streamfile=None)[source]¶
Write merging parameters into the INI file. ‘hkl_filename’ is saved under [Paths], all other parameters under [Parameters] with keys prefixed by ‘merging_’.
- coseda.initialize.write_peakfindersettings(input_path, threshold, min_snr, min_pix_count, max_pix_count, local_bg_radius, min_res, max_res, x0=None, y0=None, num_threads=None)[source]¶
Write Diffractem peakfinder_8 parameters and geometry hints into each INI.
- coseda.initialize.write_stripsettings(input, strip_threshold, strip_force)[source]¶
Persist strip-empty-frame settings.
- coseda.initialize.write_xgandalfsettings(input_path, tolerance, sampling_pitch, min_lattice_vector_length, max_lattice_vector_length, grad_desc_iterations, tolerance_5d, fix_profile_radius)[source]¶
Writes Xgandalf settings to the [Parameters] section of each config file determined by handle_input. Logs the new settings if [Paths] logfile is present.