cosedaUI package

Subpackages

Submodules

cosedaUI.about_window module

About dialog for COSEDA.

class cosedaUI.about_window.AboutWindow(*args, **kwargs)[source]

Bases: QDialog

Modal dialog that shows product name, authors, license text, and changelog.

init_ui()[source]

Assemble the dialog layout and populate static text and license contents.

cosedaUI.about_window.open_about_window(window_title, changelog, theme, parent=None)[source]

Instantiate and display the modal About dialog.

cosedaUI.aurora_window module

Aurora plot dialog for detector saturation inspection.

class cosedaUI.aurora_window.AuroraPlotWindow(*args, **kwargs)[source]

Bases: QDialog

Small non-modal window that renders peak max intensity versus detector radius.

Parameters:
  • hdf5_path (Optional[str])

  • ini_path (Optional[str])

  • workspace_files (Optional[list[dict]])

closeEvent(event)[source]
property hdf5_path
start_plot(force_recompute)[source]
Parameters:

force_recompute (bool)

class cosedaUI.aurora_window.AuroraPlotWorker(*args, **kwargs)[source]

Bases: QObject

Worker object for computing aurora histograms outside the UI thread.

Parameters:
  • file_specs (list[dict])

  • force_recompute (bool)

  • window_size (int)

failed

alias of str

finished

alias of object

progress

alias of str

run()[source]

cosedaUI.cellfile_window module

Modal editor to create and persist CrystFEL .cell files from an INI workspace.

class cosedaUI.cellfile_window.CellfileWindow(*args, **kwargs)[source]

Bases: QWidget

Dialog for entering lattice parameters and writing a CrystFEL .cell file.

save_cell_file()[source]

Validate inputs, write the .cell file, and update the INI Paths.cellfile entry.

cosedaUI.export module

UI for exporting SHELX HKLF4 files and generating INS/P4P from merged streams (cell parsed from stream header).

class cosedaUI.export.ExportMtzWindow(*args, **kwargs)[source]

Bases: QDialog

UI to list CrystFEL HKL files under merge folders and export HKLF4.

Parameters:
  • workspace_path (str)

  • parent (Optional[QWidget])

cosedaUI.findcenters_window module

UI for running and reviewing center finding workflows.

class cosedaUI.findcenters_window.CenterFinderSettingsWindow(*args, **kwargs)[source]

Bases: QDialog

Settings dialog for configuring and running centerfinding across datasets.

add_plot_to_viewer(batch_num, iter_num, file_path)[source]

Adds a plot to the QTreeWidget under the appropriate batch and iteration.

closeEvent(event)[source]

Ensures that the timer is stopped when the dialog is closed.

display_selected_plot(item, column)[source]

Displays the selected plot from saved numpy arrays.

get_parameter_from_config(config, section, parameter, default_value, is_optional=False, value_type=<class 'int'>, aliases=None)[source]

Retrieve parameter from config. If optional and not present, return empty string. Otherwise, return value converted to specified type or default.

init_ui()[source]

Build the settings UI (method selection, params, progress, preview).

on_field_focused()[source]

Request coordinate selection from the main viewer when x0/y0 gains focus.

on_find_centers_all()[source]

Initiates center finding on all INI files in the directory using the selected method.

on_find_centers_current()[source]

Initiates center finding on the current INI file using the selected method.

on_force_linear_toggled(checked)[source]

Force cannot stay enabled when skip is active.

Parameters:

checked (bool)

on_method_change(index)[source]

Toggle visibility of settings panels depending on method selection.

on_processing_cancelled(message)[source]

Slot to handle user-requested cancellation.

on_processing_error(error_message)[source]

Slot to handle processing errors.

on_processing_finished(message)[source]

Slot to handle successful processing.

on_progress_updated(done, total)[source]
on_save_all()[source]
on_save_current()[source]
on_skip_linear_toggled(checked)[source]

Skip and force are mutually exclusive; skip wins.

Parameters:

checked (bool)

on_stop_clicked()[source]

User requested stop.

progress_updated

alias of int

receive_coordinate(x_value, y_value)[source]

Receive picked coordinates from the main viewer and populate x0/y0 fields.

Parameters:
  • x_value (int)

  • y_value (int)

settings_applied

alias of dict

stop_monitoring()[source]

Stops the plot viewer monitoring.

update_plot_viewer()[source]

Scans the plots folder for new .npz files created after the monitoring started. Adds them to the plot viewer.

