Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-toml
Expand All @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
rev: v0.16.5
hooks:
- id: ruff
args:
Expand All @@ -23,17 +23,17 @@ repos:
files: ^(siapy|tests)/
- id: ruff-format
- repo: https://github.com/gitleaks/gitleaks
rev: v8.27.2
rev: v8.30.0
hooks:
- id: gitleaks
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.3
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.2.0
rev: v4.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
The datasets module provides structured containers and utilities for transforming spectral image data into formats optimized for analysis and machine learning. It bridges the gap between raw spectral data and analytical workflows.

```python
--8<-- "docs/concepts/src/datasets_01.py"
--8 < --"docs/concepts/src/datasets_01.py"
```
28 changes: 14 additions & 14 deletions docs/concepts/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Since spectral images often contain distinct objects with different spectral pro
The `Pixels` class represents spatial coordinates within spectral image, providing a container for *(x, y)* coordinate pairs. It uses pandas DataFrame internally for storage, enabling high-performance operations. The class provides multiple initialization methods and conversion functions to work with different data representations (i.e. DataFrames, list, arrays)

```python
--8<-- "docs/concepts/src/pixels_01.py"
--8 < --"docs/concepts/src/pixels_01.py"
```

## Signals
Expand All @@ -66,7 +66,7 @@ The `Pixels` class represents spatial coordinates within spectral image, providi
The `Signals` class stores spectral data for each pixel in a pandas DataFrame, allowing you to use any column names you choose (e.g. "band_1", "nir", "red_edge"). You can initialize it from a DataFrame, lists, dicts or NumPy arrays.

```python
--8<-- "docs/concepts/src/signals_01.py"
--8 < --"docs/concepts/src/signals_01.py"
```

However, direct initialization of `Signals` is typically not necessary in practice. When you create a `Signatures` instance, the underlying `Signals` object is automatically generated and managed for you. This section demonstrates the `Signals` class primarily to illustrate how the `Signatures` class (discussed next) is composed internally and to provide insight into the data structure that powers spectral analysis.
Expand All @@ -81,19 +81,19 @@ The `Signatures` class represents spectral data collections by combining spatial
`Signatures` can be initialized in multiple ways. The explicit approach creates each component separately before combining them, providing clarity about the composition:

```python
--8<-- "docs/concepts/src/signatures_01.py:long"
--8 < --"docs/concepts/src/signatures_01.py:long"
```

For more concise code, you can initialize a `Signatures` object directly from coordinate and signal values:

```python
--8<-- "docs/concepts/src/signatures_01.py:short"
--8 < --"docs/concepts/src/signatures_01.py:short"
```

Both approaches yield equivalent results when initialized with the same data. You can access and work with the data using various DataFrame operations and conversion methods:

```python
--8<-- "docs/concepts/src/signatures_01.py:assert"
--8 < --"docs/concepts/src/signatures_01.py:assert"
```

## Shape
Expand All @@ -104,7 +104,7 @@ Both approaches yield equivalent results when initialized with the same data. Yo
The `Shape` class represents geometric shapes that can be associated with images, such as points, lines, and polygons.

```python
--8<-- "docs/concepts/src/shapes_01.py"
--8 < --"docs/concepts/src/shapes_01.py"
```

## Spectral Image
Expand All @@ -121,31 +121,31 @@ A `SpectralImage` is the primary container for spectral image data. It's a gener
This is commonly used for hyperspectral imagery from airborne or satellite sensors.

```python
--8<-- "docs/concepts/src/spectral_image_01.py"
--8 < --"docs/concepts/src/spectral_image_01.py"
```

#### 2. Load from GeoTIFF or other geospatial formats (using rasterio)

Perfect for georeferenced data with spatial information.

```python
--8<-- "docs/concepts/src/spectral_image_02.py"
--8 < --"docs/concepts/src/spectral_image_02.py"
```

#### 3. Create from numpy array

Useful for testing or when you already have image data in memory.

```python
--8<-- "docs/concepts/src/spectral_image_03.py"
--8 < --"docs/concepts/src/spectral_image_03.py"
```

#### 4. Create your own custom image class

For specialized file formats or custom processing needs, you can extend the ImageBase class.

