[med-svn] [aghermann] 22/31: fix, update basic_score.lua

andrei zavada hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:18 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit 72045efd82846757c914e9d8099f15d885696101
Author: Andrei Zavada <hmmr at ra>
Date:   Sat Nov 9 20:48:44 2013 +0200

    fix, update basic_score.lua
---
 upstream/data/basic_score.lua |   49 +++++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/upstream/data/basic_score.lua b/upstream/data/basic_score.lua
index 82782fe..fb8820b 100644
--- a/upstream/data/basic_score.lua
+++ b/upstream/data/basic_score.lua
@@ -18,10 +18,14 @@ local op_get_channel_data         = 3
 local op_get_psd                  = 100
 local op_get_mc                   = 101
 local op_get_swu                  = 102
-local op_get_signal_envelope      = 104
+local op_get_signal_envelope      = 103
+local op_get_page_dirty           = 104
 
--- For convenience, here are wrappers:
--- (on error, Fi returns {false, error_string}; else, results as described below)
+-- For convenience, here are wrappers
+
+-- common notes:
+--  (a) on error, Fi returns {false, error_string}; else, results as described below;
+--  (b) all page parameters are 1-baaed.
 
 function get_channel_list ()
    -- returns: n_channels, ch1, ch2, ...
@@ -36,7 +40,7 @@ end
 
 function get_channel_data (h)
    -- args: h: channel, e.g., "Fz"
-   -- returns: n_pages, n_full_pages, pagesize, samplerate
+   -- returns: n_full_pages, n_total_pages, pagesize, samplerate
    return Fi(A, op_get_channel_data, h)
 end
 
@@ -45,7 +49,7 @@ function get_psd (h, pa, pz, fa, fz)
    --       pa, pz: starting and ending pages, inclusive;
    --       fa, fz: frequncy range to extract PSD in.
    -- returns: a vector of numbers.
-   return Fi(A, op_get_psd, h, pa, pz, fa, fz)
+   return Fi(A, op_get_psd, h, pa-1, pz-1, fa, fz)
 end
 
 function get_mc (h, pa, pz, fa, _)
@@ -53,7 +57,7 @@ function get_mc (h, pa, pz, fa, _)
    --       pa, pz: start and end pages, inclusive;
    --       fa: f0 range to extract MC at.
    -- returns: a vector of numbers.
-   return Fi(A, op_get_psd, h, pa, pz, fa, fz)
+   return Fi(A, op_get_psd, h, pa-1, pz-1, fa, _)
 end
 
 function get_swu (h, pa, pz, fa, _)
@@ -61,7 +65,7 @@ function get_swu (h, pa, pz, fa, _)
    --       pa, pz: starting and ending pages, inclusive;
    --       fa: frequncy to extract SWU at.
    -- returns: a vector of numbers.
-   return Fi(A, op_get_psd, h, pa, pz, fa, fz)
+   return Fi(A, op_get_psd, h, pa-1, pz-1, fa, _)
 end
 
 function get_signal_envelope (h, p, scope, dt)
@@ -70,7 +74,14 @@ function get_signal_envelope (h, p, scope, dt)
    --       scope: envelope scope (tightness) parameter, sec (1 should be OK),
    --       dt: time resolution of resulting vector
    -- returns: a vector of signal envelope breadth values, taken at dt intervals.
-   return Fi(A, op_get_signal_envelope, p, scope, dt)
+   return Fi(A, op_get_signal_envelope, h, p-1, scope, dt)
+end
+
+function get_page_dirty (h, p)
+   -- args: h: channel, e.g., "Fz",
+   --       p: page,
+   -- returns: a portion [0..1] of signal on page p in channel h marked as artifact
+   return Fi(A, op_get_page_dirty, h, p-1)
 end
 
 
@@ -90,24 +101,34 @@ function put_score (p, s)
 end
 
 
+--
 -- function main
+--
 local cc = {get_channel_list_of_type ("EEG")}
 print( string.format( "Montage has %d EEG channels", cc[1]))
 
 local H = cc[2]
-local np, nf, ps, sr = get_channel_data (H)
-print( string.format( "Looking at channel %q: %d pages (%d full) @%d sec, samplerate %d", H, np, nf, ps, sr))
+local nf, np, ps, sr = get_channel_data (H)
+print( string.format( "Looking at channel %q: %d full pages (%d total) @%d sec, samplerate %d", H, np, nf, ps, sr))
 
-local delta = {get_psd (H, 0, np-1, 2, 3)}
-local theta = {get_psd (H, 0, np-1, 4, 8)}
+local delta = {get_psd (H, 1, nf, 2, 3)}
+local theta = {get_psd (H, 1, nf, 4, 8)}
 
 local n_scored = 0
-for p=1,np-1 do
+for p=1,nf-1 do
+  dirty = get_page_dirty(H, p)
+  if dirty > 0 then
+     print( string.format("p %d dirty (%g)", p, dirty))
+  end
+  -- print( get_signal_envelope(H, p, 1, 1))
+
   if delta[p] > theta[p] * 1.5 then
      n_scored = n_scored+1
---    print( "mark page ", p)
+     print( "mark page ", p)
      put_score (p, nrem3)
   end
 end
 
+print( string.format("scored %d pages", n_scored))
+
 return n_scored

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list