update_run_list()[source]

Refresh the run dropdown to include any new findcenters_ folders containing either direct_centers_raw.npy or any .npz file, auto-selecting the latest run and updating the preview.

class cosedaUI.findcenters_window.FocusableLineEdit(*args, **kwargs)[source]

Bases: QLineEdit

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

focusInEvent(event)[source]
focusOutEvent(event)[source]
class cosedaUI.findcenters_window.NumericSortTreeWidgetItem(*args, **kwargs)[source]

Bases: QTreeWidgetItem

Tree item that sorts batch numbers numerically on column 0.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

class cosedaUI.findcenters_window.PreviewWindow(*args, **kwargs)[source]

Bases: QDialog

Pop-out preview showing per-batch centerfinding plots and metadata.

auto_display_initial()[source]

Automatically select and display the first available plot.

display_selected_plot(item, column)[source]
set_run(run_name)[source]
update_preview()[source]

Refresh the tree with available plots and redraw the selected run.

class cosedaUI.findcenters_window.Worker(*args, **kwargs)[source]

Bases: QObject

Threaded worker that runs centerfinding and reports progress.

cancelled

alias of str

error

alias of str

finished

alias of str

progress

alias of int

request_cancel()[source]

Signal cancellation to the running task.

run()[source]

Execute the center finding process.

cosedaUI.geomfile_window module

UI to build and validate a CrystFEL geometry file from an INI workspace.

class cosedaUI.geomfile_window.GeomfileWindow(*args, **kwargs)[source]

Bases: QWidget

Form-driven editor that emits a CrystFEL geometry file and updates the INI.

Parameters:

ini_path (str)

cosedaUI.geomfile_window.calculate_electron_wavelength(acceleration_voltage_V)[source]

Relativistic electron wavelength (m) from acceleration voltage (V).

Parameters:

acceleration_voltage_V (float)

cosedaUI.h5_metadata_loader module

Background worker for collecting essential HDF5 metadata.

class cosedaUI.h5_metadata_loader.H5MetadataLoader(*args, **kwargs)[source]

Bases: QObject

Load lightweight metadata from an HDF5 file without blocking the UI.

Parameters:

h5_path (str)

failed

alias of str

finished

alias of dict

run()[source]

cosedaUI.ici_window module

class cosedaUI.ici_window.GuiStream(callback)[source]

Bases: object

Simple stream object that forwards writes to a callback. Used to capture stdout/stderr and send to the GUI.

flush()[source]
write(text)[source]
class cosedaUI.ici_window.OrchestratorMainWindow(*args, **kwargs)[source]

Bases: QMainWindow

closeEvent(event)[source]
class cosedaUI.ici_window.OrchestratorWidget(*args, **kwargs)[source]

Bases: QWidget

add_h5_files()[source]
append_text(text)[source]
Parameters:

text (str)

browse_cell()[source]
browse_geom()[source]
browse_run_root()[source]
build_argv()[source]

Build a CLI-style argv list for orch.main from the GUI state. Instead of passing –flags on the CLI (which is awkward because the flags themselves begin with “-“), we override orch.DEFAULT_FLAGS directly based on the free-text field.

clear_h5_files()[source]
on_progress_done()[source]
on_progress_init(total)[source]
Parameters:

total (int)

on_progress_step(step)[source]
Parameters:

step (int)

on_run_clicked()[source]
on_stop_clicked()[source]
on_worker_finished(exit_code)[source]
Parameters:

exit_code (int)

request_stop_on_close()[source]
class cosedaUI.ici_window.OrchestratorWorker(*args, **kwargs)[source]

Bases: QObject

Worker object that runs orch.main(argv) inside a QThread and forwards stdout/stderr and progress to the GUI via signals.

finished

alias of int

progress_init

alias of int

progress_step

alias of int

run()[source]
text_ready

alias of str

cosedaUI.ici_window.main()[source]

cosedaUI.image_tools module

Utilities for inspecting and exporting images in the COSEDA UI.

class cosedaUI.image_tools.HoverLabel(*args, **kwargs)[source]

Bases: QLabel

QLabel that emits cursor position while hovering (mouse tracking on).

hovered

alias of int

mouseMoveEvent(event)[source]
class cosedaUI.image_tools.ImageInspector(image_label, original_image_getter, parent)[source]

Bases: object

Interactive ROI inspector that shows zoomed pixel values from the displayed image.

on_mouse_move(event)[source]

Update rubber-band rectangle while dragging.