```python
--8<-- "docs/concepts/src/spectral_image_04.py"
--8 < --"docs/concepts/src/spectral_image_04.py"
```

### Data conversion methods
Expand All @@ -156,7 +156,7 @@ The example below demonstrates two key conversion methods of `SpectralImage` ins
2. `to_subarray()`: Converts selected pixel data to a NumPy array for numerical processing or integration with other scientific libraries

```python
--8<-- "docs/concepts/src/spectral_image_05.py"
--8 < --"docs/concepts/src/spectral_image_05.py"
```

### Manipulation of Shapes
Expand All @@ -166,13 +166,13 @@ Each `SpectralImage` instance automatically initializes a `GeometricShapes` obje
The `GeometricShapes` class provides a list-like interface that wraps a standard Python list, enhancing it with specialized functionality for manipulating geometric shapes while preserving standard list behavior. The list of shapes can be accessed via the `image.geometric_shapes.shapes` property.

```python
--8<-- "docs/concepts/src/spectral_image_shapes_01.py:init"
--8 < --"docs/concepts/src/spectral_image_shapes_01.py:init"
```

As a result, shapes can be added to the spectral image using standard list operations. The example below demonstrates how this can be done:

```python
--8<-- "docs/concepts/src/spectral_image_shapes_01.py:operations"
--8 < --"docs/concepts/src/spectral_image_shapes_01.py:operations"
```

## Spectral Image Set
Expand All @@ -183,5 +183,5 @@ As a result, shapes can be added to the spectral image using standard list opera
The `SpectralImageSet` class manages a collection of spectral images.

```python
--8<-- "docs/concepts/src/spectral_image_set_01.py"
--8 < --"docs/concepts/src/spectral_image_set_01.py"
```
12 changes: 6 additions & 6 deletions docs/concepts/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ Spectral indices are mathematical combinations of spectral bands that highlight
The `get_spectral_indices()` function returns all spectral indices that can be computed from the available bands:

```python
--8<-- "docs/concepts/src/features_01.py"
--8 < --"docs/concepts/src/features_01.py"
```

### Computing spectral indices

The `compute_spectral_indices()` function calculates spectral indices from DataFrame data:

```python
--8<-- "docs/concepts/src/features_02.py"
--8 < --"docs/concepts/src/features_02.py"
```

### Band mapping

When your data uses non-standard column names, use the `bands_map` parameter:

```python
--8<-- "docs/concepts/src/features_03.py:map"
--8 < --"docs/concepts/src/features_03.py:map"
```

## Automatic features generation
Expand All @@ -49,21 +49,21 @@ When your data uses non-standard column names, use the `bands_map` parameter:
The AutoFeat classes provide deterministic wrappers around the AutoFeat library, which automatically generates and selects engineered features through symbolic regression.

```python
--8<-- "docs/concepts/src/features_04.py"
--8 < --"docs/concepts/src/features_04.py"
```

### Features extracted using spectral indices

These classes integrate spectral index computation with automated feature selection, offering end-to-end pipelines for identifying the most relevant spectral indices.

```python
--8<-- "docs/concepts/src/features_05.py"
--8 < --"docs/concepts/src/features_05.py"
```

## Integration with siapy enitites

The features module integrates seamlessly with siapy entity system.

```python
--8<-- "docs/concepts/src/features_06.py"
--8 < --"docs/concepts/src/features_06.py"
```
10 changes: 5 additions & 5 deletions docs/concepts/optimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The optimizers module provides hyperparameter optimization capabilities for mach
The `TabularOptimizer` class provides automated hyperparameter optimization for sklearn-compatible models using tabular spectral data.

```python
--8<-- "docs/concepts/src/optimizers_01.py"
--8 < --"docs/concepts/src/optimizers_01.py"
```

## Trial Parameters
Expand All @@ -28,7 +28,7 @@ The `TabularOptimizer` class provides automated hyperparameter optimization for
Trial parameters define the hyperparameter search space for optimization. You can specify integer, float, and categorical parameters:

```python
--8<-- "docs/concepts/src/optimizers_02.py"
--8 < --"docs/concepts/src/optimizers_02.py"
```

## Scorers
Expand All @@ -43,21 +43,21 @@ Scorers define how model performance is evaluated during optimization.
Use cross-validation for robust model evaluation:

