except: pass try: os.mkdir('datasets') except: pass #Downloading subjects for subject in list_subjects: utils.download_subject(subject,personal_access_key_id,secret_access_key) #Reading data, extracting epochs and creating data-set print("\n\n\n>>Creating a dataset with the subject: ",subject,"\n\n\n") try: #Creating epochs and preprocessing X_train, Y_train, pick_chans = utils.create_dataset([subject]) except: print("\n\nERROR! \nProbably your Amazon S3 credentials are not valid...\n\n") sys.exit() #Splitting X_train, X_validate, Y_train, Y_validate = train_test_split(X_train, Y_train, test_size=0.2, random_state=1) #Second split the validation (20%) #Convert labels to one-hot encodings (00010000000...) Y_train = np_utils.to_categorical(Y_train) Y_validate = np_utils.to_categorical(Y_validate) #Number channels (Same for task and resting) n_chans = len(pick_chans)
n_subjects_stage = 3 #Number of subjects load in memory in each stage of the training #Spliting the testing subjects in different stages subjects_stages_test = [] for i in range(0, len(list_subjects_test), n_subjects_stage): subjects_stages_test.append(list_subjects_test[i:i + n_subjects_stage]) ####################### TESTING LOOP ####################### for i in range(len(subjects_stages_test)): ####################### FIRST TEST - Whole recording ####################### #Reading data, extracting epochs and creating data-set print("\n\n\n>>Creating a dataset with the subjects: ", subjects_stages_test[i], "\n\n\n") X_complete, Y_complete, pick_chans = utils.create_dataset( subjects_stages_test[i]) #Convert labels to one-hot encodings (00010000000...) Y_complete = np_utils.to_categorical(Y_complete) #Number channels (Same for task and resting) n_chans = len(pick_chans) #Number of time points in each sample (Same for task and resting) samples = X_complete.shape[-1] #Kernels (To transform data to NCHW (batch_size, channel, height, width) kernels = 1 #Convert data to NCHW (trials, kernels, channels, samples) X_complete = X_complete.reshape(X_complete.shape[0], kernels, n_chans, samples)