on_mouse_press(event)[source]

Begin rubber-band selection when in inspect mode.

on_mouse_release(event)[source]

Finalize selection and open the inspection popup.

open_popup(rect)[source]

Open a modal dialog showing magnified pixel values for the selected ROI.

start_inspect()[source]

Enable inspection mode and set crosshair cursor.

cosedaUI.image_tools.draw_pixmap_scalebar(pixmap, x_span_m, font_frac=0.045, margin_x_frac=0.05)[source]

Draw a 1-2-5 ‘nice’ scalebar (nm/µm/mm) bottom-left onto a QPixmap.

x_span_m is the physical width the pixmap spans, in metres. Fractions size the font / horizontal inset relative to the pixmap so it works at any scale.

cosedaUI.image_tools.export_display_image(parent, pil_image)[source]

Prompt for a filename and save the displayed PIL image (RGB) as PNG or JPEG.

cosedaUI.image_tools.export_display_pixmap(parent, pixmap)[source]

Prompt for a filename and save the displayed QPixmap as PNG or JPEG.

cosedaUI.image_tools.export_raw_image(parent, raw_array)[source]

Prompt for a filename and save the raw numpy array preserving its bit depth.

cosedaUI.indexing_stream_manager module

Helper class for parsing CrystFEL streams and matching them to HDF5 frames.

class cosedaUI.indexing_stream_manager.IndexingStreamManager(stream_parser, get_hdf5_path, get_total_frames, log_fn=None)[source]

Bases: object

Encapsulates stream parsing, frame matching, and overlay caching.

Parameters:
  • get_hdf5_path (Callable[[], Optional[str]])

  • get_total_frames (Callable[[], Optional[int]])

  • log_fn (Optional[Callable[[str], None]])

compare_peaks(h5_peaks, stream_peaks, tolerance=0.6)[source]

Return counts of unmatched peaks between HDF5 and stream within +/- tolerance.

Parameters:

tolerance (float)

ensure_loaded()[source]

Parse the stream file if needed.

Return type:

bool

find_chunk_with_reflections_from(start_index, step)[source]
Parameters:
  • start_index (int)

  • step (int)

get_chunk_for_frame(frame_index)[source]
Parameters:

frame_index (int)

get_chunk_index(chunk)[source]
Return type:

int | None

get_frame_index_for_chunk(chunk)[source]
Return type:

int | None

get_last_chunk_with_reflections()[source]
get_last_error()[source]
Return type:

str | None

get_parsed_stream()[source]

Return the parsed stream object, loading it if needed.

get_reflections_for_frame(frame_index, chunk, image_shape=(None, None))[source]
Parameters:
  • frame_index (int)

  • image_shape (Tuple[int | None, int | None])

get_stream_peaks_for_frame(frame_index, chunk, image_shape)[source]
Parameters:
  • frame_index (int)

  • image_shape (Tuple[int | None, int | None])

has_chunks()[source]
Return type:

bool

has_parser()[source]
Return type:

bool

has_stream_file()[source]
Return type:

bool

is_loaded()[source]
Return type:

bool

is_stream_available()[source]
Return type:

bool

reset_for_new_hdf5()[source]

Invalidate caches when the loaded HDF5 changes.

set_stream_path(stream_path)[source]
Parameters:

stream_path (str | None)

cosedaUI.indexintegrate_window module

UI for configuring and running CrystFEL indexing/integration from the workspace.

class cosedaUI.indexintegrate_window.IndexingControlWindow(*args, **kwargs)[source]

Bases: IndexSettingsMixin, CellfileMixin, GeomfileMixin, IciMixin, RunControlMixin, QWidget

Tabbed dialog for managing runs, editing params, and launching indexamajig.

MAX_INDEXER_THREADS = 1
class ProcessOutputThread(*args, **kwargs)[source]

Bases: QThread

Stream stdout from a subprocess and emit lines to the UI.

output_received

alias of str

run()[source]

Read lines until the process finishes and emit each one.

ini_selection_changed

alias of str

cosedaUI.mainwindow module

Main application window for COSEDA UI.

class cosedaUI.mainwindow.AspectRatioWidget(*args, **kwargs)[source]

Bases: QWidget

A container that maintains a fixed aspect ratio based on the latest image loaded.

hasHeightForWidth()[source]
heightForWidth(width)[source]
minimumSizeHint()[source]
set_aspect_ratio(ratio)[source]
Parameters:

ratio (float)

