Ejemplo n.º 1
0
def trainOnly(roi='',train=('TESTSTU','TESTSTI')):
	"""
	This function creates an PyML dataset from vtc amd roi (Brainvoyager) 
	formatted data.  It should be used when the ONLY TRAINING
	labels are needed but different labels will be used for each 
	(as in diffLabels()).
	
	Returns:
		- a pair of z-normalized BOLD datasets, one for svm training
		and one for testing; BOLD data was extracted from the full
		(vtc) timecourse via the given roi (as .vmr)
		- data from identical runs is silently overwritten, but
		user is informed of this
	"""
	niiFiles, labFiles = pre.nii_LabelListMatch('.')
		## Create lists of all the needed files

	svmBaseName = (str.split(roi,'.'))[0] + '.txt'
		## suffix of the file to be written

	## TRAIN SET: ###################################################
	svmName = 'train_'+ train[0] + 'x' + train[1] + '_' + svmBaseName	
	print('Creating training data: {0}'.format(svmName))
	if os.path.exists(svmName):
		print('Overwriting {0}.'.format(svmName))
		os.remove(svmName)

	createDataset(svmName,roi,labFiles,niiFiles,train[0],train[1])
Ejemplo n.º 2
0
def sameLabels(roi='',fracTrain=0.3,labels=('STI','STU')):
	"""
	Creates a unmodified and z-normalized PyML datasets from BV data
	dividing part (as specified by percentTrain) into 
	a training set and part into a testing set.  
	
	This is to be used when the same labels are applied to training 
	and testing sets AND the training and testing are pulled from 
	the same Brainvoyager data files.
	"""
	niiFiles, labFiles = pre.nii_LabelListMatch('.')

	svmBaseName = (str.split(roi,'.'))[0] + '.txt'
	svmName = labels[0] + 'x' + labels[1] + '_' + svmBaseName
	
	createDataset(svmName,roi,labFiles,niiFiles,labels[0],labels[1])
	pre.vSplit(vecName='vec_'+svmName,fracTrain=0.3)
import nifti as nf
import os as os

## Globals needed to create the SVMLIB data for a run
## =================================================
svmBaseName = 'rPRC_block_svmData.txt'

roiVmr = 'rPRC_block.nii'

trainLab1 = 'STI'
trainLab2 = 'STU'
testLab1 = 'TESTSTI'
testLab2 = 'TESTSTU'

os.chdir('/Users/type/Lab/RWCR/bv_AR/mvpa_data/')
niiFiles, labFiles = pre.nii_LabelListMatch('.')

trainLabsFiles = labFiles
trainNiiFiles  = niiFiles
testLabsFiles  = labFiles
testNiiFiles   = niiFiles

## =================================================
## 

from time import localtime, strftime
svmBaseName = strftime("%a%d%b%Y_%H-%M-%S", localtime()) + svmBaseName  
	# Add a timestamp to the SVM file name, preventing accidental
	# overwriting or modification.

#print('Creating training data:')
Ejemplo n.º 4
0
## =================================================
svmBaseName = 'rPRC_block_svmData.txt'

roiVmr = 'rPRC_block.nii'

trainLab1 = 'TESTSTU'
trainLab2 = 'TESTNSU'
testLab1 = 'TESTSTU'
testLab2 = 'TESTNSU'

from wordSceneFiles import *
	# Creates 4 lists containing the nii and labelList files:
	# - wordLab, wordNii, sceneNii,sceneLab

os.chdir('/Users/type/Lab/RWCR/bv_AR/mvpa_data/')
niiFiles, labFiles = pre.nii_LabelListMatch('.')

trainLabsFiles = sceneLab
trainNiiFiles  = sceneNii
testLabsFiles  = wordLab
testNiiFiles   = wordNii
## =================================================
## 

from time import localtime, strftime
svmBaseName = strftime("%a%d%b%Y_%H-%M-%S", localtime()) + svmBaseName  
	# Add a timestamp to the SVM file name, preventing accidental
	# overwriting or modification.

print('Creating training data:')
for labF, niiF in zip(trainLabsFiles, trainNiiFiles):