maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   All about SleepAnalyser (https://talk.maemo.org/showthread.php?t=57419)

caco3 2010-08-03 17:40

Re: [ANNOUNCE]: SleepAnalyser
 
Hi rexii23

Thank you for your feedback.

I for sure can plan to include a function like that.
The challenge is to interprete the data. I always hoped to see the 90 minutes cycles during our sleep. But at least for my sleep I seem sometimes not to move for 3..4 hours. Because of that I can not figure out (jet) how the iPhone app can detect the sleep states and cycles :(

Would you always want to hear the same song?
Or do you have a list of various songs?
Should it be generally enabled every time you start the recording?
If you can give me some suggestions, that makes it easier.
Also the volume has to be set. (This I also will need for the alarm function). I most likely will use the already built in alarm functions, but I have to find a way to communicate with that function (D-BUS?).
My internet connection is very slow, so I can not do much research. I also still have to find a way how I can change the volume control from Python (most likely via D-BUS).

rexii23 2010-08-04 07:32

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by caco3 (Post 774527)
Hi rexii23

Thank you for your feedback.

I for sure can plan to include a function like that.
The challenge is to interprete the data. I always hoped to see the 90 minutes cycles during our sleep. But at least for my sleep I seem sometimes not to move for 3..4 hours. Because of that I can not figure out (jet) how the iPhone app can detect the sleep states and cycles :(

Would you always want to hear the same song?
Or do you have a list of various songs?
Should it be generally enabled every time you start the recording?
If you can give me some suggestions, that makes it easier.
Also the volume has to be set. (This I also will need for the alarm function). I most likely will use the already built in alarm functions, but I have to find a way to communicate with that function (D-BUS?).
My internet connection is very slow, so I can not do much research. I also still have to find a way how I can change the volume control from Python (most likely via D-BUS).

Yes having the right algorithm to find out the sleep cycles will be the hard part. For some recordings I have quite distinct sleep cycles but for others I have blocks of 3-4 hrs too. Maybe have a basic function for now that says after x minutes of 'green' then trigger the mp3? I don't have an iphone so can't test jet :(

I think one song would be enough, so a selection box to select the mp3 file will be excellent.

I think the option should default to having this feature as off and only enable it when I wish to test it out. I don't think I have any particular requirements about volume.

testerus 2010-08-04 15:48

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by caco3 (Post 774527)
Because of that I can not figure out (jet) how the iPhone app can detect the sleep states and cycles :(

According to this article at spiegel.de it doesn't.

caco3 2010-08-08 16:25

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by testerus (Post 775551)
According to this article at spiegel.de it doesn't.

It was never my intention to show in which sleep state you are.
It is not possible with just measuring the movement.
I do not know how the iPhone app makes it, but I am very sure it is not trustworthy.
Everybody who has a bit of a scientific understanding, knows that you never should draw an interpretation you can not solidify with facts.
Because of that SleepAnalyser never whill show you in which sleep state you are.
But beside of that, I think it is quite cool to se your movements.

Beside this statement, I just wanted to let you know that I uploaded a new Development version (1.5.9x) . It now has an experimental alarm function.
Please test it and give some feedback.

ndi 2010-08-10 09:28

Re: [ANNOUNCE]: SleepAnalyser
 
Hi.

Latest seems broken (101)

Code:

# ./main.py
Configuration file: /home/user/.SleepAnalyser/SleepAnalyser.conf
/home/user/.SleepAnalyser/SleepAnalyser.conf not existing or not read properly, using default parameters...
Application path: ./
Application version: 1.5 Build: 101
Traceback (most recent call last):
  File "./main.py", line 1336, in <module>
    main()
  File "./main.py", line 127, in main
    Show_passed_time("Application fully loaded", 1)
NameError: global name 'Show_passed_time' is not defined

(null)
Nokia-N900-42-11:~#

There is no .conf because i reinstalled. Didin't work before, either.

caco3 2010-08-10 11:45

Re: [ANNOUNCE]: SleepAnalyser
 
It seems that the function 'Show_passed_time' in the file myFunctions.py is missing for some reasons.
I will try to have a look on it later on.

bushi 2010-08-10 13:02

Re: [ANNOUNCE]: SleepAnalyser
 
I'm also very interested in a lucid dreaming function for N900.

I'm on Dreamviews (a pretty large lucid dreaming forum). I should refer them to this page of the thread and see if they might be able to shed some light on this problem.

I'll do this tomorrow.

Cheers and thanks for your work!

rexii23 2010-08-11 10:13

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by bushi (Post 781546)
I'm also very interested in a lucid dreaming function for N900.

I'm on Dreamviews (a pretty large lucid dreaming forum). I should refer them to this page of the thread and see if they might be able to shed some light on this problem.

I'll do this tomorrow.

Cheers and thanks for your work!

Good to know someone else is interested in lucid dreaming here too =P caco3 thanks again!

bushi 2010-08-11 11:01

Re: [ANNOUNCE]: SleepAnalyser
 
I used to have the Lucid Weaver app for my old Nokias but that wasn't the best really.

Basically it was just a set of alarms with preset times to go off.

It would be awesome if we could have something with actual potential to be automatically customized for each and every person.



I asked a very broad question.

Could you guys help me out - Give me some direct questions to ask so that I can get answers more easily?

rexii23 2010-08-11 11:37

Re: [ANNOUNCE]: SleepAnalyser
 
I cant really think of anything in particular. I think its more a technical challenge in implementation than anything else. detecting sleep cycles is the hard part. My simple logic would just go along the lines of:

detect period in 'red' moving phase, if 'green' sleeping phase follows for >60min trigger alarm/mp3

The program does a reasonable job already at detection though!

bushi 2010-08-12 10:20

Re: [ANNOUNCE]: SleepAnalyser
 
Sleep cyles are 90minutes I think.

Would 60minutes still be a good idea?

rexii23 2010-08-12 10:47

Re: [ANNOUNCE]: SleepAnalyser
 
sleep cycles are 90min but from memory I think its 60 of normal sleep followed by around 30min of REM sleep. the ratio of them changes too as the night goes on with bigger proportion of REM sleep in the later stages of the night. Don't quote me though as I'm quite rusty now with my sleep knowledge :P

caco3 2010-08-14 21:07

Re: [ANNOUNCE]: SleepAnalyser
 
Dear all

I just uploaded a new version 1.6-x.
Changes:
- Alarm function
- Improved User interactions
- Changed file format
- Rewrote huge part of code and clean up

Please have a look and test it.

mirakels 2010-08-15 14:42

Re: [ANNOUNCE]: SleepAnalyser
 
this was not nice.... upgraded to 1.6 and now I cannot look at my old records anymore.

I see the 'Changed file format' change, but I guess you should at least have left the code to READ old records and possibly convert them to the new format.

caco3 2010-08-15 16:33

Re: [ANNOUNCE]: SleepAnalyser
 
Dont forget it is a development version!
If you want to use it for real, go to stable or testing!

I will see what I can doo, but it is not that easy.

rexii23 2010-08-16 09:50

Re: [ANNOUNCE]: SleepAnalyser
 
Just used it last night. no problems. and it actually picked out my sleeping cycles extremely well, with distinct 90min cycles!!! I can't wait till you implement some lucid dream function.

I haven't tested alarm yet. might do it on the weekend so I won't be accidentally late for work!

Also I've noticed that battery drain is less now compared to the old old versions. around 10% in 8hrs is very very good. It use to be around 40%

mirakels 2010-08-16 19:08

Re: [ANNOUNCE]: SleepAnalyser
 
Great job Caco3! I see vesion 1.6-4 can read the old format files. Thanks.

Small bug: the duration seems to be same as the end time.

caco3 2010-08-16 22:47

Re: [ANNOUNCE]: SleepAnalyser
 
Hi all

The new uploaded version should have again some less bugs :)
- Duration time is fixed
- Graph should now be correct


@rexii23:
I would like to see your graph.
On my graphs I just can not see any cycles :(
Where do you put your phone?

caco3 2010-08-16 22:52

Re: [ANNOUNCE]: SleepAnalyser
 
Hi all

The new uploaded version should have again some less bugs :)
- Duration time is fixed
- Graph should now be correct

@rexii23:
I would like to see your graph.
On my graphs I just can not see any cycles :(
Where do you put your phone?

P.S: There is still one bug, but unless somebody finds it, it can stay there :)

rexii23 2010-08-17 08:20

Re: [ANNOUNCE]: SleepAnalyser
 
1 Attachment(s)
Attached is my graph for the last 2 days.

The Aug 15 one is the best with very good cycles. To reinforce the results, I know I had really good sleep with clear dreams and waking up feeling refreshed. Mostly likely becuase its a weekend!=P

Yesterday's one wasn't as great, but its becuase I know I had bad sleep. Dreading working on monday.

My phone is placed approximately 8cm away from my pillow on the bed. I have yet to try any other locations as it works quite well for me.

Strutten 2010-08-17 20:44

Re: [ANNOUNCE]: SleepAnalyser
 
Thank you fot this great app!

A couple of things;

Have you thought about translations? I volonteer for Swedish.

It doesn't seem to handle the scandinavian едц.

I would really like a function where you set how long you want to sleep, and that timer starts ticking when you fall asleep (lay still) rather than when you start the recording. Is that even possible?

Thanks again!

mirakels 2010-08-18 21:33

Re: [ANNOUNCE]: SleepAnalyser
 
Hi,

duration reporting is better in 1.6-6 but still not correct.
exmaple of last night:
In record view:
Wed 08/18/2010 12:29:11 AM - 07:57:51 AM (Duration: 08:28:40)

Off by one hour....

In Show adittional info (about this record):
Start: Wed. 18.08.2010 00:29:11
End: Wed.18.08.2010 07:57:51
Duration: 07:57:51

Eg duration equal End time.

Note also the different format for displaying data/time in 'record view' and 'about'.

My localization settings are 24 hour clock so for me the format in record view is wrong...

Thanks!

caco3 2010-08-18 21:48

Re: [ANNOUNCE]: SleepAnalyser
 
Hi all

I just fixed some small bugs and added unicode support.

Translations for sure would be nice, but have to wait for a later version.
Same for a lucid dream function.

@Strutten:
I do not really see a good usage for a set time after you felt asleep. Most people have to get up at a certain time, so just wait for a full cycle is over might not work.
Also the main thing is to clearly figure out when you felt asleep.
Maybe I can have a look on that later on.

caco3 2010-08-19 22:42

Re: [ANNOUNCE]: SleepAnalyser
 
Hi all

Version 1.6-12 should be free of bugs :)
If you find one, please let me know, else I will more focus on the documentation and then push it into testing.
The only new thing I added is an option to change to silent profile when recording is started (like switching to offline mode)

joh 2010-08-20 00:09

Re: [ANNOUNCE]: SleepAnalyser
 
Hi caco3

Just tried to install using the program manager. Installed without error messages. But when starting, after 10 s SleepAnalyser crashes to the desktop -- before any user interface is drawn up. So I uninstalled again.

Any dependency problem?

caco3 2010-08-20 00:15

Re: [ANNOUNCE]: SleepAnalyser
 
Hi joh

Which version are you using?
Can you start it in the terminal (CTRL-SHIFT-X) with
python /opt/SleepAnalyser/main.py
What does it say there?

ConiKost 2010-08-20 23:39

Re: [ANNOUNCE]: SleepAnalyser
 
Hi caco3,
I've installed today the SleepTracker. Nothing starts :(
Version 1.6 from devel.

Output from console:

Code:

# python /opt/SleepAnalyser/main.py
Configuration file /home/user/.SleepAnalyser/SleepAnalyser.conf not existing or not compatible
Traceback (most recent call last):
  File "/opt/SleepAnalyser/main.py", line 1447, in <module>
    main() #Now we can start it.
  File "/opt/SleepAnalyser/main.py", line 79, in main
    config=LoadConfig()
  File "/opt/SleepAnalyser/functions_general.py", line 54, in LoadConfig
    config.set('main', 'sample_smoothing', str(data.sample_smoothing))
AttributeError: 'module' object has no attribute 'sample_smoothing'


rexii23 2010-08-20 23:52

Re: [ANNOUNCE]: SleepAnalyser
 
Tried version Version 1.6-12. So far no big issues. The duration is still in a time format instead of just displaying the duration in hr, min & sec. otherwise I couldnt find any bugs right now. will keep on testing

convulted 2010-08-21 00:16

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by ConiKost (Post 793565)
Hi caco3,
I've installed today the SleepTracker. Nothing starts :(
Version 1.6 from devel.

Output from console:

Code:

# python /opt/SleepAnalyser/main.py
Configuration file /home/user/.SleepAnalyser/SleepAnalyser.conf not existing or not compatible
Traceback (most recent call last):
  File "/opt/SleepAnalyser/main.py", line 1447, in <module>
    main() #Now we can start it.
  File "/opt/SleepAnalyser/main.py", line 79, in main
    config=LoadConfig()
  File "/opt/SleepAnalyser/functions_general.py", line 54, in LoadConfig
    config.set('main', 'sample_smoothing', str(data.sample_smoothing))
AttributeError: 'module' object has no attribute 'sample_smoothing'


This is a bug in data.py, and happens when the config file is not found. "Sample_smoothing = ..." in data.py needs to change to "sample_smoothing = ...". (Or, "sample_smoothing" in main.py needs to change to "Sample_smoothing". Not sure.)

Edit: This is in a virgin version 1.6-15 installation.

c:drive 2010-08-21 00:56

Re: [ANNOUNCE]: SleepAnalyser
 
install,,,,,reboot,,,,,,,,,then,,,,,open,,,,,loadi ng,,,,,,,,nothing! previous verson works fine with my device,now it refused to open,any thought?
mine: stock kernel,,,,(fade up with enhanch kernel)

mmlado 2010-08-21 07:15

Re: [ANNOUNCE]: SleepAnalyser
 
Could you add a new option, checkbox, which when checked the application stops recording movement when the alarm is started.
As it is now I always get a big spike at the end, probably because I'm lifting up the N900 to hit the button to turn off the alarm.

It has the duration of the whole sleep. It would be nice to know the duration of REM sleep to.

kamil365 2010-08-21 08:55

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by convulted (Post 793591)
This is a bug in data.py, and happens when the config file is not found. "Sample_smoothing = ..." in data.py needs to change to "sample_smoothing = ...". (Or, "sample_smoothing" in main.py needs to change to "Sample_smoothing". Not sure.)

I've had the same problem. I've changed "Sample_smoothing = ..." into "sample_smoothing = ..." and now it's working like a charm:) thx

mirakels 2010-08-21 11:16

Re: [ANNOUNCE]: SleepAnalyser
 
I played with Yscale a bit and noticed that triger levels are influenced by it. To fix this I made the following change:
Code:

--- functions_record.py.org    2010-08-21 12:07:17.000000000 +0200
+++ functions_record.py 2010-08-21 13:07:09.000000000 +0200
@@ -103,7 +103,8 @@
            Xder=0
            Yder=0
            XYder=0
-        records.arrData[3][i]=min(XYder*data.Yscale,  data.Ysize-17) #cut off if higher than graph border
+#        records.arrData[3][i]=min(XYder*data.Yscale,  data.Ysize-17) #cut off if higher than graph border
+        records.arrData[3][i]=XYder
        records.arrData[4][i]=lastindexovertrigger
 #        if(records.arrData[3][i]>data.Trigger): #over trigger
 #            lastindexovertrigger=i
@@ -304,7 +305,8 @@
            if(records.arrData[3][p+j]>peak): peak=records.arrData[3][p+j]
        x=i/Xscale
 #        x=i/Xscale+1
-        paint.drawLine(x, data.Ysize-peak-1-15, x, data.Ysize-1-15)  #draw yellow movement bar
+        h=min(peak*data.Yscale,  data.Ysize-17) #cut off if higher than graph border
+        paint.drawLine(x, data.Ysize-h-1-15, x, data.Ysize-1-15)  #draw yellow movement bar
       
       
        if(peak>data.Trigger):

the changes just applies the scaling at drawing time and does not change the actual measurements data!

With this change you can savely change the yscale parameter in the SleepAnalyser.conf file.

My 'movements' are inte order of 10 to 20. With a yscale of 1 the graph is quite difficult to read. Using yscale=4 gives me a much nicer view of the record.

mirakels 2010-08-21 11:20

Re: [ANNOUNCE]: SleepAnalyser
 
The durations are still printed using AM/PM format. The follwong change fixes that:

Code:

--- main.py.org 2010-08-21 12:07:23.000000000 +0200
+++ main.py    2010-08-21 13:18:25.000000000 +0200
@@ -725,7 +725,7 @@                                                                                                                         
 #        diff_tuple=Seconds2Tuple(diff_sec)                                                                                                 
 #        print diff_tuple,  records.StartTime_tuple,  EndTime_tuple                                                                         
 #        diff=strftime("%H:%M:%S", diff_tuple)                                                                                             
-        diff=time.strftime("%X", time.gmtime(diff_sec))                                                                                     
+        diff=time.strftime("%H:%M:%S", time.gmtime(diff_sec))                                                                               
        if(diff_sec>86400): d="1 day, " #longer than 24h                                                                                   
        else: d=""                                                                                                                         
        self.ui.lblTimes.setText(str(d0)+"  -  "+str(d1)+"  (Duration: "+d+str(diff)+")")                                                   
@@ -1157,7 +1157,7 @@                                                                         
            d1=strftime("%a. %d.%m.%Y  %H:%M:%S", EndTime_tuple)                       
                                                                                         
        diff_sec=records.Index*records.Sampling_interval*records.Value_smoothing/1000   
-        diff=time.strftime("%X", time.gmtime(diff_sec))                                 
+        diff=time.strftime("%H:%M:%S", time.gmtime(diff_sec))                           
                                                                                         
        if(diff_sec>86400): diff="1 day, "+diff #longer than 24h


rm42 2010-08-21 12:27

Re: [ANNOUNCE]: SleepAnalyser
 
Just installed from devel (never installed before) and the app won't start.

convulted 2010-08-21 13:54

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by rm42 (Post 793903)
Just installed from devel (never installed before) and the app won't start.

This seems to be a known issue. See post #107 and post #109. It would be best to let the developer fix this problem if you don't understand how to apply the fix in post #109.

caco3 2010-08-21 21:28

Re: [ANNOUNCE]: SleepAnalyser
 
Wow, what a great response :)

Thank you all for the ideas and the bug fixes.
I fixed the config bug, added the stop function (mmlado's request) and corrected the displayed duration time (thanks to mirakels).
I also included mirakels change for Yscale, how ever I do not suggest to increase Yscale. If I have it bigger than 1, I mainly see noise.
Maybe you can show us some screenshots?

@mmlados:
I do not see a way to properly detect when you are in the REM. Because of that i also do not know how to measure its time.
Maybe in a later version, when we have more expirience with the data.

Please check the latest version and report any bugs.

mirakels 2010-08-22 09:26

Re: [ANNOUNCE]: SleepAnalyser
 
2 Attachment(s)
I guess it all depends on what th trigger level will be (e.g. how soft your matras is and how wild youre movements are during the night :)

Anyway here are two screenshots. One with Yscale=1 and one with Yscale=4.

I thing the one with yscale=4 shows a much better picture...

caco3 2010-08-22 12:12

Re: [ANNOUNCE]: SleepAnalyser
 
Hmm, I see, your graphs are indeed much smaller. Either you have a much harder matress, put your phone further away or have a very smooth sleep :)

I guess I should add Yscale to the config screen.
How ever as it is already full, I first have to figure out how to make it scrollable.

eitama 2010-08-22 12:26

Re: [ANNOUNCE]: SleepAnalyser
 
Hey Hey!

The last 3 versions before this one, did not start on my device.
Today I updated, fired it up, and it's now running!

Gonna try it tonight!!! Woohoo!

Cheers mate!


All times are GMT. The time now is 14:59.

vBulletin® Version 3.8.8