sizeHint()[source]
class cosedaUI.mainwindow.IniListWidget(*args, **kwargs)[source]

Bases: QListWidget

QListWidget that accepts dropped INI files and emits their paths.

dragEnterEvent(event)[source]
dragMoveEvent(event)[source]
dropEvent(event)[source]
files_dropped

alias of list

class cosedaUI.mainwindow.cosedaUI(*args, **kwargs)[source]

Bases: ClusterMixin, WorkflowMixin, ImportMixin, IndexingMixin, ViewerMixin, WorkspaceMixin, QMainWindow

Primary UI shell: workspace browser, viewers, and workflow launchers.

add_generated_ini_paths(paths, show_warnings=True)

Add importer-generated INI files to the workspace.

Returns a dict with added/skipped/invalid path lists so import dialogs can report concise status without duplicating workspace mutation logic.

add_ini_files()

Open a dialog to add INI files to the workspace list.

add_ini_paths(paths)

Add provided INI file paths to the workspace list (no file dialog).

adjust_brightness(image, brightness_factor)
adjust_brightness_value()
adjust_contrast(image, contrast_factor)
adjust_contrast_value()
adjust_gamma(image, gamma=1.0)
adjust_gamma_value()
apply_center_finder_settings(settings)
apply_peakfinder_settings(settings)

Slot function to apply peak finder settings emitted from PeakFinderSettingsWindow.

calculate_radial_profiles()

Compute radial intensity profiles for this file or all workspace files.

change_frame(value)

Slot to handle changes in the frame_slider’s value.

Parameters:

value (int) – The new value from the slider representing the frame index.

change_frame_from_entry()
clear_vdf_overlay()

Remove the virtual dark-field detector overlay from the main preview.

create_layout()[source]
create_menu()[source]
create_widgets()[source]
display_log_file()
draw_peak_preview(image, peaks)
ensure_atlas_for_current_file()

Create the default saved atlas when all inputs exist and no atlas is saved.

ensure_index_dataset(hdf5_path)

Ensure that an ‘index’ dataset exists in the ‘entry/data’ group. If not, and if the length of the ‘images’ dataset matches one of the stage position datasets, create the ‘index’ dataset as a sequence [0, 1, …, num_frames-1].

Parameters:

hdf5_path (str) – The path to the HDF5 file.

export_current_frame()

Use helper to export the raw HDF5 frame as a TIFF.

export_current_frame_as_shown()

Use helper to export the displayed (adjusted) image.

find_strongest_frame()

Scan nPeaks lazily so the UI stays responsive even for large files.

go_to_strongest_frame()
handle_image_update(message)
highlight_selected_file()
ini_selection_changed

alias of str

init_ui()[source]
keyPressEvent(event)

Handle left/right arrow keys to navigate frames.

load_image_from_hdf5()
load_last_directory()

Restore last directory and last workspace (file or INI list) from config.

load_last_workspace_state()

Restore workspace state from configuration (named file or INI list).

new_workspace()

Clear the current workspace list and reset state.

next_frame()
on_frame_order_changed(index)
on_indexing_run_stream_changed(stream_path)

Called by the Index & Integrate window whenever the selected run changes. Updates the available stream path and resets cached overlays.

Parameters:

stream_path (str | None)

on_indexintegrate_requested_select_ini(ini_path)

Slot: the Index & Integrate window asked us to select a given INI path. We set the QListWidget selection accordingly; this triggers on_ini_select().

Parameters:

ini_path (str)

on_ini_select()
on_kill_all_clusters()

Kill all Dask clusters on this machine and inform the user.

on_kill_current_cluster()

Kill the current Dask cluster and inform the user.

on_open_dashboard()

Opens the Dask dashboard URL for the current cluster in the default browser.

on_set_cluster_address()

Prompt for and set the Dask scheduler address override.

on_show_strong_peaks_toggled(state)
on_slider_release()
on_slider_start()
on_toggle_indexing_results(checked)

Handle enabling/disabling the indexing overlay.

Parameters:

checked (bool)

open_aurora_plot()
open_centerfinder_settings_window()

Opens the Center Finder Settings window.

open_centerrefinement_settings_window()

Opens the Center Refinement Settings window.

open_check_metadata_window()

Opens the metadata dialog showing acquisition details.

open_export_window()

Open the Export window which lists available CrystFEL HKL files and converts them to SHELX HKLF4, and can also write RES/P4P from CrystFEL cell files.

