-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmethod_new_basic_template_matlab.py
49 lines (34 loc) · 1.72 KB
/
method_new_basic_template_matlab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
""" A template file to add new method in the benchmark.
Remark: Make sure that this file starts with "method_".
"""
""" First section ----------------------------------------------------------------------
| Import here all the modules you need.
| Remark: Make sure that neither of those modules starts with "method_".
"""
from mcsm_benchs.benchmark_utils import MethodTemplate
from mcsm_benchs.MatlabInterface import MatlabInterface
""" Second section ---------------------------------------------------------------------
| After moving a file called 'my_matlab_method.m' to
| src\methods, create an interface with the matlab engine by
| passing the name of the function file (without the .m
| extension). Then get the matlab function as:
"""
mlint = MatlabInterface('my_matlab_method')
matlab_function = mlint.matlab_function # A python function handler to the method.
""" Third section ----------------------------------------------------------------------
| Create here a new class that will encapsulate your method.
| This class should inherit the abstract class MethodTemplate.
| You must then implement the class function:
def method(self, signal, params)
| which should receive the signals and any parameters that you desire to pass to your
| method.
"""
class NewMethod(MethodTemplate):
def __init__(self):
self.id = 'my_matlab_method'
self.task = 'denoising'
def method(self, signal, *params): # Only positional args for matlab methods.
signal_output = matlab_function(signal, *params) # Only positional args.
return signal_output
# def get_parameters(self): # Use this to parametrize your method.
# return [None,]