Seizure Detection#
Seizure detection module available trained models - ‘modelA’, ‘modelB’ modelA is the model from the published work. modelB had extended training dataset. Optimal input for the model is 300 second. It is recommended to use only middle part of the signal.
Example#
from best.seizure_detection import seizure_detect import load_trained_model
# load model
modelA = load_trai ned_model('modelA')
# load data
fs = 500
x_len = 300
channels = 3
# create fake data
x_input = rand(channels, fs * x_len)
# preprocess; from raw data to spectrogram
x = best.deep_learning.seizure_detect.preprocess_input(x_input, fs)
# get seizure probability; model has 4 output classes, seizure probability is class 4.
# output is in shape (batch_size, x_len * 2 - 1); probability value for every half-second
y = best.deep_learning.seizure_detect.infer_seizure_probability(x, modelA)
Sources#
The seizure detection and training of the model is described in add website.
- brainmaze_torch.seizure_detection.infer_seizure_probability(x, model, use_cuda=False, cuda_number=0)#
infers seizure probability for a given input x; recommended signal len is 300 seconds. :param x: output from preprocess_input function, should be in shape [batch_size, 100, time_in_half-seconds] :param model: loaded seizure model :param use_cuda: if true x is loaded to cuda with cuda_number :param cuda_number: :return: seizure probability for input x in shape [batch_size, x.shape[2]] :rtype: np.array
- brainmaze_torch.seizure_detection.load_trained_model(model_name)#
Load a trained model from the specified path. Two available trained models - ‘modelA’, ‘modelB’ - modelA: the model from the published work. - modelB: trained with extended training dataset.
- Parameters:
model_name (str)
- Returns:
pytorch_model
- brainmaze_torch.seizure_detection.preprocess_input(x, fs)#
This function will calculate a spectrogram. The spectrogram has shape [batch_size, 100, len(x) in seconds * 2 - 1] :param x: raw data input in bach form [batch_size, n-samples] :type x: iterable :param fs: sampling rate of the input signal :return: batch of spectrograms from the input :rtype: np.array