open_file(ini_file_path=None, preserve_frame=False)
open_import_emd_window()
open_import_h5_window()
open_import_mrc_window()
open_import_tiff_window()
open_index_integrate_window()
open_index_window()
open_map()
open_merge_window()
open_peakfinder_settings_window()
open_strip_files_window()
open_unit_cell_hist_window(auto_refresh=False)

Open the unit cell histogram viewer for the current stream.

Parameters:

auto_refresh (bool)

open_workspace()

Load a saved workspace file (.cosedawsp) and populate the INI list.

open_workspace_unit_cell_fit_window()

Open the workspace-wide unit-cell Gaussian fit tool.

previous_frame()
reload_current_file()

Reload the currently loaded INI/HDF5 while keeping the current frame.

reload_file_preserve_frame()

Reload the current INI/HDF5 but keep the same frame index.

remove_ini_files()

Remove selected INI files from the workspace list.

report_issue()
resizeEvent(event)

On window resize, immediately refresh the image to fit the new width and adjust the container height to maintain the original aspect ratio.

save_workspace()

Save the current workspace INI paths to a .cosedawsp file.

save_workspace_state()

Save workspace paths (or workspace file) to the config file.

set_vdf_overlay(center, width, enabled=True)

Set the virtual dark-field overlay shown on the main diffraction preview.

show_about_window()[source]

Opens the About dialog defined in about_window.py.

show_latest_indexed_frame()

Jump to the most recently indexed frame based on the current stream.

show_next_indexed_frame()

Jump to the next indexed frame relative to the current chunk.

show_pixel_index(event)
show_previous_indexed_frame()

Jump to the previous indexed frame relative to the current chunk.

start_coordinate_selection()
stop_live_preview()
update_frame_from_map_click(frame_index)

Slot to update the frame index when a point is clicked in the map.

update_image()
update_map_thumbnail()

Show a saved atlas (entry/atlas/<zdim>) as a thumbnail in the Map preview box.

Renders with the current colormap and fits it within the workflow column so it never widens that column. Keeps the Atlas group available when the file has enough data to open the atlas viewer, even before a saved atlas exists.

update_workflow_buttons()
cosedaUI.mainwindow.enable_opengl()[source]
cosedaUI.mainwindow.run_app()[source]

Entry point for launching the cosedaUI application.

cosedaUI.mainwindow.user_config_dir()[source]

Returns the path to the user configuration directory.

cosedaUI.map_window module

Interactive stage map viewer for navigating frames and intensities.

class cosedaUI.map_window.MapWindow(*args, **kwargs)[source]

Bases: QDialog

closeEvent(event)[source]

Release the rendered image on dialog close.

find_closest_available_frame(x_clicked, y_clicked)[source]

Return the nearest available frame index to the clicked stage coordinates.

get_available_intensity_datasets(hdf5_path)[source]

Return available atlas contrast sources.

get_unique_alphatilts(hdf5_path)[source]

Sorted unique alpha tilts, rounded to 1 decimal, without the 999999 placeholder.

handle_print_option_change()[source]

Update z-dimension based on selection and replot.

init_ui()[source]

Build the left-column control/info group boxes and the map image.

on_backlash_offset_changed(value)[source]

Update the persistent left-streak backlash offset and refresh the map.

on_crystallinity_checkbox_toggle()[source]

Enable/disable crystallinity thresholding and refresh the plot.

on_crystallinity_threshold_changed(text)[source]

Parse user threshold and refresh plot when highlighting diffracting regions.

on_hover(px, py)[source]

Update the cursor info box with stage position + value under the cursor.

on_image_click(event)[source]

Jump the main window to the nearest available frame under the click.

on_vdf_overlay_toggled()[source]

Show/hide the main-window virtual detector overlay.

on_vdf_slider_changed()[source]

Update virtual dark-field annulus settings and refresh the map.

plot_data()[source]

Load the scan, rasterize it, and render it as a map image.

point_clicked_signal

alias of int

resizeEvent(event)[source]
set_hdf5_path(hdf5_path, ini_path=None)[source]

Switch the map to a different HDF5 file (e.g. the main window changed file).

cosedaUI.merging_window module

UI for configuring and running CrystFEL Partialator merges from stream files.

class cosedaUI.merging_window.MergingSettingsWindow(*args, **kwargs)[source]

Bases: QDialog

Dialog to select stream files, set Partialator parameters, and launch merges.

cosedaUI.metadata_window module

