Skip to content

PSG Cohort and Database Notes

jasonli17 edited this page Nov 11, 2013 · 40 revisions

Syntax Legend:

PSG Cohort
[DATABASE NAME_DB]
{Table Name_T}
(Field name, FIELD TYPE) – field values; explanation


General Application These may need their own database which can be referenced from other groups…


{StudyInfo_T}

The study information table contains metadata on each study conducted. It is primarily used to provide a single identification (i.e. PRIMARY KEY) for each study conducted based on patient’s ID and their visit number. Should be populated before diagnostics_t, and requires a directory of names containing the edf’s to populate the table from.

Source

  • auxiliary/create_StudyInfo_T.m ## Input Pathname of .EDF files DBname, DBuser, DBpassword

    Output

    Study Information (below) fields go into StudyInfo_T table of DBname database

    Fields

    (PatID, VARCHAR(5)) – ACA
    A unique identifier for each patient
    (StudyNum, TINYINT(3) Unsigned) – 1,2,…M;
    The ordinal study for the patient (1st, 2nd, 3rd, etc.)
    (PatStudyKey, SMALLINT UNSIGNED NOT NULL AUTO INCREMENT) – 1,…M
    _PRIMARY KEY for each patient based on their Patient ID and their _ visit/study number

    Field Type Description
    PatStudyKey smallint(5) unsigned Primary key –
    PatID varchar(5) Alpha numeric patient identifier (e.g. A0001)
    StudyNum Tinyint(3) Study number associated with patid, provided by WSC
    VisitSequence Tinyint(3) Ordinal number for each patid – helpful to identify first, second, third, etc. study that we have of the same patid since studynum is not consistent as we do not have all studies and not all studynum’s are associated with a psg-visit.
    Montage_suite ENUM Description of the recording montage suite used for the PSG collection: {“Embla”,”Grass”,”Gamma”,”Twin”,”Woodward”,”Unknown”} Default is Grass

    {StageStats_T}

    The staging table holds statistical information derived from .STA files

    Source:

    (1) auxiliary/stage2stats.m
    (2) auxiliary/create_StageStats_T.m
    

    Input

    (1) Pathname of .STA files -> converted to .STA2 files
    (2a) stats cell from 1
    (2b) DBname, DBuser, DBpassword
    

    Output

    (1a) .STA2 files (3rd column of .STA now represents stage cycle)
    (1b) Cell of stage stat structures that follows below field name convention
    (2) Stat fields go into TableName table of DBname database
    
    Field Type Examples Description
    PatStudyKey SMALLINT UNSIGNED NOT NULL 1,2,3,…M A unique identifier for each patient study
    Stage ENUM ‘NREM’,0,1,2,3,4,5,6,7; The stage of sleep being examined
    Duration INTEGER 0,30,60,…30*N; duration of sleepID/stage in seconds
    Count INTEGER 0,1,2,…; number of 30-s epochs of the sleep stage
    Pct_study REAL 0,…1; percent of entire study the sleep stage represents
    Pct_sleep REAL 0,…1; percent of sleep the stage represents
    Num_cycles INTEGER 0,1,2,…; number of cycles exhibited by the sleep stage
    Latency INTEGER 0,30,60,…30*N; delay in seconds from sleep onset to stage
    PRIMARY KEY PatStudyKey 1,2,...,M SleepID

    {DetectorInfo_T}

    Provides baseline detector information as found in detection.inf file. Essentially an import of the detection.inf file that can be used as a base reference for Detection_Label_T table configurations. Also keeps track of various configurations used for the event class by way of the configID field

    Source

    (1) auxiliary/create_DetectorInfo_T.m

    Input

    (1) directory of detection.inf file (2) DBname,DBuser,DBpassword

    Output

    (1) Detector_Info_T table with following fields

    Field Type Description
    DetectorID Tinyint(3) unsigned Primary key – distinguishes from other detectors with same label
    DetectorFilename varchar(50) MATLAB filename for this detector
    DetectorLabel Varchar(50) String name of the detector
    ConfigID Tinyint(3) unsigned ID to distinguish between multiple parameter configurations of the same detector
    ConfigChannelLabels tinyblob Cell names of the PSG channels used for detecting events with ConfigID
    ConfigParamStruct tinyblob Parameter structure containing the configurable parameter fields and associated values for the unique ConfigID.

    ({Detection.inf Header Fields}, NOT NULL VARCHAR(35) ---example detection.inf header line--- Matlab_filename Label Number_of_channels_required Dialog_name Batch_mode_score

    Field Type Examples Description
    Matlab_filename TEXT ‘ocular_kupfer’,’spindle_ferrareli’ Name of the detector that was used in generating data
    Label TEXT ‘ocular_kupfer’,’spindle_ferrareli’ Name of the detector that was used in generating data
    NumberOfParameters TINYINT 0,1,2,3…N Number of parameters that can be adjusted by this detector
    ParameterLabels TEXT ‘NULL’,’threshold1’,…. Names of the parameters that can be adjusted; separated by semicolon
    Type TEXT ‘ocular’,’spindle’,’artifact’ Identifier of the method used for the generated detection
    DetectorID INTEGER 1,2,…M Primary key

    {Events_T}

    These tables should be an import of evt.eventName.txt event output as generated by the SEV

    Source:

    1. auxiliary/create_Events_T.m
    2. auxiliary/populate_Events_T.m
    3. auxiliary/import_artifacts.m
    4. auxiliary/evtTxt2evtStruct.m
    Field Type Description
    PatStudyKey SMALLINT UNSIGNED Unique patient-study identifier
    DetectorID TINYINT(3) UNSIGNED Foreign key from DetectorInfo_T used to identify the detection algorithm/configuration used for each event
    Start_sample INTEGER UNSIGNED Start sample of the event
    Stop_sample INTEGER UNSIGNED Stop sample of the event
    Duration_seconds REAL UNSIGNED Duration of the event in seconds
    Epoch SMALLINT UNSIGNED Ordinal value of the epoch the event occurred in
    Stage ENUM (0,1,2,3,4,5,6,7) Sleep stage of the epoch that the event occurred in
    Params BLOB Parameters associated with the event – a structure

    {Diagnostics _T}

    source file(s):

    1. Database/create_WSC_Diagnostics_T.m
    2. Database/wsc_datasheet.txt
    3. Database/wsc_snps_corrected.txt
    4. Database/wsc_drug_info.xls

    The information from the tab-delimited and .xls source files (2,3,4) are loaded into the table using (1). SNP input .txt file must be generated using convertSNPFile2WSCFile.m script and WSC .xls medication list received from Robin.

    {BloodIron_T}

    source file(s):

    1. Database/create_WSC_Blood_T.m
    2. Load file: /Volumes/Macintosh HD 2/Sleep/PLM/DataFiles/ ll_available_WSC_with_patids_testdates_and_priority-ling1-jl-6.xls

    Iron, transferrin, and ferritin measures from (2) populate this table using (1). Fields of interest include PTSDF (diagnosis of PTSD is 2, 1 is control)

    Field Type Description
    PatStudyKey smallint(5) unsigned Primary key –
    Has_good_iron_sample BOOL, default true Identifies when good iron values exist
    Serum Decimal(6,3) serum iron value
    Transferrin Decimal(6,3) transferrin value
    Ferritin Decimal(6,3) ferritin value
    TSAT Decimal(6,3) transferrin saturation percentage
    TIBC Decimal(6,3) total iron binding coefficient

    Posttraumatic Stress Disorder

    Owner: Steven Woodward
    Filetypes:

    1. .DAT -> codas formatted 16 channel psg data
      2. .cal -> calibration files for the data set
      3. .stg -> staging data

    Synthesized Files:

    1. .EDF <-->.DAT, .cal, and .stg were used to create .EDF
    2. .STA <--> .stg converted to .STA format

    There is a bug in PTSD/convertDAT2EDF_v2/stg2sta.m, which causes some epochs to be labeled as NaN. This can be seen in aca2.stg->aca2.sta near epoch 100 and for the final 4-5 epochs.

    Source

    Directory: PTSD/database
    File: PTSD_DB_and_T_setup.m


    [PTSD_DB]

    Source file:

    (1) PTSD/database/build_WSC_DB.m

    User: PTSD_user
    Password: PTSD_password


    {Diagnostics_T}

    source file(s):

    1. Database/create_PTSD_Diagnostics_T.m
    2. Database/PTSD_diagnostics.txt <-> MASTER small.xls

    The information from the tab-delimited source file (2) is loaded into the table using the source .m file (1). The header field SUBCODE is changed to PatID in the database to ease compatibility with other database queries across cohorts. Fields of interest include PTSDF (diagnosis of PTSD is 2, 1 is control)


    {StageStats_T}

    Stage Statistics using Staging_T table template, from auxiliary directory

    Source file(s)

    1. PTSD/Database/create_PTSD_StageStats_T.m
    2. Reference Table: auxiliary/create_StageStats_T.m

    {DetectorInfo_T}

    Detection Information table based on DetectorInfoInformation concerning method configurations for events that were generated. Can be used as a unique table for comparison of generated output that is loaded into a table and you only want one unique key to identify it

    Source file(s)

    1. PTSD/create_WSC_DetectorInfo_T.m
      Input
    2. directory of detection.inf file
    3. DBname,DBuser,DBpassword