Data types#
Objects the APIs return or accept: fitting results, scan and graph objects, chart builders, and pulse operations. Protocol and library types that appear in their signatures are under Types.
ColumnQuality
dataclass
#
Invertibility verdict for one decay curve.
snr is peak intensity over the noise estimate; decay_fraction is the fraction of
intensity lost across the b-range; residual_rms is the fit residual relative to the
curve's own scale. reason is non-None exactly when invertible is False.
DiffusionPeak
dataclass
#
One resolved component of a diffusion distribution.
DosyMap
dataclass
#
A (diffusion, chemical shift) map ready for contour display.
intensities is [n_d, n_shift]; d_axis is the F1 axis in m^2/s (log-spaced, so
plot it on a log scale); shifts is the direct axis in ppm. quality and
results are indexed by the same column index as shifts.
InversionResult
dataclass
#
Recovered P(D) for a single decay curve, on d_grid.
mean_d
property
#
Weight-averaged D (m^2/s) in log space, or NaN for an empty distribution.
DeviceMetadata
#
Device metadata information.
Annotation
dataclass
#
Axis
dataclass
#
Settings for one axis: title, range, scale, gridlines, and ticks.
type
class-attribute
instance-attribute
#
Figure
dataclass
#
A complete plot: one or more data series plus a Layout. Builder methods return self for chaining.
data
class-attribute
instance-attribute
#
add
#
add(*traces: _Trace | dict[str, Any]) -> Figure
Add one or more data series (Scatter, Bar, …) to the figure. Returns self for chaining.
add_shape
#
Draw a shape (line, box, circle, …) over the figure. Returns self for chaining.
add_annotation
#
add_annotation(
annotation: Annotation | dict[str, Any],
) -> Figure
Add a text label (optionally with an arrow) at a point on the figure. Returns self for chaining.
update_layout
#
update_layout(**kwargs: Any) -> Figure
Set figure-wide options (title, xaxis, yaxis, …) by keyword. Returns self for chaining.
to_spec
#
Export the figure as a plain {"data": [...], "layout": {...}} dictionary.
Font
dataclass
#
Font styling for titles, axis labels, and annotation text.
Layout
dataclass
#
Line
dataclass
#
Line styling: color, width, and dash pattern.
dash
class-attribute
instance-attribute
#
Margin
dataclass
#
Plot margins in pixels: left, right, top, bottom.
Shape
dataclass
#
A shape drawn over the plot (line/rect/circle/path/triangle) to highlight a region or point.
type
class-attribute
instance-attribute
#
DeviceState
#
GraphResult
#
GraphResult(
results: dict[str, object],
nodes: list[PostprocessingNode],
output_id: str,
)
Read-only results of running a processing pipeline over one scan; output is its pipeline output's value.
outputs
property
#
Each final step's id mapped to the value it produced, for inspection; the result is output.
spectrum
property
#
spectrum: SpectrumNd | None
The pipeline output when it is a spectrum, else None.
GraphSpec
module-attribute
#
GraphSpec = (
str
| rpc.Postprocessing
| list[rpc.postprocessing.PostprocessingNode]
)
Page
dataclass
#
One workspace page as a script sees it: its scans (proxies, data loaded lazily) and how it shows them.
PeakSet
#
PeakSet(
scan: Scan,
peaks: list[PeakInfo] | list[PeakInfo2D],
*,
spectrum: Spectrum1D | Spectrum2D | None = None,
project: str | None = None,
)
The scan's peaks, plus edit-log operations on them; every edit method requires a reason.
log
property
#
Every edit ever made to this scan's peaks, disabled ones included.
find
#
Every peak the predicate accepts, e.g. s.peaks.find(lambda p: p.area > 3).
add_peak
#
add_peak(
frequency_hz: float,
*,
reason: str,
f1_hz: float | None = None,
height: float = 0.0,
area: float = 0.0,
) -> str
Place a peak the detector did not find. Returns the new edit's id.
delete_peak
#
delete_peak(
*,
reason: str,
peak_id: str | None = None,
frequency_hz: float | None = None,
) -> str
Remove a peak for good; a re-detected line at the same position is removed again on replay.
move_peak
#
move_peak(
to_hz: float,
*,
reason: str,
peak_id: str | None = None,
frequency_hz: float | None = None,
) -> str
Reposition a peak.
set_field
#
set_field(
*,
reason: str,
peak_id: str | None = None,
frequency_hz: float | None = None,
integral: float | None = None,
pattern: str | None = None,
j_couplings: list[float] | None = None,
label: str | None = None,
) -> str
Override one of a peak's reported values.
merge
#
merge(frequencies_hz: list[float], *, reason: str) -> str
Merge the lines at these positions into one multiplet.
split
#
Split the multiplet in [start_hz, end_hz] at the frequency boundary_hz.
set_tier
#
Override the automatic chemical-shift tier for the signal in this interval.
set_integral_scale
#
Make the signal or region in this interval read value; every other integral keeps its ratio to it.
annotate
#
annotate(
text: str,
*,
reason: str,
peak_id: str | None = None,
frequency_hz: float | None = None,
) -> str
Attach free text to a peak.
revert
#
Undo one edit by appending a compensating entry. Nothing is erased.
clear_edits
#
Withdraw every edit on this scan, as one undo entry; back to what the detector found on its own.
Scan
#
Scan(
ref: AnalysisScanRef,
scan: Scan | None = None,
*,
view: LoadedScan | None = None,
)
One stored scan; data loads lazily. Assigning signal/spectrum/peaks is in-memory until save.
signal
property
writable
#
Accumulated signal (FID) as a Signal1D/Signal2D.
spectrum
property
writable
#
spectrum: Spectrum1D | Spectrum2D | None
Accumulated spectrum as a Spectrum1D/Spectrum2D, on a ppm axis wherever it is referenced.
peaks
property
writable
#
peaks: PeakSet
Picked peaks (a PeakSet) from the most recent perform_analysis call; not auto-detected on access.
integration_regions
property
#
integration_regions: list[IntegrationRegion]
Integration regions defined on the scan.
raw
property
#
raw: Scan
The underlying stored scan record; prefer signal/spectrum/peaks/metadata where possible.
perform_analysis
#
perform_analysis(
*,
settings: PeakDetectionSettings | None = None,
adaptive: bool | None = None,
min_distance_hz: float | None = None,
min_height_ratio: float | None = None,
prominence: float | None = None,
integration_width_hz: float | None = None,
normalize_to_peak: int | None = None,
multiplet_search_width_hz: float | None = None,
) -> list[PeakInfo]
Detect peaks and integrate them on this scan's spectrum; empty list for non-1D. Unset args use globals.
stored_analysis
#
stored_analysis() -> ScanPlotAnalysis
Peaks (manual lines and edits applied), multiplets and integration-region results, as the app shows them.
Uses the global detection settings and this scan's current data; empty for non-1D. Nothing is saved
or published, and peaks is not changed.
save
#
Write modifications back to this scan's own file on disk; never touches the current/active scan.
After apply or reprocess the scan is written with the pipeline's execution record, its
snapshot and the input it read.
preprocess
#
preprocess(
*,
settings: PreprocessingSettings | None = None,
phase_correction: PhaseCorrectionSettings | None = None,
baseline_correction: BaselineCorrectionSettings
| None = None,
apodization: ApodizationSettings | None = None,
zero_fill: ZeroFillSettings | None = None,
fft: FftSettings | None = None,
reference_correction: ReferenceCorrectionSettings
| None = None,
group_delay: GroupDelaySettings | None = None,
solvent_suppression: SolventSuppressionSettings
| None = None,
linear_prediction: LinearPredictionSettings
| None = None,
reference_deconvolution: ReferenceDeconvolutionSettings
| None = None,
) -> Scan
Apply preprocessing to this scan's 1D signal; no-op for non-1D. Unset stages use globals. Returns self.
Raises:
| Type | Description |
|---|---|
PreprocessingError
|
If a stage cannot be applied as configured. |
ProcessingParameterError
|
If a stage parameter is out of range. |
analyze
#
analyze(*, with_preprocessing: bool | None = None) -> Scan
Run the app's automatic processing (optionally preprocess, then peak detection). Returns self.
process
#
process(graph: GraphSpec | None = None) -> GraphResult
Run a processing pipeline over this scan, without touching scans.current or this scan's data.
The pipeline reads what pipelines read for the scan: its data, or for a scan a pipeline produced, the input that pipeline read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
GraphSpec | None
|
The project's pipeline (None), a saved pipeline's name, a pipeline, or a node list. It must hold exactly one pipeline output. |
None
|
Returns:
| Type | Description |
|---|---|
GraphResult
|
The run's results; |
Raises:
| Type | Description |
|---|---|
PipelineError
|
The pipeline has no output, several, or its output was not produced. |
apply
#
Run a processing pipeline over this scan and keep its output as this scan's data. Returns self.
A signal output brings the spectrum computed from it; a spectrum output keeps the signal it was
processed from. save then writes it over this scan, save_as_new beside it, either with
the execution record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
GraphSpec | None
|
As for |
None
|
Returns:
| Type | Description |
|---|---|
Scan
|
This scan. |
Raises:
| Type | Description |
|---|---|
PipelineError
|
The pipeline cannot run, or its output is no signal or spectrum. |
reprocess
#
reprocess() -> Scan
Run the pipeline that produced this scan's data again, on the input it stores. Returns self.
Nothing is written until save, which records the new run.
Returns:
| Type | Description |
|---|---|
Scan
|
This scan. |
Raises:
| Type | Description |
|---|---|
PipelineError
|
No pipeline produced this scan's data, or it cannot run. |
save_as_new
#
Save this scan's data as a new scan derived from it, beside it; this scan's file is not touched.
Sample, group, experiment and acquisition metadata are carried over; after apply the new scan
holds the execution record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The new scan's name; this scan's name and the pipeline's when None. |
None
|
pipeline_name
|
str
|
The pipeline's name for the default name; the applied pipeline's when "". |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The new scan's id. |
SmartFittingResult
dataclass
#
Result from SmartFittingAPI.fit with comprehensive metadata.
r_squared
instance-attribute
#
Coefficient of determination; None when the fit failed or the data is constant.
FunctionAnalysisResult
dataclass
#
BaseOp
#
LoadedScan
dataclass
#
LoadedScan(
scan: Scan,
project: str,
signal: Signal | None = None,
spectrum: Spectrum | None = None,
preprocessed: bool = False,
stored_metadata: tuple[dict[str, str], ...] = (),
placeholder: bool = False,
source: tuple[Signal | None, Spectrum | None]
| None = None,
applied_pipeline: Postprocessing | None = None,
)
A scan as the session holds it: the record (never its arrays), where it is stored, and the data shown.
project is "" for a scan that exists only in memory. stored_metadata is the metadata of the
stored signal and spectrum traces, kept because processing may not carry it over. placeholder is
True for a record taken from the project file whose scan has not been read yet: it may be light and
stale, so it must never be written to the scan. source is what processing pipelines read for the
scan: the signal and spectrum it showed before a pipeline output was applied over them, or the input
a stored pipeline output was produced from; None when that is the data shown. A pipeline therefore
never processes its own output. applied_pipeline is the pipeline whose output an apply shows;
saving the scan records it in place of the record's own.
stored_metadata
class-attribute
instance-attribute
#
source
class-attribute
instance-attribute
#
applied_pipeline
class-attribute
instance-attribute
#
applied_pipeline: Postprocessing | None = None
input_signal
property
#
input_signal: Signal | None
The signal pipeline inputs read: the source one, never an applied output.
input_spectrum
property
#
input_spectrum: Spectrum | None
The spectrum pipeline inputs read: the source one, never an applied output.
with_arrays
#
with_arrays() -> Scan
The record with the shown signal and spectrum written into it, for saving the data as a scan.
Shown pipeline output keeps the input it was produced from and the pipeline's snapshot.
from_stored
classmethod
#
from_stored(scan: Scan, project: str) -> LoadedScan
scan with the data it stores, unprocessed, and the input a pipeline produced it from.
scan itself is not changed.
unsaved
classmethod
#
unsaved(
signal: Signal | None, spectrum: Spectrum | None
) -> LoadedScan
A new in-memory scan, under a record of its own, showing signal and spectrum.
AnalysisScanRef
dataclass
#
Lightweight identity of a scan in the multi-scan analysis working set.
Holds only identifiers; the actual scan is resolved lazily from the repository.