CS 1173 Data Analysis and Visualization Lab 3
Basic statistics of your sleep diary data
Objectives:
 Practice using statistical tools and plots.
 Become familiar with sleep diary data for the project.
 Handle more realistic data.
 Interpret data and draw conclusions.


Handin Requirements:
 The lab3Script.m script containing your work for all parts.
 The published script in the same directory.
 A document with your analysis.
All projects and laboratories should be submitted submitted electronically through
Blackboard under the Assignments menu. Zip up your entire lab3 directory
to submit. (Right click on the project folder and follow the Send To link.)
Overview
This laboratory examines your sleep patterns as recorded in your sleep diary.
Description of the data
File 
Description 
Last_First_gender.mat 
Your sleep diary file contains the following fields in a structure called diary:
 bedTimes  bed times in decimaldate format (vector)
 dayCaffeine  daytime caffeine indicators (vector)
 nightCaffeine  evening caffeine indicators (vector)
 toSleepMinutes  number of minutes to fall asleep (vector)
 useAlarm  alarm use indicators (vector)
 wakeTimes  wakeup times in decimaldate format (vector)
 lastName  your last name
 firstName  your first name
 gender  'male' or 'female'
 section  your section number (vector)
 minutesNap  number of minutes of napping (vector)
 minsAwake  number of times awakened each night (vector)
 SSI  Stanford Sleepiness Scale (or Index)

Structures are used to keep variables in a group. To access your bedtimes, for example, you would use
diary.bedTimes. If you wanted a separate variable for your bed times, you would do:
myBedTimes = diary.bedTimes;
If you did not do a sleep diary, you will have to make up some data, enter it into the Excel spreadsheet and run
the test scripts.
The bedtimes and wakeup times use MATLAB's decimal date format. The date is a number
representing the offset from 0:00 of a particular reference day. The integer part
of this value represents the day and the fractional part represents the fraction of 24 hours
represented by the hour and minutes. Use the datestr function to convert
the decimal value to a string for printing or viewing.
To properly handle times, you will convert time in decimaldate format to time
in hours using the fractional part and ignoring the day part. Each timehour
will be relative to the day recorded in the sleep diary.
Example 1:The wakeup time 6:00 am on 9/23/2009 has the decimal date value of
734039.25. The 0.25 represents 6/24 fraction of a day.
The timehour would be 6.0
Example 2:The decimal date of 9/22/2009 at 9:00 pm is 734038.875.
If the day of the recording was 9/23, 734038.875  734039 = 0.125 represents
3/24 hours before midnight of the previous day. The timehour would be 3.0
Example 3:The decimal date of 9/23/2009 at 5:49 am is 734039.242361111. The
fraction 0.242361111 can be calculated as (5 + 49/60)/24.
The timehr would be 5.817
Part I: Initial set up
 Create a directory called lab3 in V:.
 Change your MATLAB working directory to be this directory.
 Copy your processed diary .mat into this directory.
Part II: Data analysis requirements:
In this project you should analyze your sleep characteristics using the statistical and graphical
tools covered in class. Your script should calculate and output the following:
 You should calculate and output the basic statistical indicators
for your individual diary (maximum, minimum, mean, median, standard
deviation, AAD and MAD) of:
 Wakeup timehours (relative to midnight on wakeup day)
 Bed timehours (relative to midnight on wakeup day)
 Hours of sleep (wake times  bed times converted to hours)
 Minutes to sleep
 Minutes napping
 Minutes awake during the night
 Total daily sleep (hours of sleep + hours of napping  hours awake during the night  hours to fall asleep)
 Your Stanford Sleepiness Scale (SSI)
Your output should be in tabular format (use %#.#f to line up the columns) with
the names of the variables (e.g., wakeup time, etc.) in the left most column.
Label the columns with the names of the indicators (e.g., Maximum, etc.).
 You should calculate and output:
 Percentage of days you woke up to an alarm
 Percentage of days you used caffeine
 Percentage of nights you used caffeine
 Overall percentage of caffeine use
 Percentage of days that you took a nap
 You should create the following graphs:
 A graph showing your average bedtime with a standard deviation errorbar.
 A graph showing your average total hours of sleep with a standard deviation errorbar.
 Two additional graphs showing average bedtime time and hours of sleep by day of the week. This graph is to be median with IQR error bars.
Part III: Publish the results
Publish your script by pushing the Publish icon. Make sure that your script is separated appropriately
into cells and that each cell has a title indicating what is computed in that cell.
Analysis
 Make 3 observations (from the statistical indicators) in bullet point form.
 Make 3 observations (from the graphs) in bullet point form. Refer to specific
figures when making the observations.
Grading rubric (point values)
Criterion 
Performance indicator 
Missing 
Needs improvement 
Needs a little improvement 
Meets expectations 
Excellent 
Statistical indicators correctly computed and presented in tabular form 
0 
5 
8 
9 
10 
Percentages computed 
0 
3.75 
6 
6.75 
7.5 
Four errorbar graphs correctly labeled 
0 
3.75 
6 
6.75 
7.5 
The lab2Script contains all code and is published 
0 
2.5 
4 
4.5 
5 
Bullet points on statistics 
0 
5 
8 
9 
10 
Bullet points on graphs 
0 
5 
8 
9 
10 
This laboratory was last modified 08Aug2016.
The image is a screen shot of 30 seconds of
an EEG recording of a patient during Slow Wave Sleep. The photograph was taken by S.
S. Jähnichen on 12/9/2005. The image is available on Wikipedia as
http://en.wikipedia.org/wiki/File:Sleep_EEG_Stage_4.jpg.