Ejemplo n.º 1
0
 def test_feature_addition(self):
     """ Add feature data from multiple sources to FeatureTable. """
     d = self.dataset
     new_data = pd.DataFrame(np.array([
         [0.001, 0.1, 0.003],
         [0.02, 0.0008, 0.0003],
         [0.001, 0.002, 0.05]]),
         index=['study1', 'study4', 'study6'], columns=['g1', 'g2', 'g3'])
     # Replace all features
     d.add_features(new_data, append=False)
     self.assertEqual(d.feature_table.data.shape, (3, 3))
     self.assertAlmostEqual(d.feature_table.data['g2']['study4'], 0.0008)
     # Outer merge and ignore duplicate features
     d = get_test_dataset()
     d.add_features(new_data)
     self.assertEqual(d.feature_table.data.shape, (6, 7))
     self.assertEqual(d.feature_table.data['g2']['study2'], 0.0)
     self.assertEqual(d.feature_table.data['g1']['study1'], 0.02)
     # Outer merge but overwrite old features with new ones
     d = get_test_dataset()
     d.add_features(new_data, duplicates='replace')
     self.assertEqual(d.feature_table.data.shape, (6, 7))
     self.assertEqual(d.feature_table.data['g1']['study1'], 0.001)
     # Left join (i.e., keep only old rows) and rename conflicting features
     d = get_test_dataset()
     d.add_features(new_data, merge='left', duplicates='merge')
     self.assertEqual(d.feature_table.data.shape, (5, 8))
     self.assertEqual(d.feature_table.data['g1_y']['study1'], 0.001)
     # Apply threshold
     d = get_test_dataset()
     d.add_features(new_data, min_studies=2, threshold=0.003)
     self.assertEqual(d.feature_table.data.shape, (6, 6))
Ejemplo n.º 2
0
def test_plot_brain():
    """Ensure that utils.plot_brain returns a matplotlib figure.
    """
    from gclda.utils import plot_brain
    ns_dset = get_test_dataset()
    underlay = ns_dset.masker.volume

    test_file = join(get_test_data_path(), 'continuous.nii.gz')
    test_data = nib.load(test_file).get_data()

    fig = plot_brain(test_data, underlay)
    assert isinstance(fig, matplotlib.figure.Figure)
 def setUpClass(self):
     """ Create a new Dataset and add features. """
     self.dataset = get_test_dataset()
     self.real_dataset = get_test_dataset(prefix='test_real')
Ejemplo n.º 4
0
 def setUp(self):
     """ Create a new Dataset and add features. """
     self.dataset = get_test_dataset()
     self.real_dataset = get_test_dataset(prefix='test_real')
Ejemplo n.º 5
0
 def setUp(self):
     """ Create a new Dataset and add features. """
     self.dataset = get_test_dataset()
Ejemplo n.º 6
0
 def setUp(self):
     """ Create a new Dataset and add features. """
     self.dataset = get_test_dataset()