For a given sigma, the kernel size is calculated as `int(sigma * 4) + 1`.
To use, add `'b'` to the `augment` hyperparameter string (e.g. `'xyrjb'`), or set `augment=True` to include all augmentations.
Open-Source Solver for Site-Preserved Cross-Validation
Slideflow no longer requires CPLEX for solving site-preserved cross-validation splits, which is proprietary software. Instead, the open-source Pyomo (with Bonmin solver) can now be used for those without access to CPLEX. Slideflow will first attempt to use CPLEX if available.
Other New Features
- Enables L2 regularization for models trained in the PyTorch backend.
- Predictions can now be saved in CSV, feather, or parquet format. The `save_predictions` argument can now be a string to specify save format (`'csv'`, `'feather'`, `'parquet'`). By default, will save in parquet format.
- `Project.predict()`will now save tile, slide, and patient-level predictions.
- More than 10-fold speed improvement when calculating metrics for datasets tens of millions of images in size
- Significant performance improvements for `Dataset` functions, particularly for large projects with tens of thousands of slides
- `sf.io.tensorflow.decode_image()` function now accepts `crop_left`, `crop_width`, `resize_target`, `resize_method`, and `resize_aa` methods for cropping and resizing dataset images. These arguments can be passed as keyword arguments to the `dataset.tensorflow(...)` function.
- New utility function `sf.util.get_model_normalizer()` for easily loading the normalizer used to train a given model.
- Support for feature-conditioned GAN training via `sf.io.torch.LocLabelInterleaver`, an extension of the `InterleaveIterator` class which reads a pandas DataFrame for tile-level labels.
- `sf.stats.metrics_from_dataset()` includes new option `categorical_reduce` which determines how slide/patient-level predictions are determined from tile-level predictions. If 'raw' (default), slide-/patient-level predictions are averages of tile-level predictions. If `onehot`, tile-level predictions are converted to onehot via `argmax` prior to average.
- Adds option for specifying UMAP kwargs to `Project.generate_mosaic()`. For example, `P.generate_mosaic(umap_kwargs={'densmap'=True})`
- New function `sf.util.get_tfrecord_by_location()` enables finding a record in a TFRecord by a given location tuple (x, y)
- New function `DatasetFeatures.to_df()` exports activations into a pandas dataframe
- New function `sf.model.tensorflow.unwrap()` returns the input, post-convolutional output, and model output tensors for the model, for easier model surgery.
- New functions `Dataset.find_slide()` and `Dataset.find_tfrecord()` enable finding slide paths or tfrecord locations from a given slide/patient name.
- Compatibility update for Tensorflow 2.9
Bug Fixes and Other Changes
- Updates Otsu's thresholding method to only apply thresholding to areas within ROIs (if supplied). This helps prevent large pen marks and other artifacts outside ROIs from interfering with the foreground/background threshold calculation.
- Adds `method='pca'` for `SlideMap.neighbors()`
- Allows specifying heatmap `img_format` with `P.generate_heatmaps()`
- Logs warning if a dataset source is supplied to `sf.Dataset` (either manually or via project `settings.json`) and that source does not exist in the dataset configuration JSON file.
- Allows import of Slideflow if pyvips or libvips is not installed.
- Fixes error where logs were not being written to the project folder.
- Fixes training bug when `validate_on_batch` is set to 0 in the pytorch backend
- Corrected logging when testing multiple/single linear outcomes during testing
- Fixes a logging message when generating features
- Fixes bug where, in certain environments, tile extraction would hang if started after pyvips was imported and used in another process.
- Fixes bug where models were not being saved if early stopping was triggered.
Breaking Changes
- Replaces `resolution` argument to `.plot()` with `figsize`, so the matplotlib figsize can be specified directly
- Removes the `buffer` argument to `Heatmap` and `Project.generate_heatmaps()`
- Removes `histogram` argument and functionality from evaluation.
- Renames `SlideMap.export_to_csv()` -> `.to_csv()`
- Renames `SlideMap.save_2d_plot()` -> `.save()`
- Renames `SlideMap.save_3d_plot()` -> `.save_3d()`
- Renames `Mosaic.place_tiles()` -> `.plot()`
- Renames `DatasetFeatures.export_to_torch()` -> `to_torch()`
Patch Notes