Skip to content
Commits on Source (3)
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
test -d /usr/share/autoconf-archive && AUTOCONF_ARCHIVE="-I /usr/share/autoconf-archive"
test -d /usr/share/aclocal/ac-archive && AUTOCONF_ARCHIVE=$AUTOCONF_ARCHIVE" -I /usr/share/aclocal/ac-archive"
libtoolize --force --copy
aclocal $AUTOCONF_ARCHIVE
autoheader
automake --gnu --add-missing --copy
autoconf
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
aghermann (1.1.2-1) unstable; urgency=medium
aghermann (1.1.2-2) unstable; urgency=medium
* Team upload.
* New upstream version
* Team maintenance in Debian Med team
* debhelper 11
* Point Vcs fields to salsa.debian.org
......@@ -11,6 +10,12 @@ aghermann (1.1.2-1) unstable; urgency=medium
-- Andreas Tille <tille@debian.org> Tue, 30 Oct 2018 08:54:52 +0100
aghermann (1.1.2-1) unstable; urgency=low
* New upstream version.
-- Andrei Zavada <johnhommer@gmail.com> Tue, 3 Jan 2017 15:31:00 +0200
aghermann (1.1.1-1) unstable; urgency=low
* New upstream version (Closes: #833472).
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#+TITLE: EEG Micrcontinuity lite
#+AUTHOR: Andrei Zavada
#+EMAIL: johnhommer@gmail.com
#+LANGUAGE: en
#+OPTIONS: toc:nil num:nil LaTeX:t
#+LINK_UP:
#+LINK_HOME: aghermann.html
* EEG Microcontinuity
The concept of EEG microcontinuity, as described in the [[http://www.ncbi.nlm.nih.gov/pubmed/11008419][original
paper]] by Kemp et al (2000), proposes a new SWA metric which is,
citing from the Abstract, "the fraction (0%-100%) of the current
slow wave which continues in the near-future (0.02 s later) EEG".
Ths metric in Aghermann is implemented by translating relevant bits
from the C# code [[http://code.google.com/p/neuroloopgain/][published]] by Marco Roessen, who in turn did the
coding of the original concept in collaboration with Bob Kemp.
The algorithm, following the logic and comments in said C# code,
proceeds like so:
1. Perform SU and SS reduction;
2. Compute PiB value;
3. Detect artifacts;
4. Smooth SU and SS;
5. Detect events;
6. Re-smooth signals and detecting jumps;
7. Compute final gains.
In doing my part, I got stuck in the C# thicket just after step 2.
Eventually, as part of a debugging effort, I noticed that the
intermediate results coming out after step 1, bore remarkable
semblance to the ultimate course of "SW%" as it appears on fig. 2
(chart 2).
Step 1, thus, produces the "lite" SW% metric, at each page p, as
SS[p] - SU[p], where SS and SU are computed as shown in eq. 22 of
the cited paper. Note that these values are computed over the
entire page length (typically, 30 sec) rather than the shorter 1-sec
intervals used in the paper.
For what it is, the SWA (or SW%) profiles of EEG Microcontinuity do
look handsome to me, nicely following the ultradian cycle and
expressing the SWA swing with clear emphasis. And it even elicits a
novel feature, which is a steadier buildup of the metric towards the
end of a slow-wave hump where PSD yields a more steep increase early
on into the period.
Please take this with a pinch of salt.
* Artifact detection
The SS-SU difference is used for *artifact detection*.
#+TITLE: Achermann model
#+AUTHOR: Andrei Zavada
#+EMAIL: johnhommer@gmail.com
#+LANGUAGE: en
#+OPTIONS: toc:nil num:nil LaTeX:t
#+LINK_UP:
#+LINK_HOME: aghermann.html
* Process S
The Process S is the colloquial sleepiness, or sleep pressure,
physiologically defined and quantified numerically in EEG spectral
power units. It is intimately reciprocally related to the
instantaneous SWA, the latter being the means to dissipate the
former, whilst the former builds up in absence of the latter.
Acting together in a self-regulating fashion, these processes
constitute an hourglass mechanism: the *sleep homeostat*.
Elaborating on the original Borbély et al's assumptions,
Achermann's Process S needs not be a mathematically pure
exponential line; rather, the function of S(t) depends on both
S(t-1), SWA(t-1) as well as on the current vigilance state. Thus
the model can capture the process of sleep pressure dissipation in
a more refined way, less abstract way.
* Simulation of Achermann's model with Aghermann
The equations used to compute the S and SWA in Aghermann are those
originally proposed in the 1993 paper, except that:
+ Noise is not used;
+ Three (optional) 'amendments' can be enforced.
One prerequisite for running the simulations is that your episodes
must be sufficiently scored. This is mainly to differentiate
between principal vigilance states (that is, NREM, REM and Wake).
The table below shows the most interesting parameters of the model:
/gc/ is the precious one.
| Parameter | Unit | Description |
|-------------------+--------+-------------------------------------|
| $rc$ | min^-1 | SWA rise constant |
| $fc_{\mathrm{R}}$ | min^-1 | SWA fall constant triggered by REM |
| $fc_{\mathrm{W}}$ | min^-1 | SWA fall constant triggered by Wake |
| $gc$ | min^-1 | Gain constant, x10^-2 |
| $S_0$ | % | Level of /S/ at sleep onset |
| $S_U$ | % | Upper asymptote of /S/ |
| $t_{\mathrm{a}}$ | min | Anticipated effect of REM on SWA |
| $t_{\mathrm{p}}$ | min | Extension of effect of REM on SWA |
| $rs$ | min^-1 | Rise rate of /S/, 10^-3 |
(*) $S_{\mathrm{U}}$ is tied to $rs$ and not tuned independently:
$S_{\mathrm{U}} = (S_{0} - S_{\mathrm{baseline\_end}} \cdot \mathrm{exp}(-t \cdot rs)) / (1 - \mathrm{exp}( -t \cdot rs))$,
$t$ being here 24~h less the duration of the baseline night.
#+TITLE: EEG Slow Wave Upswing
#+AUTHOR: Andrei Zavada
#+EMAIL: johnhommer@gmail.com
#+LANGUAGE: en
#+OPTIONS: toc:nil num:nil LaTeX:t
#+LINK_UP:
#+LINK_HOME: aghermann.html
* Slow Wave Upswing
Introduced in version 0.7.5, *SWU* is a poor man's take on measuring
the local synchronicity of neurons acting together to produce a slow
wave.
It is computed as a total sum, over a page, of area under the curve
of the signal's first derivative where it is positive, discarding
periods shorter than a certain threshold.
SWU should to be lower where slow waves have front interrupted by a
`kink'. It may be extended to also degrade in presence of a slow
wave terminating in a peak with many (rather than few) local minima.
#+TITLE: Aghermann Usage Notes
#+AUTHOR: Andrei Zavada
#+EMAIL: johnhommer@gmail.com
#+LANGUAGE: en
#+OPTIONS: toc:nil num:nil LaTeX:t
#+LINK_UP:
#+LINK_HOME: aghermann.html
* Setting up the experimental design
Assuming you have all your edf files available and have your
experimental design laid out, first spend a minute collecting your
edf sources in an experiment tree following this pattern:
#+begin_example
ExperimentRoot/Group/Subject/Session/Episode.edf
#+end_example
Secondly, make sure the recording times stored in the edf files are
*actual and correct* as Aghermann will not take guesses if this
information is missing or incorrect.
Once your directory tree is set up, start Aghermann, go to session
chooser (by closing the default, empty experiment) and point it to
the newly created experiment tree root directory.
Alternatively, you can drag-and-drop edf files and assign them
individually to groups/sessions.
If any edf file needs fixing its header, use edfhed or edfhed-gtk.
* Notes on Signal Type and Label fields in EDF headers
Make sure the =Label= field is (without quotes) either of
the form:
#+begin_example
"<SignalType> <Channel>",
#+end_example
or just
#+begin_example
"<Channel>",
#+end_example
where <SignalType> is one of "EEG", "ECG", "EOG", "ERG", "EMG",
"NC", "MEG", "MCG", "EP", "Temp", "Resp", "SaO2", "Light", "Sound",
"Event", "Freq". Only signals of EEG type will be selected for the
PSD analysis (other features are applicable to all signals
regardless).
If SignalType is omitted, Aghermann will try to match the Channel
against the list of System 1020 channels for EEG signal types.
Additionally, channels "Left" and "Right" are recognised as EOG,
and "Chin", as an EMG signal.
At present, EDF+ features (in particular, discontinuous signals
and sub-fields of the `PatientID' field) are not supported.
* Measurements Overview
All properly placed recordings will appear on the =1. Measurements=
tab.
* Displaying individual episode channel signals and scoring
** Opening an episode in the Scoring Facility
In the =1. Measurements= view, left-clicking on an episode will
start the scoring facility for that episode.
Ctrl-wheel will scale the profile up and down.
In the Scoring Facility, hover the mouse over the "(hint)" label to
see what actions are available by clicking on the signal, power
course overlay and hypnogram views; similarly, tooltips for the
scoring controls will show corresponding keyboard shortcuts.
Right-Click (or pressing Alt+1..9 while mouse is over a channel)
pops up a context menu with actions applicable to the
nearest-zeroline channel, as well as some generally applicable
actions. Also note that two different context menus are available
depending on whether you click above or below the channel zeroline:
the first has the options for the signal proper (filtering, scale
etc), whilst the second context menu exposes options and actions
applicable for the whole-episode profile (currently, PSD and MC
profiles), such as which of the two to display, whether to display
the PSD spectrum overlay, and also whether to display the profile
on EMG channels.
With Alt-Left-Click, you can drag channels around on montage.
Scoring controls will be inaccessible if you switch to a page
length different from that specified on the =1. Measurements ->
Setup -> Profile= tab.
Click =Score= at bottom-right to save the scores and artifact
markings (see below).
Multiple Scoring Facilities can be opened, also for one and the
same episode. In the latter case, the one closing last will
overwrite the .montage file for that episode.
** Signals displayed
Both /original/ and /filtered/ waveforms can be displayed,
individually or both at once. The filtered signal is produced by
applying the following, in order:
+ Any artifacts. These artifact-marked portions of the signal will
have the signal dampened by a factor with edges smoothly merging
with the adjacent signal regions.
+ Any enabled filters.
** Artifacts
To mark or clear an artifact manually, select a region with the
mouse and choose the corresponding menu item. Holding Shift while
making selection will do the marking in all channels.
You can experiment with the automatic *Artifact detection*
algorithm. It is based on the difference between
microcontinuity-dependent and -independent metrics (/SS/ and /SU/)
determined for a given epoch (these are the values displayed on the
selection bottom-centre).
The various parameters affecting how /SS/ and /SU/ are computed and
how a decision is reached are as follows:
| Parameter | Description |
|-------------------------------+---------------------------------------------------------------------------------------------------------------|
| Granularity | Minimal length of a single artifact marking, sec |
| /Continuity\/noise metrics/ | |
| F_0 | Centre and -3db-cutoff frequencies, Hz (for these and other parameters, better see paper) |
| F_cutoff | |
| Bandwidth | |
| MC Gain | |
| Back-polate factor | |
| /Artifact selection criteria/ | |
| /E/ value | Unless given explicitly, determine this value as the largest bin of /SS/-/SU/ histogram (see below) |
| Smooth | Smooth /SS/-/SU/ vector before building histogram |
| Compute range | If enabled, histogram range is taken as min thru max of the /SS/-/SU/ vector, else as given explicitly |
| Histogram bins | Number of histogram bins |
| Upper threshold | Mark period as a hi-freq artifact if /SS/-/SU/[p] > /E/ + /E/ times this value |
| Lower threshold | Mark period as a lo-freq artifact if /SS/-/SU/[p] < /E/ + /E/ times this value (see pp 1190-1 of cited paper) |
Once you have tuned these parameters to your satisfaction, you can
save them as a named profile, and subsequently apply AD globally
to all your recordings.
** Patterns
From a signal selection menu, you can take the selected portion as
a pattern to search for. In the Patterns dialog, you define the
four pattern properties and choose the channel to search in, and a
search increment size.
Searching can take some seconds to build match indices, shown in
the lower part of the field area. When you focus on one of the
criteria spin buttons on the left, a corresponding match index
appears; a match on a given criterion happens wherever its index
attains the criterion line. When all four criteria are met, the
pattern is found; it gets marked as an annotation in montage.
Patterns can be saved for future use. User-scope patterns will be
kept in ~/.local/share/aghermann/patterns; experiment- and
subject-scope ones, in dir .patterns/ in the experiment directory
root and, respectively, any individual subject's dir.
* Refining EEG further with ICA
You can also try to isolate/distill EEG signals with *Independent
Component Analysis* (ICA); for
explanation of the many options to control ICA process, please
refer to the authors of the original software (there are handy
links right next to the Separate button).
There are two modes of reconstructing channels with ICA:
+ *Map* individual components to channels, possibly preserving others;
+ *Punch* out some ICs and remix.
* EEG score import/export
The import filter reads the tokens and attempt to identify the
score as follows (in a case-insensitive manner):
| Code | Score |
|---------------------------+-----------------|
| W, Wake, 0 | Wake |
| N1, N2..4; NREM1..4; 1..4 | NREM Stage 1..4 |
| R, REM, 5 | REM |
| -, unscored, 9 | Unscored |
These codes can be configured on =Settings= tab. All other,
unrecognised tokens are skipped and the next token is read, but the
page currently being identified is not assigned any score. That
is, for example, if your file has something other than "-",
"unscored" or "0" for the Unscored identifier, the current page
will not get assigned a score at all, with the next score being
applied instead. Do some sed work to change the score codes
accordingly.
* Preparing the profiles for simulations
Once you are done preparing your SWA profiles, proceed
to the most interesting part, the Process S simulations.
Edit as necessary the simulatied annealing controlling parameters
and the tunables. With tunables, those for which the step is set
to 0, will not be tuned.
If you have a single sleeping episode per subject/session, the DB2
amendment does not make sense as it requires some substantial wake
intervals between sleeping episodes: turn it off in such a case,
and also set the step value for the rise rate to 0. (Strictly
speaking, for DB2 amendments to be effective, the profile needs to
be (a) >24h long, and (b) have the timepoint at t=24h in Wake.)
Likewise, AZ1 amendment is ineffective for single-episode profiles.
* Running the simulations
Then, double-click on a row in the =2. Simultions= tab. If all
constituent episodes have been sufficiently scored, the model run
facility will be displayed, showing the profile with the simulated
SWA and S obtained with the default tunable values (which you set
on the Parameters->Tunables tab).
Click on an episode to display that episode alone. You can take a
snapshot and save (as a png image) the current view by doing
Alt+leftclick.
The unscored pages will be patched up per settings on the
=2. Simulations -> Controlling Parameters= tab (i.e., they can be
assigned a Wake score or the score of the previous page).
Click =Run= to find the minimal cost function (sum of squared
distances between original and simulated SWA) using simulated
annealing (set/review controlling parameters on
Parameters->Simulated Annealing tab).
One especially useful and nifty feature is the live updating of the
course of Process S in response to your modifying the parameter
values. Enabling Live update before starting the annealing will
show the process of optimisation, but this will be slow.
You can review the courses of S and either copy-paste the resulting
tunable values for your stats, or return to the main window and
click Export to save all obtained simulations to a tsv file.
You can also run simulations in a batch.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.