Exemplo n.º 1
0
 def test_can_extract_hagmann_density(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     wm_img = nibabel.load("%s/CMTK_wm_1mm.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fibers.extract_hagmann_density(my_connectome, roi_img, wm_img)
     for i,j in my_connectome.edges_iter():
         assert my_connectome[i][j]['hagmann_density'] > 0
Exemplo n.º 2
0
 def test_can_extract_hagmann_density(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     wm_img = nibabel.load("%s/CMTK_wm_1mm.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fibers.extract_hagmann_density(my_connectome, roi_img, wm_img)
     for i, j in my_connectome.edges_iter():
         assert my_connectome[i][j]['hagmann_density'] > 0
Exemplo n.º 3
0
 def test_can_get_cmat_for_key(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fiber_cmat = fibers.cmat_for_key(my_connectome, 'number_of_fibers')
     for i,j in my_connectome.edges_iter():
         expected_fibers = my_connectome[i][j]['number_of_fibers']
         assert fiber_cmat[i-1][j-1] == expected_fibers
         assert fiber_cmat[j-1][i-1] == expected_fibers
Exemplo n.º 4
0
 def test_can_get_cmat_for_key(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fiber_cmat = fibers.cmat_for_key(my_connectome, 'number_of_fibers')
     for i, j in my_connectome.edges_iter():
         expected_fibers = my_connectome[i][j]['number_of_fibers']
         assert fiber_cmat[i - 1][j - 1] == expected_fibers
         assert fiber_cmat[j - 1][i - 1] == expected_fibers
Exemplo n.º 5
0
 def test_can_map_vertices_to_roi(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     import networkx
     expected_connectome = networkx.read_gpickle(
         "%s/CMTK_connectome_scale33.gpickle" % FIBERS_DIR)
     for i,j in my_connectome.edges_iter():
         assert my_connectome[i][j]['number_of_fibers'] == \
                expected_connectome[i][j]['number_of_fibers']
         assert rms(my_connectome[i][j]['fiber_length_mean'],
                    expected_connectome[i][j]['fiber_length_mean']) < 10**-4
Exemplo n.º 6
0
 def test_can_map_vertices_to_roi(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     import networkx
     expected_connectome = networkx.read_gpickle(
         "%s/CMTK_connectome_scale33.gpickle" % FIBERS_DIR)
     for i, j in my_connectome.edges_iter():
         assert my_connectome[i][j]['number_of_fibers'] == \
                expected_connectome[i][j]['number_of_fibers']
         assert rms(my_connectome[i][j]['fiber_length_mean'],
                    expected_connectome[i][j]['fiber_length_mean']) < 10**-4
Exemplo n.º 7
0
 def test_can_extract_scalars(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fa_img = nibabel.load("%s/CMTK_fa.nii.gz" % IMAGES_DIR)
     fibers.extract_scalars(f_cmtk, my_connectome, fa_img, 'fa', scale_factor=[2.,2.,2.])
     import networkx
     expected_connectome = networkx.read_gpickle(
         "%s/CMTK_connectome_scale33.gpickle" % FIBERS_DIR)
     for i,j in my_connectome.edges_iter():
         print i, j
         assert rms(my_connectome[i][j]['fa_mean'],
                    expected_connectome[i][j]['fa_mean']) < 10**-4
Exemplo n.º 8
0
 def test_can_extract_scalars(self):
     global f_cmtk
     f_cmtk.set_spacing('mm')
     import nibabel
     roi_img = nibabel.load("%s/CMTK_roi.nii.gz" % IMAGES_DIR)
     my_connectome = fibers.generate_connectome(f_cmtk, roi_img)
     fa_img = nibabel.load("%s/CMTK_fa.nii.gz" % IMAGES_DIR)
     fibers.extract_scalars(f_cmtk,
                            my_connectome,
                            fa_img,
                            'fa',
                            scale_factor=[2., 2., 2.])
     import networkx
     expected_connectome = networkx.read_gpickle(
         "%s/CMTK_connectome_scale33.gpickle" % FIBERS_DIR)
     for i, j in my_connectome.edges_iter():
         print i, j
         assert rms(my_connectome[i][j]['fa_mean'],
                    expected_connectome[i][j]['fa_mean']) < 10**-4