Skip to content

Commit

Permalink
remove MAX_MESSAGE_SAMPLES threshold in auto interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Jan 19, 2019
1 parent 64fcd4e commit 6831028
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 4 additions & 9 deletions src/urh/ainterpretation/AutoInterpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from urh.cythonext import signal_functions
from urh.cythonext import util

# Maximum number of samples to consider when summing all samples over all messages during segmentation for performance.
MAX_MESSAGE_SAMPLES = int(1e6)


def max_without_outliers(data: np.ndarray, z=3):
if len(data) == 0:
Expand Down Expand Up @@ -78,15 +75,15 @@ def detect_noise_level(magnitudes):
return math.ceil(result * 10000) / 10000


def segment_messages_from_magnitudes(magnitudes: np.ndarray, noise_threshold: float, max_message_samples=0):
def segment_messages_from_magnitudes(magnitudes: np.ndarray, noise_threshold: float):
"""
Get the list of start, end indices of messages
:param magnitudes: Magnitudes of samples
:param q: Factor which controls how many samples of previous above noise plateau must be under noise to be counted as noise
:param noise_threshold: Threshold for noise
:return:
"""
return c_auto_interpretation.segment_messages_from_magnitudes(magnitudes, noise_threshold, max_message_samples)
return c_auto_interpretation.segment_messages_from_magnitudes(magnitudes, noise_threshold)


def merge_message_segments_for_ook(segments: list):
Expand Down Expand Up @@ -353,9 +350,7 @@ def estimate(signal: np.ndarray, noise: float = None, modulation: str = None) ->
noise = detect_noise_level(magnitudes) if noise is None else noise

# segment messages
message_indices = segment_messages_from_magnitudes(magnitudes,
noise_threshold=noise,
max_message_samples=MAX_MESSAGE_SAMPLES)
message_indices = segment_messages_from_magnitudes(magnitudes, noise_threshold=noise)

# detect modulation
modulation = detect_modulation_for_messages(signal, message_indices) if modulation is None else modulation
Expand Down
5 changes: 1 addition & 4 deletions src/urh/cythonext/auto_interpretation.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cpdef tuple k_means(float[:] data, unsigned int k=2):
return centers, clusters


def segment_messages_from_magnitudes(float[:] magnitudes, float noise_threshold, unsigned long max_message_samples=0):
def segment_messages_from_magnitudes(float[:] magnitudes, float noise_threshold):
"""
Get the list of start, end indices of messages
Expand Down Expand Up @@ -98,9 +98,6 @@ def segment_messages_from_magnitudes(float[:] magnitudes, float noise_threshold,
start = i - conseq_above
conseq_below = conseq_above = 0

if max_message_samples > 0 and summed_message_samples > max_message_samples:
return result

# append last message
if state == 1 and start < N - conseq_below:
result.append((start, N - conseq_below))
Expand Down

0 comments on commit 6831028

Please sign in to comment.