Esempio n. 1
0
if useEMG:
    print('using EMG.')
    label4EMG = params.label4withEMG
else:
    label4EMG = params.label4withoutEMG
    print('not using EMG')

print('pastStageLookUpNum = ' + str(pastStageLookUpNum))

#---------------
# read pickled files that stores EEG and stage labels

prefix = 'eegAndStage'

fileIDs = getFileIDs(eegDir, prefix)
### fileIDs = ['HET-NR-D0717', 'DBL-NO-D1473', 'HET-NO-D0905']

for fileID in fileIDs:
    print('fileID = ' + str(fileID))
    featureFileName = params.featureFilePrefix + '.' + params.extractorType + '.' + label4EMG + '.' + fileID + '.pkl'
    if oFilter.isOutlier(fileID):
        print('file ' + fileID + ' is an outlier, so skipping.')
    else:
        flag4extraction = 1
        if option != '-o':
            for fileName in listdir(featureDir):
                if fileName == featureFileName:
                    flag4extraction = 0
                    print(featureFileName + ' already exists, so skipping')
                    break
Esempio n. 2
0
from classifierTrainer import trainClassifier
from writeResults import writePredictions

orderMin = 0
orderMax = 8
# orderMax = 1
paramID = 0

params = ParameterSetup()
pickledDir = params.pickledDir
paramDir = params.pickledDir
classifierType = params.classifierType
classifierParams = params.classifierParams
eegFilePrefix = 'eegAndStage'

fileIDs = getFileIDs(pickledDir, eegFilePrefix)

print('classifier type = ' + str(classifierType))
print('useEMG = ' + str(params.useEMG))
print('emgTimeFrameNum = ' + str(params.emgTimeFrameNum))
print('binWidth4freqHisto = ' + str(params.binWidth4freqHisto))

stageLabels = params.stageLabels4evaluation
labelNum = len(stageLabels)
fileNum = len(fileIDs)

orderNum = orderMax - orderMin + 1
sensitivityMat = np.zeros((orderNum, labelNum), dtype=float)
specificityMat = np.zeros((orderNum, labelNum), dtype=float)
accuracyMat = np.zeros((orderNum, labelNum), dtype=float)
precisions = np.zeros((orderNum), dtype=float)
Esempio n. 3
0
from parameterSetup import ParameterSetup
from fileManagement import getFileIDs

#---------------
# main
splitID = ''.join(
    random.choice(string.ascii_uppercase + string.digits) for _ in range(4))
print('splitID =', splitID)

args = sys.argv
blockNum = int(args[1])

params = ParameterSetup()
# printMetadata(params)
prefix = 'eegAndStage'
fileIDs = getFileIDs(params.pickledDir, prefix)

recordNum = len(fileIDs)
print('recordNum =', recordNum)
# blockSize = np.int(np.floor(recordNum / blockNum))
blockSize = np.int(np.ceil(recordNum / blockNum))
print('blockSize =', blockSize)
print('fileIDs =', fileIDs[:5])
random.shuffle(fileIDs)
print('shuffled fileIDs =', fileIDs[:5])

blocks = []
for blockID in range(blockNum):
    blocks.append(fileIDs[(blockID * blockSize):((blockID + 1) * blockSize)])

with open(params.pickledDir + '/blocks_of_records.' + splitID + '.csv',