Preflight/metadata dialog for viewing and editing acquisition details and masks.

class cosedaUI.metadata_window.MetadataWindow(*args, **kwargs)[source]

Bases: QDialog

Dialog to view/edit acquisition metadata and manage detector masks.

apply_to_workspace()[source]

Copy current metadata (AcquisitionDetails) and mask (if present) to all INIs in the workspace. Requires confirmation that datasets were collected under the same conditions.

confirm_metadata_edit()[source]

Warn before unlocking metadata fields that were populated automatically.

is_metadata_complete()[source]

Returns True if all required metadata fields have values (non-empty).

Return type:

bool

load_and_print_acquisition_details()[source]

Populate widgets from the current INI and set read-only/editable states.

on_generate_full_mask_clicked()[source]

Generate a full-valid mask and save it to the HDF5, then show the remove button.

on_pixelmask_btn_clicked()[source]

Load a mask image, generate mask data, and store it into the current HDF5.

on_remove_mask_clicked()[source]

Remove the mask dataset from the current HDF5 and update button visibility.

open_pixel_calc_dialog()[source]

Open the PixelCalcDialog and link its result back to the pixels_per_meter field.

save_acceleration_voltage(value)[source]

Convert back to volts and write acceleration_voltage to INI.

Parameters:

value (str)

save_camera_length_correction(value)[source]

Write the updated camera_length_correction value back to the INI file.

Parameters:

value (str)

save_metadata_field(field, value)[source]

Write an arbitrary metadata field back to the INI file.

Parameters:
  • field (str)

  • value (str)

save_pixels_per_meter(value)[source]

Write the updated pixels_per_meter value back to the INI file.

Parameters:

value (str)

class cosedaUI.metadata_window.PixelCalcDialog(*args, **kwargs)[source]

Bases: QDialog

Dialog to calculate pixels_per_meter based on detector or custom.

calculate()[source]
on_detector_changed(text)[source]

cosedaUI.peakfinder_window module

UI for configuring peakfinder settings and launching batch peakfinding runs.

class cosedaUI.peakfinder_window.FocusableLineEdit(*args, **kwargs)[source]

Bases: QLineEdit

QLineEdit subclass that emits signals on focus in/out.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

focusInEvent(event)[source]
focusOutEvent(event)[source]
class cosedaUI.peakfinder_window.PeakFinderSettingsWindow(*args, **kwargs)[source]

Bases: QDialog

Settings dialog for configuring peakfinder_8 / peakfinder9 and running them.

apply_settings()[source]
check_and_enable_findpeaks_button()[source]

Enable Find Peaks buttons only when all required keys exist in the INI.

closeEvent(event)[source]

Emit closed signal so the main window can re-enable buttons/menus.

file_progress_updated

alias of str

get_parameter_from_config(config, section, parameter, default_value, is_optional=False)[source]
init_ui()[source]

Build the settings form, preview widgets, and buttons.

on_field_focused()[source]
on_file_progress_updated(filename, index, total)[source]
on_find_peaks_all()[source]
on_find_peaks_current()[source]
on_peakfinding_error(message)[source]
on_peakfinding_finished()[source]
on_plot_histogram()[source]

Load peak_counts.npy from the selected run and plot a histogram.

on_progress_updated(done, total)[source]
on_save_all()[source]
on_save_current()[source]
on_setting_changed()[source]
peakfinding_error

alias of str

progress_updated

alias of int

receive_coordinate(x_value, y_value)[source]
run_findpeaks(input_paths, algo)[source]

Execute peak finding with the chosen algorithm in a background thread.

settings_applied

alias of dict

update_run_list()[source]

Scan for findpeaks_* and findpeaks9_* result folders and populate the dropdown.

cosedaUI.refinecenters_window module

UI for configuring and running center refinement for beamstop/direct methods.

class cosedaUI.refinecenters_window.CenterRefinementSettingsWindow(*args, **kwargs)[source]

Bases: QDialog

Settings dialog to launch center refinement across selected INIs.

add_plot_to_viewer(iter_num, plot_type, file_path)[source]

Adds a plot to the QTreeWidget under the appropriate iteration and plot type.

closeEvent(event)[source]

Ensures that the timer is stopped when the dialog is closed.

display_selected_plot(item, column)[source]

Displays the selected plot in the QLabel.

get_parameter_from_config(config, section, parameter, default_value, is_optional=False)[source]

Retrieve parameter from config. If optional and not present, return default. Otherwise, return integer or float value or default.

