Exemple #1
0
    def __iter__(self):
        ''' This is were all the fun starts '''
        x, y, z, g = self.a.shape
        # for all seeds
        for i in range(self.seed_no):
            if self.seed_list == None:
                rx = (x - 1) * np.random.rand()
                ry = (y - 1) * np.random.rand()
                rz = (z - 1) * np.random.rand()
                seed = np.ascontiguousarray(
                    np.array([rx, ry, rz]), dtype=np.float64)
            else:
                seed = np.ascontiguousarray(
                    self.seed_list[i], dtype=np.float64)
            # for all peaks
            for ref in range(g):
                track = eudx_both_directions(seed.copy(),
                                             ref,
                                             self.a,
                                             self.ind,
                                             self.odf_vertices,
                                             self.a_low,
                                             self.ang_thr,
                                             self.step_sz,
                                             self.total_weight,
                                             self.max_points)

                if track == None:
                    pass
                else:
                    if track.shape[0] > 1:
                        yield track + self.voxel_shift
Exemple #2
0
    def _voxel_tracks(self, seed_voxels):
        ''' This is were all the fun starts '''
        if seed_voxels is not None and seed_voxels.dtype != np.float64:
            # This is a private method so users should never see this error. If
            # you've reached this error, there is a bug somewhere.
            raise ValueError("wrong dtype seeds have to be float64")
        x, y, z, g = self.a.shape
        edge = np.array([x, y, z], dtype=np.float64) - 1.

        # for all seeds
        for i in range(self.seed_no):
            if seed_voxels is None:
                seed = np.random.rand(3) * edge
            else:
                seed = seed_voxels[i]
                if np.any(seed < 0.) or np.any(seed > edge):
                    raise ValueError('Seed outside boundaries', seed)
            seed = np.ascontiguousarray(seed)

            # for all peaks
            for ref in range(g):
                track = eudx_both_directions(seed.copy(), ref, self.a,
                                             self.ind, self.odf_vertices,
                                             self.a_low, self.ang_thr,
                                             self.step_sz, self.total_weight,
                                             self.max_points)
                if track is not None and track.shape[0] > 1:
                    yield track
Exemple #3
0
    def _voxel_tracks(self, seed_voxels):
        ''' This is were all the fun starts '''
        if seed_voxels is not None and seed_voxels.dtype != np.float64:
            # This is a private method so users should never see this error. If
            # you've reached this error, there is a bug somewhere.
            raise ValueError("wrong dtype seeds have to be float64")
        x, y, z, g = self.a.shape
        edge = np.array([x, y, z], dtype=np.float64) - 1.

        # for all seeds
        for i in range(self.seed_no):
            if seed_voxels is None:
                seed = np.random.rand(3) * edge
            else:
                seed = seed_voxels[i]
                if np.any(seed < 0.) or np.any(seed > edge):
                    raise ValueError('Seed outside boundaries', seed)
            seed = np.ascontiguousarray(seed)

            # for all peaks
            for ref in range(g):
                track = eudx_both_directions(seed.copy(),
                                             ref,
                                             self.a,
                                             self.ind,
                                             self.odf_vertices,
                                             self.a_low,
                                             self.ang_thr,
                                             self.step_sz,
                                             self.total_weight,
                                             self.max_points)
                if track is not None and track.shape[0] > 1:
                    yield track
Exemple #4
0
    def __iter__(self):
        ''' This is were all the fun starts '''

        x, y, z, g = self.a.shape
        #for all seeds
        for i in range(self.seed_no):
            if self.seed_list == None:
                rx = (x - 1) * np.random.rand()
                ry = (y - 1) * np.random.rand()
                rz = (z - 1) * np.random.rand()
                seed = np.ascontiguousarray(np.array([rx, ry, rz]),
                                            dtype=np.float64)
            else:
                seed = np.ascontiguousarray(self.seed_list[i],
                                            dtype=np.float64)
            #for all peaks
            for ref in range(g):
                track = eudx_both_directions(seed.copy(), ref, self.a,
                                             self.ind, self.odf_vertices,
                                             self.a_low, self.ang_thr,
                                             self.step_sz, self.total_weight,
                                             self.max_points)
                if track == None:
                    pass
                else:
                    yield track
Exemple #5
0
    def __iter__(self):
        """ This is were all the fun starts """

        x, y, z, g = self.a.shape

        # for all seeds
        for i in range(self.seed_no):
            if self.seed_list == None:
                rx = (x - 1) * np.random.rand()
                ry = (y - 1) * np.random.rand()
                rz = (z - 1) * np.random.rand()
                seed = np.ascontiguousarray(np.array([rx, ry, rz]), dtype=np.float64)
            else:
                seed = np.ascontiguousarray(self.seed_list[i], dtype=np.float64)
            # for all peaks
            for ref in range(g):
                # propagate up and down
                # print g,self.a.shape
                # """
                # print i,seed
                track = eudx_both_directions(
                    seed.copy(),
                    ref,
                    self.a,
                    self.ind,
                    self.odf_vertices,
                    self.a_low,
                    self.ang_thr,
                    self.step_sz,
                    self.total_weight,
                )
                # """
                # track =None
                if track == None:
                    # print 'None'
                    pass
                else:
                    # return a track from that seed
                    if length(track) > self.length_thr:
                        # print 'track'
                        yield track
Exemple #6
0
    def __iter__(self):
        ''' This is were all the fun starts '''

        x, y, z, g = self.a.shape

        #for all seeds
        for i in range(self.seed_no):
            if self.seed_list == None:
                rx = (x - 1) * np.random.rand()
                ry = (y - 1) * np.random.rand()
                rz = (z - 1) * np.random.rand()
                seed = np.ascontiguousarray(np.array([rx, ry, rz]),
                                            dtype=np.float64)
            else:
                seed = np.ascontiguousarray(self.seed_list[i],
                                            dtype=np.float64)
            #for all peaks
            for ref in range(g):
                #propagate up and down
                #print g,self.a.shape
                #"""
                #print i,seed
                track = eudx_both_directions(seed.copy(), ref, self.a,
                                             self.ind, self.odf_vertices,
                                             self.a_low, self.ang_thr,
                                             self.step_sz, self.total_weight)
                #"""
                #track =None
                if track == None:
                    #print 'None'
                    pass
                else:
                    #return a track from that seed
                    if length(track) > self.length_thr:
                        #print 'track'
                        yield track