Bring-Your-Own-Features (BYOFS)
The Bring-Your-Own-Features (BYOFS) allows users to add custom feature sets to sleepKIT to be used with built-in or custom tasks.
How it Works
Section titled “How it Works”-
Create a Feature Set: Define a new feature set class that subclasses
sk.FeatureSetand implements the feature contract. The following is a skeleton: implement the writer before calling it.Python example import sleepkit as skclass CustomFeatureSet(sk.FeatureSet):@staticmethoddef name() -> str:return "custom"@staticmethoddef feature_names() -> list[str]:return ["feature1", "feature2", "feature3"]@staticmethoddef generate_subject_features(subject_id: str, ds_name: str, params: sk.TaskParams):raise NotImplementedError("Write feature, mask and label arrays for this subject") -
Register the Feature Set: Register the new feature set with the
sk.FeatureFactoryby calling theregistermethod. This method takes the feature set name and the feature set class as arguments.Python example import sleepkit as sksk.FeatureFactory.register(CustomFeatureSet.name(), CustomFeatureSet) -
Use the Feature Set: The new feature set can now be used to generate feature sets.
Python example import sleepkit as skfrom pathlib import Pathparams = sk.TaskParams.model_validate_json(Path("configuration.json").read_text())params.feature.name = "custom"# Load a tasktask = sk.TaskFactory.get("stage")# Use the custom feature settask.feature(params)