Tabular
siapy.datasets.tabular
¶
MetaDataEntity
¶
Bases: BaseModel
TabularDataEntity
¶
Bases: MetaDataEntity
model_config
class-attribute
instance-attribute
¶
model_config = ConfigDict(arbitrary_types_allowed=True)
TabularDataset
dataclass
¶
TabularDataset(container: ImageContainerType)
Creates a tabular dataset that can extract and organize spectral signatures from geometric shapes within spectral images for analysis and modeling.
PARAMETER | DESCRIPTION |
---|---|
container
|
Either a single SpectralImage or a SpectralImageSet containing multiple spectral images to process.
TYPE:
|
Example
from siapy.entities import SpectralImage
from siapy.datasets import TabularDataset
# With a single image
image = SpectralImage.open_rasterio("path/to/image.tif")
dataset = TabularDataset(image)
# With multiple images
image_set = SpectralImageSet([image1, image2])
dataset = TabularDataset(image_set)
Source code in siapy/datasets/tabular.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
image_set
property
¶
image_set: SpectralImageSet
Get the spectral image set being processed.
RETURNS | DESCRIPTION |
---|---|
SpectralImageSet
|
The SpectralImageSet containing all spectral images in this dataset. |
Note
This is the original image set provided during initialization, possibly converted from a single SpectralImage.
data_entities
property
¶
data_entities: list[TabularDataEntity]
Get all processed data entities.
RETURNS | DESCRIPTION |
---|---|
list[TabularDataEntity]
|
A list of TabularDataEntity objects, each containing spectral signatures and metadata for a geometric shape instance within the image set. |
Note
This list will be empty until process_image_data()
is called.
Each entity represents signatures extracted from one geometric shape
in one image.
process_image_data
¶
process_image_data() -> None
Extract spectral signatures from geometric shapes in all images.
Processes each image in the image set, extracting spectral signatures from within the convex hull of each geometric shape. Creates TabularDataEntity objects containing the signatures along with associated metadata.
Side Effects
- Clears any existing data entities
- Populates the
data_entities
list with new TabularDataEntity objects - Each geometric shape may produce multiple entities if signatures are organized into multiple groups
Note
This method must be called before accessing data entities through
iteration, indexing, or generate_dataset_data()
.
Example
dataset = TabularDataset(image_set)
dataset.process_image_data()
print(f"Processed {len(dataset)} data entities")
Source code in siapy/datasets/tabular.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
generate_dataset_data
¶
generate_dataset_data(
mean_signatures: bool = True,
) -> TabularDatasetData
Generate structured dataset data for analysis or export.
Combines all spectral signatures and metadata from processed data entities into a unified TabularDatasetData structure suitable for machine learning or statistical analysis.
PARAMETER | DESCRIPTION |
---|---|
mean_signatures
|
If True, compute the mean of all signatures within each data entity. If False, include all individual signature measurements. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
TabularDatasetData
|
A TabularDatasetData object containing: |
RAISES | DESCRIPTION |
---|---|
InvalidInputError
|
If no data entities exist (image data hasn't been processed yet). |
Note
The metadata DataFrame columns correspond to MetaDataEntity fields: image_idx, image_filepath, camera_id, shape_idx, shape_type, shape_label, geometry_idx.
Example
dataset.process_image_data()
# Get averaged signatures per shape
data = dataset.generate_dataset_data(mean_signatures=True)
# Get all individual signature measurements
data_detailed = dataset.generate_dataset_data(mean_signatures=False)
print(f"Signatures shape: {data.signatures.to_numpy().shape}")
print(f"Metadata shape: {data.metadata.shape}")
Source code in siapy/datasets/tabular.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|