init_ui()[source]
on_find_refinement_all()[source]

Initiates center refinement on all INI files in the directory using the selected method.

on_find_refinement_current()[source]

Initiates center refinement on the current INI file using the selected method.

on_method_change(index)[source]
on_plot_display_label_clicked()[source]

Displays the current plot image in a larger dialog when the label is clicked.

on_refinement_cancelled(message)[source]

Slot to handle user-requested cancellation.

on_refinement_error(error_message)[source]

Slot to handle refinement errors.

on_refinement_finished(message)[source]

Slot to handle successful refinement.

on_save_all()[source]
on_save_current()[source]
on_stop_clicked()[source]

Request cancellation of any running refinement job.

open_plot_image(item, column)[source]

Opens the selected plot image in the default image viewer.

stop_monitoring()[source]

Stops the plot viewer monitoring.

update_plot_viewer()[source]

Scans the plots folder for new plots created after the monitoring started. Adds them to the plot viewer.

update_refine_progress()[source]

Periodically count completed iterations and update the progress bar, ignoring runs predating the start time.

class cosedaUI.refinecenters_window.ClickableLabel(*args, **kwargs)[source]

Bases: QLabel

Label that emits a clicked signal when the user releases the left mouse button.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

mouseReleaseEvent(event)[source]
class cosedaUI.refinecenters_window.PreviewWindow(*args, **kwargs)[source]

Bases: QDialog

Non-modal preview window for inspecting refinecenters outputs and runs.

on_next()[source]
on_prev()[source]
on_run_selected(index)[source]

Handles selection of a specific run from the dropdown.

update_preview()[source]

Monitors for refinecenters_ folders, populates dropdown with all runs, and auto-selects the newest run created after monitoring started. Only supports NPZ iteration detection.

class cosedaUI.refinecenters_window.TrimmingDoubleSpinBox(*args, **kwargs)[source]

Bases: QDoubleSpinBox

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

textFromValue(value)[source]
Parameters:

value (float)

Return type:

str

class cosedaUI.refinecenters_window.Worker(*args, **kwargs)[source]

Bases: QObject

Threaded worker that runs center refinement and reports success/errors.

cancelled

alias of str

error

alias of str

finished

alias of str

request_cancel()[source]

Signal the worker’s underlying job to stop.

run()[source]

Execute the configured center refinement workflow.

cosedaUI.refinecenters_window.decimate(x, y, max_points)[source]

Downsample by taking every nth point so that at most max_points remain.

Parameters:
  • x (numpy.ndarray)

  • y (numpy.ndarray)

  • max_points (int)

cosedaUI.refinecenters_window.envelope_downsample(x, y, n_bins)[source]

Downsample by capturing first, last, min, and max in each of n_bins equally-sized bins. Returns (downsampled_x, downsampled_y).

Parameters:
  • x (numpy.ndarray)

  • y (numpy.ndarray)

  • n_bins (int)

cosedaUI.strip_file_window module

UI for stripping empty/low-peak frames from HDF5 datasets.

class cosedaUI.strip_file_window.StripFilesWindow(*args, **kwargs)[source]

Bases: QDialog

abort_stripping()[source]
on_empty_only_checkbox_changed(state)[source]
start_stripping()[source]
class cosedaUI.strip_file_window.StripWorker(*args, **kwargs)[source]

Bases: QThread

Worker thread to strip a single HDF5 file based on peak threshold.

abort()[source]
finished

alias of str

progress

alias of int

run()[source]
class cosedaUI.strip_file_window.StripWorkerBatch(*args, **kwargs)[source]

Bases: QThread

Worker thread to strip batches of INIs/HDF5 files, emitting per-file progress.

abort()[source]
file_progress

alias of str

finished

alias of str

progress

alias of int

run()[source]

cosedaUI.unitcell_window module

Dialog for plotting unit cell histograms from CrystFEL stream files.

class cosedaUI.unitcell_window.UnitCellHistogramWindow(*args, **kwargs)[source]

Bases: QDialog

Plot unit cell parameter histograms for the current CrystFEL stream.

Parameters:

stream_path (Optional[str])

closeEvent(event)[source]
set_stream_path(path, auto_plot=False)[source]

Update the linked stream path (called when selection changes externally).

Parameters:
  • path (str | None)

  • auto_plot (bool)

start_auto_refresh(interval_sec=60)[source]

Begin auto-refreshing plots every interval_sec with countdown.