```python
--8<-- "docs/concepts/src/optimizers_03.py"
--8 < --"docs/concepts/src/optimizers_03.py"
```

### Hold-out scorer

Use hold-out validation for faster evaluation:

```python
--8<-- "docs/concepts/src/optimizers_04.py"
--8 < --"docs/concepts/src/optimizers_04.py"
```

## Integration with siapy entities

The optimizers module integrates seamlessly with the siapy entity system.

```python
--8<-- "docs/concepts/src/optimizers_05.py"
--8 < --"docs/concepts/src/optimizers_05.py"
```
10 changes: 5 additions & 5 deletions docs/concepts/transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ The transformations module provides essential image processing and co-registrati
### Basic transformations

```python
--8<-- "docs/concepts/src/transformations_01.py"
--8 < --"docs/concepts/src/transformations_01.py"
```

### Data augmentation

Data augmentation transformations are useful for expanding training datasets and testing algorithm robustness.

```python
--8<-- "docs/concepts/src/transformations_02.py"
--8 < --"docs/concepts/src/transformations_02.py"
```

### Normalization

The `area_normalization` function normalizes spectral signals by their area under the curve, which is particularly useful for comparing spectral shapes regardless of overall intensity.

```python
--8<-- "docs/concepts/src/transformations_03.py"
--8 < --"docs/concepts/src/transformations_03.py"
```

## Co-registration
Expand All @@ -44,13 +44,13 @@ Co-registration enables alignment and coordinate transformation between differen
The typical co-registration workflow involves selecting corresponding points in both images and computing a transformation matrix:

```python
--8<-- "docs/concepts/src/transformations_04.py"
--8 < --"docs/concepts/src/transformations_04.py"
```

### Applying transformations

Once you have a transformation matrix, you can transform pixel coordinates between image spaces:

```python
--8<-- "docs/concepts/src/transformations_05.py"
--8 < --"docs/concepts/src/transformations_05.py"
```
8 changes: 4 additions & 4 deletions docs/concepts/utils_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ The image utilities module provides functions for saving, loading, and processin
The SPy backend saves images in ENVI format.

```python
--8<-- "docs/concepts/src/utils_image_01.py"
--8 < --"docs/concepts/src/utils_image_01.py"
```

### Rasterio backend

The Rasterio backend provides geospatial capabilities and supports various formats.

```python
--8<-- "docs/concepts/src/utils_image_02.py"
--8 < --"docs/concepts/src/utils_image_02.py"
```

## Radiance to Reflectance Conversion

Converting radiance measurements to reflectance using reference panels is essential for quantitative spectral analysis.

```python
--8<-- "docs/concepts/src/utils_image_03.py"
--8 < --"docs/concepts/src/utils_image_03.py"
```

## Additional Utility Functions

```python
--8<-- "docs/concepts/src/utils_image_04.py"
--8 < --"docs/concepts/src/utils_image_04.py"
```
10 changes: 5 additions & 5 deletions docs/concepts/utils_plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ The plotting utilities module provides interactive tools for pixel and area sele
Select individual pixels from an image by clicking on them.

```python
--8<-- "docs/concepts/src/utils_plotting_01.py"
--8 < --"docs/concepts/src/utils_plotting_01.py"
```

### Area-based Selection

Select irregular areas from an image using lasso selection tool.

```python
--8<-- "docs/concepts/src/utils_plotting_02.py"
--8 < --"docs/concepts/src/utils_plotting_02.py"
```

## Image Visualization
Expand All @@ -30,21 +30,21 @@ Select irregular areas from an image using lasso selection tool.
Visualize spectral images with overlaid selected pixels or areas.

```python
--8<-- "docs/concepts/src/utils_plotting_03.py"
--8 < --"docs/concepts/src/utils_plotting_03.py"
```

### Multiple Image Comparison

Display multiple images side by side with their corresponding selected areas.

```python
--8<-- "docs/concepts/src/utils_plotting_04.py"
--8 < --"docs/concepts/src/utils_plotting_04.py"
```

## Signal Visualization

Plot mean spectral signatures with standard deviation bands for different classes.

```python
--8<-- "docs/concepts/src/utils_plotting_05.py"
--8 < --"docs/concepts/src/utils_plotting_05.py"
```
Loading
Loading