Exemplo n.º 1
0
    def test_brain_atlas(self):

        brain_atlas = BrainAtlas(self.atlas_name, "vec", rois=self.roi_list)
        new_data = brain_atlas.transform(self.X)
        self.assertTrue(len(self.X), len(brain_atlas.rois))

        brain_atlas_mean = BrainAtlas(self.atlas_name, "mean", rois="all")
        brain_atlas_mean.transform(self.X)
        # Todo: how to compare?
        debug = True
Exemplo n.º 2
0
    def test_brain_masker(self):

        affine, shape = BrainMask.get_format_info_from_first_image(self.X)
        atlas_obj = AtlasLibrary().get_atlas(self.atlas_name, affine, shape)
        roi_objects = BrainAtlas._get_rois(atlas_obj, which_rois=self.roi_list, background_id=0)

        for roi in roi_objects:
            masker = BrainMask(mask_image=roi, affine=affine, shape=shape, extract_mode="vec")
            own_calculation = masker.transform(self.X[0])
            nilearn_func = NiftiMasker(mask_img=roi.mask, target_affine=affine, target_shape=shape, dtype='float32')
            nilearn_calculation = nilearn_func.fit_transform(self.X[0])

            self.assertTrue(np.array_equal(own_calculation, nilearn_calculation))
Exemplo n.º 3
0
    def test_validity_check_roi_extraction(self):
        for atlas in AtlasLibrary().ATLAS_DICTIONARY.keys():
            print("Checking atlas {}".format(atlas))
            rois = AtlasLibrary().get_atlas(atlas).roi_list[1:3]
            rois = [roi.label for roi in rois]
            brain_atlas = BrainAtlas(atlas_name=atlas)
            brain_atlas.rois = rois
            X_t = brain_atlas.transform(self.X[0:2])

            "-".join(rois)
            name = os.path.join(self.test_folder, atlas + "_" + "-".join(rois))
            brain_atlas._validity_check_roi_extraction(X_t[0], filename=name)
Exemplo n.º 4
0
 def _find_rois(element):
     roi_list = element.base_element.rois
     atlas_obj = AtlasLibrary().get_atlas(element.base_element.atlas_name)
     roi_objects = BrainAtlas._get_rois(atlas_obj, roi_list)
     return [roi.label for roi in roi_objects], atlas_obj