Parameters:

interval_sec (int)

stop_auto_refresh()[source]

cosedaUI.update module

In-app update checks via Homebrew.

cosedaUI.update.check_for_updates(_checked=False, formula=None, parent=None, silent=False, notify_only_on_update=False)[source]

Refresh Homebrew metadata, then check if the COSEDA formula is outdated. Prompts the user with the result and suggests upgrading via Homebrew.

Parameters:
  • _checked (bool)

  • formula (str | None)

  • silent (bool)

  • notify_only_on_update (bool)

Return type:

None

cosedaUI.windowsettings module

Utilities for UI settings: version, changelog, and OS-specific style hints.

cosedaUI.windowsettings.get_version_from_log(versionlog)[source]

Return the most recent version entry from the version log; fallback to ‘Unknown’ on error.

cosedaUI.windowsettings.load_changelog(versionlog='CHANGELOG')[source]

Return changelog text safely.

Lookup order:
  1. packaged resource: cosedaUI/resources/CHANGELOG (wheel/Homebrew safe)

  2. local resources dir next to the module (editable installs)

3) project root one level above the package (dev tree) If none found, return an empty string.

cosedaUI.windowsettings.set_style()[source]

cosedaUI.workflow_wizzard module

Workflow guards to decide which steps are available based on HDF5 contents.

cosedaUI.workflow_wizzard.check_findcenters_allowed(h5file_path)[source]

Find centers only allowed if there are peaks.

cosedaUI.workflow_wizzard.check_index_integrate_allowed(h5file_path)[source]

Index & Integrate requires a mask dataset.

cosedaUI.workflow_wizzard.check_peakfinding_allowed(h5file_path)[source]

Peakfinding is allowed only when a mask dataset exists.

cosedaUI.workflow_wizzard.check_refinecenters_allowed(h5file_path)[source]

Refine centers only allowed if detector shift present.

cosedaUI.workflow_wizzard.has_detector_shift(h5file_path)[source]

Return True if the HDF5 file has detector shift/center datasets.

cosedaUI.workflow_wizzard.has_mask_dataset(h5file_path)[source]

Return True if a 2D mask dataset exists in HDF5.

cosedaUI.workflow_wizzard.has_peak_dataset(h5file_path)[source]

Return True if the HDF5 file has a non-empty peak dataset.

cosedaUI.workspace_functions module

Helpers for saving, loading, and manipulating workspace INI lists and view state.

cosedaUI.workspace_functions.add_generated_ini_paths(self, paths, show_warnings=True)[source]

Add importer-generated INI files to the workspace.

Returns a dict with added/skipped/invalid path lists so import dialogs can report concise status without duplicating workspace mutation logic.

cosedaUI.workspace_functions.add_ini_files(self)[source]

Open a dialog to add INI files to the workspace list.

cosedaUI.workspace_functions.add_ini_paths(self, paths)[source]

Add provided INI file paths to the workspace list (no file dialog).

cosedaUI.workspace_functions.load_last_directory(self)[source]

Restore last directory and last workspace (file or INI list) from config.

cosedaUI.workspace_functions.load_last_workspace_state(self)[source]

Restore workspace state from configuration (named file or INI list).

cosedaUI.workspace_functions.new_workspace(self)[source]

Clear the current workspace list and reset state.

cosedaUI.workspace_functions.open_workspace(self)[source]

Load a saved workspace file (.cosedawsp) and populate the INI list.

cosedaUI.workspace_functions.remove_ini_files(self)[source]

Remove selected INI files from the workspace list.

cosedaUI.workspace_functions.save_workspace(self)[source]

Save the current workspace INI paths to a .cosedawsp file.

cosedaUI.workspace_functions.save_workspace_state(self)[source]

Save workspace paths (or workspace file) to the config file.

cosedaUI.workspace_unitcell_fit_window module

Workspace-wide unit-cell histogram and Gaussian fit dialog.

class cosedaUI.workspace_unitcell_fit_window.WorkspaceUnitCellFitWindow(*args, **kwargs)[source]

Bases: QDialog

Aggregate unit-cell values from all workspace files and fit selected peaks.

Parameters:
  • workspace_ini_paths (Optional[list[str]])

  • workspace_path (Optional[str])

set_workspace_context(paths, workspace_path)[source]
Parameters:
  • paths (list[str])

  • workspace_path (str | None)

set_workspace_ini_paths(paths)[source]
Parameters:

paths (list[str])

Module contents