Exemple #1
0
def partition_volumes():
	volume_indices = np.array(range(NUM_VOLUMES - NUM_OFFSET_VOLUMES))
	clean_slice_mask = ss.SceneSlicer().get_clean_slice_mask()
	volume_indices = volume_indices[clean_slice_mask]
	np.random.shuffle(volume_indices)
	num_train = int(TRAINING_PERCENT*len(volume_indices))
	train_indices = volume_indices[:num_train]
	test_indices = volume_indices[num_train:]
	return train_indices, test_indices
Exemple #2
0
def setup_test():
    with open('test_scenes.csv', 'w') as csvfile:
        scenewriter = csv.writer(csvfile, delimiter=',', quotechar='"')
        scenewriter.writerow([17.0, 'SAVANNAH', 'DAY', 'EXT'])
        scenewriter.writerow([40.0, 'DOCTORS OFFICE', 'NIGHT', 'INT'])
        scenewriter.writerow([61.0, 'GUMP', 'DAY', 'EXT'])
        scenewriter.writerow([82.0, 'GUMP', 'DAY', 'EXT'])
        scenewriter.writerow([91.0, 'GUMP', 'NIGHT', 'INT'])
    return scene_slicer.SceneSlicer('test_scenes.csv')
def setup_test():
    data = np.zeros((2, 2, 2, 50))
    img = nib.Nifti1Image(data, affine=np.diag([1, 1, 1, 1]))
    nib.save(img, 'test_data.nii')
    with open('test_scenes.csv', 'w') as csvfile:
        scenewriter = csv.writer(csvfile, delimiter=',', quotechar='"')
        scenewriter.writerow([17.0, 'SAVANNAH', 'DAY', 'EXT'])
        scenewriter.writerow([40.0, 'DOCTORS OFFICE', 'NIGHT', 'INT'])
        scenewriter.writerow([61.0, 'GUMP', 'DAY', 'EXT'])
        scenewriter.writerow([82.0, 'GUMP', 'DAY', 'EXT'])
        scenewriter.writerow([91.0, 'GUMP', 'NIGHT', 'INT'])
    return scene_slicer.SceneSlicer('test_data.nii', 'test_scenes.csv')
Exemple #4
0
def get_design_matrix():
    """
    Returns
    -------
    Design matrix with 5 columns, including the 3 columns of interest,
    the linear drift column, and the column of ones
    """
    data = nib.load(data_path)
    n_trs = data.shape[-1]
    X = np.ones((n_trs, 3))
    ss = ssm.SceneSlicer('test_data.nii', 'scenes.csv')
    day_night, int_ext = ss.get_scene_slices()
    X[:, 1] = np.linspace(-1, 1, n_trs)
    X[:, 2] = day_night
    return X
 def get_design_matrix(self):
     """
     Returns
     -------
     Design matrix with 3 columns, including the column of interest,
     the linear drift column, and the column of ones
     """
     if self.design is None:
         scene_path = dp.get_scene_csv()
         ss = ssm.SceneSlicer(scene_path)
         interest_col = ss.get_scene_slices()[self.interest_col_ind]
         n_trs = self.data.shape[-1]
         design = np.ones((n_trs, 3))
         design[:, 1] = np.linspace(-1, 1, n_trs)
         design[:, 2] = interest_col[NUM_OFFSET_VOLUMES:NUM_OFFSET_VOLUMES +
                                     n_trs]
         self.design = design
     return self.design
Exemple #6
0
def partition_volumes():
    """
	Partitions the volumes from the SceneSlicer object randomly to generate
	training and testing data

	Parameters
	----------
	None

	Returns
	-------
	train_indices : array
	test_indices : array
	"""
    volume_indices = np.array(range(NUM_VOLUMES - NUM_OFFSET_VOLUMES))
    clean_slice_mask = ss.SceneSlicer().get_clean_slice_mask()
    volume_indices = volume_indices[clean_slice_mask]
    np.random.shuffle(volume_indices)
    num_train = int(TRAINING_PERCENT * len(volume_indices))
    train_indices = volume_indices[:num_train]
    test_indices = volume_indices[num_train:]
    return train_indices, test_indices
Exemple #7
0
 def __init__(self, data_file):
     self.X = np.load(data_file).T[NUM_OFFSET_VOLUMES:, :]
     ss = ssm.SceneSlicer()
     self.y = np.array(ss.get_scene_slices()[0][NUM_OFFSET_VOLUMES:])