Pipeline¶
spectrakit.pipeline.Pipeline ¶
Chain spectral processing steps into a reusable pipeline.
Each step is a callable that takes a numpy array (W,) or (N, W) and returns the same shape. Steps are executed in order.
Examples:
>>> from spectrakit import Pipeline, baseline_als, normalize_snv
>>> pipe = Pipeline()
>>> pipe.add("baseline", baseline_als, lam=1e6)
>>> pipe.add("normalize", normalize_snv)
>>> corrected = pipe.transform(raw_intensities)
Source code in src/spectrakit/pipeline.py
__init__ ¶
__init__(
steps: list[
tuple[str, Callable[..., ndarray], dict[str, Any]]
]
| None = None,
) -> None
Initialize pipeline with optional named steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steps
|
list[tuple[str, Callable[..., ndarray], dict[str, Any]]] | None
|
List of (name, callable, kwargs) tuples. |
None
|
Source code in src/spectrakit/pipeline.py
add ¶
Add a processing step to the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable step name for logging. |
required |
fn
|
Callable[..., ndarray]
|
Processing function (e.g., baseline_als, normalize_snv). |
required |
**kwargs
|
Any
|
Keyword arguments passed to fn. |
{}
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Self, for method chaining. |
Source code in src/spectrakit/pipeline.py
transform ¶
Apply all pipeline steps to the input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Input spectral data, shape (W,) or (N, W). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Processed spectral data, same shape. |
Source code in src/spectrakit/pipeline.py
transform_spectrum ¶
Apply pipeline to a Spectrum, returning a new Spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
Spectrum
|
Input Spectrum. |
required |
Returns:
| Type | Description |
|---|---|
Spectrum
|
New Spectrum with processed intensities. |