pyIrena GUI Quick Start Guide#
Installation#
Step 1: Install pyIrena with GUI support#
# Install from source with GUI dependencies
pip install -e ".[gui]"
This installs:
pyirena (core package)
PySide6 (Qt6 for Python)
matplotlib (for plotting)
All required dependencies (numpy, scipy, h5py)
Step 2: Verify Installation#
# Check that pyirena-gui command is available
pyirena-gui --help 2>&1 || python -m pyirena.gui.launch
Running the GUI#
Method 1: Command-line launcher#
pyirena-gui
Method 2: Python module#
python -m pyirena.gui.launch
Method 3: From Python script#
from pyirena.gui.data_selector import main
main()
Using the Data Selector#
Interface Layout#
┌─────────────────────────────────────────────────────────┐
│ pyIrena │
├─────────────────────────────────────────────────────────┤
│ [Select Data Folder] [Refresh] /path/to/data │
│ │
│ File Type: [HDF5 Files (.hdf, .h5, .hdf5) ▼] │
│ │
│ Filter: [Enter text to filter files... ] │
│ │
│ ┌──────────────────────────────┐ │
│ │ ☑ complexUnified.h5 │ [Create Graph] │
│ │ ☐ fractal_aggregate.h5 │ │
│ │ ☐ hierarchical_structure.h5 │ │
│ │ ☑ spheres_Rg50.h5 │ │
│ │ ☐ spheres_Rg100.h5 │ │
│ │ ☐ surface_fractal.h5 │ │
│ │ │ │
│ └──────────────────────────────┘ │
│ │
│ Status: Showing 6 of 6 files │
└─────────────────────────────────────────────────────────┘
Step-by-Step Workflow#
1. Select Data Folder#
Click “Select Data Folder” button
Navigate to your data directory (e.g.,
testData/)Click “Select Folder” or “Choose”
The folder path appears next to the button, and files are automatically loaded.
Note: The dialog will remember your last selected folder and start from there on subsequent selections.
1.1 Refresh Folder Contents#
Click the “Refresh” button to reload files from the current folder
Useful if files are added/removed while the GUI is running
2. Choose File Type (Optional)#
Use the dropdown to filter by file type:
HDF5 Files (.hdf, .h5, .hdf5) - Default
Text Files (.txt, .dat, .csv) - For ASCII data
All Supported Files - Show all
3. Filter Files (Optional)#
Type in the Filter box to search for files
Works like grep: the text is a full regular expression, matched anywhere in the file name, case-insensitively
Examples:
sphere→ shows only files containing “sphere”Rg50→ shows spheres_Rg50.h560C|100C→ files containing either “60C” or “100C”0[12]min→ files with “01min” or “02min”^sample→ files whose name starts with “sample”\.h5$→ files ending in “.h5”^(?!.*bkg)→ files that do not contain “bkg”
An incomplete or invalid pattern (e.g. while you are still typing) falls back to a plain substring match rather than emptying the list
The same filter syntax applies in Data Selector, Data Manipulation, Data Merge and the HDF5 Viewer.
4. Select Files to Plot#
Single selection:
Click on a file name
Multiple selection:
Hold Ctrl (Windows/Linux) or Cmd (Mac)
Click multiple files
Or: Click first file, hold Shift, click last file (range selection)
Quick plot:
Double-click any file to plot immediately
5. Create Graph#
Select one or more files (the “Create Graph” button is only enabled when files are selected)
Click “Create Graph” button
A new window opens with the plot
Multiple selected files are overlaid on the same graph
Graph Window Features#
The graph displays:
Log-log scale for Q vs Intensity
Multiple datasets with different colors
Legend showing file names
Grid for easy reading
Axis labels: Q (Å⁻¹) and Intensity (cm⁻¹)
Checking for Updates#
The Data Selector checks GitHub for a new stable pyIrena release on startup, and at most once a week thereafter. If a newer version is available, a small banner appears below the title bar with a link to the GitHub releases page — otherwise nothing is shown.
The check runs in the background and never delays startup.
If you’re offline, or GitHub can’t be reached, the check fails silently — no error, no popup.
Pre-release versions (betas, release candidates) are never reported as “latest”; only full stable releases trigger the notice.
To turn this off, open Configure… in the Data Selector and uncheck “Check for new pyIrena releases on startup”.
Test Data#
The package includes synthetic test data in testData/:
File |
Description |
Features |
|---|---|---|
|
Small spherical particles |
Rg ≈ 50 Å, Porod tail |
|
Large spherical particles |
Rg ≈ 100 Å |
|
Mass fractal |
Power law slope ≈ 2.5 |
|
Surface fractal |
Power law slope ≈ 3.5 |
|
Multi-level |
Two size scales |
|
Complex 3-level |
Primary + aggregates + clusters |
Regenerate Test Data#
python create_test_data.py
Features#
Current Features ✅#
[x] Folder browsing with persistent last-folder memory
[x] File type filtering (HDF5 / Text / All)
[x] File list with scroll, sort (A→Z, Z→A, newest, oldest), and text filter
[x] Multiple file selection (Ctrl/Shift-click, double-click to plot)
[x] Graph window: log-log I(Q) vs Q, multiple datasets, colour-coded legend
[x] NXcanSAS HDF5 support; text file support (.txt, .dat, .csv)
[x] Zoom/pan with hard ViewBox limits (x: nearest decade ±1; y: P99 range ±3 decades)
[x] Unified Fit — Beaucage hierarchical model, 1–5 levels, correlation function
[x] Size Distribution — four inversion methods, complex background, MC uncertainty
[x] Simple Fits — 13 analytical models, linearization, MC uncertainty, HDF5 save
[x] Create Report — Markdown summary per file (data, Unified Fit, Sizes, Simple Fits)
[x] Tabulate Results — spreadsheet of all stored fit parameters, saveable as CSV
[x] All tables: Ctrl+C / Ctrl+Shift+C clipboard copy, right-click menu, numeric column sorting
[x] Batch fitting via “… (script)” buttons (reads
pyirena_config.json)[x] Export/Import Parameters for all three fit tools (shared JSON config format)
[x] All fit results stored in NXcanSAS HDF5 alongside raw data
[x] GitHub-based update notification (weekly check, opt-out in Configure…)
Using the Unified Fit Model#
Launching Unified Fit#
After selecting data files, you can launch the Unified Fit model in two ways:
Method 1: Menu Bar
Select one or more data files
Click Models → Unified Fit from the menu bar
Method 2: Button
Select one or more data files
Click the “Unified Fit” button (green button on the right panel)
The Unified Fit window will open with:
Left panel: Parameter controls for 1-5 structural levels
Right panel: Data plot + fit + residuals
Quick Start#
Select number of levels (start with 1)
Set initial parameters for Level 1:
G (Guinier prefactor)
Rg (radius of gyration)
B (Porod constant)
P (power law slope)
Check which parameters to fit (Fit? checkboxes)
Click “Fit” to run the optimization
View results in the graph (fit curve + residuals)
For detailed instructions, see Unified Fit
Using the Size Distribution Tool#
After loading data, click “Size Dist.” in the Data Selector to open the Size Distribution panel. Four inversion methods are available:
Regularization — general-purpose; recommended default
MaxEnt — most conservative; fewest artefacts
TNNLS — sharpest peaks; no smoothness penalty
Monte Carlo — Monte Carlo method; provides per-bin ±1σ uncertainty estimate
For a full explanation of each method and its parameters, see Size Distribution.
Using the Simple Fits Tool#
Simple Fits provides direct analytical model fitting for common SAS scattering functions. It is most useful when the scattering is well described by a single model (e.g., a Guinier regime, a Porod tail, monodisperse spheres).
Launching Simple Fits#
In the Data Selector, click “Simple Fits (GUI)” to open the panel with the currently selected file loaded.
Panel layout#
┌─────────────────────────────────────────────────────────────┐
│ Left panel (controls) │ Right: three plots │
│ │ │
│ Model: [Guinier ▼] │ ┌── I(Q) log-log ──────┐ │
│ Q range: [0.003] to [0.08] │ │ data + model + BG │ │
│ [Set Q from cursors] │ └──────────────────────┘ │
│ │ ┌── Residuals ─────────┐ │
│ □ Complex background │ │ (I−model)/σ vs Q │ │
│ □ No limits │ └──────────────────────┘ │
│ │ ┌── Linearization ─────┐ │
│ ── Parameters ── │ │ (Guinier/Porod only)│ │
│ I0 [1.0] lo [0] hi [—] ✓ │ └──────────────────────┘ │
│ Rg [50.0] lo [0.01] hi [500]│ │
│ │ │
│ [Fit] [Calc Uncertainty] │ │
│ [Store in File] │ │
│ [Export params] [Import params] │
└─────────────────────────────────────────────────────────────┘
Workflow#
Select a model from the dropdown (13 models available).
Set Q range by typing values or clicking “Set Q from cursors” (drag the cursor lines on the I(Q) plot to the desired range).
Adjust initial parameters — enter starting values and optional lower/upper bounds. Check “Fit?” for each parameter to include it in the optimisation.
Click Fit — results appear as ± labels next to each parameter field.
(Optional) Click “Calculate Uncertainty” to run a Monte Carlo error analysis (N Gaussian-perturbed fits; configurable via the N-runs spinbox).
Click “Store in File” to save results to the HDF5 file. Text files cannot store results; use “Export Parameters” instead.
Export Parameters — writes the model config to
pyirena_config.jsonfor batch processing withfit_simpleorfit_pyirena.
Models and linearization#
The Guinier, Guinier Rod, and Guinier Sheet models show a linearized plot (ln(I) or ln(QI) vs Q²) so you can visually confirm the fit quality in the linear representation. The Porod model shows IQ⁴ vs Q⁴. All other models show “No linearization available.”
For the full model list with formulas, see Simple Fits.
Keyboard Shortcuts#
Every pyIrena window:
Shortcut |
Action |
|---|---|
Cmd + W (macOS) / Ctrl + W (Windows, Linux) |
Close this window |
F1 |
Open this tool’s documentation in your browser — the same thing the ? Help button does. Only on windows that have one. |
Cmd/Ctrl + C |
Copy the selected cells of a table |
Cmd/Ctrl + Shift + C |
Copy a table with its column headers |
In the file list:
Shortcut |
Action |
|---|---|
Double-click |
Plot selected file immediately |
Ctrl/Cmd + A |
Select all visible files |
Ctrl/Cmd + Click |
Add/remove file from selection |
Shift + Click |
Select range of files |
Shift + click a tool button |
Open that tool at its default size and position, forgetting where you last left it |
Supported File Formats#
HDF5 Files (NXcanSAS and Simple HDF5)#
The GUI supports two HDF5 formats:
1. Full NXcanSAS format (preferred):
/entry/samplename/sasdata/
Q - Scattering vector [1/Å]
I - Intensity [cm⁻¹]
Idev - Error/uncertainty (optional)
Qdev - Q resolution (optional)
2. Simple HDF5 format (fallback):
/entry1/data1/ (or /entry/data/, /data/, or root level)
Q - Scattering vector [1/Å]
I - Intensity [cm⁻¹]
Idev/Error - Error/uncertainty (optional)
Qdev/dQ - Q resolution (optional)
The GUI first tries to read full NXcanSAS structure using pyirena.io.hdf5.readGenericNXcanSAS(). If that fails, it automatically falls back to the simple HDF5 reader readSimpleHDF5().
Text Files (.txt, .dat, .csv)#
Supported format:
# Comment lines start with #
# Column 1: Q (Å⁻¹)
# Column 2: Intensity (cm⁻¹)
# Column 3: Error (cm⁻¹) - optional
#
Q Intensity Error
1.000000e-03 1.000003e+10 3.000009e+08
1.047452e-03 8.307389e+09 2.492217e+08
...
Comma-separated .csv files are supported the same way, with or without a
header row:
Q,I,dI
1.000000e-03,1.000003e+10,3.000009e+08
1.047452e-03,8.307389e+09,2.492217e+08
...
Features:
Comment lines starting with
#are ignoredHeader rows (column names) are automatically detected and skipped
At least 2 columns required: Q and Intensity
Optional 3rd column: Error/uncertainty
Optional 4th column: dQ/Q resolution
Delimiter (whitespace/tab or comma) is auto-detected per file
Q (and dQ) is assumed to be in 1/Å by default; if your files use a different unit (e.g. 1/nm), set it in Configure → Text File Options → Q unit in text files and it will be converted to 1/Å automatically — see Q units for details
Scientific notation supported
Robust parser handles various text file formats
Generate test .dat files:
python convert_to_dat.py
Troubleshooting#
Issue: “No module named PySide6”#
Solution:
pip install pyirena[gui]
# or
pip install PySide6 matplotlib
Issue: GUI doesn’t start#
Solution 1: Check Python version
python --version # Should be 3.8+
Solution 2: Try running directly
python -m pyirena.gui.data_selector
Solution 3: Check error messages
python -c "from pyirena.gui.data_selector import main; main()"
Issue: “Error loading file”#
Possible causes:
File is not valid NXcanSAS format
File is corrupted
Missing read permissions
Solution: Check file with h5py
import h5py
with h5py.File('testData/complexUnified.h5', 'r') as f:
print(list(f.keys()))
print(list(f['entry1']['data1'].keys()))
Issue: Graph window is blank#
Solution 1: Update matplotlib
pip install --upgrade matplotlib
Solution 2: Try different backend
import matplotlib
matplotlib.use('TkAgg') # or 'Qt5Agg'
Issue: Can’t select multiple files#
Solution: Use Ctrl/Cmd key while clicking
Tips#
Performance: For many files (>100), use the filter to narrow the list
Quick plotting: Double-click is fastest for single files
Comparison: Select multiple files to overlay and compare
File organization: Name files systematically for easy filtering
Test first: Use the provided test data to learn the interface
Advanced Usage#
Creating Custom Test Data#
import numpy as np
import h5py
# Generate synthetic data
q = np.logspace(-3, 0, 100)
I = 1000 * q**(-4) + 0.01
# Save as HDF5
with h5py.File('my_data.h5', 'w') as f:
entry = f.create_group('entry1')
data = entry.create_group('data1')
data.create_dataset('Q', data=q)
data.create_dataset('I', data=I)
Programmatic Access#
from pyirena.gui.data_selector import DataSelectorPanel
from PySide6.QtWidgets import QApplication
app = QApplication([])
window = DataSelectorPanel()
window.show()
app.exec()
Next Steps#
After getting familiar with the data selector:
Analyze your data - Load your experimental files
Try unified fitting - Use
pyirena.core.unifiedExplore examples - See
pyirena/examples/Read documentation - Check the full user guide
Getting Help#
GitHub Issues: https://github.com/jilavsky/pyirena/issues
Documentation: https://github.com/jilavsky/pyirena#readme
Email: ilavsky@aps.anl.gov
Screenshots#
(Screenshots will be added here)
Enjoy using pyIrena GUI! 🚀